displacementLaplacian_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 "OFstream.H"
30 #include "meshTools.H"
31 #include "polyTopoChangeMap.H"
32 #include "volPointInterpolation.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace fvMotionSolvers
40 {
42 
44  (
47  fvMesh
48  );
49 
51  (
55  );
56 }
57 }
58 
59 
60 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
61 
63 (
64  const polyMesh& mesh,
65  const dictionary& dict
66 )
67 :
69  pointMeshMovers::displacement(mesh, dict, typeName),
70  cellDisplacement_
71  (
72  IOobject
73  (
74  "cellDisplacement",
75  mesh.time().name(),
76  mesh,
77  IOobject::READ_IF_PRESENT,
78  IOobject::AUTO_WRITE
79  ),
82  (
83  "cellDisplacement",
84  pointDisplacement_.dimensions(),
85  Zero
86  ),
87  cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
88  ),
89  pointLocation_(nullptr),
90  diffusivityType_(dict.lookup("diffusivity")),
91  diffusivityPtr_
92  (
93  motionDiffusivity::New(fvMotionSolver::mesh(), diffusivityType_)
94  ),
95  frozenPointsZone_
96  (
97  dict.found("frozenPointsZone")
98  ? fvMotionSolver::mesh().pointZones().findIndex
99  (
100  dict.lookup("frozenPointsZone")
101  )
102  : -1
103  )
104 {
106  (
107  "pointLocation",
112  );
113 
114  if (debug)
115  {
116  Info<< "displacementLaplacian:" << nl
117  << " diffusivity : " << diffusivityPtr_().type() << nl
118  << " frozenPoints zone : " << frozenPointsZone_ << endl;
119  }
120 
121  if (io.headerOk())
122  {
123  pointLocation_.reset
124  (
125  new pointVectorField
126  (
127  io,
129  )
130  );
131 
132  if (debug)
133  {
134  Info<< "displacementLaplacian :"
135  << " Read pointVectorField "
136  << io.name()
137  << " to be used for boundary conditions on points."
138  << nl
139  << "Boundary conditions:"
140  << pointLocation_().boundaryField().types() << endl;
141  }
142  }
143 }
144 
145 
147 (
148  fvMesh& mesh,
149  const dictionary& dict
150 )
151 :
153 {}
154 
155 
156 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
157 
159 {}
160 
161 
162 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
163 
166 {
167  if (!diffusivityPtr_.valid())
168  {
169  diffusivityType_.rewind();
170  diffusivityPtr_ = motionDiffusivity::New
171  (
172  mesh(),
173  diffusivityType_
174  );
175  }
176  return diffusivityPtr_();
177 }
178 
179 
182 {
183  // The points have moved so before interpolation update
184  // the pointMeshMover accordingly
185  movePoints(mesh().points());
186 
187  diffusivity().correct();
188  pointDisplacement_.boundaryFieldRef().updateCoeffs();
189 
191  (
193  (
194  diffusivity().operator()(),
195  cellDisplacement_,
196  "laplacian(diffusivity,cellDisplacement)"
197  )
198  );
199 
201  (
202  cellDisplacement_,
203  pointDisplacement_
204  );
205 
206  if (pointLocation_.valid())
207  {
208  if (debug)
209  {
210  Info<< "displacementLaplacian : applying "
211  << " boundary conditions on " << pointLocation_().name()
212  << " to new point location."
213  << endl;
214  }
215 
216  pointLocation_().primitiveFieldRef() =
217  points0()
218  + pointDisplacement_.primitiveField();
219 
220  pointLocation_().correctBoundaryConditions();
221 
222  // Implement frozen points
223  if (frozenPointsZone_ != -1)
224  {
225  const pointZone& pz = mesh().pointZones()[frozenPointsZone_];
226 
227  forAll(pz, i)
228  {
229  pointLocation_()[pz[i]] = points0()[pz[i]];
230  }
231  }
232 
233  twoDCorrectPoints(pointLocation_().primitiveFieldRef());
234 
235  return tmp<pointField>(pointLocation_().primitiveField());
236  }
237  else
238  {
239  tmp<pointField> tcurPoints
240  (
241  points0() + pointDisplacement_.primitiveField()
242  );
243  pointField& curPoints = tcurPoints.ref();
244 
245  // Implement frozen points
246  if (frozenPointsZone_ != -1)
247  {
248  const pointZone& pz = mesh().pointZones()[frozenPointsZone_];
249 
250  forAll(pz, i)
251  {
252  curPoints[pz[i]] = points0()[pz[i]];
253  }
254  }
255 
256  twoDCorrectPoints(curPoints);
257 
258  return tcurPoints;
259  }
260 }
261 
262 
264 (
265  const polyTopoChangeMap& map
266 )
267 {
269  diffusivityPtr_.clear();
270 }
271 
272 
274 (
275  const polyMeshMap& map
276 )
277 {
279  diffusivityPtr_.clear();
280 }
281 
282 
283 // ************************************************************************* //
bool found
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
Macros for easy insertion into run-time selection tables.
static pointMesh & New(const word &name, const polyMesh &mesh)
Construct and return the named DemandDrivenMeshObject.
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
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
fvMesh & mesh()
Return the fvMesh.
Definition: fvMeshMover.H:102
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 Laplacian for the motion displacem...
displacementLaplacian(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.
motionDiffusivity & diffusivity()
Return reference to the diffusivity field.
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)
Named list of point indices representing a sub-set of the mesh faces.
Definition: pointZone.H:60
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
const pointZoneList & pointZones() const
Return point zones.
Definition: polyMesh.H:426
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
Templated form of IOobject providing type information for file reading and header type checking.
Definition: IOobject.H:545
bool headerOk()
Read header (uses typeGlobalFile to find file) and check.
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 matrix for the laplacian of the field.
const pointField & points
const dimensionSet time
defineTypeNameAndDebug(displacementLaplacian, 0)
addToRunTimeSelectionTable(fvMeshMover, displacementLaplacian, fvMesh)
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
static const char nl
Definition: Ostream.H:297
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
dictionary dict
conserve primitiveFieldRef()+