displacementSBRStress_fvMotionSolver.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) 2011-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 
27 #include "motionDiffusivity.H"
28 #include "fvmLaplacian.H"
29 #include "fvcDiv.H"
30 #include "fvcGrad.H"
31 #include "surfaceInterpolate.H"
32 #include "fvcLaplacian.H"
33 #include "polyTopoChangeMap.H"
34 #include "volPointInterpolation.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 namespace fvMotionSolvers
42 {
44 
46  (
49  fvMesh
50  );
51 
53  (
57  );
58 }
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
65 (
66  const polyMesh& mesh,
67  const dictionary& dict
68 )
69 :
71  pointMeshMovers::displacement(mesh, dict, typeName),
72  cellDisplacement_
73  (
74  IOobject
75  (
76  "cellDisplacement",
77  mesh.time().name(),
78  mesh,
79  IOobject::READ_IF_PRESENT,
80  IOobject::AUTO_WRITE
81  ),
84  (
85  "cellDisplacement",
86  pointDisplacement().dimensions(),
87  Zero
88  ),
89  cellMotionBoundaryTypes<vector>(pointDisplacement().boundaryField())
90  ),
91  diffusivityType_(dict.lookup("diffusivity")),
92  diffusivityPtr_
93  (
94  motionDiffusivity::New(fvMotionSolver::mesh(), diffusivityType_)
95  )
96 {}
97 
98 
100 (
101  fvMesh& mesh,
102  const dictionary& dict
103 )
104 :
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
110 
112 {}
113 
114 
115 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
116 
119 {
120  // The points have moved so before interpolation update
121  // the mtionSolver accordingly
122  movePoints(mesh().points());
123 
124  diffusivityPtr_->correct();
125  pointDisplacement_.boundaryFieldRef().updateCoeffs();
126 
127  surfaceScalarField Df(diffusivityPtr_->operator()());
128 
129  volTensorField gradCd("gradCd", fvc::grad(cellDisplacement_));
130 
132  (
134  (
135  2*Df,
136  cellDisplacement_,
137  "laplacian(diffusivity,cellDisplacement)"
138  )
139 
140  + fvc::div
141  (
142  Df
143  *(
145  (
146  cellDisplacement_.mesh().Sf(),
147  gradCd.T() - gradCd
148  )
149 
150  // Solid-body rotation "lambda" term
151  - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
152  )
153  )
154 
155  /*
156  - fvc::laplacian
157  (
158  2*Df,
159  cellDisplacement_,
160  "laplacian(diffusivity,cellDisplacement)"
161  )
162 
163  + fvc::div
164  (
165  Df
166  *(
167  fvc::dotInterpolate
168  (
169  cellDisplacement_.mesh().Sf(),
170  gradCd + gradCd.T()
171  )
172 
173  // Solid-body rotation "lambda" term
174  - cellDisplacement_.mesh().Sf()*fvc::interpolate(tr(gradCd))
175  )
176  )
177  */
178  );
179 
181  (
182  cellDisplacement_,
183  pointDisplacement_
184  );
185 
186  tmp<pointField> tcurPoints
187  (
188  points0() + pointDisplacement().primitiveField()
189  );
190 
191  twoDCorrectPoints(tcurPoints.ref());
192 
193  return tcurPoints;
194 }
195 
196 
198 (
199  const polyTopoChangeMap& map
200 )
201 {
203 
204  // Update diffusivity. Note two stage to make sure old one is de-registered
205  // before creating/registering new one.
206  diffusivityPtr_.reset(nullptr);
207  diffusivityType_.rewind();
208  diffusivityPtr_ = motionDiffusivity::New
209  (
210  mesh(),
211  diffusivityType_
212  );
213 }
214 
215 
217 (
218  const polyMeshMap& map
219 )
220 {
222 
223  // Update diffusivity. Note two stage to make sure old one is de-registered
224  // before creating/registering new one.
225  diffusivityPtr_.reset(nullptr);
226  diffusivityType_.rewind();
227  diffusivityPtr_ = motionDiffusivity::New
228  (
229  mesh(),
230  diffusivityType_
231  );
232 }
233 
234 
235 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
static volPointInterpolation & New(const word &name, const fvMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
Generic GeometricField class.
tmp< GeometricField< Type, GeoMesh, Field > > T() const
Return transpose (only if it is a tensor field)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for fvMesh movers.
Definition: fvMeshMover.H:53
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
Base class for fvMesh motion solvers.
Mesh motion solver for an fvMesh. Based on solving the cell-centre solid-body rotation stress equatio...
displacementSBRStress(fvMesh &, const dictionary &)
Construct from fvMesh and dictionary.
virtual void topoChange(const polyTopoChangeMap &)
Update corresponding to the given map.
virtual tmp< pointField > newPoints()
Return point location obtained from the current motion field.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Abstract base class for cell-centre mesh motion diffusivity.
static autoPtr< motionDiffusivity > New(const fvMesh &mesh, Istream &mdData)
Select null constructed.
Abstract base class for pointMesh movers.
virtual void topoChange(const polyTopoChangeMap &)
Update local data for topology changes.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map (not implemented)
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for managing temporary objects.
Definition: tmp.H:55
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:197
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
tmp< PointField< Type > > interpolate(const VolField< Type > &) const
Interpolate volField using inverse distance weighting.
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 laplacian of the field.
const pointField & points
const dimensionSet time
defineTypeNameAndDebug(displacementLaplacian, 0)
addToRunTimeSelectionTable(fvMeshMover, displacementLaplacian, fvMesh)
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
static tmp< SurfaceField< typename innerProduct< vector, Type >::type > > dotInterpolate(const surfaceVectorField &Sf, const VolField< Type > &tvf)
Interpolate field onto faces.
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< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
void tr(pointPatchField< scalar > &, const pointPatchField< tensor > &)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
dictionary dict