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