dynamicMotionSolverListFvMesh.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 OpenFOAM Foundation
9  Copyright (C) 2019 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 
31 #include "motionSolver.H"
32 #include "pointMesh.H"
33 #include "volFields.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(dynamicMotionSolverListFvMesh, 0);
41  (
42  dynamicFvMesh,
43  dynamicMotionSolverListFvMesh,
44  IOobject
45  );
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 Foam::dynamicMotionSolverListFvMesh::dynamicMotionSolverListFvMesh
52 (
53  const IOobject& io
54 )
55 :
56  dynamicFvMesh(io),
57  motionSolvers_()
58 {
59  IOobject ioDict
60  (
61  "dynamicMeshDict",
62  time().constant(),
63  *this,
64  IOobject::MUST_READ,
65  IOobject::NO_WRITE,
66  false
67  );
68 
69  IOdictionary dict(ioDict);
70 
71  label i = 0;
72  if (dict.found("solvers"))
73  {
74  const dictionary& solvertDict = dict.subDict("solvers");
75 
76  motionSolvers_.setSize(solvertDict.size());
77 
78  for (const entry& dEntry : solvertDict)
79  {
80  if (dEntry.isDict())
81  {
82  IOobject io(ioDict);
83  io.readOpt() = IOobject::NO_READ;
84  io.writeOpt() = IOobject::AUTO_WRITE;
85  io.rename(dEntry.dict().dictName());
86 
87  IOdictionary IOsolverDict
88  (
89  io,
90  dEntry.dict()
91  );
92 
93  motionSolvers_.set
94  (
95  i++,
96  motionSolver::New(*this, IOsolverDict)
97  );
98  }
99  }
100  motionSolvers_.setSize(i);
101  }
102  else
103  {
104  motionSolvers_.setSize(1);
105  motionSolvers_.set(i++, motionSolver::New(*this));
106  }
107 }
108 
109 
110 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 
113 {}
114 
115 
116 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
117 
119 {
120  if (motionSolvers_.size())
121  {
122  // Accumulated displacement
123  pointField disp(motionSolvers_[0].newPoints() - fvMesh::points());
124 
125  for (label i = 1; i < motionSolvers_.size(); i++)
126  {
127  disp += motionSolvers_[i].newPoints() - fvMesh::points();
128  }
129 
130  fvMesh::movePoints(points() + disp);
131 
132  volVectorField* Uptr = getObjectPtr<volVectorField>("U");
133 
134  if (Uptr)
135  {
137  }
138  }
139 
140  return true;
141 }
142 
143 
144 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
volFields.H
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:1038
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
motionSolver.H
Foam::dynamicFvMesh
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:78
Foam::dictionary::set
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:842
dynamicMotionSolverListFvMesh.H
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:62
Foam::Field< vector >
Foam::IOobject::writeOpt
writeOption writeOpt() const
The write option.
Definition: IOobjectI.H:153
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::surfaceInterpolation::movePoints
bool movePoints()
Do what is necessary if the mesh has moved.
Definition: surfaceInterpolation.C:125
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IOobject::rename
virtual void rename(const word &newName)
Rename.
Definition: IOobject.H:368
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:909
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
Foam::IOobject::readOpt
readOption readOpt() const
The read option.
Definition: IOobjectI.H:141
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::dynamicMotionSolverListFvMesh::update
virtual bool update()
Dummy update function which does not change the mesh.
Definition: dynamicMotionSolverListFvMesh.C:118
Foam::dynamicMotionSolverListFvMesh::~dynamicMotionSolverListFvMesh
~dynamicMotionSolverListFvMesh()
Destructor.
Definition: dynamicMotionSolverListFvMesh.C:112
Foam::GeometricField< vector, fvPatchField, volMesh >
constant
constant condensation/saturation model.
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
pointMesh.H