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-2023 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 {
40 
42  (
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().name(),
67  mesh,
68  IOobject::READ_IF_PRESENT,
69  IOobject::AUTO_WRITE
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().findIndex(coeffDict().lookup("frozenPointsZone"))
89  : -1
90  )
91 {
93  (
94  "pointLocation",
95  fvMesh_.time().name(),
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,
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 // ************************************************************************* //
bool found
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:310
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
const word & name() const
Return const reference to name.
Mesh motion solver for an fvMesh. Based on solving the cell-centre Laplacian for the motion displacem...
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
displacementLaplacianFvMotionSolver(const word &name, const polyMesh &, const dictionary &)
Construct from polyMesh and dictionary.
virtual void topoChange(const polyTopoChangeMap &)
Update corresponding to the given map.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
motionDiffusivity & diffusivity()
Return reference to the diffusivity field.
Virtual base class for displacement motion solver.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:418
Base class for fvMesh based motionSolvers.
const fvMesh & fvMesh_
The fvMesh to be moved.
Abstract base class for cell-centre mesh motion diffusivity.
static autoPtr< motionDiffusivity > New(const fvMesh &mesh, Istream &mdData)
Select null constructed.
Virtual base class for mesh motion solver.
Definition: motionSolver.H:57
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list.
Definition: pointZone.H:59
virtual void topoChange(const polyTopoChangeMap &)
Update local data for topology changes.
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
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:181
Templated form of IOobject providing type information for file reading and header type checking.
Definition: IOobject.H:531
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.
A class for handling words, derived from string.
Definition: word.H:62
Calculate the matrix for the laplacian of the field.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
Namespace for OpenFOAM.
static const zero Zero
Definition: zero.H:97
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
const HashTable< dimensionSet > & dimensions()
Get the table of dimension sets.
Definition: dimensionSets.C:96
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
messageStream Info
defineTypeNameAndDebug(combustionModel, 0)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
static const char nl
Definition: Ostream.H:266
SolverPerformance< Type > solve(fvMatrix< Type > &, const word &)
Solve returning the solution statistics given convergence tolerance.
dictionary dict
conserve primitiveFieldRef()+