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-2020 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 "AMIInterpolation.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  // Inter-region AMI interpolation caching
118 
119  //- List of region names this region is coupled to
121 
122  //- List of AMI objects per coupled region
124 
125 
126  // Protected member functions
127 
128  //- Read control parameters from dictionary
129  virtual bool read();
130 
131  //- Read control parameters from dictionary
132  virtual bool read(const dictionary& dict);
133 
134  //- Create or return a new inter-region AMI object
135  virtual const AMIInterpolation& interRegionAMI
136  (
137  const regionModel& nbrRegion,
138  const label regionPatchi,
139  const label nbrPatchi,
140  const bool flip
141  ) const;
142 
143 
144 public:
145 
146  //- Runtime type information
147  TypeName("regionModel");
148 
149 
150  // Constructors
151 
152  //- Construct null
153  regionModel(const fvMesh& mesh, const word& regionType);
154 
155  //- Construct from mesh, region type and name
157  (
158  const fvMesh& mesh,
159  const word& regionType,
160  const word& modelName,
161  bool readFields = true
162  );
163 
164  //- Construct from mesh and name and dict
166  (
167  const fvMesh& mesh,
168  const word& regionType,
169  const word& modelName,
170  const dictionary& dict,
171  bool readFields = true
172  );
173 
174 
175  //- Destructor
176  virtual ~regionModel();
177 
178 
179  // Member Functions
180 
181  // Access
182 
183  //- Return the reference to the primary mesh database
184  inline const fvMesh& primaryMesh() const;
185 
186  //- Return the reference to the time database
187  inline const Time& time() const;
188 
189  //- Return the information flag
190  inline const Switch& infoOutput() const;
191 
192  //- Return the model name
193  inline const word& modelName() const;
194 
195  //- Return the region mesh database
196  inline const fvMesh& regionMesh() const;
197 
198  //- Return the region mesh database for manipulation
199  inline fvMesh& regionMesh();
200 
201  //- Return the model coefficients dictionary
202  inline const dictionary& coeffs() const;
203 
204  //- Return the solution dictionary
205  inline const dictionary& solution() const;
206 
207  //- Return const access to the output properties dictionary
208  inline const IOdictionary& outputProperties() const;
209 
210  //- Return output properties dictionary
211  inline IOdictionary& outputProperties();
212 
213 
214  // Addressing
215 
216  //- Return true if patchi on the local region is a coupled
217  // patch to the primary region
218  inline bool isCoupledPatch(const label regionPatchi) const;
219 
220  //- Return true if patchi on the primary region is a coupled
221  // patch to the local region
222  inline bool isRegionPatch(const label primaryPatchi) const;
223 
224  //- Return the list of patch IDs on the primary region coupled
225  // to this region
226  inline const labelList& primaryPatchIDs() const;
227 
228  //- Return the list of patch IDs internally coupled with the
229  // primary region
230  inline const labelList& intCoupledPatchIDs() const;
231 
232  //- Return region ID corresponding to primaryPatchID
233  inline label regionPatchID(const label primaryPatchID) const;
234 
235 
236  // Helper
237 
238  //- Return the coupled patch ID paired with coupled patch
239  // regionPatchi
241  (
242  const regionModel& nbrRegion,
243  const label regionPatchi
244  ) const;
245 
246  //- Map patch field from another region model to local patch
247  template<class Type>
249  (
250  const regionModel& nbrRegion,
251  const label regionPatchi,
252  const label nbrPatchi,
253  const Field<Type>& nbrField,
254  const bool flip = false
255  ) const;
256 
257  //- Map patch field from another region model to local patch
258  template<class Type>
260  (
261  const regionModel& nbrRegion,
262  const word& fieldName,
263  const label regionPatchi,
264  const bool flip = false
265  ) const;
266 
267  //- Map patch internal field from another region model to local
268  // patch
269  template<class Type>
271  (
272  const regionModel& nbrRegion,
273  const word& fieldName,
274  const label regionPatchi,
275  const bool flip = false
276  ) const;
277 
278  //- Convert a local region field to the primary region
279  template<class Type>
280  void toPrimary
281  (
282  const label regionPatchi,
283  List<Type>& regionField
284  ) const;
285 
286  //- Convert a local region field to the primary region with op
287  template<class Type, class CombineOp>
288  void toPrimary
289  (
290  const label regionPatchi,
291  List<Type>& regionField,
292  const CombineOp& cop
293  ) const;
294 
295  //- Convert a primary region field to the local region
296  template<class Type>
297  void toRegion
298  (
299  const label regionPatchi,
300  List<Type>& primaryFieldField
301  ) const;
302 
303  //- Return a primary patch field mapped the region internal field
304  template<class Type>
305  void toRegion
306  (
307  Field<Type>& regionField,
308  const label regionPatchi,
309  const fvPatchField<Type>& primaryPatchField
310  ) const;
311 
312  //- Return a primary patch field mapped the local region
313  template<class Type>
314  void toRegion
315  (
316  Field<Type>& rf,
317  const typename GeometricField
318  <
319  Type,
320  fvPatchField,
321  volMesh
322  >::Boundary& pBf
323  ) const;
324 
325 
326  // Evolution
327 
328  //- Main driver routing to evolve the region - calls other evolves
329  virtual void evolve();
330 
331  //- Pre-evolve region
332  virtual void preEvolveRegion();
333 
334  //- Evolve the region
335  virtual void evolveRegion();
336 
337  //- Post-evolve region
338  virtual void postEvolveRegion();
339 
340 
341  // I-O
342 
343  //- Provide some feedback
344  virtual void info();
345 };
346 
347 
348 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 
350 } // End namespace regionModels
351 } // End namespace Foam
352 
353 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
354 
355 #include "regionModelI.H"
356 
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 
359 #ifdef NoRepository
360  #include "regionModelTemplates.C"
361 #endif
362 
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 
365 #endif
366 
367 // ************************************************************************* //
dictionary dict
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:79
const word modelName_
Model name.
Definition: regionModel.H:88
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:119
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:496
virtual void info()
Provide some feedback.
Definition: regionModel.C:506
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
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: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
dynamicFvMesh & mesh
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:490
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:263
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:500
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
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: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:452
PtrList< PtrList< AMIInterpolation > > interRegionAMI_
List of AMI objects per coupled region.
Definition: regionModel.H:122
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:94
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:82
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:113
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:458
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: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
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: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
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:176
Namespace for OpenFOAM.