regionModel.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::regionModels::regionModel
26 
27 Description
28  Base class for region models
29 
30 SourceFiles
31  regionModelI.H
32  regionModel.C
33  regionModelTemplates.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef regionModel_H
38 #define regionModel_H
39 
40 #include "fvMesh.H"
41 #include "timeIOdictionary.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 namespace regionModels
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class regionModel Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class regionModel
57 :
58  public IOdictionary
59 {
60  // Private Member Functions
61 
62  //- Disallow default bitwise copy construction
63  regionModel(const regionModel&) = delete;
64 
65  //- Disallow default bitwise assignment
66  void operator=(const regionModel&) = delete;
67 
68  //- Construct region mesh and fields
69  void constructMeshObjects();
70 
71  //- Initialise the region
72  void initialise();
73 
74 
75 protected:
76 
77  // Protected data
78 
79  //- Reference to the primary mesh database
80  const fvMesh& primaryMesh_;
81 
82  //- Reference to the time database
83  const Time& time_;
84 
85  //- Information output
87 
88  //- Model name
89  const word modelName_;
90 
91  //- Pointer to the region mesh database
93 
94  //- Model coefficients dictionary
96 
97  //- Dictionary of output properties
99 
100 
101  // Addressing
102 
103  //- List of patch IDs on the primary region coupled to this region
105 
106  //- List of patch IDs internally coupled with the primary region
108 
109 
110  //- Region name
112 
113  //- Region model function objects
115 
116 
117  // Protected member functions
118 
119  //- Read control parameters from dictionary
120  virtual bool read();
121 
122  //- Read control parameters from dictionary
123  virtual bool read(const dictionary& dict);
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("regionModel");
130 
131 
132  // Constructors
133 
134  //- Construct null
135  regionModel(const fvMesh& mesh, const word& regionType);
136 
137  //- Construct from mesh, region type and name
139  (
140  const fvMesh& mesh,
141  const word& regionType,
142  const word& modelName,
143  bool readFields = true
144  );
145 
146  //- Construct from mesh and name and dict
148  (
149  const fvMesh& mesh,
150  const word& regionType,
151  const word& modelName,
152  const dictionary& dict,
153  bool readFields = true
154  );
155 
156 
157  //- Destructor
158  virtual ~regionModel();
159 
160 
161  // Member Functions
162 
163  // Access
164 
165  //- Return the reference to the primary mesh database
166  inline const fvMesh& primaryMesh() const;
167 
168  //- Return the reference to the time database
169  inline const Time& time() const;
170 
171  //- Return the information flag
172  inline const Switch& infoOutput() const;
173 
174  //- Return the model name
175  inline const word& modelName() const;
176 
177  //- Return the region mesh database
178  inline const fvMesh& regionMesh() const;
179 
180  //- Return the region mesh database for manipulation
181  inline fvMesh& regionMesh();
182 
183  //- Return the model coefficients dictionary
184  inline const dictionary& coeffs() const;
185 
186  //- Return the solution dictionary
187  inline const dictionary& solution() const;
188 
189  //- Return const access to the output properties dictionary
190  inline const IOdictionary& outputProperties() const;
191 
192  //- Return output properties dictionary
193  inline IOdictionary& outputProperties();
194 
195 
196  // Addressing
197 
198  //- Return true if patchi on the local region is a coupled
199  // patch to the primary region
200  inline bool isCoupledPatch(const label regionPatchi) const;
201 
202  //- Return true if patchi on the primary region is a coupled
203  // patch to the local region
204  inline bool isRegionPatch(const label primaryPatchi) const;
205 
206  //- Return the list of patch IDs on the primary region coupled
207  // to this region
208  inline const labelList& primaryPatchIDs() const;
209 
210  //- Return the list of patch IDs internally coupled with the
211  // primary region
212  inline const labelList& intCoupledPatchIDs() const;
213 
214  //- Return region ID corresponding to primaryPatchID
215  inline label regionPatchID(const label primaryPatchID) const;
216 
217 
218  // Helper
219 
220  //- Return the coupled patch ID paired with coupled patch
221  // regionPatchi
223  (
224  const regionModel& nbrRegion,
225  const label regionPatchi
226  ) const;
227 
228  //- Convert a local region field to the primary region
229  template<class Type>
230  void toPrimary
231  (
232  const label regionPatchi,
233  List<Type>& regionField
234  ) const;
235 
236  //- Convert a local region field to the primary region with op
237  template<class Type, class CombineOp>
238  void toPrimary
239  (
240  const label regionPatchi,
241  List<Type>& regionField,
242  const CombineOp& cop
243  ) const;
244 
245  //- Convert a primary region field to the local region
246  template<class Type>
247  void toRegion
248  (
249  const label regionPatchi,
250  List<Type>& primaryFieldField
251  ) const;
252 
253  //- Return a primary patch field mapped the region internal field
254  template<class Type>
255  void toRegion
256  (
257  Field<Type>& regionField,
258  const label regionPatchi,
259  const fvPatchField<Type>& primaryPatchField
260  ) const;
261 
262  //- Return a primary patch field mapped the local region
263  template<class Type>
264  void toRegion
265  (
266  Field<Type>& rf,
267  const typename GeometricField
268  <
269  Type,
270  fvPatchField,
271  volMesh
272  >::Boundary& pBf
273  ) const;
274 
275 
276  // Evolution
277 
278  //- Main driver routing to evolve the region - calls other evolves
279  virtual void evolve();
280 
281  //- Pre-evolve region
282  virtual void preEvolveRegion();
283 
284  //- Evolve the region
285  virtual void evolveRegion();
286 
287  //- Post-evolve region
288  virtual void postEvolveRegion();
289 
290 
291  // I-O
292 
293  //- Provide some feedback
294  virtual void info();
295 };
296 
297 
298 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
299 
300 } // End namespace regionModels
301 } // End namespace Foam
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 #include "regionModelI.H"
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #ifdef NoRepository
310  #include "regionModelTemplates.C"
311 #endif
312 
313 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
314 
315 #endif
316 
317 // ************************************************************************* //
dictionary dict
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:79
const word modelName_
Model name.
Definition: regionModel.H:88
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:406
virtual void info()
Provide some feedback.
Definition: regionModel.C:416
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
bool isRegionPatch(const label primaryPatchi) const
Return true if patchi on the primary region is a coupled.
Definition: regionModelI.H:149
A simple wrapper around bool so that it can be read as a word: true/false, on/off, yes/no, y/n, t/f, or none/any.
Definition: Switch.H:60
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
autoPtr< fvMesh > regionMeshPtr_
Pointer to the region mesh database.
Definition: regionModel.H:91
Generic GeometricField class.
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:37
fvMesh & mesh
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
TypeName("regionModel")
Runtime type information.
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
Definition: regionModel.H:97
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
const word & modelName() const
Return the model name.
Definition: regionModelI.H:49
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
const fvMesh & primaryMesh() const
Return the reference to the primary mesh database.
Definition: regionModelI.H:31
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:53
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:400
Pre-declare SubField and related Field type.
Definition: Field.H:56
A class for handling words, derived from string.
Definition: word.H:59
virtual bool read()
Read control parameters from dictionary.
Definition: regionModel.C:141
bool isCoupledPatch(const label regionPatchi) const
Return true if patchi on the local region is a coupled.
Definition: regionModelI.H:132
label nbrCoupledPatchID(const regionModel &nbrRegion, const label regionPatchi) const
Return the coupled patch ID paired with coupled patch.
Definition: regionModel.C:175
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:410
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.
Definition: regionModelI.H:104
const dictionary & solution() const
Return the solution dictionary.
Definition: regionModelI.H:97
label regionPatchID(const label primaryPatchID) const
Return region ID corresponding to primaryPatchID.
Definition: regionModelI.H:180
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:55
Switch infoOutput_
Information output.
Definition: regionModel.H:85
const labelList & primaryPatchIDs() const
Return the list of patch IDs on the primary region coupled.
Definition: regionModelI.H:166
virtual ~regionModel()
Destructor.
Definition: regionModel.C:362
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:94
const Time & time_
Reference to the time database.
Definition: regionModel.H:82
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:113
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Definition: regionModel.C:368
void toRegion(const label regionPatchi, List< Type > &primaryFieldField) const
Convert a primary region field to the local region.
Base class for region models.
Definition: regionModel.H:55
const Switch & infoOutput() const
Return the information flag.
Definition: regionModelI.H:43
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
labelList intCoupledPatchIDs_
List of patch IDs internally coupled with the primary region.
Definition: regionModel.H:106
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:173
const dictionary & coeffs() const
Return the model coefficients dictionary.
Definition: regionModelI.H:90
word regionName_
Region name.
Definition: regionModel.H:110
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
Definition: regionModel.H:103
Namespace for OpenFOAM.