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-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
37namespace Foam
38{
41 (
45 );
47 (
50 doInit
51 );
52}
53
54
55// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56
58(
59 const IOobject& io,
60 const bool doInit
61)
62:
63 dynamicFvMesh(io, doInit),
64 motionSolvers_()
65{
66 if (doInit)
67 {
68 init(false); // do not initialise lower levels
69 }
70}
71
72
74(
75 const bool doInit,
76 const bool mandatory
77)
78{
79 if (doInit)
80 {
81 dynamicFvMesh::init(doInit);
82 }
83
84 IOobject ioDict
85 (
86 "dynamicMeshDict",
87 time().constant(),
88 *this,
91 false
92 );
93
94 IOdictionary dict(ioDict);
95
96 label i = 0;
97 if (dict.found("solvers"))
98 {
99 const dictionary& solvertDict = dict.subDict("solvers");
100
101 motionSolvers_.setSize(solvertDict.size());
102
103 for (const entry& dEntry : solvertDict)
104 {
105 if (dEntry.isDict())
106 {
107 IOobject io(ioDict);
110 io.rename(dEntry.dict().dictName());
111
112 IOdictionary IOsolverDict
113 (
114 io,
115 dEntry.dict()
116 );
117
118 motionSolvers_.set
119 (
120 i++,
121 motionSolver::New(*this, IOsolverDict)
122 );
123 }
124 }
125 motionSolvers_.setSize(i);
126 }
127 else if (mandatory)
128 {
129 motionSolvers_.setSize(1);
130 motionSolvers_.set(i++, motionSolver::New(*this, dict));
131 }
132
133 // Assume something changed
134 return true;
135}
136
137
139{
140 // Fall-back to always constructing motionSolver
141 return init(doInit, true);
142}
143
144
145// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
146
148{}
149
150
151// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
152
153
155(
156 const mapPolyMesh& mpm
157)
158{
160
161 // Update the motionSolvers for any topo change ...
162 for (auto& ms : motionSolvers_)
163 {
164 ms.updateMesh(mpm);
165 }
166}
167
168
170{
171 if (motionSolvers_.size())
172 {
173 // Accumulated displacement
174 pointField disp(motionSolvers_[0].newPoints() - fvMesh::points());
175
176 for (label i = 1; i < motionSolvers_.size(); i++)
177 {
178 disp += motionSolvers_[i].newPoints() - fvMesh::points();
179 }
180
181 fvMesh::movePoints(points() + disp);
182
183 volVectorField* Uptr = getObjectPtr<volVectorField>("U");
184
185 if (Uptr)
186 {
188 }
189 }
190
191 return true;
192}
193
194
195// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void correctBoundaryConditions()
Correct boundary field.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
readOption readOpt() const noexcept
The read option.
Definition: IOobjectI.H:164
virtual void rename(const word &newName)
Rename the object.
Definition: IOobject.H:497
writeOption writeOpt() const noexcept
The write option.
Definition: IOobjectI.H:179
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:81
Dynamic mesh able to handle multiple motion solvers. NOTE: If the word entry "solvers" is not found i...
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
virtual bool update()
Update the mesh for both mesh motion and topology change.
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
Maps input fields from local mesh to secondary mesh at runtime.
Definition: mapFields.H:225
virtual bool movePoints()
Avoid masking surfaceInterpolation method.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
constant condensation/saturation model.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
const pointField & points
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
dictionary dict