solidBodyDisplacementLaplacianFvMotionSolver.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "motionInterpolation.H"
30 #include "motionDiffusivity.H"
31 #include "fvmLaplacian.H"
33 #include "OFstream.H"
34 #include "meshTools.H"
35 #include "mapPolyMesh.H"
37 #include "transformField.H"
38 #include "fvOptions.H"
39 
40 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44  defineTypeNameAndDebug(solidBodyDisplacementLaplacianFvMotionSolver, 0);
45 
47  (
48  motionSolver,
49  solidBodyDisplacementLaplacianFvMotionSolver,
50  dictionary
51  );
52 
54  (
55  displacementMotionSolver,
56  solidBodyDisplacementLaplacianFvMotionSolver,
57  displacement
58  );
59 }
60 
61 
62 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
63 
64 Foam::solidBodyDisplacementLaplacianFvMotionSolver::
65 solidBodyDisplacementLaplacianFvMotionSolver
66 (
67  const polyMesh& mesh,
68  const IOdictionary& dict
69 )
70 :
73  SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time())),
74  cellDisplacement_
75  (
76  IOobject
77  (
78  "cellDisplacement",
79  mesh.time().timeName(),
80  mesh,
81  IOobject::READ_IF_PRESENT,
82  IOobject::AUTO_WRITE
83  ),
84  fvMesh_,
85  dimensionedVector(pointDisplacement_.dimensions(), Zero),
86  cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
87  ),
88  pointLocation_(nullptr),
89  interpolationPtr_
90  (
91  coeffDict().found("interpolation")
92  ? motionInterpolation::New(fvMesh_, coeffDict().lookup("interpolation"))
93  : motionInterpolation::New(fvMesh_)
94  ),
95  diffusivityPtr_
96  (
97  motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
98  ),
99  frozenPointsZone_
100  (
101  coeffDict().found("frozenPointsZone")
102  ? fvMesh_.pointZones().findZoneID
103  (
104  coeffDict().get<word>("frozenPointsZone")
105  )
106  : -1
107  )
108 {
109  IOobject io
110  (
111  "pointLocation",
112  fvMesh_.time().timeName(),
113  fvMesh_,
114  IOobject::MUST_READ,
115  IOobject::AUTO_WRITE
116  );
117 
118  if (debug)
119  {
120  Info<< "solidBodyDisplacementLaplacianFvMotionSolver:" << nl
121  << " diffusivity : " << diffusivityPtr_().type() << nl
122  << " frozenPoints zone : " << frozenPointsZone_ << endl;
123  }
124 
125 
126  if (io.typeHeaderOk<pointVectorField>(true))
127  {
128  pointLocation_.reset
129  (
130  new pointVectorField
131  (
132  io,
133  pointMesh::New(fvMesh_)
134  )
135  );
136 
137  if (debug)
138  {
139  Info<< "solidBodyDisplacementLaplacianFvMotionSolver :"
140  << " Read pointVectorField "
141  << io.name()
142  << " to be used for boundary conditions on points."
143  << nl
144  << "Boundary conditions:"
145  << pointLocation_().boundaryField().types() << endl;
146  }
147  }
148 }
149 
150 
151 Foam::solidBodyDisplacementLaplacianFvMotionSolver::
152 solidBodyDisplacementLaplacianFvMotionSolver
153 (
154  const polyMesh& mesh,
155  const IOdictionary& dict,
156  const pointVectorField& pointDisplacement,
157  const pointIOField& points0
158 )
159 :
160  displacementMotionSolver(mesh, dict, pointDisplacement, points0, typeName),
162  SBMFPtr_(solidBodyMotionFunction::New(coeffDict(), mesh.time())),
163  cellDisplacement_
164  (
165  IOobject
166  (
167  "cellDisplacement",
168  mesh.time().timeName(),
169  mesh,
170  IOobject::READ_IF_PRESENT,
171  IOobject::AUTO_WRITE
172  ),
173  fvMesh_,
174  dimensionedVector(pointDisplacement_.dimensions(), Zero),
175  cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
176  ),
177  pointLocation_(nullptr),
178  interpolationPtr_
179  (
180  coeffDict().found("interpolation")
181  ? motionInterpolation::New(fvMesh_, coeffDict().lookup("interpolation"))
182  : motionInterpolation::New(fvMesh_)
183  ),
184  diffusivityPtr_
185  (
186  motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
187  ),
188  frozenPointsZone_
189  (
190  coeffDict().found("frozenPointsZone")
191  ? fvMesh_.pointZones().findZoneID
192  (
193  coeffDict().get<word>("frozenPointsZone")
194  )
195  : -1
196  )
197 {
198  IOobject io
199  (
200  "pointLocation",
201  fvMesh_.time().timeName(),
202  fvMesh_,
203  IOobject::MUST_READ,
204  IOobject::AUTO_WRITE
205  );
206 
207  if (debug)
208  {
209  Info<< "solidBodyDisplacementLaplacianFvMotionSolver:" << nl
210  << " diffusivity : " << diffusivityPtr_().type() << nl
211  << " frozenPoints zone : " << frozenPointsZone_ << endl;
212  }
213 
214 
215  if (io.typeHeaderOk<pointVectorField>(true))
216  {
217  pointLocation_.reset
218  (
219  new pointVectorField
220  (
221  io,
222  pointMesh::New(fvMesh_)
223  )
224  );
225 
226  if (debug)
227  {
228  Info<< "solidBodyDisplacementLaplacianFvMotionSolver :"
229  << " Read pointVectorField "
230  << io.name()
231  << " to be used for boundary conditions on points."
232  << nl
233  << "Boundary conditions:"
234  << pointLocation_().boundaryField().types() << endl;
235  }
236  }
237 }
238 
239 
240 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
241 
244 {}
245 
246 
247 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
248 
251 {
252  if (!diffusivityPtr_)
253  {
254  diffusivityPtr_ = motionDiffusivity::New
255  (
256  fvMesh_,
257  coeffDict().lookup("diffusivity")
258  );
259  }
260 
261  return *diffusivityPtr_;
262 }
263 
264 
267 {
268  interpolationPtr_->interpolate
269  (
270  cellDisplacement_,
271  pointDisplacement_
272  );
273 
274  tmp<pointField> tnewPoints
275  (
276  transformPoints(SBMFPtr_().transformation(), points0())
277  );
278  const pointField& newPoints = tnewPoints();
279 
280  if (pointLocation_)
281  {
282  if (debug)
283  {
284  Info<< "solidBodyDisplacementLaplacianFvMotionSolver : applying "
285  << " boundary conditions on " << pointLocation_().name()
286  << " to new point location."
287  << endl;
288  }
289 
290  pointLocation_().primitiveFieldRef() =
291  newPoints
292  + pointDisplacement_.internalField();
293 
294  pointLocation_().correctBoundaryConditions();
295 
296  // Implement frozen points
297  if (frozenPointsZone_ != -1)
298  {
299  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
300 
301  forAll(pz, i)
302  {
303  pointLocation_()[pz[i]] = newPoints[pz[i]];
304  }
305  }
306 
307  twoDCorrectPoints(pointLocation_().primitiveFieldRef());
308 
309  return tmp<pointField>(pointLocation_().primitiveField());
310  }
311  else
312  {
313  tmp<pointField> tcurPoints
314  (
315  newPoints + pointDisplacement_.primitiveField()
316  );
317  pointField& curPoints = tcurPoints.ref();
318 
319  // Implement frozen points
320  if (frozenPointsZone_ != -1)
321  {
322  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
323 
324  forAll(pz, i)
325  {
326  curPoints[pz[i]] = newPoints[pz[i]];
327  }
328  }
329 
330  twoDCorrectPoints(curPoints);
331 
332  return tcurPoints;
333  }
334 }
335 
336 
338 {
339  // The points have moved so before interpolation update
340  // the motionSolver accordingly
341  movePoints(fvMesh_.points());
342 
343  diffusivity().correct();
344  pointDisplacement_.boundaryFieldRef().updateCoeffs();
345 
347 
349  (
351  (
352  dimensionedScalar("viscosity", dimViscosity, 1.0)
353  *diffusivity().operator()(),
354  cellDisplacement_,
355  "laplacian(diffusivity,cellDisplacement)"
356  )
357  ==
358  fvOptions(cellDisplacement_)
359  );
360 
363  fvOptions.correct(cellDisplacement_);
364 }
365 
366 
368 (
369  const mapPolyMesh& mpm
370 )
371 {
373 
374  // Update diffusivity. Note two stage to make sure old one is de-registered
375  // before creating/registering new one.
376  diffusivityPtr_.clear();
377 }
378 
379 
380 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
meshTools.H
solidBodyMotionFunction.H
fvOptions.H
Foam::fv::optionList::correct
void correct(GeometricField< Type, fvPatchField, volMesh > &field)
Apply correction to field.
Definition: fvOptionListTemplates.C:355
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:61
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::motionDiffusivity
Abstract base class for cell-centre mesh motion diffusivity.
Definition: motionDiffusivity.H:51
Foam::fv::optionList::constrain
void constrain(fvMatrix< Type > &eqn)
Apply constraints to equation.
Definition: fvOptionListTemplates.C:314
Foam::fv::options::New
static options & New(const fvMesh &mesh)
Construct fvOptions and register to database if not present.
Definition: fvOptions.C:103
Foam::fvMatrix::solveSegregatedOrCoupled
SolverPerformance< Type > solveSegregatedOrCoupled(const dictionary &)
Solve segregated or coupled returning the solution statistics.
Definition: fvMatrixSolve.C:62
mapPolyMesh.H
Foam::pointZone
A subset of mesh points.
Definition: pointZone.H:65
Foam::solidBodyDisplacementLaplacianFvMotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update topology.
Definition: solidBodyDisplacementLaplacianFvMotionSolver.C:368
solidBodyDisplacementLaplacianFvMotionSolver.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
primitiveFieldRef
conserve primitiveFieldRef()+
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
transformField.H
Spatial transformation functions for primitive fields.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
OFstream.H
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
TEqn
fvScalarMatrix TEqn(fvm::ddt(T)+fvm::div(phi, T) - fvm::laplacian(alphaEff, T)==radiation->ST(rhoCpRef, T)+fvOptions(T))
Foam::fvMotionSolver
Base class for fvMesh based motionSolvers.
Definition: fvMotionSolver.H:50
Foam::solidBodyDisplacementLaplacianFvMotionSolver::diffusivity
motionDiffusivity & diffusivity()
Return reference to the diffusivity field.
Definition: solidBodyDisplacementLaplacianFvMotionSolver.C:250
fvOptions
fv::options & fvOptions
Definition: setRegionFluidFields.H:23
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:48
Foam::solidBodyDisplacementLaplacianFvMotionSolver::~solidBodyDisplacementLaplacianFvMotionSolver
~solidBodyDisplacementLaplacianFvMotionSolver()
Destructor.
Definition: solidBodyDisplacementLaplacianFvMotionSolver.C:243
fvmLaplacian.H
Calculate the matrix for the laplacian of the field.
Foam::solidBodyDisplacementLaplacianFvMotionSolver::curPoints
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Definition: solidBodyDisplacementLaplacianFvMotionSolver.C:266
Foam::motionDiffusivity::New
static autoPtr< motionDiffusivity > New(const fvMesh &mesh, Istream &mdData)
Select null constructed.
Definition: motionDiffusivity.C:51
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::radiation::lookup
Lookup type of boundary radiation properties.
Definition: lookup.H:63
Foam::fv::options
Finite-volume options.
Definition: fvOptions.H:55
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dimViscosity
const dimensionSet dimViscosity
Foam::displacementMotionSolver
Virtual base class for displacement motion solver.
Definition: displacementMotionSolver.H:53
Foam::transformPoints
void transformPoints(vectorField &, const septernion &, const vectorField &)
Transform given vectorField of coordinates with the given septernion.
Definition: transformField.C:73
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
motionDiffusivity.H
Foam::solidBodyDisplacementLaplacianFvMotionSolver::solve
virtual void solve()
Solve for motion.
Definition: solidBodyDisplacementLaplacianFvMotionSolver.C:337
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
found
bool found
Definition: TABSMDCalcMethod2.H:32
points0
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::points0MotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Definition: points0MotionSolver.C:157
Foam::fvMatrix::solverDict
const dictionary & solverDict() const
Return the solver dictionary taking into account finalIteration.
Definition: fvMatrix.C:1649
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::GeometricField< vector, pointPatchField, pointMesh >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
motionInterpolation.H