displacementLaplacianFvMotionSolver.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-2022 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"
30 #include "OFstream.H"
31 #include "meshTools.H"
32 #include "polyTopoChangeMap.H"
33 #include "volPointInterpolation.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(displacementLaplacianFvMotionSolver, 0);
40 
42  (
43  motionSolver,
44  displacementLaplacianFvMotionSolver,
45  dictionary
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
53 (
54  const word& name,
55  const polyMesh& mesh,
56  const dictionary& dict
57 )
58 :
59  displacementMotionSolver(name, mesh, dict, typeName),
60  fvMotionSolver(mesh),
61  cellDisplacement_
62  (
63  IOobject
64  (
65  "cellDisplacement",
66  mesh.time().timeName(),
67  mesh,
70  ),
71  fvMesh_,
73  (
74  "cellDisplacement",
75  pointDisplacement_.dimensions(),
76  Zero
77  ),
78  cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
79  ),
80  pointLocation_(nullptr),
81  diffusivityPtr_
82  (
83  motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
84  ),
85  frozenPointsZone_
86  (
87  coeffDict().found("frozenPointsZone")
88  ? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone"))
89  : -1
90  )
91 {
93  (
94  "pointLocation",
95  fvMesh_.time().timeName(),
96  fvMesh_,
99  );
100 
101  if (debug)
102  {
103  Info<< "displacementLaplacianFvMotionSolver:" << nl
104  << " diffusivity : " << diffusivityPtr_().type() << nl
105  << " frozenPoints zone : " << frozenPointsZone_ << endl;
106  }
107 
108  if (io.headerOk())
109  {
110  pointLocation_.reset
111  (
112  new pointVectorField
113  (
114  io,
115  pointMesh::New(fvMesh_)
116  )
117  );
118 
119  if (debug)
120  {
121  Info<< "displacementLaplacianFvMotionSolver :"
122  << " Read pointVectorField "
123  << io.name()
124  << " to be used for boundary conditions on points."
125  << nl
126  << "Boundary conditions:"
127  << pointLocation_().boundaryField().types() << endl;
128  }
129  }
130 }
131 
132 
133 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
134 
137 {}
138 
139 
140 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
141 
144 {
145  if (!diffusivityPtr_.valid())
146  {
147  diffusivityPtr_ = motionDiffusivity::New
148  (
149  fvMesh_,
150  coeffDict().lookup("diffusivity")
151  );
152  }
153  return diffusivityPtr_();
154 }
155 
156 
159 {
161  (
162  cellDisplacement_,
163  pointDisplacement_
164  );
165 
166  if (pointLocation_.valid())
167  {
168  if (debug)
169  {
170  Info<< "displacementLaplacianFvMotionSolver : applying "
171  << " boundary conditions on " << pointLocation_().name()
172  << " to new point location."
173  << endl;
174  }
175 
176  pointLocation_().primitiveFieldRef() =
177  points0()
178  + pointDisplacement_.primitiveField();
179 
180  pointLocation_().correctBoundaryConditions();
181 
182  // Implement frozen points
183  if (frozenPointsZone_ != -1)
184  {
185  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
186 
187  forAll(pz, i)
188  {
189  pointLocation_()[pz[i]] = points0()[pz[i]];
190  }
191  }
192 
193  twoDCorrectPoints(pointLocation_().primitiveFieldRef());
194 
195  return tmp<pointField>(pointLocation_().primitiveField());
196  }
197  else
198  {
199  tmp<pointField> tcurPoints
200  (
201  points0() + pointDisplacement_.primitiveField()
202  );
203  pointField& curPoints = tcurPoints.ref();
204 
205  // Implement frozen points
206  if (frozenPointsZone_ != -1)
207  {
208  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
209 
210  forAll(pz, i)
211  {
212  curPoints[pz[i]] = points0()[pz[i]];
213  }
214  }
215 
216  twoDCorrectPoints(curPoints);
217 
218  return tcurPoints;
219  }
220 }
221 
222 
224 {
225  // The points have moved so before interpolation update
226  // the motionSolver accordingly
227  movePoints(fvMesh_.points());
228 
229  diffusivity().correct();
230  pointDisplacement_.boundaryFieldRef().updateCoeffs();
231 
233  (
235  (
236  diffusivity().operator()(),
237  cellDisplacement_,
238  "laplacian(diffusivity,cellDisplacement)"
239  )
240  );
241 }
242 
243 
245 (
246  const polyTopoChangeMap& map
247 )
248 {
250  diffusivityPtr_.clear();
251 }
252 
253 
255 (
256  const polyMeshMap& map
257 )
258 {
260  diffusivityPtr_.clear();
261 }
262 
263 
264 // ************************************************************************* //
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
Virtual base class for displacement motion solver.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual void topoChange(const polyTopoChangeMap &)
Update corresponding to the given map.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Templated form of IOobject providing type information for file reading and header type checking...
Definition: IOobject.H:537
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Calculate the matrix for the laplacian of the field.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
displacementLaplacianFvMotionSolver(const word &name, const polyMesh &, const dictionary &)
Construct from polyMesh and dictionary.
fvMesh & mesh
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
conserve primitiveFieldRef()+
Macros for easy insertion into run-time selection tables.
Base class for fvMesh based motionSolvers.
stressControl lookup("compactNormalStress") >> compactNormalStress
static word timeName(const scalar, const int precision=curPrecision_)
Return time name of given scalar time.
Definition: Time.C:666
A class for handling words, derived from string.
Definition: word.H:59
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
static const zero Zero
Definition: zero.H:97
virtual void topoChange(const polyTopoChangeMap &)
Update local data for topology changes.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Abstract base class for cell-centre mesh motion diffusivity.
static const char nl
Definition: Ostream.H:260
const Time & time() const
Return time.
defineTypeNameAndDebug(combustionModel, 0)
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list...
Definition: pointZone.H:62
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
A class for managing temporary objects.
Definition: PtrList.H:53
static autoPtr< motionDiffusivity > New(const fvMesh &mesh, Istream &mdData)
Select null constructed.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:50
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
bool found
Namespace for OpenFOAM.
motionDiffusivity & diffusivity()
Return reference to the diffusivity field.