regionModel.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) 2011-2017 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::regionModels::regionModel
29
30Description
31 Base class for region models
32
33SourceFiles
34 regionModelI.H
35 regionModel.C
36
37\*---------------------------------------------------------------------------*/
38
39#ifndef regionModel_H
40#define regionModel_H
41
42#include "IOdictionary.H"
43#include "Switch.H"
44#include "labelList.H"
45#include "volFields.H"
46#include "mappedPatchBase.H"
48
49// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50
51namespace Foam
52{
53
54namespace regionModels
55{
56
57/*---------------------------------------------------------------------------*\
58 Class regionModel Declaration
59\*---------------------------------------------------------------------------*/
61class regionModel
62:
63 public IOdictionary
64{
65
66private:
67
68 // Private Member Functions
69
70 //- No copy construct
71 regionModel(const regionModel&) = delete;
72
73 //- No copy assignment
74 void operator=(const regionModel&) = delete;
75
76 //- Construct region mesh and fields
77 void constructMeshObjects();
78
79 //- Initialise the region
80 void initialise();
81
82
83protected:
84
85 // Protected data
86
87 //- Reference to the primary mesh database
88 const fvMesh& primaryMesh_;
89
90 //- Reference to the time database
91 const Time& time_;
92
93 //- Active flag
95
96 //- Active information output
98
99 //- Model name
100 const word modelName_;
101
102 //- Model coefficients dictionary
104
105 //- Dictionary of output properties
107
108
109 // Addressing
110
111 //- List of patch IDs on the primary region coupled to this region
113
114 //- List of patch IDs internally coupled with the primary region
116
117
118 //- Region name
120
121 //- Region model function objects
123
124
125 // Inter-region AMI interpolation caching
126
127 //- List of region names this region is coupled to
129
130 //- List of AMI objects per coupled region
133
134
135 // Protected member functions
136
137 //- Read control parameters from dictionary
138 virtual bool read();
139
140 //- Read control parameters from dictionary
141 virtual bool read(const dictionary& dict);
142
143 //- Create or return a new inter-region AMI object
145 (
146 const regionModel& nbrRegion,
147 const label regionPatchi,
148 const label nbrPatchi,
149 const bool flip
150 ) const;
151
152
153public:
154
155 //- Runtime type information
156 TypeName("regionModel");
157
158
159 // Constructors
160
161 //- Construct null
162 regionModel(const fvMesh& mesh, const word& regionType);
163
164 //- Construct from mesh, region type and name
166 (
167 const fvMesh& mesh,
168 const word& regionType,
169 const word& modelName,
170 bool readFields = true
171 );
172
173 //- Construct from mesh and name and dict
175 (
176 const fvMesh& mesh,
177 const word& regionType,
178 const word& modelName,
179 const dictionary& dict,
180 bool readFields = true
181 );
182
183
184 //- Destructor
185 virtual ~regionModel() = default;
186
187
188 // Member Functions
189
190 // Access
191
192 //- Return the reference to the primary mesh database
193 inline const fvMesh& primaryMesh() const;
194
195 //- Return the reference to the time database
196 inline const Time& time() const;
197
198 //- Return the active flag
199 inline Switch active() const;
200
201 //- Return the information flag
202 inline Switch infoOutput() const;
203
204 //- Return the model name
205 inline const word& modelName() const;
206
207 //- Return the region mesh database
208 inline const fvMesh& regionMesh() const;
209
210 //- Return the region mesh database for manipulation
211 inline fvMesh& regionMesh();
212
213 //- Return the model coefficients dictionary
214 inline const dictionary& coeffs() const;
215
216 //- Return the solution dictionary
217 inline const dictionary& solution() const;
218
219 //- Return const access to the output properties dictionary
220 inline const IOdictionary& outputProperties() const;
221
222 //- Return output properties dictionary
224
225
226 // Addressing
227
228 //- Return true if patchi on the local region is a coupled
229 // patch to the primary region
230 inline bool isCoupledPatch(const label regionPatchi) const;
231
232 //- Return true if patchi on the primary region is a coupled
233 // patch to the local region
234 inline bool isRegionPatch(const label primaryPatchi) const;
235
236 //- Return the list of patch IDs on the primary region coupled
237 // to this region
238 inline const labelList& primaryPatchIDs() const;
239
240 //- Return the list of patch IDs internally coupled with the
241 // primary region
242 inline const labelList& intCoupledPatchIDs() const;
243
244 //- Return region ID corresponding to primaryPatchID
245 inline label regionPatchID(const label primaryPatchID) const;
246
247
248 // Helper
249
250 //- Return the coupled patch ID paired with coupled patch
251 // regionPatchi
253 (
254 const regionModel& nbrRegion,
255 const label regionPatchi
256 ) const;
257
258 //- Map patch field from another region model to local patch
259 template<class Type>
261 (
262 const regionModel& nbrRegion,
263 const label regionPatchi,
264 const label nbrPatchi,
265 const Field<Type>& nbrField,
266 const bool flip = false
267 ) const;
268
269 //- Map patch field from another region model to local patch
270 template<class Type>
272 (
273 const regionModel& nbrRegion,
274 const word& fieldName,
275 const label regionPatchi,
276 const bool flip = false
277 ) const;
278
279 //- Map patch internal field from another region model to local
280 // patch
281 template<class Type>
283 (
284 const regionModel& nbrRegion,
285 const word& fieldName,
286 const label regionPatchi,
287 const bool flip = false
288 ) const;
289
290 //- Convert a local region field to the primary region
291 template<class Type>
292 void toPrimary
293 (
294 const label regionPatchi,
295 List<Type>& regionField
296 ) const;
297
298 //- Convert a primary region field to the local region
299 template<class Type>
300 void toRegion
301 (
302 const label regionPatchi,
303 List<Type>& primaryFieldField
304 ) const;
305
306 //- Convert a local region field to the primary region with op
307 template<class Type, class CombineOp>
308 void toPrimary
309 (
310 const label regionPatchi,
311 List<Type>& regionField,
312 const CombineOp& cop
313 ) const;
314
315 //- Convert a primary region field to the local region with op
316 template<class Type, class CombineOp>
317 void toRegion
318 (
319 const label regionPatchi,
320 List<Type>& primaryFieldField,
321 const CombineOp& cop
322 ) const;
323
324
325 // Evolution
326
327 //- Main driver routing to evolve the region - calls other evolves
328 virtual void evolve();
329
330 //- Pre-evolve region
331 virtual void preEvolveRegion();
332
333 //- Evolve the region
334 virtual void evolveRegion();
335
336 //- Post-evolve region
337 virtual void postEvolveRegion();
338
339
340 // I-O
341
342 //- Provide some feedback
343 virtual void info();
344};
345
346
347// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
348
349} // End namespace regionModels
350} // End namespace Foam
351
352// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
353
354#include "regionModelI.H"
355
356// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357
358#ifdef NoRepository
359 #include "regionModelTemplates.C"
360#endif
361
362// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363
364#endif
365
366// ************************************************************************* //
Interpolation class dealing with transfer of data between two primitive patches with an arbitrary mes...
Generic templated field type.
Definition: Field.H:82
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:78
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:80
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Base class for region models.
Definition: regionModel.H:63
tmp< Field< Type > > mapRegionPatchField(const regionModel &nbrRegion, const word &fieldName, const label regionPatchi, const bool flip=false) const
Map patch field from another region model to local patch.
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
Definition: regionModel.H:105
Switch active_
Active flag.
Definition: regionModel.H:93
const Time & time_
Reference to the time database.
Definition: regionModel.H:90
const word modelName_
Model name.
Definition: regionModel.H:99
virtual void postEvolveRegion()
Post-evolve region.
Definition: regionModel.C:510
const Time & time() const
Return the reference to the time database.
Definition: regionModelI.H:40
const dictionary & solution() const
Return the solution dictionary.
Definition: regionModelI.H:99
Switch infoOutput_
Active information output.
Definition: regionModel.H:96
bool isCoupledPatch(const label regionPatchi) const
Return true if patchi on the local region is a coupled.
Definition: regionModelI.H:134
void toRegion(const label regionPatchi, List< Type > &primaryFieldField) const
Convert a primary region field to the local region.
label nbrCoupledPatchID(const regionModel &nbrRegion, const label regionPatchi) const
Return the coupled patch ID paired with coupled patch.
Definition: regionModel.C:272
TypeName("regionModel")
Runtime type information.
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
Definition: regionModel.H:111
virtual const AMIPatchToPatchInterpolation & 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:189
const dictionary & coeffs() const
Return the model coefficients dictionary.
Definition: regionModelI.H:92
const fvMesh & primaryMesh() const
Return the reference to the primary mesh database.
Definition: regionModelI.H:34
virtual ~regionModel()=default
Destructor.
dictionary coeffs_
Model coefficients dictionary.
Definition: regionModel.H:102
const fvMesh & regionMesh() const
Return the region mesh database.
Definition: regionModelI.H:64
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.
PtrList< PtrList< AMIPatchToPatchInterpolation > > interRegionAMI_
List of AMI objects per coupled region.
Definition: regionModel.H:131
virtual void preEvolveRegion()
Pre-evolve region.
Definition: regionModel.C:500
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
Definition: regionModel.C:467
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition: regionModel.H:87
label regionPatchID(const label primaryPatchID) const
Return region ID corresponding to primaryPatchID.
Definition: regionModelI.H:182
Switch infoOutput() const
Return the information flag.
Definition: regionModelI.H:52
bool isRegionPatch(const label primaryPatchi) const
Return true if patchi on the primary region is a coupled.
Definition: regionModelI.H:151
const word & modelName() const
Return the model name.
Definition: regionModelI.H:58
regionModelFunctionObjectList functions_
Region model function objects.
Definition: regionModel.H:121
virtual void info()
Provide some feedback.
Definition: regionModel.C:516
wordList interRegionAMINames_
List of region names this region is coupled to.
Definition: regionModel.H:127
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.
Definition: regionModelI.H:106
const labelList & primaryPatchIDs() const
Return the list of patch IDs on the primary region coupled.
Definition: regionModelI.H:168
void toPrimary(const label regionPatchi, List< Type > &regionField) const
Convert a local region field to the primary region.
labelList intCoupledPatchIDs_
List of patch IDs internally coupled with the primary region.
Definition: regionModel.H:114
const labelList & intCoupledPatchIDs() const
Return the list of patch IDs internally coupled with the.
Definition: regionModelI.H:175
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.
Switch active() const
Return the active flag.
Definition: regionModelI.H:46
virtual bool read()
Read control parameters from dictionary.
Definition: regionModel.C:149
virtual void evolveRegion()
Evolve the region.
Definition: regionModel.C:506
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
Namespace for OpenFOAM.
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73