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  ),
131  )
132  );
133 
134  if (debug)
135  {
136  Info<< "displacementComponentLaplacian :"
137  << " Read pointVectorField "
138  << pointLocation_().name()
139  << " to be used for boundary conditions on points."
140  << nl
141  << "Boundary conditions:"
142  << pointLocation_().boundaryField().types() << endl;
143  }
144  }
145 }
146 
147 
150 (
151  fvMesh& mesh,
152  const dictionary& dict
153 )
154 :
156 {}
157 
158 
159 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
160 
163 {}
164 
165 
166 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
167 
170 {
171  // The points have moved so before interpolation update
172  // the pointMeshMover accordingly
173  movePoints(mesh().points());
174 
175  diffusivityPtr_->correct();
176  pointDisplacement_.boundaryFieldRef().updateCoeffs();
177 
179  (
181  (
182  diffusivityPtr_->operator()(),
183  cellDisplacement_,
184  "laplacian(diffusivity,cellDisplacement)"
185  )
186  );
187 
189  (
190  cellDisplacement_,
191  pointDisplacement_
192  );
193 
194  if (pointLocation_.valid())
195  {
196  if (debug)
197  {
198  Info<< "displacementComponentLaplacian : applying "
199  << " boundary conditions on " << pointLocation_().name()
200  << " to new point location."
201  << endl;
202  }
203 
204  // Apply pointLocation_ b.c. to mesh points.
205 
206  pointLocation_().primitiveFieldRef() = mesh().points();
207 
208  pointLocation_().primitiveFieldRef().replace
209  (
210  cmpt_,
211  points0_ + pointDisplacement_.primitiveField()
212  );
213 
214  pointLocation_().correctBoundaryConditions();
215 
216  // Implement frozen points
217  if (frozenPointsZone_ != -1)
218  {
219  const pointZone& pz = mesh().pointZones()[frozenPointsZone_];
220 
221  forAll(pz, i)
222  {
223  label pointi = pz[i];
224 
225  pointLocation_()[pointi][cmpt_] = points0_[pointi];
226  }
227  }
228 
229  twoDCorrectPoints(pointLocation_().primitiveFieldRef());
230 
231  return tmp<pointField>(pointLocation_().primitiveField());
232  }
233  else
234  {
235  tmp<pointField> tcurPoints(new pointField(mesh().points()));
236  pointField& curPoints = tcurPoints.ref();
237 
238  curPoints.replace
239  (
240  cmpt_,
241  points0_ + pointDisplacement_.primitiveField()
242  );
243 
244  // Implement frozen points
245  if (frozenPointsZone_ != -1)
246  {
247  const pointZone& pz = mesh().pointZones()[frozenPointsZone_];
248 
249  forAll(pz, i)
250  {
251  label pointi = pz[i];
252 
253  curPoints[pointi][cmpt_] = points0_[pointi];
254  }
255  }
256 
257  twoDCorrectPoints(curPoints);
258 
259  return tcurPoints;
260  }
261 }
262 
263 
265 (
266  const polyTopoChangeMap& map
267 )
268 {
270 
271  // Update diffusivity. Note two stage to make sure old one is de-registered
272  // before creating/registering new one.
273  diffusivityPtr_.reset(nullptr);
274  diffusivityType_.rewind();
275  diffusivityPtr_ = motionDiffusivity::New
276  (
277  mesh(),
278  diffusivityType_
279  );
280 }
281 
282 
284 (
285  const polyMeshMap& map
286 )
287 {
289 
290  // Update diffusivity. Note two stage to make sure old one is de-registered
291  // before creating/registering new one.
292  diffusivityPtr_.reset(nullptr);
293  diffusivityType_.rewind();
294  diffusivityPtr_ = motionDiffusivity::New
295  (
296  mesh(),
297  diffusivityType_
298  );
299 }
300 
301 
302 // ************************************************************************* //
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
const dimensionSet length
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()+