displacementComponentLaplacianFvMotionSolver.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "motionInterpolation.H"
31 #include "motionDiffusivity.H"
32 #include "fvmLaplacian.H"
34 #include "mapPolyMesh.H"
35 #include "fvOptions.H"
36 
37 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41  defineTypeNameAndDebug(displacementComponentLaplacianFvMotionSolver, 0);
42 
44  (
45  motionSolver,
46  displacementComponentLaplacianFvMotionSolver,
47  dictionary
48  );
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 Foam::displacementComponentLaplacianFvMotionSolver::
55 displacementComponentLaplacianFvMotionSolver
56 (
57  const polyMesh& mesh,
58  const IOdictionary& dict
59 )
60 :
63  cellDisplacement_
64  (
65  IOobject
66  (
67  "cellDisplacement" + cmptName_,
68  mesh.time().timeName(),
69  mesh,
70  IOobject::READ_IF_PRESENT,
71  IOobject::AUTO_WRITE
72  ),
73  fvMesh_,
74  dimensionedScalar(pointDisplacement_.dimensions(), Zero),
75  cellMotionBoundaryTypes<scalar>(pointDisplacement_.boundaryField())
76  ),
77  pointLocation_(nullptr),
78  interpolationPtr_
79  (
80  coeffDict().found("interpolation")
81  ? motionInterpolation::New(fvMesh_, coeffDict().lookup("interpolation"))
82  : motionInterpolation::New(fvMesh_)
83  ),
84  diffusivityPtr_
85  (
86  motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
87  ),
88  frozenPointsZone_
89  (
90  coeffDict().found("frozenPointsZone")
91  ? fvMesh_.pointZones().findZoneID
92  (
93  coeffDict().get<word>("frozenPointsZone")
94  )
95  : -1
96  )
97 {
98  if (coeffDict().getOrDefault("applyPointLocation", true))
99  {
100  pointLocation_.reset
101  (
102  new pointVectorField
103  (
104  IOobject
105  (
106  "pointLocation",
107  fvMesh_.time().timeName(),
108  fvMesh_,
109  IOobject::MUST_READ,
110  IOobject::AUTO_WRITE
111  ),
112  pointMesh::New(fvMesh_)
113  )
114  );
115 
116  //if (debug)
117  {
118  Info<< "displacementComponentLaplacianFvMotionSolver :"
119  << " Read pointVectorField "
120  << pointLocation_().name()
121  << " to be used for boundary conditions on points."
122  << nl
123  << "Boundary conditions:"
124  << pointLocation_().boundaryField().types() << endl;
125  }
126  }
127 }
128 
129 
130 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
131 
134 {}
135 
136 
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 
141 {
142  interpolationPtr_->interpolate
143  (
144  cellDisplacement_,
145  pointDisplacement_
146  );
147 
148  if (pointLocation_)
149  {
150  if (debug)
151  {
152  Info<< "displacementComponentLaplacianFvMotionSolver : applying "
153  << " boundary conditions on " << pointLocation_().name()
154  << " to new point location."
155  << endl;
156  }
157 
158  // Apply pointLocation_ b.c. to mesh points.
159 
160  pointLocation_().primitiveFieldRef() = fvMesh_.points();
161 
162  pointLocation_().primitiveFieldRef().replace
163  (
164  cmpt_,
165  points0_ + pointDisplacement_.primitiveField()
166  );
167 
168  pointLocation_().correctBoundaryConditions();
169 
170  // Implement frozen points
171  if (frozenPointsZone_ != -1)
172  {
173  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
174 
175  forAll(pz, i)
176  {
177  label pointi = pz[i];
178 
179  pointLocation_()[pointi][cmpt_] = points0_[pointi];
180  }
181  }
182 
183  twoDCorrectPoints(pointLocation_().primitiveFieldRef());
184 
185  return tmp<pointField>(pointLocation_().primitiveField());
186  }
187  else
188  {
189  tmp<pointField> tcurPoints(new pointField(fvMesh_.points()));
190  pointField& curPoints = tcurPoints.ref();
191 
192  curPoints.replace
193  (
194  cmpt_,
195  points0_ + pointDisplacement_.primitiveField()
196  );
197 
198  // Implement frozen points
199  if (frozenPointsZone_ != -1)
200  {
201  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
202 
203  forAll(pz, i)
204  {
205  label pointi = pz[i];
206 
207  curPoints[pointi][cmpt_] = points0_[pointi];
208  }
209  }
210 
211  twoDCorrectPoints(curPoints);
212 
213  return tcurPoints;
214  }
215 }
216 
217 
219 {
220  // The points have moved so before interpolation update
221  // the motionSolver accordingly
222  movePoints(fvMesh_.points());
223 
224  diffusivityPtr_->correct();
225  pointDisplacement_.boundaryFieldRef().updateCoeffs();
226 
228 
229  // We explicitly do NOT want to interpolate the motion inbetween
230  // different regions so bypass all the matrix manipulation.
232  (
234  (
235  dimensionedScalar("viscosity", dimViscosity, 1.0)
236  *diffusivityPtr_->operator()(),
237  cellDisplacement_,
238  "laplacian(diffusivity,cellDisplacement)"
239  )
240  ==
241  fvOptions(cellDisplacement_)
242  );
243 
246  fvOptions.correct(cellDisplacement_);
247 }
248 
249 
251 (
252  const mapPolyMesh& mpm
253 )
254 {
256 
257  // Update diffusivity. Note two stage to make sure old one is de-registered
258  // before creating/registering new one.
259  diffusivityPtr_.reset(nullptr);
260  diffusivityPtr_ = motionDiffusivity::New
261  (
262  fvMesh_,
263  coeffDict().lookup("diffusivity")
264  );
265 }
266 
267 
268 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
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
fvOptions.H
Foam::fv::optionList::correct
void correct(GeometricField< Type, fvPatchField, volMesh > &field)
Apply correction to field.
Definition: fvOptionListTemplates.C:355
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::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::componentDisplacementMotionSolver
Virtual base class for displacement motion solver.
Definition: componentDisplacementMotionSolver.H:56
Foam::displacementComponentLaplacianFvMotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update topology.
Definition: displacementComponentLaplacianFvMotionSolver.C:251
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
Foam::displacementComponentLaplacianFvMotionSolver::~displacementComponentLaplacianFvMotionSolver
~displacementComponentLaplacianFvMotionSolver()
Destructor.
Definition: displacementComponentLaplacianFvMotionSolver.C:133
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
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::componentDisplacementMotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Definition: componentDisplacementMotionSolver.C:149
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:227
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
fvmLaplacian.H
Calculate the matrix for the laplacian of the field.
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::Field::replace
void replace(const direction, const UList< cmptType > &)
Replace a component field of the field.
Definition: Field.C:551
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
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::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
Foam::displacementComponentLaplacianFvMotionSolver::curPoints
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Definition: displacementComponentLaplacianFvMotionSolver.C:140
Foam::nl
constexpr char nl
Definition: Ostream.H:404
displacementComponentLaplacianFvMotionSolver.H
Foam::fvMatrix::solverDict
const dictionary & solverDict() const
Return the solver dictionary taking into account finalIteration.
Definition: fvMatrix.C:1649
Foam::displacementComponentLaplacianFvMotionSolver::solve
virtual void solve()
Solve for motion.
Definition: displacementComponentLaplacianFvMotionSolver.C:218
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
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