faFieldDecomposer.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) 2016-2017 Wikki Ltd
9 Copyright (C) 2021-2022 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::faFieldDecomposer
29
30Description
31 Finite Area area and edge field decomposer.
32
33Author
34 Zeljko Tukovic, FSB Zagreb
35 Hrvoje Jasak, Wikki Ltd.
36
37SourceFiles
38 faFieldDecomposer.C
39 fvFieldDecomposerCache.C
40 faFieldDecomposerTemplates.C
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef Foam_faFieldDecomposer_H
45#define Foam_faFieldDecomposer_H
46
47#include "faMesh.H"
48#include "faPatchFieldMapper.H"
49#include "edgeFields.H"
50
51// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52
53namespace Foam
54{
55
56// Forward Declarations
57class IOobjectList;
58
59/*---------------------------------------------------------------------------*\
60 Class faFieldDecomposer Declaration
61\*---------------------------------------------------------------------------*/
64{
65public:
66
67 // Public Classes
68
69 //- Patch field decomposer class
71 :
73 {
74 // Private Data
75
76 label sizeBeforeMapping_;
77 labelList directAddressing_;
78
79 public:
80
81 // Constructors
82
83 //- Construct given addressing
85 (
86 const label sizeBeforeMapping,
87 const labelUList& addressingSlice,
88 const label addressingOffset
89 );
90
91
92 // Member functions
94 label size() const
95 {
96 return directAddressing_.size();
97 }
99 virtual label sizeBeforeMapping() const
100 {
101 return sizeBeforeMapping_;
102 }
104 bool direct() const
105 {
106 return true;
107 }
109 virtual bool hasUnmapped() const
110 {
111 return false;
112 }
114 const labelUList& directAddressing() const
115 {
116 return directAddressing_;
117 }
118 };
119
120
121 //- Processor patch field decomposer class
123 :
124 public faPatchFieldMapper
125 {
126 // Private Data
127
128 label sizeBeforeMapping_;
129 labelListList addressing_;
130 scalarListList weights_;
131
132 public:
133
134 //- Construct addressing from details
136 (
137 const label nTotalFaces,
138 const labelUList& edgeOwner,
139 const labelUList& edgeNeigbour,
140 const labelUList& addressingSlice,
141 const scalarField& edgeWeights = scalarField::null()
142 );
143
144 //- Construct given addressing from complete mesh
146 (
147 const faMesh& mesh,
148 const labelUList& addressingSlice
149 );
150
151
152 // Member Functions
154 label size() const
155 {
156 return addressing_.size();
157 }
159 virtual label sizeBeforeMapping() const
160 {
161 return sizeBeforeMapping_;
162 }
164 bool direct() const
165 {
166 return false;
167 }
169 virtual bool hasUnmapped() const
170 {
171 return false;
172 }
174 const labelListList& addressing() const
175 {
176 return addressing_;
177 }
179 const scalarListList& weights() const
180 {
181 return weights_;
182 }
183 };
184
185
186 //- Processor patch field decomposer class
188 :
189 public faPatchFieldMapper
190 {
191 label sizeBeforeMapping_;
192 labelListList addressing_;
193 scalarListList weights_;
194
195 public:
196
197 //- Construct given addressing
199 (
200 label sizeBeforeMapping,
201 const labelUList& addressingSlice
202 );
203
204
205 // Member Functions
207 label size() const
208 {
209 return addressing_.size();
210 }
212 virtual label sizeBeforeMapping() const
213 {
214 return sizeBeforeMapping_;
215 }
217 bool direct() const
218 {
219 return false;
220 }
222 virtual bool hasUnmapped() const
223 {
224 return false;
225 }
227 const labelListList& addressing() const
228 {
229 return addressing_;
230 }
232 const scalarListList& weights() const
233 {
234 return weights_;
235 }
236 };
237
238
239private:
240
241 // Private Data
242
243 //- Reference to processor mesh
244 const faMesh& procMesh_;
245
246 //- Reference to edge addressing
247 const labelList& edgeAddressing_;
248
249 //- Reference to face addressing
250 const labelList& faceAddressing_;
251
252 //- Reference to boundary addressing
253 const labelList& boundaryAddressing_;
254
255 //- List of patch field decomposers
256 PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
257
259 processorAreaPatchFieldDecomposerPtrs_;
260
262 processorEdgePatchFieldDecomposerPtrs_;
263
264
265 // Private Member Functions
266
267 //- No copy construct
268 faFieldDecomposer(const faFieldDecomposer&) = delete;
269
270 //- No copy assignment
271 void operator=(const faFieldDecomposer&) = delete;
272
273
274public:
275
276 // Public Classes
277 class fieldsCache;
278
279
280 // Constructors
281
282 //- Construct without mappers, added later with reset()
284 (
285 const Foam::zero,
286 const faMesh& procMesh, // Target mesh
287 const labelList& edgeAddressing,
288 const labelList& faceAddressing,
289 const labelList& boundaryAddressing
290 );
291
292 //- Construct from components using information from the complete mesh
294 (
295 const faMesh& completeMesh, // Source mesh
296 const faMesh& procMesh, // Target mesh
297 const labelList& edgeAddressing,
298 const labelList& faceAddressing,
299 const labelList& boundaryAddressing
300 );
301
302 //- Construct from components without the complete mesh
304 (
305 // Information about the complete mesh
306 const label nTotalFaces,
307 const List<labelRange>& boundaryRanges,
308 const labelUList& edgeOwner,
309 const labelUList& edgeNeigbour,
310
311 // Addressing for processor mesh
312 const faMesh& procMesh, // Target mesh
313 const labelList& edgeAddressing,
314 const labelList& faceAddressing,
315 const labelList& boundaryAddressing
316 );
317
318
319 //- Destructor
320 ~faFieldDecomposer() = default;
321
322
323 // Member Functions
324
325 //- True if no mappers have been allocated
326 bool empty() const;
327
328 //- Remove all mappers
329 void clear();
330
331 //- Reset mappers using information from the complete mesh
332 void reset(const faMesh& completeMesh);
333
334 //- Reset mapper using information about the complete mesh
335 void reset
336 (
337 const label nTotalFaces,
338 const List<labelRange>& boundaryRanges,
339 const labelUList& edgeOwner,
340 const labelUList& edgeNeigbour
341 );
342
343
344 // Mapping
345
346 //- Decompose area field
347 template<class Type>
350 (
352 ) const;
353
354 //- Decompose surface field
355 template<class Type>
358 (
360 ) const;
361
362 template<class GeoField>
363 void decomposeFields(const PtrList<GeoField>& fields) const;
364
365
366 // Reading helpers
367
368 //- Read the fields and store on the pointer list
369 template
370 <
371 class Type,
372 template<class> class PatchField,
373 class GeoMesh
375 static void readFields
376 (
377 const typename GeoMesh::Mesh& mesh,
378 const IOobjectList& objects,
380 const bool readOldTime
381 );
382
383 //- Read fields and store on the pointer list
384 template<class Mesh, class GeoField>
385 static void readFields
386 (
387 const Mesh& mesh,
388 const IOobjectList& objects,
390 );
391};
392
393
394
395/*---------------------------------------------------------------------------*\
396 Class faFieldDecomposer::fieldsCache Declaration
397\*---------------------------------------------------------------------------*/
400{
401 // Private Data
402
403 class privateCache;
404
405 //- All field and field-field types for lagrangian
406 std::unique_ptr<privateCache> cache_;
407
408
409 // Private Member Functions
410
411 //- No copy construct
412 fieldsCache(const fieldsCache&) = delete;
413
414 //- No copy assignment
415 void operator=(const fieldsCache&) = delete;
416
417
418public:
419
420 // Constructors
421
422 //- Default construct
423 fieldsCache();
424
425
426 //- Destructor
427 ~fieldsCache();
428
429
430 // Member Functions
431
432 //- No fields
433 bool empty() const;
434
435 //- Number of fields
436 label size() const;
437
438 //- Clear out
439 void clear();
440
441
442 //- Read all fields given mesh and objects
443 void readAllFields
444 (
445 const faMesh& mesh,
446 const IOobjectList& objects
447 );
448
449 //- Decompose and write all fields
451 (
452 const faFieldDecomposer& decomposer,
453 bool report = false
454 ) const;
455};
456
457
458// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
459
460} // End namespace Foam
461
462// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
463
464#ifdef NoRepository
466#endif
467
468// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
469
470#endif
471
472// ************************************************************************* //
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:49
MESH Mesh
Definition: GeoMesh.H:62
Generic GeometricField class.
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
label size() const
Number of fields.
void readAllFields(const faMesh &mesh, const IOobjectList &objects)
Read all fields given mesh and objects.
void decomposeAllFields(const faFieldDecomposer &decomposer, bool report=false) const
Decompose and write all fields.
virtual bool hasUnmapped() const
Any unmapped values?
bool direct() const
Is it a direct (non-interpolating) mapper?
label size() const
The size of the mapper.
const labelUList & directAddressing() const
Return the direct addressing values.
virtual bool hasUnmapped() const
Any unmapped values?
const scalarListList & weights() const
Return the interpolation weights.
const labelListList & addressing() const
Return the interpolation addressing.
bool direct() const
Is it a direct (non-interpolating) mapper?
virtual bool hasUnmapped() const
Any unmapped values?
const scalarListList & weights() const
Return the interpolation weights.
const labelListList & addressing() const
Return the interpolation addressing.
bool direct() const
Is it a direct (non-interpolating) mapper?
Finite Area area and edge field decomposer.
tmp< GeometricField< Type, faPatchField, areaMesh > > decomposeField(const GeometricField< Type, faPatchField, areaMesh > &field) const
Decompose area field.
tmp< GeometricField< Type, faePatchField, edgeMesh > > decomposeField(const GeometricField< Type, faePatchField, edgeMesh > &field) const
Decompose surface field.
static void readFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, const bool readOldTime)
Read the fields and store on the pointer list.
void decomposeFields(const PtrList< GeoField > &fields) const
bool empty() const
True if no mappers have been allocated.
~faFieldDecomposer()=default
Destructor.
void reset(const faMesh &completeMesh)
Reset mappers using information from the complete mesh.
void clear()
Remove all mappers.
static void readFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields)
Read fields and store on the pointer list.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
A FieldMapper for finite-area patch fields.
A class for managing temporary objects.
Definition: tmp.H:65
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:63
rDeltaTY field()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97