displacementComponentLaplacian_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 "polyTopoChangeMap.H"
30 #include "volPointInterpolation.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 namespace fvMotionSolvers
38 {
40 
42  (
45  fvMesh
46  );
47 
49  (
53  );
54 }
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
62 (
63  const polyMesh& mesh,
64  const dictionary& dict
65 )
66 :
68  pointMeshMovers::displacementComponent(mesh, dict, type()),
69  cellDisplacement_
70  (
71  IOobject
72  (
73  "cellDisplacement" + cmptName_,
74  mesh.time().name(),
75  mesh,
76  IOobject::READ_IF_PRESENT,
77  IOobject::AUTO_WRITE
78  ),
80  dimensionedScalar(pointDisplacement_.dimensions(), 0),
81  cellMotionBoundaryTypes<scalar>(pointDisplacement_.boundaryField())
82  ),
83  pointLocation_(nullptr),
84  diffusivityType_(dict.lookup("diffusivity")),
85  diffusivityPtr_
86  (
87  motionDiffusivity::New(fvMotionSolver::mesh(), diffusivityType_)
88  ),
89  frozenPointsZone_
90  (
91  dict.found("frozenPointsZone")
92  ? fvMotionSolver::mesh().pointZones().findIndex
93  (
94  dict.lookup("frozenPointsZone")
95  )
96  : -1
97  )
98 {
100  (
101  "pointLocation",
106  );
107 
108  if (debug)
109  {
110  Info<< "displacementComponentLaplacian:" << nl
111  << " diffusivity : " << diffusivityPtr_().type() << nl
112  << " frozenPoints zone : " << frozenPointsZone_ << endl;
113  }
114 
115  if (io.headerOk())
116  {
117  pointLocation_.reset
118  (
119  new pointVectorField
120  (
121  IOobject
122  (
123  "pointLocation",
128  ),
130  )
131  );
132 
133  if (debug)
134  {
135  Info<< "displacementComponentLaplacian :"
136  << " Read pointVectorField "
137  << pointLocation_().name()
138  << " to be used for boundary conditions on points."
139  << nl
140  << "Boundary conditions:"
141  << pointLocation_().boundaryField().types() << endl;
142  }
143  }
144 }
145 
146 
149 (
150  fvMesh& mesh,
151  const dictionary& dict
152 )
153 :
155 {}
156 
157 
158 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
159 
162 {}
163 
164 
165 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
166 
169 {
170  // The points have moved so before interpolation update
171  // the pointMeshMover accordingly
172  movePoints(mesh().points());
173 
174  diffusivityPtr_->correct();
175  pointDisplacement_.boundaryFieldRef().updateCoeffs();
176 
178  (
180  (
181  diffusivityPtr_->operator()(),
182  cellDisplacement_,
183  "laplacian(diffusivity,cellDisplacement)"
184  )
185  );
186 
188  (
189  cellDisplacement_,
190  pointDisplacement_
191  );
192 
193  if (pointLocation_.valid())
194  {
195  if (debug)
196  {
197  Info<< "displacementComponentLaplacian : applying "
198  << " boundary conditions on " << pointLocation_().name()
199  << " to new point location."
200  << endl;
201  }
202 
203  // Apply pointLocation_ b.c. to mesh points.
204 
205  pointLocation_().primitiveFieldRef() = mesh().points();
206 
207  pointLocation_().primitiveFieldRef().replace
208  (
209  cmpt_,
210  points0_ + pointDisplacement_.primitiveField()
211  );
212 
213  pointLocation_().correctBoundaryConditions();
214 
215  // Implement frozen points
216  if (frozenPointsZone_ != -1)
217  {
218  const pointZone& pz = mesh().pointZones()[frozenPointsZone_];
219 
220  forAll(pz, i)
221  {
222  label pointi = pz[i];
223 
224  pointLocation_()[pointi][cmpt_] = points0_[pointi];
225  }
226  }
227 
228  twoDCorrectPoints(pointLocation_().primitiveFieldRef());
229 
230  return tmp<pointField>(pointLocation_().primitiveField());
231  }
232  else
233  {
234  tmp<pointField> tcurPoints(new pointField(mesh().points()));
235  pointField& curPoints = tcurPoints.ref();
236 
237  curPoints.replace
238  (
239  cmpt_,
240  points0_ + pointDisplacement_.primitiveField()
241  );
242 
243  // Implement frozen points
244  if (frozenPointsZone_ != -1)
245  {
246  const pointZone& pz = mesh().pointZones()[frozenPointsZone_];
247 
248  forAll(pz, i)
249  {
250  label pointi = pz[i];
251 
252  curPoints[pointi][cmpt_] = points0_[pointi];
253  }
254  }
255 
256  twoDCorrectPoints(curPoints);
257 
258  return tcurPoints;
259  }
260 }
261 
262 
264 (
265  const polyTopoChangeMap& map
266 )
267 {
269 
270  // Update diffusivity. Note two stage to make sure old one is de-registered
271  // before creating/registering new one.
272  diffusivityPtr_.reset(nullptr);
273  diffusivityType_.rewind();
274  diffusivityPtr_ = motionDiffusivity::New
275  (
276  mesh(),
277  diffusivityType_
278  );
279 }
280 
281 
283 (
284  const polyMeshMap& map
285 )
286 {
288 
289  // Update diffusivity. Note two stage to make sure old one is de-registered
290  // before creating/registering new one.
291  diffusivityPtr_.reset(nullptr);
292  diffusivityType_.rewind();
293  diffusivityPtr_ = motionDiffusivity::New
294  (
295  mesh(),
296  diffusivityType_
297  );
298 }
299 
300 
301 // ************************************************************************* //
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.
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
Definition: Field.C:498
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
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 given component ...
displacementComponentLaplacian(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.
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
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1295
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.
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.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
messageStream Info
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
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
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
dictionary dict
conserve primitiveFieldRef()+