solidDisplacement.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "solidDisplacement.H"
27 #include "fvcGrad.H"
28 #include "fvcDiv.H"
29 #include "fvcLaplacian.H"
30 #include "fvmD2dt2.H"
31 #include "fvmLaplacian.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace solvers
39 {
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
47 
49 {
51 }
52 
53 
55 {
56  solid::read();
57 
58  nCorr = pimple.dict().lookupOrDefault<int>("nCorrectors", 1);
59  convergenceTolerance = pimple.dict().lookupOrDefault<scalar>("D", 0);
60  pimple.dict().lookup("compactNormalStress") >> compactNormalStress;
61  accFac = pimple.dict().lookupOrDefault<scalar>("accelerationFactor", 1);
62 
63  return true;
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 :
71  solid
72  (
73  mesh,
75  ),
76 
77  thermo_(refCast<solidDisplacementThermo>(solid::thermo_)),
78 
79  compactNormalStress(pimple.dict().lookup("compactNormalStress")),
80 
81  D_
82  (
83  IOobject
84  (
85  "D",
86  runTime.name(),
87  mesh,
88  IOobject::MUST_READ,
89  IOobject::AUTO_WRITE
90  ),
91  mesh,
92  dimensions::length
93  ),
94 
95  E(thermo_.E()),
96  nu(thermo_.nu()),
97 
98  mu(E/(2*(1 + nu))),
99 
100  lambda
101  (
102  thermo_.planeStress()
103  ? nu*E/((1 + nu)*(1 - nu))
104  : nu*E/((1 + nu)*(1 - 2*nu))
105  ),
106 
107  threeK
108  (
109  thermo_.planeStress()
110  ? E/(1 - nu)
111  : E/(1 - 2*nu)
112  ),
113 
114  threeKalpha("threeKalpha", threeK*thermo_.alphav()),
115 
116  sigmaD
117  (
118  IOobject
119  (
120  "sigmaD",
121  runTime.name(),
122  mesh
123  ),
124  mu*twoSymm(fvc::grad(D_)) + lambda*(I*tr(fvc::grad(D_)))
125  ),
126 
127  divSigmaExp
128  (
129  IOobject
130  (
131  "divSigmaExp",
132  runTime.name(),
133  mesh
134  ),
135  fvc::div(sigmaD)
136  - (
137  compactNormalStress
138  ? fvc::laplacian(2*mu + lambda, D_, "laplacian(DD,D)")
139  : fvc::div((2*mu + lambda)*fvc::grad(D_), "div(sigmaD)")
140  )
141  ),
142 
143  thermo(thermo_),
144  D(D_)
145 {
147 
148  // Read the controls
149  read();
150 }
151 
152 
153 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
154 
156 {}
157 
158 
159 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
160 
162 {
163  if (thermo.thermalStress())
164  {
166  }
167 }
168 
169 
171 {
172  if (thermo.thermalStress())
173  {
175  }
176 }
177 
178 
180 {
181  volVectorField& D(D_);
182 
183  const volScalarField& rho = thermo_.rho();
184 
185  int iCorr = 0;
186  scalar initialResidual = 0;
187 
188  {
189  {
190  fvVectorMatrix DEqn
191  (
192  fvm::d2dt2(rho, D)
193  ==
194  fvm::laplacian(2*mu + lambda, D, "laplacian(DD,D)")
195  + divSigmaExp
196  + rho*fvModels().d2dt2(D)
197  );
198 
199  if (thermo.thermalStress())
200  {
201  DEqn += fvc::grad(threeKalpha*T);
202  }
203 
204  fvConstraints().constrain(DEqn);
205 
206  initialResidual = DEqn.solve().max().initialResidual();
207 
208  // For steady-state optionally accelerate the solution
209  // by over-relaxing the displacement
210  if (mesh.schemes().steady() && accFac > 1)
211  {
212  D += (accFac - 1)*(D - D.oldTime());
213  }
214 
215  if (!compactNormalStress)
216  {
217  divSigmaExp = fvc::div(DEqn.flux());
218  }
219  }
220 
221  const volTensorField gradD(fvc::grad(D));
222  sigmaD = mu*twoSymm(gradD) + (lambda*I)*tr(gradD);
223 
224  if (compactNormalStress)
225  {
226  divSigmaExp = fvc::div
227  (
228  sigmaD - (2*mu + lambda)*gradD,
229  "div(sigmaD)"
230  );
231  }
232  else
233  {
234  divSigmaExp += fvc::div(sigmaD);
235  }
236 
237  } while (initialResidual > convergenceTolerance && ++iCorr < nCorr);
238 }
239 
240 
242 {
243  if (thermo.thermalStress())
244  {
246  }
247 }
248 
249 
251 {
252  if (runTime.writeTime())
253  {
255  (
256  IOobject
257  (
258  "sigma",
259  runTime.name(),
260  mesh
261  ),
262  sigmaD
263  );
264 
265  if (thermo.thermalStress())
266  {
267  sigma = sigma - I*(threeKalpha*thermo.T());
268  }
269 
270  volScalarField sigmaEq
271  (
272  IOobject
273  (
274  "sigmaEq",
275  runTime.name(),
276  mesh
277  ),
278  sqrt((3.0/2.0)*magSqr(dev(sigma)))
279  );
280 
281  Info<< "Max sigmaEq = " << max(sigmaEq).value()
282  << endl;
283 
284  sigma.write();
285  sigmaEq.write();
286  }
287 }
288 
289 
290 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Generic GeometricField class.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
const word & name() const
Return name.
Definition: IOobject.H:307
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
SolverPerformance< Type > solve(const dictionary &)
Solve segregated or coupled returning the solution statistics.
Definition: fvMatrixSolve.C:58
tmp< SurfaceField< Type > > flux() const
Return the face-flux field from the matrix.
Definition: fvMatrix.C:963
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1795
const fvSolution & solution() const
Return the fvSolution.
Definition: fvMesh.C:1806
void setFluxRequired(const word &name) const
Definition: fvSchemes.C:434
bool steady() const
Return true if the default ddtScheme is steadyState.
Definition: fvSchemes.H:145
virtual bool modified() const
Return true if the object's file (or files for objectRegistry)
virtual bool write(const bool write=true) const
Write using setting from DB.
Fundamental solid thermodynamic properties.
Base-class for solid thermodynamic properties.
Definition: solidThermo.H:59
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
Solver module for steady or transient segregated finite-volume solution of linear-elastic,...
virtual void thermophysicalPredictor()
Construct and solve the energy equation,.
virtual ~solidDisplacement()
Destructor.
virtual void prePredictor()
Called at the beginning of the PIMPLE loop.
virtual void postSolve()
Called after the PIMPLE loop at the end of the time-step.
virtual bool dependenciesModified() const
Return true if the solver's dependencies have been modified.
solidDisplacement(fvMesh &mesh)
Construct from region mesh.
const volVectorField & D
Reference to the Displacement field.
virtual void pressureCorrector()
Construct and solve the displacement equation to obtain the stress.
virtual void thermophysicalTransportCorrector()
Correct the thermophysical transport modelling.
virtual bool read()
Read controls.
Solver module for thermal transport in solid domains and regions for conjugate heat transfer,...
Definition: solid.H:56
virtual void thermophysicalPredictor()
Construct and solve the energy equation,.
Definition: solid.C:169
virtual void prePredictor()
Called at the beginning of the PIMPLE loop.
Definition: solid.C:151
virtual bool dependenciesModified() const
Return true if the solver's dependencies have been modified.
Definition: solid.C:46
virtual void thermophysicalTransportCorrector()
Correct the thermophysical transport.
Definition: solid.C:205
virtual bool read()
Read controls.
Definition: solid.C:52
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
pimpleControl pimple(mesh)
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Calculate the divergence of the given field.
Calculate the gradient of the given field.
Calculate the laplacian of the given field.
Calculate the matrix for the second-order temporal derivative.
Calculate the matrix for the laplacian of the field.
rho
Definition: pEqn.H:1
dimensionedScalar lambda("lambda", inv(dimensions::kinematicViscosity), viscosity)
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
const dimensionedScalar mu
Atomic mass unit.
const dimensionSet length
tmp< VolField< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvcLaplacian.C:45
tmp< VolField< typename outerProduct< vector, Type >::type > > grad(const SurfaceField< Type > &ssf)
Definition: fvcGrad.C:46
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< VolField< Type > > d2dt2(const VolField< Type > &vf)
Definition: fvcD2dt2.C:45
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
tmp< fvMatrix< Type > > d2dt2(const VolField< Type > &vf)
Definition: fvmD2dt2.C:46
static const coefficient D("D", dimTemperature, 257.14)
addToRunTimeSelectionTable(solver, compressibleMultiphaseVoF, fvMesh)
defineTypeNameAndDebug(basicFluidSolver, 0)
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:141
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
static const Identity< scalar > I
Definition: Identity.H:93
void tr(pointPatchField< scalar > &, const pointPatchField< tensor > &)
void dev(pointPatchField< tensor > &, const pointPatchField< tensor > &)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void twoSymm(pointPatchField< tensor > &, const pointPatchField< tensor > &)
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
tmp< DimensionedField< scalar, GeoMesh, Field > > magSqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void T(GeometricField< Type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type, GeoMesh, PrimitiveField2 > &gf1)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict
fluidMulticomponentThermo & thermo
Definition: createFields.H:15