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-2019 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 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef regionModel_H
37 #define regionModel_H
38 
39 #include "IOdictionary.H"
40 #include "Switch.H"
41 #include "labelList.H"
42 #include "volFields.H"
43 #include "mappedPatchBase.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 namespace regionModels
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class regionModel Declaration
56 \*---------------------------------------------------------------------------*/
57 
58 class regionModel
59 :
60  public IOdictionary
61 {
62  // Private Member Functions
63 
64  //- Disallow default bitwise copy construction
65  regionModel(const regionModel&) = delete;
66 
67  //- Disallow default bitwise assignment
68  void operator=(const regionModel&) = delete;
69 
70  //- Construct region mesh and fields
71  void constructMeshObjects();
72 
73  //- Initialise the region
74  void initialise();
75 
76 
77 protected:
78 
79  // Protected data
80 
81  //- Reference to the primary mesh database
82  const fvMesh& primaryMesh_;
83 
84  //- Reference to the time database
85  const Time& time_;
86 
87  //- Active flag
89 
90  //- Active information output
92 
93  //- Model name
94  const word modelName_;
95 
96  //- Pointer to the region mesh database
98 
99  //- Model coefficients dictionary
101 
102  //- Dictionary of output properties
104 
105 
106  // Addressing
107 
108  //- List of patch IDs on the primary region coupled to this region
110 
111  //- List of patch IDs internally coupled with the primary region
113 
114 
115  //- Region name
117 
118  //- Region model function objects
120 
121 
122  // Inter-region AMI interpolation caching
123 
124  //- List of region names this region is coupled to
126 
127  //- List of AMI objects per coupled region
129 
130 
131  // Protected member functions
132 
133  //- Read control parameters from dictionary
134  virtual bool read();
135 
136  //- Read control parameters from dictionary
137  virtual bool read(const dictionary& dict);
138 
139  //- Create or return a new inter-region AMI object
140  virtual const AMIInterpolation& interRegionAMI
141  (
142  const regionModel& nbrRegion,
143  const label regionPatchi,
144  const label nbrPatchi,
145  const bool flip
146  ) const;
147 
148 
149 public:
150 
151  //- Runtime type information
152  TypeName("regionModel");
153 
154 
155  // Constructors
156 
157  //- Construct null
158  regionModel(const fvMesh& mesh, const word& regionType);
159 
160  //- Construct from mesh, region type and name
162  (
163  const fvMesh& mesh,
164  const word& regionType,
165  const word& modelName,
166  bool readFields = true
167  );
168 
169  //- Construct from mesh and name and dict
171  (
172  const fvMesh& mesh,
173  const word& regionType,
174  const word& modelName,
175  const dictionary& dict,
176  bool readFields = true
177  );
178 
179 
180  //- Destructor
181  virtual ~regionModel();
182 
183 
184  // Member Functions
185 
186  // Access
187 
188  //- Return the reference to the primary mesh database
189  inline const fvMesh& primaryMesh() const;
190 
191  //- Return the reference to the time database
192  inline const Time& time() const;
193 
194  //- Return the active flag
195  inline const Switch& active() const;
196 
197  //- Return the information flag
198  inline const Switch& infoOutput() const;
199 
200  //- Return the model name
201  inline const word& modelName() const;
202 
203  //- Return the region mesh database
204  inline const fvMesh& regionMesh() const;
205 
206  //- Return the region mesh database for manipulation
207  inline fvMesh& regionMesh();
208 
209  //- Return the model coefficients dictionary
210  inline const dictionary& coeffs() const;
211 
212  //- Return the solution dictionary
213  inline const dictionary& solution() const;
214 
215  //- Return const access to the output properties dictionary
216  inline const IOdictionary& outputProperties() const;
217 
218  //- Return output properties dictionary
219  inline IOdictionary& outputProperties();
220 
221 
222  // Addressing
223 
224  //- Return true if patchi on the local region is a coupled
225  // patch to the primary region
226  inline bool isCoupledPatch(const label regionPatchi) const;
227 
228  //- Return true if patchi on the primary region is a coupled
229  // patch to the local region
230  inline bool isRegionPatch(const label primaryPatchi) const;
231 
232  //- Return the list of patch IDs on the primary region coupled
233  // to this region
234  inline const labelList& primaryPatchIDs() const;
235 
236  //- Return the list of patch IDs internally coupled with the
237  // primary region
238  inline const labelList& intCoupledPatchIDs() const;
239 
240  //- Return region ID corresponding to primaryPatchID
241  inline label regionPatchID(const label primaryPatchID) const;
242 
243 
244  // Helper
245 
246  //- Return the coupled patch ID paired with coupled patch
247  // regionPatchi
249  (
250  const regionModel& nbrRegion,
251  const label regionPatchi
252  ) const;
253 
254  //- Map patch field from another region model to local patch
255  template<class Type>
257  (
258  const regionModel& nbrRegion,
259  const label regionPatchi,
260  const label nbrPatchi,
261  const Field<Type>& nbrField,
262  const bool flip = false
263  ) const;
264 
265  //- Map patch field from another region model to local patch
266  template<class Type>
268  (
269  const regionModel& nbrRegion,
270  const word& fieldName,
271  const label regionPatchi,
272  const bool flip = false
273  ) const;
274 
275  //- Map patch internal field from another region model to local
276  // patch
277  template<class Type>
279  (
280  const regionModel& nbrRegion,
281  const word& fieldName,
282  const label regionPatchi,
283  const bool flip = false
284  ) const;
285 
286  //- Convert a local region field to the primary region
287  template<class Type>
288  void toPrimary
289  (
290  const label regionPatchi,
291  List<Type>& regionField
292  ) const;
293 
294  //- Convert a primary region field to the local region
295  template<class Type>
296  void toRegion
297  (
298  const label regionPatchi,
299  List<Type>& primaryFieldField
300  ) const;
301 
302  //- Convert a local region field to the primary region with op
303  template<class Type, class CombineOp>
304  void toPrimary
305  (
306  const label regionPatchi,
307  List<Type>& regionField,
308  const CombineOp& cop
309  ) const;
310 
311  //- Convert a primary region field to the local region with op
312  template<class Type, class CombineOp>
313  void toRegion
314  (
315  const label regionPatchi,
316  List<Type>& primaryFieldField,
317  const CombineOp& cop
318  ) const;
319 
320 
321  // Evolution
322 
323  //- Main driver routing to evolve the region - calls other evolves
324  virtual void evolve();
325 
326  //- Pre-evolve region
327  virtual void preEvolveRegion();
328 
329  //- Evolve the region
330  virtual void evolveRegion();
331 
332  //- Post-evolve region
333  virtual void postEvolveRegion();
334 
335 
336  // I-O
337 
338  //- Provide some feedback
339  virtual void info();
340 };
341 
342 
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 
345 } // End namespace regionModels
346 } // End namespace Foam
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 #include "regionModelI.H"
351 
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353 
354 #ifdef NoRepository
355  #include "regionModelTemplates.C"
356 #endif
357 
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
359 
360 #endif
361 
362 // ************************************************************************* //
dictionary dict
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:81
const word modelName_
Model name.
Definition: regionModel.H:93
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
wordList interRegionAMINames_
List of region names this region is coupled to.
Definition: regionModel.H:124
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:525
virtual void info()
Provide some feedback.
Definition: regionModel.C:535
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:158
bool isRegionPatch(const label primaryPatchi) const
Return true if patchi on the primary region is a coupled.
Definition: regionModelI.H:155
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
autoPtr< fvMesh > regionMeshPtr_
Pointer to the region mesh database.
Definition: regionModel.H:96
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:37
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
TypeName("regionModel")
Runtime type information.
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
Definition: regionModel.H:102
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
const word & modelName() const
Return the model name.
Definition: regionModelI.H:55
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
dynamicFvMesh & mesh
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:519
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:146
bool isCoupledPatch(const label regionPatchi) const
Return true if patchi on the local region is a coupled.
Definition: regionModelI.H:138
label nbrCoupledPatchID(const regionModel &nbrRegion, const label regionPatchi) const
Return the coupled patch ID paired with coupled patch.
Definition: regionModel.C:278
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:529
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.
Definition: regionModelI.H:110
const dictionary & solution() const
Return the solution dictionary.
Definition: regionModelI.H:103
label regionPatchID(const label primaryPatchID) const
Return region ID corresponding to primaryPatchID.
Definition: regionModelI.H:186
tmp< Field< Type > > mapRegionPatchInternalField(const regionModel &nbrRegion, const word &fieldName, const label regionPatchi, const bool flip=false) const
Map patch internal field from another region model to local.
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:61
Switch infoOutput_
Active information output.
Definition: regionModel.H:90
const labelList & primaryPatchIDs() const
Return the list of patch IDs on the primary region coupled.
Definition: regionModelI.H:172
Switch active_
Active flag.
Definition: regionModel.H:87
virtual ~regionModel()
Destructor.
Definition: regionModel.C:476
PtrList< PtrList< AMIInterpolation > > interRegionAMI_
List of AMI objects per coupled region.
Definition: regionModel.H:127
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:99
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
const Time & time_
Reference to the time database.
Definition: regionModel.H:84
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Definition: regionModel.C:482
tmp< Foam::Field< Type > > mapRegionPatchField(const regionModel &nbrRegion, const label regionPatchi, const label nbrPatchi, const Field< Type > &nbrField, const bool flip=false) const
Map patch field from another region model to local patch.
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
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:57
const Switch & infoOutput() const
Return the information flag.
Definition: regionModelI.H:49
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:111
A class for managing temporary objects.
Definition: PtrList.H:53
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:179
const dictionary & coeffs() const
Return the model coefficients dictionary.
Definition: regionModelI.H:96
word regionName_
Region name.
Definition: regionModel.H:115
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
Definition: regionModel.H:108
virtual const AMIInterpolation & interRegionAMI(const regionModel &nbrRegion, const label regionPatchi, const label nbrPatchi, const bool flip) const
Create or return a new inter-region AMI object.
Definition: regionModel.C:191
const Switch & active() const
Return the active flag.
Definition: regionModelI.H:43
Namespace for OpenFOAM.