velocityDisplacementMotionSolver.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2016 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 
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(velocityDisplacementMotionSolver, 0);
39 
41  (
42  motionSolver,
43  velocityDisplacementMotionSolver,
44  dictionary
45  );
46 }
47 
48 
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
50 
52 Foam::velocityDisplacementMotionSolver::pointDisplacementBoundaryTypes() const
53 {
54  const pointVectorField::Boundary& pmUbf(pointMotionU().boundaryField());
55 
56  wordList cmUbf = pmUbf.types();
57 
58  forAll(pmUbf, patchI)
59  {
60  if (isA<fixedValuePointPatchField<vector>>(pmUbf[patchI]))
61  {
62  cmUbf[patchI] = fixedValuePointPatchField<vector>::typeName;
63  }
64  }
65 
66  return cmUbf;
67 }
68 
69 
70 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
71 
72 Foam::velocityDisplacementMotionSolver::velocityDisplacementMotionSolver
73 (
74  const polyMesh& mesh,
75  const IOdictionary& dict
76 )
77 :
78  velocityMotionSolver(mesh, dict, typeName),
79  displacementMotionSolverPtr_()
80 {
82 
83  pointVectorField pointDisplacement
84  (
85  IOobject
86  (
87  "pointVelocityDisplacement",
88  mesh.time().timeName(),
89  mesh
90  ),
91  pointMotionU().mesh(),
92  dimLength,
93  pointDisplacementBoundaryTypes()
94  );
95 
96  pointDisplacement.primitiveFieldRef() = mesh.points() - points0;
97 
98  displacementMotionSolverPtr_.reset
99  (
100  dynamic_cast<displacementMotionSolver*>
101  (
103  (
104  coeffDict().get<word>("solver"),
105  mesh,
107  (
108  IOobject
109  (
110  dict.name() + "Coeffs",
111  mesh.time().constant(),
112  mesh
113  ),
114  coeffDict()
115  ),
116  pointDisplacement,
117  points0
118  ).ptr()
119  )
120  );
121 }
122 
123 
124 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
125 
127 {}
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
134 {
135  return displacementMotionSolverPtr_->curPoints();
136 }
137 
138 
140 {
141  movePoints(mesh().points());
142 
143  const scalar deltaT(mesh().time().deltaTValue());
144 
145  // Current and old point displacements
146  pointVectorField& displacement
147  (
148  displacementMotionSolverPtr_->pointDisplacement()
149  );
150  const vectorField displacementOld
151  (
152  mesh().points() - displacementMotionSolverPtr_->points0()
153  );
154 
155  // Update the velocity boundary conditions
156  pointMotionU().correctBoundaryConditions();
157 
158  pointVectorField::Boundary& dispBf = displacement.boundaryFieldRef();
159 
160  // Update the displacement boundary conditions
161  forAll(pointMotionU().boundaryField(), patchI)
162  {
163  const pointPatchVectorField& patchField
164  (
165  pointMotionU().boundaryField()[patchI]
166  );
167 
168  dispBf[patchI] ==
169  patchField.patchInternalField()*deltaT
170  + patchField.patchInternalField(displacementOld);
171  }
172 
173  // Run the sub-solver
174  displacementMotionSolverPtr_->solve();
175 
176  // Update the velocity
177  pointMotionU().primitiveFieldRef() =
178  (displacement.primitiveField() - displacementOld)/deltaT;
179 }
180 
181 
183 {
185 
186  displacementMotionSolverPtr_->movePoints(p);
187 }
188 
189 
191 (
192  const mapPolyMesh& mpm
193 )
194 {
196 
197  displacementMotionSolverPtr_->updateMesh(mpm);
198 }
199 
200 
201 // ************************************************************************* //
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::polyMesh::points
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1069
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::velocityDisplacementMotionSolver::movePoints
virtual void movePoints(const pointField &)
Update geometry.
Definition: velocityDisplacementMotionSolver.C:182
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::displacementMotionSolver::New
static autoPtr< displacementMotionSolver > New(const word &solverTypeName, const polyMesh &, const IOdictionary &, const pointVectorField &pointDisplacement, const pointIOField &points0)
Select constructed from polyMesh, dictionary and components.
Definition: displacementMotionSolver.C:87
Foam::IOField
A primitive field of type <T> with automated input and output.
Definition: foamVtkLagrangianWriter.H:61
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::velocityMotionSolver::movePoints
virtual void movePoints(const pointField &)
Update local data for geometry changes.
Definition: velocityMotionSolver.C:66
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::velocityMotionSolver
Virtual base class for velocity motion solver.
Definition: velocityMotionSolver.H:58
Foam::velocityDisplacementMotionSolver::~velocityDisplacementMotionSolver
~velocityDisplacementMotionSolver()
Destructor.
Definition: velocityDisplacementMotionSolver.C:126
Foam::dictionary::name
const fileName & name() const noexcept
The dictionary name.
Definition: dictionaryI.H:48
Foam::pointPatchField< vector >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::velocityDisplacementMotionSolver::curPoints
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Definition: velocityDisplacementMotionSolver.C:133
Foam::points0MotionSolver::points0IO
static IOobject points0IO(const polyMesh &mesh)
Return IO object for points0.
Definition: points0MotionSolver.C:42
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
velocityDisplacementMotionSolver.H
Foam::Field< vector >
Foam::velocityMotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update local data for topology changes.
Definition: velocityMotionSolver.C:72
fixedValuePointPatchField.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::displacementMotionSolver
Virtual base class for displacement motion solver.
Definition: displacementMotionSolver.H:53
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::velocityDisplacementMotionSolver::solve
virtual void solve()
Solve for motion.
Definition: velocityDisplacementMotionSolver.C:139
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
displacementMotionSolver.H
Foam::velocityDisplacementMotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update topology.
Definition: velocityDisplacementMotionSolver.C:191
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
points0
pointField points0(pointIOField(IOobject("points", mesh.time().constant(), polyMesh::meshSubDir, mesh, IOobject::MUST_READ, IOobject::NO_WRITE, false)))
Foam::isA
const TargetType * isA(const Type &t)
Check if dynamic_cast to TargetType is possible.
Definition: typeInfo.H:197
Foam::List< word >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::velocityMotionSolver::pointMotionU
pointVectorField & pointMotionU()
Return reference to the point motion velocity field.
Definition: velocityMotionSolver.H:102
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
Foam::pointPatchField::patchInternalField
tmp< Field< Type > > patchInternalField() const
Return field created from appropriate internal field values.
Definition: pointPatchField.C:130
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Foam::GeometricField< vector, pointPatchField, pointMesh >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)