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
38  region <word>;
39  active <bool>;
40 
41  <model>Coeffs
42  {
43  // subdictionary entries
44  }
45 
46  // Optional entries
47  infoOutput <bool>;
48 
49  // Inherited entries
50  ...
51  }
52  \endverbatim
53 
54  where the entries mean:
55  \table
56  Property | Description | Type | Reqd | Deflt
57  region | Name of operand region | word | yes | -
58  active | Flag to activate the model | bool | yes | -
59  infoOutput | Flag to activate information output | bool | no | false
60  \endtable
61 
62 SourceFiles
63  regionFaModelI.H
64  regionFaModel.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef Foam_regionFaModel_H
69 #define Foam_regionFaModel_H
70 
71 #include "volMesh.H"
72 #include "volSurfaceMapping.H"
73 
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
76 namespace Foam
77 {
78 namespace regionModels
79 {
80 
81 /*---------------------------------------------------------------------------*\
82  Class regionFaModel Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 class regionFaModel
86 :
87  public IOdictionary
88 {
89  // Private Member Functions
90 
91  //- Construct region mesh and fields
92  void constructMeshObjects();
93 
94  //- Initialise the region
95  void initialise();
96 
97  //- Read control parameters from dictionary
98  bool init(const dictionary& dict);
99 
100 
101 protected:
102 
103  // Protected Data
105  //- Reference to the primary mesh database
106  const fvMesh& primaryMesh_;
107 
108  //- Reference to the time database
109  const Time& time_;
110 
111  //- Active flag
112  Switch active_;
113 
114  //- Active information output
116 
117  //- Model name
118  const word modelName_;
119 
120  //- Pointer to the region mesh database
122 
123  //- Model coefficients dictionary
125 
126  //- Dictionary of output properties
128 
129  //- Volume/surface mapping
131 
132  //- Region name
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("regionFaModel");
140 
141 
142  //- Default name regionFaModel
143  static const word regionFaModelName;
144 
145  // Constructors
146 
147  //- Construct from mesh and name and dict
149  (
150  const fvMesh& mesh,
151  const word& regionType,
152  const word& modelName,
153  const dictionary& dict,
154  bool readFields = true
155  );
156 
157  //- No copy construct
158  regionFaModel(const regionFaModel&) = delete;
159 
160  //- No copy assignment
161  void operator=(const regionFaModel&) = delete;
162 
164  //- Destructor
165  virtual ~regionFaModel() = default;
166 
167 
168  // Member Functions
169 
170  // Access
171 
172  //- Return the reference to the primary mesh database
173  const fvMesh& primaryMesh() const noexcept { return primaryMesh_; }
174 
175  //- Return the reference to the time database
176  const Time& time() const noexcept { return time_; }
177 
178  //- Return the active flag
179  Switch active() const noexcept { return active_; }
180 
181  //- Return the information flag
182  Switch infoOutput() const noexcept { return infoOutput_; }
183 
184  //- Return the model name
185  const word& modelName() const noexcept { return modelName_; }
186 
187  //- Return the region mesh database
188  inline const faMesh& regionMesh() const;
189 
190  //- Return the region mesh database for manipulation
191  inline faMesh& regionMesh();
193  //- Return the model coefficients dictionary
194  const dictionary& coeffs() const noexcept { return coeffs_; }
195 
196  //- Return const access to the output properties dictionary
197  inline const IOdictionary& outputProperties() const;
198 
199  //- Return output properties dictionary
200  inline IOdictionary& outputProperties();
201 
202  //- Return the solution dictionary
203  inline const dictionary& solution() const;
204 
205 
206  // Addressing
207 
208  //- List of patch IDs on the primary region coupled to this region
209  inline const labelList& primaryPatchIDs() const;
210 
211  //- True if patchi on the primary region is coupled to this region
212  inline bool isRegionPatch(const label patchi) const;
213 
214 
215  // Helper Functions
216 
217  //- Return mapping between surface and volume fields
218  const volSurfaceMapping& vsm() const;
219 
220 
221  // Evolution
222 
223  //- Main driver routing to evolve the region - calls other evolves
224  virtual void evolve();
225 
226  //- Pre-evolve region
227  virtual void preEvolveRegion();
228 
229  //- Evolve the region
230  virtual void evolveRegion();
231 
232  //- Post-evolve region
233  virtual void postEvolveRegion();
234 
235  //- Courant number of the region
236  virtual scalar CourantNumber() const;
238 
239  // IO
240 
241  //- Provide some feedback
242  virtual void info() = 0;
243 };
244 
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
248 } // End namespace regionFaModels
249 } // End namespace Foam
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 #include "regionFaModelI.H"
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 
258 #endif
259 
260 // ************************************************************************* //
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.