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-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 
29 #include "dynamicFvMesh.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(dynamicFvMesh, 0);
36  defineRunTimeSelectionTable(dynamicFvMesh, IOobject);
37 }
38 
39 
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 
42 void Foam::dynamicFvMesh::readDict()
43 {
44  IOobject dictHeader
45  (
46  "dynamicMeshDict",
47  thisDb().time().constant(),
48  thisDb(),
51  false // Do not register
52  );
53 
54  if (dictHeader.typeHeaderOk<IOdictionary>(false, false))
55  {
56  IOdictionary dict(dictHeader);
57  timeControl_.read(dict);
58 
59  if (!timeControl_.always())
60  {
61  // Feedback about the trigger mechanism
62  Info<< "Controlled mesh update triggered on "
63  << timeControl_.type() << " interval "
64  << timeControl_.interval() << nl;
65  }
66  }
67  else
68  {
69  // Ensure it is indeed pass-through
70  timeControl_.clear();
71  }
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
76 
77 Foam::dynamicFvMesh::dynamicFvMesh(const IOobject& io)
78 :
79  fvMesh(io),
80  timeControl_(io.time(), "update")
81 {
82  readDict();
83 }
84 
85 
86 Foam::dynamicFvMesh::dynamicFvMesh
87 (
88  const IOobject& io,
89  const zero,
90  const bool syncPar
91 )
92 :
93  fvMesh(io, Zero, syncPar),
94  timeControl_(io.time(), "update")
95 {
96  readDict();
97 }
98 
99 
100 Foam::dynamicFvMesh::dynamicFvMesh
101 (
102  const IOobject& io,
103  pointField&& points,
104  faceList&& faces,
105  labelList&& allOwner,
106  labelList&& allNeighbour,
107  const bool syncPar
108 )
109 :
110  fvMesh
111  (
112  io,
113  std::move(points),
114  std::move(faces),
115  std::move(allOwner),
116  std::move(allNeighbour),
117  syncPar
118  ),
119  timeControl_(io.time(), "update")
120 {
121  readDict();
122 }
123 
124 
125 Foam::dynamicFvMesh::dynamicFvMesh
126 (
127  const IOobject& io,
128  pointField&& points,
129  faceList&& faces,
130  cellList&& cells,
131  const bool syncPar
132 )
133 :
134  fvMesh
135  (
136  io,
137  std::move(points),
138  std::move(faces),
139  std::move(cells),
140  syncPar
141  ),
142  timeControl_(io.time(), "update")
143 {
144  readDict();
145 }
146 
147 
149 {
150  if (timeControl_.execute())
151  {
152  if (!timeControl_.always())
153  {
154  // Feedback that update has been triggered
155  Info<< "Mesh update triggered based on "
156  << timeControl_.type() << nl;
157  }
158 
159  return this->update();
160  }
161 
162  return false;
163 }
164 
165 
166 // ************************************************************************* //
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
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::IOdictionary::IOdictionary
IOdictionary(const IOobject &)
Construct given an IOobject.
Definition: IOdictionary.C:35
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
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:258
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::IOobject::time
const Time & time() const
Return time.
Definition: IOobject.C:438
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
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:148
Foam::timeControl::clear
void clear()
Reset control to 'always' - ie, no intervention.
Definition: timeControl.C:100
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::IOobject::IOobject
IOobject(const word &name, const fileName &instance, const objectRegistry &registry, readOption r=NO_READ, writeOption w=NO_WRITE, bool registerObject=true)
Construct from name, instance, registry, io options.
Definition: IOobject.C:276
Foam::List< face >
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
dynamicFvMesh.H
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:246
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), which can be used to avoid manipulating objects that ar...
Definition: zero.H:61