Loading...
Searching...
No Matches
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{
57/*---------------------------------------------------------------------------*\
58 Class regionModel Declaration
59\*---------------------------------------------------------------------------*/
60
61class regionModel
62:
63 public IOdictionary
64{
65private:
66
67 // Private Member Functions
68
69 //- No copy construct
70 regionModel(const regionModel&) = delete;
71
72 //- No copy assignment
73 void operator=(const regionModel&) = delete;
74
75 //- Construct region mesh and fields
76 void constructMeshObjects();
77
78 //- Initialise the region
79 void initialise();
80
81
82protected:
83
84 // Protected data
85
86 //- Reference to the primary mesh database
87 const fvMesh& primaryMesh_;
88
89 //- Reference to the time database
90 const Time& time_;
91
92 //- Active flag
94
95 //- Active information output
98 //- Model name
99 const word modelName_;
100
101 //- Model coefficients dictionary
103
104 //- Dictionary of output properties
106
108 // Addressing
109
110 //- List of patch IDs on the primary region coupled to this region
113 //- List of patch IDs internally coupled with the primary region
115
116
117 //- Region name
119
120 //- Region model function objects
123
124 // Inter-region AMI interpolation caching
125
126 //- List of region names this region is coupled to
128
129 //- List of AMI objects per coupled region
132
133
134 // Protected Member Functions
136 //- Read control parameters from dictionary
137 virtual bool read();
138
139 //- Read control parameters from dictionary
140 virtual bool read(const dictionary& dict);
142 //- Create or return a new inter-region AMI object
144 (
145 const regionModel& nbrRegion,
146 const label regionPatchi,
147 const label nbrPatchi,
148 const bool flip
149 ) const;
150
151
152public:
153
154 //- Runtime type information
155 TypeName("regionModel");
156
157
158 // Constructors
159
160 //- Construct null
161 regionModel(const fvMesh& mesh, const word& regionType);
162
163 //- Construct from mesh, region type and name
164 regionModel
165 (
166 const fvMesh& mesh,
167 const word& regionType,
168 const word& modelName,
169 bool readFields = true
170 );
171
172 //- Construct from mesh and name and dict
173 regionModel
174 (
175 const fvMesh& mesh,
176 const word& regionType,
177 const word& modelName,
178 const dictionary& dict,
179 bool readFields = true
180 );
181
182
183 //- Destructor
184 virtual ~regionModel() = default;
185
186
187 // Member Functions
188
189 // Access
190
191 //- Return the reference to the primary mesh database
192 const fvMesh& primaryMesh() const noexcept { return primaryMesh_; }
193
194 //- Return the reference to the time database
195 const Time& time() const noexcept { return time_; }
196
197 //- Return the active flag
198 Switch active() const noexcept { return active_; }
199
200 //- Return the information flag
201 Switch infoOutput() const noexcept { return infoOutput_; }
202
203 //- Return the model name
204 const word& modelName() const noexcept { return modelName_; }
205
206 //- Return the region mesh database
207 inline const fvMesh& regionMesh() const;
208
209 //- Return the region mesh database for manipulation
210 inline fvMesh& regionMesh();
211
212 //- Return the model coefficients dictionary
213 const dictionary& coeffs() const noexcept { return coeffs_; }
214
215 //- Return the solution dictionary
216 inline const dictionary& solution() const;
217
218 //- Return const access to the output properties dictionary
219 inline const IOdictionary& outputProperties() const;
220
221 //- Return output properties dictionary
223
224
225
226 // Addressing
227
228 //- List of patch IDs on the primary region coupled to this region
229 inline const labelList& primaryPatchIDs() const noexcept;
230
231 //- List of patch IDs internally coupled with the primary region
232 inline const labelList& intCoupledPatchIDs() const noexcept;
233
234 //- True if patchi on the local region is a coupled
235 //- patch to the primary region
236 inline bool isCoupledPatch(const label regionPatchi) const;
237
238 //- True if patchi on the primary region is a coupled
239 //- patch to the local region
240 inline bool isRegionPatch(const label primaryPatchi) const;
241
242 //- Return region ID corresponding to primaryPatch ID
243 inline label regionPatchID(const label primaryPatchi) const;
245
246 // Helper Functions
247
248 //- Return the coupled patch ID paired with coupled patch
249 // regionPatchi
251 (
252 const regionModel& nbrRegion,
253 const label regionPatchi
254 ) const;
255
256 //- Map patch field from another region model to local patch
257 template<class Type>
260 const regionModel& nbrRegion,
261 const label regionPatchi,
262 const label nbrPatchi,
263 const Field<Type>& nbrField,
264 const bool flip = false
265 ) const;
266
267 //- Map patch field from another region model to local patch
268 template<class Type>
270 (
271 const regionModel& nbrRegion,
272 const word& fieldName,
273 const label regionPatchi,
274 const bool flip = false
275 ) const;
276
277 //- Map patch internal field from another region model to local
278 // patch
279 template<class Type>
281 (
282 const regionModel& nbrRegion,
283 const word& fieldName,
284 const label regionPatchi,
285 const bool flip = false
286 ) const;
287
288 //- Convert a local region field to the primary region
289 template<class Type>
290 void toPrimary
291 (
292 const label regionPatchi,
293 List<Type>& regionField
294 ) const;
295
296 //- Convert a primary region field to the local region
297 template<class Type>
298 void toRegion
299 (
300 const label regionPatchi,
301 List<Type>& primaryFieldField
302 ) const;
303
304 //- Convert a local region field to the primary region with op
305 template<class Type, class CombineOp>
306 void toPrimary
307 (
308 const label regionPatchi,
309 List<Type>& regionField,
310 const CombineOp& cop
311 ) const;
312
313 //- Convert a primary region field to the local region with op
314 template<class Type, class CombineOp>
315 void toRegion
316 (
317 const label regionPatchi,
318 List<Type>& primaryFieldField,
319 const CombineOp& cop
320 ) const;
321
322
323 // Evolution
324
325 //- Main driver routing to evolve the region - calls other evolves
326 virtual void evolve();
327
328 //- Pre-evolve region
329 virtual void preEvolveRegion();
330
331 //- Evolve the region
332 virtual void evolveRegion();
333
334 //- Post-evolve region
335 virtual void postEvolveRegion();
336
337
338 // I-O
339
340 //- Provide some feedback
341 virtual void info();
342};
343
344
345// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
346
347} // End namespace regionModels
348} // End namespace Foam
349
350// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
351
352#include "regionModelI.H"
354// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
355
356#ifdef NoRepository
357 #include "regionModelTemplates.C"
358#endif
359
360// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361
362#endif
363
364// ************************************************************************* //
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition Switch.H:81
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
dictionary()
Default construct, a top-level empty dictionary.
Definition dictionary.C:68
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Base class for region models.
Definition regionModel.H:59
autoPtr< IOdictionary > outputPropertiesPtr_
Dictionary of output properties.
const Time & time_
Reference to the time database.
Definition regionModel.H:97
const word modelName_
Model name.
virtual void postEvolveRegion()
Post-evolve region.
const dictionary & solution() const
Return the solution dictionary.
const labelList & primaryPatchIDs() const noexcept
List of patch IDs on the primary region coupled to this region.
Switch infoOutput_
Active information output.
bool isCoupledPatch(const label regionPatchi) const
True if patchi on the local region is a coupled patch to the primary region.
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.
TypeName("regionModel")
Runtime type information.
labelList primaryPatchIDs_
List of patch IDs on the primary region coupled to this region.
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.
Switch active() const noexcept
Return the active flag.
virtual ~regionModel()=default
Destructor.
const Time & time() const noexcept
Return the reference to the time database.
dictionary coeffs_
Model coefficients dictionary.
Switch infoOutput() const noexcept
Return the information flag.
const fvMesh & regionMesh() const
Return the region mesh database.
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.
virtual void preEvolveRegion()
Pre-evolve region.
const labelList & intCoupledPatchIDs() const noexcept
List of patch IDs internally coupled with the primary region.
virtual void evolve()
Main driver routing to evolve the region - calls other evolves.
const fvMesh & primaryMesh_
Reference to the primary mesh database.
Definition regionModel.H:92
label regionPatchID(const label primaryPatchi) const
Return region ID corresponding to primaryPatch ID.
bool isRegionPatch(const label primaryPatchi) const
True if patchi on the primary region is a coupled patch to the local region.
regionModelFunctionObjectList functions_
Region model function objects.
virtual void info()
Provide some feedback.
wordList interRegionAMINames_
List of region names this region is coupled to.
const fvMesh & primaryMesh() const noexcept
Return the reference to the primary mesh database.
const IOdictionary & outputProperties() const
Return const access to the output properties dictionary.
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.
const word & modelName() const noexcept
Return the model name.
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.
const dictionary & coeffs() const noexcept
Return the model coefficients dictionary.
virtual bool read()
Read control parameters from dictionary.
virtual void evolveRegion()
Evolve the region.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
Namespace for OpenFOAM.
List< word > wordList
List of word.
Definition fileName.H:60
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.
List< label > labelList
A List of labels.
Definition List.H:62
AMIInterpolation AMIPatchToPatchInterpolation
Patch-to-patch interpolation == Foam::AMIInterpolation.
const direction noexcept
Definition scalarImpl.H:265
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68