regionFaModel.H
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) 2019-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::regionModels::regionFaModel
28 
29 Description
30  Base class for area region models.
31 
32 Usage
33  Example of the model specification:
34  \verbatim
35  <patchName>
36  {
37  // Mandatory entries (runtime modifiable)
38  region <regionName>;
39  active true;
40 
41  // Optional entries (runtime modifiable)
42  infoOutput false;
43  <model>Coeffs
44  {
45  // subdictionary entries
46  }
47 
48  // Mandatory/Optional (derived) entries
49  ...
50  }
51  \endverbatim
52 
53  where the entries mean:
54  \table
55  Property | Description | Type | Reqd | Dflt
56  region | Name of operand region | word | yes | -
57  active | Flag to activate the model | bool | yes | -
58  infoOutput | Flag to activate information output | bool | no | false
59  \endtable
60 
61 SourceFiles
62  regionFaModelI.H
63  regionFaModel.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef Foam_regionFaModel_H
68 #define Foam_regionFaModel_H
69 
70 #include "volMesh.H"
71 #include "IOdictionary.H"
72 #include "Switch.H"
73 #include "labelList.H"
74 #include "areaFields.H"
75 #include "faMesh.H"
76 #include "volSurfaceMapping.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 namespace regionModels
83 {
84 
85 /*---------------------------------------------------------------------------*\
86  Class regionFaModel Declaration
87 \*---------------------------------------------------------------------------*/
88 
89 class regionFaModel
90 :
91  public IOdictionary
92 {
93  // Private Member Functions
94 
95  //- Construct region mesh and fields
96  void constructMeshObjects();
97 
98  //- Initialise the region
99  void initialise();
100 
101  //- Read control parameters from dictionary
102  bool init(const dictionary& dict);
103 
104 
105 protected:
106 
107  // Protected Data
109  //- Reference to the primary mesh database
110  const fvMesh& primaryMesh_;
111 
112  //- Reference to the time database
113  const Time& time_;
114 
115  //- Active flag
116  Switch active_;
117 
118  //- Active information output
120 
121  //- Model name
122  const word modelName_;
123 
124  //- Pointer to the region mesh database
126 
127  //- Model coefficients dictionary
129 
130  //- Dictionary of output properties
132 
133  //- Volume/surface mapping
135 
136  //- Region name
138 
139 
140 public:
141 
142  //- Runtime type information
143  TypeName("regionFaModel");
144 
145 
146  //- Default name regionFaModel
147  static const word regionFaModelName;
148 
149  // Constructors
150 
151  //- Construct from mesh and name and dict
153  (
154  const fvMesh& mesh,
155  const word& regionType,
156  const word& modelName,
157  const dictionary& dict,
158  bool readFields = true
159  );
160 
161  //- No copy construct
162  regionFaModel(const regionFaModel&) = delete;
163 
164  //- No copy assignment
165  void operator=(const regionFaModel&) = delete;
166 
168  //- Destructor
169  virtual ~regionFaModel() = default;
170 
171 
172  // Member Functions
173 
174  // Access
175 
176  //- Return the reference to the primary mesh database
177  const fvMesh& primaryMesh() const noexcept { return primaryMesh_; }
178 
179  //- Return the reference to the time database
180  const Time& time() const noexcept { return time_; }
181 
182  //- Return the active flag
183  Switch active() const noexcept { return active_; }
184 
185  //- Return the information flag
186  Switch infoOutput() const noexcept { return infoOutput_; }
187 
188  //- Return the model name
189  const word& modelName() const noexcept { return modelName_; }
190 
191  //- Return the region mesh database
192  inline const faMesh& regionMesh() const;
193 
194  //- Return the region mesh database for manipulation
195  inline faMesh& regionMesh();
197  //- Return the model coefficients dictionary
198  const dictionary& coeffs() const noexcept { return coeffs_; }
199 
200  //- Return const access to the output properties dictionary
201  inline const IOdictionary& outputProperties() const;
202 
203  //- Return output properties dictionary
204  inline IOdictionary& outputProperties();
205 
206  //- Return the solution dictionary
207  inline const dictionary& solution() const;
208 
209 
210  // Addressing
211 
212  //- List of patch IDs on the primary region coupled to this region
213  inline const labelList& primaryPatchIDs() const;
214 
215  //- True if patchi on the primary region is coupled to this region
216  inline bool isRegionPatch(const label patchi) const;
217 
218 
219  // Helper Functions
220 
221  //- Return mapping between surface and volume fields
222  const volSurfaceMapping& vsm() const;
223 
224 
225  // Evolution
226 
227  //- Main driver routing to evolve the region - calls other evolves
228  virtual void evolve();
229 
230  //- Pre-evolve region
231  virtual void preEvolveRegion();
232 
233  //- Evolve the region
234  virtual void evolveRegion();
235 
236  //- Post-evolve region
237  virtual void postEvolveRegion();
238 
239  //- Courant number of the region
240  virtual scalar CourantNumber() const;
242 
243  // IO
244 
245  //- Provide some feedback
246  virtual void info() = 0;
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 } // End namespace regionFaModels
253 } // End namespace Foam
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 #include "regionFaModelI.H"
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 
262 #endif
263 
264 // ************************************************************************* //
virtual ~regionFaModel()=default
Destructor.
const Time & time_
Reference to the time database.
dictionary dict
const dictionary & solution() const
Return the solution dictionary.
bool isRegionPatch(const label patchi) const
True if patchi on the primary region is coupled to this region.
Switch infoOutput() const noexcept
Return the information flag.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
const volSurfaceMapping & vsm() const
Return mapping between surface and volume fields.
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
TypeName("regionFaModel")
Runtime type information.
virtual void postEvolveRegion()
Post-evolve region.
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, any/none. Also accepts 0/1 as a string and shortcuts t/f, y/n.
Definition: Switch.H:77
Volume to surface and surface to volume mapping.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
autoPtr< faMesh > regionMeshPtr_
Pointer to the region mesh database.
dictionary()
Default construct, a top-level empty dictionary.
Definition: dictionary.C:68
Switch infoOutput_
Active information output.
virtual void info()=0
Provide some feedback.
dynamicFvMesh & mesh
const word modelName_
Model name.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const NameMatchPredicate &selectedFields, DynamicList< regIOobject *> &storedObjects)
Read the selected GeometricFields of the templated type and store on the objectRegistry.
A class for handling words, derived from Foam::string.
Definition: word.H:63
regionFaModel(const fvMesh &mesh, const word &regionType, const word &modelName, const dictionary &dict, bool readFields=true)
Construct from mesh and name and dict.
const fvMesh & primaryMesh() const noexcept
Return the reference to the primary mesh database.
dictionary coeffs_
Model coefficients dictionary.
void operator=(const regionFaModel &)=delete
No copy assignment.
const faMesh & regionMesh() const
Return the region mesh database.
virtual scalar CourantNumber() const
Courant number of the region.
Switch active() const noexcept
Return the active flag.
virtual void preEvolveRegion()
Pre-evolve region.
const direction noexcept
Definition: Scalar.H:258
Base class for area region models.
const fvMesh & primaryMesh_
Reference to the primary mesh database.
const labelList & primaryPatchIDs() const
List of patch IDs on the primary region coupled to this region.
static const word regionFaModelName
Default name regionFaModel.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void evolveRegion()
Evolve the region.
const Time & time() const noexcept
Return the reference to the time database.
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
const word & modelName() const noexcept
Return the model name.
autoPtr< volSurfaceMapping > vsmPtr_
Volume/surface mapping.
Namespace for OpenFOAM.
const dictionary & coeffs() const noexcept
Return the model coefficients dictionary.
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.