dynamicFvMesh.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) 2011-2012 OpenFOAM Foundation
9 Copyright (C) 2018-2021 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
29#include "dynamicFvMesh.H"
30#include "profiling.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
39}
40
41
42// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43
44void Foam::dynamicFvMesh::readDict()
45{
46 IOobject dictHeader
47 (
48 "dynamicMeshDict",
49 thisDb().time().constant(),
50 thisDb(),
53 false // Do not register
54 );
55
56 if (dictHeader.typeHeaderOk<IOdictionary>(false, false))
57 {
58 IOdictionary dict(dictHeader);
59 timeControl_.read(dict);
60
61 if (!timeControl_.always())
62 {
63 // Feedback about the trigger mechanism
64 Info<< "Controlled mesh update triggered on "
65 << timeControl_.type() << " interval "
66 << timeControl_.interval() << nl;
67 }
68 }
69 else
70 {
71 // Ensure it is indeed pass-through
72 timeControl_.clear();
73 }
74}
75
76
77// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
78
80:
81 fvMesh(io, doInit),
82 timeControl_(io.time(), "update") // assume has no side effects
83{
84 if (doInit)
85 {
86 init(false); // do not initialise lower levels
87 }
88}
89
90
91bool Foam::dynamicFvMesh::init(const bool doInit)
92{
93 if (doInit)
94 {
95 fvMesh::init(doInit);
96 }
97
98 readDict();
99
100 // Assume something changed
101 return true;
102}
103
104
106(
107 const IOobject& io,
108 const Foam::zero,
109 bool syncPar
110)
111:
112 fvMesh(io, Foam::zero{}, syncPar),
113 timeControl_(io.time(), "update")
114{
115 readDict();
116}
117
118
120(
121 const IOobject& io,
123 faceList&& faces,
124 labelList&& allOwner,
125 labelList&& allNeighbour,
126 const bool syncPar
127)
128:
129 fvMesh
130 (
131 io,
132 std::move(points),
133 std::move(faces),
134 std::move(allOwner),
135 std::move(allNeighbour),
136 syncPar
137 ),
138 timeControl_(io.time(), "update")
139{
140 readDict();
141}
142
143
145(
146 const IOobject& io,
148 faceList&& faces,
149 cellList&& cells,
150 const bool syncPar
151)
152:
153 fvMesh
154 (
155 io,
156 std::move(points),
157 std::move(faces),
158 std::move(cells),
159 syncPar
160 ),
161 timeControl_(io.time(), "update")
162{
163 readDict();
164}
165
166
168{
169 if (timeControl_.execute())
170 {
171 if (!timeControl_.always())
172 {
173 // Feedback that update has been triggered
174 Info<< "Mesh update triggered based on "
175 << timeControl_.type() << nl;
176 }
177
178 addProfiling(mesh, "mesh.update()");
179 return this->update();
180 }
181
182 return false;
183}
184
185
186// ************************************************************************* //
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
@ MUST_READ_IF_MODIFIED
Definition: IOobject.H:180
Abstract base class for geometry and/or topology changing fvMesh.
Definition: dynamicFvMesh.H:81
virtual bool controlledUpdate()
Update the mesh if controller permits.
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
Definition: dynamicFvMesh.C:91
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
virtual const objectRegistry & thisDb() const
Return the object registry - resolve conflict polyMesh/lduMesh.
Definition: fvMesh.H:302
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
constant condensation/saturation model.
scalar interval() const
Return interval.
Definition: timeControlI.H:65
void read(const dictionary &dict)
Read from dictionary.
Definition: timeControl.C:109
void clear()
Reset control to 'always' - ie, no intervention.
Definition: timeControl.C:100
bool always() const
Return true if the control will always execute - ie, no intervention.
Definition: timeControlI.H:55
const word & type() const
Return the named control enumeration as its 'type'.
Definition: timeControlI.H:43
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
mesh update()
dynamicFvMesh & mesh
const pointField & points
const cellShapeList & cells
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define addProfiling(name, descr)
Define profiling trigger with specified name and description string.
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict