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 | Copyright (C) 2011-2015 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 "motionInterpolation.H"
28 #include "motionDiffusivity.H"
29 #include "fvmLaplacian.H"
31 #include "mapPolyMesh.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(displacementComponentLaplacianFvMotionSolver, 0);
38 
40  (
41  motionSolver,
42  displacementComponentLaplacianFvMotionSolver,
43  dictionary
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
52 (
53  const polyMesh& mesh,
54  const IOdictionary& dict
55 )
56 :
59  cellDisplacement_
60  (
61  IOobject
62  (
63  "cellDisplacement" + cmptName_,
64  mesh.time().timeName(),
65  mesh,
66  IOobject::READ_IF_PRESENT,
67  IOobject::AUTO_WRITE
68  ),
69  fvMesh_,
71  (
72  "cellDisplacement",
73  pointDisplacement_.dimensions(),
74  0
75  ),
76  cellMotionBoundaryTypes<scalar>(pointDisplacement_.boundaryField())
77  ),
78  pointLocation_(NULL),
79  interpolationPtr_
80  (
81  coeffDict().found("interpolation")
82  ? motionInterpolation::New(fvMesh_, coeffDict().lookup("interpolation"))
83  : motionInterpolation::New(fvMesh_)
84  ),
85  diffusivityPtr_
86  (
87  motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
88  ),
89  frozenPointsZone_
90  (
91  coeffDict().found("frozenPointsZone")
92  ? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone"))
93  : -1
94  )
95 {
96  Switch applyPointLocation
97  (
98  coeffDict().lookupOrDefault
99  (
100  "applyPointLocation",
101  true
102  )
103  );
104 
105  if (applyPointLocation)
106  {
107  pointLocation_.reset
108  (
109  new pointVectorField
110  (
111  IOobject
112  (
113  "pointLocation",
114  fvMesh_.time().timeName(),
115  fvMesh_,
116  IOobject::MUST_READ,
117  IOobject::AUTO_WRITE
118  ),
119  pointMesh::New(fvMesh_)
120  )
121  );
122 
123  //if (debug)
124  {
125  Info<< "displacementComponentLaplacianFvMotionSolver :"
126  << " Read pointVectorField "
127  << pointLocation_().name()
128  << " to be used for boundary conditions on points."
129  << nl
130  << "Boundary conditions:"
131  << pointLocation_().boundaryField().types() << endl;
132  }
133  }
134 }
135 
136 
137 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
138 
141 {}
142 
143 
144 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
145 
148 {
149  interpolationPtr_->interpolate
150  (
151  cellDisplacement_,
152  pointDisplacement_
153  );
154 
155  if (pointLocation_.valid())
156  {
157  if (debug)
158  {
159  Info<< "displacementComponentLaplacianFvMotionSolver : applying "
160  << " boundary conditions on " << pointLocation_().name()
161  << " to new point location."
162  << endl;
163  }
164 
165  // Apply pointLocation_ b.c. to mesh points.
166 
167  pointLocation_().internalField() = fvMesh_.points();
168 
169  pointLocation_().internalField().replace
170  (
171  cmpt_,
172  points0_ + pointDisplacement_.internalField()
173  );
174 
175  pointLocation_().correctBoundaryConditions();
176 
177  // Implement frozen points
178  if (frozenPointsZone_ != -1)
179  {
180  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
181 
182  forAll(pz, i)
183  {
184  label pointI = pz[i];
185 
186  pointLocation_()[pointI][cmpt_] = points0_[pointI];
187  }
188  }
189 
190  twoDCorrectPoints(pointLocation_().internalField());
191 
192  return tmp<pointField>(pointLocation_().internalField());
193  }
194  else
195  {
196  tmp<pointField> tcurPoints(new pointField(fvMesh_.points()));
197 
198  tcurPoints().replace
199  (
200  cmpt_,
201  points0_ + pointDisplacement_.internalField()
202  );
203 
204  // Implement frozen points
205  if (frozenPointsZone_ != -1)
206  {
207  const pointZone& pz = fvMesh_.pointZones()[frozenPointsZone_];
208 
209  forAll(pz, i)
210  {
211  label pointI = pz[i];
212 
213  tcurPoints()[pointI][cmpt_] = points0_[pointI];
214  }
215  }
216 
217  twoDCorrectPoints(tcurPoints());
218 
219  return tcurPoints;
220  }
221 }
222 
223 
225 {
226  // The points have moved so before interpolation update
227  // the motionSolver accordingly
228  movePoints(fvMesh_.points());
229 
230  diffusivityPtr_->correct();
231  pointDisplacement_.boundaryField().updateCoeffs();
232 
234  (
236  (
237  diffusivityPtr_->operator()(),
238  cellDisplacement_,
239  "laplacian(diffusivity,cellDisplacement)"
240  )
241  );
242 }
243 
244 
246 (
247  const mapPolyMesh& mpm
248 )
249 {
251 
252  // Update diffusivity. Note two stage to make sure old one is de-registered
253  // before creating/registering new one.
254  diffusivityPtr_.reset(NULL);
255  diffusivityPtr_ = motionDiffusivity::New
256  (
257  fvMesh_,
258  coeffDict().lookup("diffusivity")
259  );
260 }
261 
262 
263 // ************************************************************************* //
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::displacementComponentLaplacianFvMotionSolver::displacementComponentLaplacianFvMotionSolver
displacementComponentLaplacianFvMotionSolver(const displacementComponentLaplacianFvMotionSolver &)
Disallow default bitwise copy construct.
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
mapPolyMesh.H
Foam::pointZone
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list.
Definition: pointZone.H:62
Foam::componentDisplacementMotionSolver
Virtual base class for displacement motion solver.
Definition: componentDisplacementMotionSolver.H:54
Foam::displacementComponentLaplacianFvMotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update topology.
Definition: displacementComponentLaplacianFvMotionSolver.C:246
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::displacementComponentLaplacianFvMotionSolver::~displacementComponentLaplacianFvMotionSolver
~displacementComponentLaplacianFvMotionSolver()
Destructor.
Definition: displacementComponentLaplacianFvMotionSolver.C:140
Foam::componentDisplacementMotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Definition: componentDisplacementMotionSolver.C:144
Foam::label
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
Foam::fvMotionSolverCore
Base class for fvMesh based motionSolvers.
Definition: fvMotionSolverCore.H:48
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::fvm::laplacian
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
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:48
dict
dictionary dict
Definition: searchingEngine.H:14
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
motionDiffusivity.H
internalField
conserve internalField()+
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::solve
SolverPerformance< Type > solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
Foam::displacementComponentLaplacianFvMotionSolver::curPoints
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Definition: displacementComponentLaplacianFvMotionSolver.C:147
displacementComponentLaplacianFvMotionSolver.H
Foam::displacementComponentLaplacianFvMotionSolver::solve
virtual void solve()
Solve for motion.
Definition: displacementComponentLaplacianFvMotionSolver.C:224
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
motionInterpolation.H
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress