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 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 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
47 
49 {
51 
52  nCorr = pimple.dict().lookupOrDefault<int>("nCorrectors", 1);
53  convergenceTolerance = pimple.dict().lookupOrDefault<scalar>("D", 0);
54  pimple.dict().lookup("compactNormalStress") >> compactNormalStress;
55  accFac = pimple.dict().lookupOrDefault<scalar>("accelerationFactor", 1);
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
60 
62 :
63  solid
64  (
65  mesh,
67  ),
68 
69  thermo_(refCast<solidDisplacementThermo>(solid::thermo_)),
70 
71  compactNormalStress(pimple.dict().lookup("compactNormalStress")),
72 
73  D_
74  (
75  IOobject
76  (
77  "D",
78  runTime.name(),
79  mesh,
80  IOobject::MUST_READ,
81  IOobject::AUTO_WRITE
82  ),
83  mesh
84  ),
85 
86  E(thermo_.E()),
87  nu(thermo_.nu()),
88 
89  mu(E/(2*(1 + nu))),
90 
91  lambda
92  (
93  thermo_.planeStress()
94  ? nu*E/((1 + nu)*(1 - nu))
95  : nu*E/((1 + nu)*(1 - 2*nu))
96  ),
97 
98  threeK
99  (
100  thermo_.planeStress()
101  ? E/(1 - nu)
102  : E/(1 - 2*nu)
103  ),
104 
105  threeKalpha("threeKalpha", threeK*thermo_.alphav()),
106 
107  sigmaD
108  (
109  IOobject
110  (
111  "sigmaD",
112  runTime.name(),
113  mesh
114  ),
115  mu*twoSymm(fvc::grad(D_)) + lambda*(I*tr(fvc::grad(D_)))
116  ),
117 
118  divSigmaExp
119  (
120  IOobject
121  (
122  "divSigmaExp",
123  runTime.name(),
124  mesh
125  ),
126  fvc::div(sigmaD)
127  - (
128  compactNormalStress
129  ? fvc::laplacian(2*mu + lambda, D_, "laplacian(DD,D)")
130  : fvc::div((2*mu + lambda)*fvc::grad(D_), "div(sigmaD)")
131  )
132  ),
133 
134  thermo(thermo_),
135  D(D_)
136 {
138 
139  // Read the controls
140  readControls();
141 }
142 
143 
144 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
145 
147 {}
148 
149 
150 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
151 
153 {
154  if (thermo.thermalStress())
155  {
157  }
158 }
159 
160 
162 {
163  if (thermo.thermalStress())
164  {
166  }
167 }
168 
169 
171 {
172  volVectorField& D(D_);
173 
174  const volScalarField& rho = thermo_.rho();
175 
176  int iCorr = 0;
177  scalar initialResidual = 0;
178 
179  {
180  {
181  fvVectorMatrix DEqn
182  (
183  fvm::d2dt2(rho, D)
184  ==
185  fvm::laplacian(2*mu + lambda, D, "laplacian(DD,D)")
186  + divSigmaExp
187  + rho*fvModels().d2dt2(D)
188  );
189 
190  if (thermo.thermalStress())
191  {
192  DEqn += fvc::grad(threeKalpha*T);
193  }
194 
195  fvConstraints().constrain(DEqn);
196 
197  initialResidual = DEqn.solve().max().initialResidual();
198 
199  // For steady-state optionally accelerate the solution
200  // by over-relaxing the displacement
201  if (mesh.schemes().steady() && accFac > 1)
202  {
203  D += (accFac - 1)*(D - D.oldTime());
204  }
205 
206  if (!compactNormalStress)
207  {
208  divSigmaExp = fvc::div(DEqn.flux());
209  }
210  }
211 
212  const volTensorField gradD(fvc::grad(D));
213  sigmaD = mu*twoSymm(gradD) + (lambda*I)*tr(gradD);
214 
215  if (compactNormalStress)
216  {
217  divSigmaExp = fvc::div
218  (
219  sigmaD - (2*mu + lambda)*gradD,
220  "div(sigmaD)"
221  );
222  }
223  else
224  {
225  divSigmaExp += fvc::div(sigmaD);
226  }
227 
228  } while (initialResidual > convergenceTolerance && ++iCorr < nCorr);
229 }
230 
231 
233 {
234  if (thermo.thermalStress())
235  {
237  }
238 }
239 
240 
242 {
243  if (runTime.writeTime())
244  {
246  (
247  IOobject
248  (
249  "sigma",
250  runTime.name(),
251  mesh
252  ),
253  sigmaD
254  );
255 
256  if (thermo.thermalStress())
257  {
258  sigma = sigma - I*(threeKalpha*thermo.T());
259  }
260 
261  volScalarField sigmaEq
262  (
263  IOobject
264  (
265  "sigmaEq",
266  runTime.name(),
267  mesh
268  ),
269  sqrt((3.0/2.0)*magSqr(dev(sigma)))
270  );
271 
272  Info<< "Max sigmaEq = " << max(sigmaEq).value()
273  << endl;
274 
275  sigma.write();
276  sigmaEq.write();
277  }
278 }
279 
280 
281 // ************************************************************************* //
static const Foam::dimensionedScalar D("D", Foam::dimTemperature, 257.14)
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:310
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:860
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:101
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1748
void setFluxRequired(const word &name) const
Definition: fvSchemes.C:503
virtual bool write(const bool write=true) const
Write using setting from DB.
virtual const dictionary & dict() const
Return the solution dictionary.
Fundamental solid thermodynamic properties.
Base-class for solid thermodynamic properties.
Definition: solidThermo.H:56
Abstract base class for run-time selectable region solvers.
Definition: solver.H:55
pimpleNoLoopControl pimple
PIMPLE inner-loop controls.
Definition: solver.H:100
const fvMesh & mesh
Region mesh.
Definition: solver.H:94
Solver module for steady or transient segregated finite-volume solution of linear-elastic,...
virtual void thermophysicalPredictor()
Construct and solve the energy equation,.
scalar convergenceTolerance
Convergence tolerance for the displacement/stress correctors.
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.
scalar accFac
Acceleration factor for faster steady-state simulations.
Switch compactNormalStress
Switch for normal stress discretisation (required)
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 postCorrector()
Correct the thermophysical transport modelling.
virtual void readControls()
Read controls.
int nCorr
Maximum number of displacement/stress correctors per time-step.
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:203
virtual void prePredictor()
Called at the beginning of the PIMPLE loop.
Definition: solid.C:190
virtual void postCorrector()
Correct the thermophysical transport modelling.
Definition: solid.C:235
virtual void readControls()
Read controls.
Definition: solid.C:46
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
pimpleControl pimple(mesh)
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.
dimensionedScalar lambda(viscosity->lookup("lambda"))
const dimensionedScalar sigma
Stefan-Boltzmann constant: default SI units: [W/m^2/K^4].
const dimensionedScalar mu
Atomic mass unit.
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
addToRunTimeSelectionTable(solver, compressibleMultiphaseVoF, fvMesh)
defineTypeNameAndDebug(compressibleMultiphaseVoF, 0)
Namespace for OpenFOAM.
dimensionedSymmTensor dev(const dimensionedSymmTensor &dt)
dimensionedScalar tr(const dimensionedSphericalTensor &dt)
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:111
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
dimensionedSymmTensor twoSymm(const dimensionedSymmTensor &dt)
messageStream Info
static const Identity< scalar > I
Definition: Identity.H:93
dimensionedScalar sqrt(const dimensionedScalar &ds)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< scalar > magSqr(const dimensioned< Type > &)
dictionary dict
fluidMulticomponentThermo & thermo
Definition: createFields.H:31