displacementLaplacianFvMotionSolver.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-2013 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 "mapPolyMesh.H"
33 #include "volPointInterpolation.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(displacementLaplacianFvMotionSolver, 0);
40 
42  (
43  motionSolver,
44  displacementLaplacianFvMotionSolver,
45  dictionary
46  );
47 }
48 
49 
50 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
51 
52 Foam::displacementLaplacianFvMotionSolver::displacementLaplacianFvMotionSolver
53 (
54  const polyMesh& mesh,
55  const IOdictionary& dict
56 )
57 :
58  displacementMotionSolver(mesh, dict, typeName),
59  fvMotionSolverCore(mesh),
60  cellDisplacement_
61  (
62  IOobject
63  (
64  "cellDisplacement",
65  mesh.time().timeName(),
66  mesh,
69  ),
70  fvMesh_,
72  (
73  "cellDisplacement",
74  pointDisplacement_.dimensions(),
76  ),
77  cellMotionBoundaryTypes<vector>(pointDisplacement_.boundaryField())
78  ),
79  pointLocation_(NULL),
80  diffusivityPtr_
81  (
82  motionDiffusivity::New(fvMesh_, coeffDict().lookup("diffusivity"))
83  ),
84  frozenPointsZone_
85  (
86  coeffDict().found("frozenPointsZone")
87  ? fvMesh_.pointZones().findZoneID(coeffDict().lookup("frozenPointsZone"))
88  : -1
89  )
90 {
91  IOobject io
92  (
93  "pointLocation",
94  fvMesh_.time().timeName(),
95  fvMesh_,
98  );
99 
100  if (debug)
101  {
102  Info<< "displacementLaplacianFvMotionSolver:" << nl
103  << " diffusivity : " << diffusivityPtr_().type() << nl
104  << " frozenPoints zone : " << frozenPointsZone_ << endl;
105  }
106 
107 
108  if (io.headerOk())
109  {
110  pointLocation_.reset
111  (
112  new pointVectorField
113  (
114  io,
115  pointMesh::New(fvMesh_)
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_().internalField() =
177  points0()
178  + pointDisplacement_.internalField();
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_().internalField());
194 
195  return tmp<pointField>(pointLocation_().internalField());
196  }
197  else
198  {
199  tmp<pointField> tcurPoints
200  (
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  tcurPoints()[pz[i]] = points0()[pz[i]];
212  }
213  }
214 
215  twoDCorrectPoints(tcurPoints());
216 
217  return tcurPoints;
218  }
219 }
220 
221 
223 {
224  // The points have moved so before interpolation update
225  // the motionSolver accordingly
226  movePoints(fvMesh_.points());
227 
228  diffusivity().correct();
229  pointDisplacement_.boundaryField().updateCoeffs();
230 
232  (
234  (
235  diffusivity().operator()(),
236  cellDisplacement_,
237  "laplacian(diffusivity,cellDisplacement)"
238  )
239  );
240 }
241 
242 
244 (
245  const mapPolyMesh& mpm
246 )
247 {
249 
250  // Update diffusivity. Note two stage to make sure old one is de-registered
251  // before creating/registering new one.
252  diffusivityPtr_.clear();
253 }
254 
255 
256 // ************************************************************************* //
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
static autoPtr< motionDiffusivity > New(const fvMesh &mesh, Istream &mdData)
Select null constructed.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
static const pointMesh & New(const polyMesh &mesh)
A subset of mesh points. The labels of points in the zone can be obtained from the addressing() list...
Definition: pointZone.H:62
tmp< fvMatrix< Type > > laplacian(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvmLaplacian.C:46
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Definition: Time.C:741
messageStream Info
dynamicFvMesh & mesh
Namespace for OpenFOAM.
Base class for fvMesh based motionSolvers.
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Abstract base class for cell-centre mesh motion diffusivity.
stressControl lookup("compactNormalStress") >> compactNormalStress
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define forAll(list, i)
Definition: UList.H:421
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Macros for easy insertion into run-time selection tables.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
virtual void updateMesh(const mapPolyMesh &)
Update topology.
bool found
Calculate the matrix for the laplacian of the field.
solverPerformance solve(fvMatrix< Type > &, const dictionary &)
Solve returning the solution statistics given convergence tolerance.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
static const Vector zero
Definition: Vector.H:80
const Time & time() const
Return time.
motionDiffusivity & diffusivity()
Return reference to the diffusivity field.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
A class for managing temporary objects.
Definition: PtrList.H:118
conserve internalField()+
defineTypeNameAndDebug(combustionModel, 0)
Virtual base class for displacement motion solver.