Loading...
Searching...
No Matches
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-2025 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.cxx
39 faFieldDecomposer.txx
40 fvFieldDecomposerCache.cxx
41
42\*---------------------------------------------------------------------------*/
43
44#ifndef Foam_faFieldDecomposer_H
45#define Foam_faFieldDecomposer_H
46
47#include "faMesh.H"
48#include "faMeshSubset.H"
49#include "faPatchFieldMapper.H"
50#include "edgeFields.H"
51
52// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53
54namespace Foam
55{
56
57// Forward Declarations
58class IOobjectList;
60/*---------------------------------------------------------------------------*\
61 Class faFieldDecomposer Declaration
62\*---------------------------------------------------------------------------*/
63
64class faFieldDecomposer
65{
66public:
67
68 // Public Classes
69
70 //- Patch field decomposer class
72 :
74 {
75 // Private Data
76
77 label sizeBeforeMapping_;
78 labelList directAddressing_;
79
80 public:
81
82 // Constructors
83
84 //- Construct given addressing
86 (
87 const label sizeBeforeMapping,
88 const labelUList& addressingSlice,
89 const label addressingOffset
90 );
91
92
93 // Member Functions
95 label size() const noexcept
96 {
97 return directAddressing_.size();
98 }
100 virtual label sizeBeforeMapping() const
101 {
102 return sizeBeforeMapping_;
103 }
105 bool direct() const noexcept
106 {
107 return true;
108 }
110 virtual bool hasUnmapped() const
111 {
112 return false;
113 }
116 {
117 return directAddressing_;
118 }
119 };
120
121
122 //- Processor patch field decomposer class
123 class processorAreaPatchFieldDecomposer
125 public faPatchFieldMapper
126 {
127 // Private Data
128
129 label sizeBeforeMapping_;
130 labelList directAddressing_;
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 bitSet& flip
142 );
143
144
145 // Member Functions
146
147 label size() const noexcept
148 {
149 return directAddressing_.size();
151
152 virtual label sizeBeforeMapping() const
153 {
154 return sizeBeforeMapping_;
156
157 bool direct() const noexcept
158 {
159 return true;
161
162 virtual bool hasUnmapped() const
163 {
164 return false;
166
168 {
169 return directAddressing_;
171 };
172
173
174 //- Processor patch field decomposer class
175 class processorEdgePatchFieldDecomposer
176 :
177 public faPatchFieldMapper
178 {
179 label sizeBeforeMapping_;
180 labelListList addressing_;
181 scalarListList weights_;
182
183 public:
184
185 //- Construct given addressing
187 (
188 label sizeBeforeMapping,
189 const labelUList& addressingSlice
190 );
191
192
193 // Member Functions
194
195 label size() const noexcept
196 {
197 return addressing_.size();
198 }
199
200 virtual label sizeBeforeMapping() const
201 {
202 return sizeBeforeMapping_;
203 }
204
205 bool direct() const noexcept
206 {
207 return false;
208 }
209
210 virtual bool hasUnmapped() const
211 {
212 return false;
213 }
214
215 const labelListList& addressing() const noexcept
216 {
217 return addressing_;
218 }
219
220 const scalarListList& weights() const noexcept
221 {
222 return weights_;
223 }
224 };
225
226
227private:
228
229 // Private Data
230
231 //- Reference to processor mesh
232 const faMesh& procMesh_;
233
234 //- Reference to edge addressing
235 const labelUList& edgeAddressing_;
236
237 //- Reference to face addressing
238 const labelUList& faceAddressing_;
239
240 //- Reference to boundary addressing
241 const labelUList& boundaryAddressing_;
242
243 //- List of patch field decomposers
244 PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
245
247 processorAreaPatchFieldDecomposerPtrs_;
248
250 processorEdgePatchFieldDecomposerPtrs_;
251
252
253 // Private Member Functions
254
255 //- No copy construct
256 faFieldDecomposer(const faFieldDecomposer&) = delete;
257
258 //- No copy assignment
259 void operator=(const faFieldDecomposer&) = delete;
260
261
262public:
263
264 // Public Classes
265 class fieldsCache;
266
267
268 // Constructors
269
270 //- Construct without mappers, added later with reset()
271 faFieldDecomposer
272 (
274 const faMesh& procMesh, // Target mesh
275 const labelUList& edgeAddressing,
276 const labelUList& faceAddressing,
277 const labelUList& boundaryAddressing
278 );
279
280 //- Construct from components using information from the complete mesh
281 faFieldDecomposer
282 (
283 const faMesh& completeMesh, // Source mesh
284 const faMesh& procMesh, // Target mesh
285 const labelUList& edgeAddressing,
286 const labelUList& faceAddressing,
287 const labelUList& boundaryAddressing
288 );
289
290 //- Construct from components without the complete mesh
291 faFieldDecomposer
292 (
293 // Information about the complete mesh
294 const label nTotalFaces,
295 const UList<labelRange>& boundaryRanges,
296 const labelUList& edgeOwner,
297 const labelUList& edgeNeigbour,
298
299 // Addressing for processor mesh
300 const faMesh& procMesh, // Target mesh
301 const labelUList& edgeAddressing,
302 const labelUList& faceAddressing,
303 const labelUList& boundaryAddressing
304 );
305
307 //- Destructor
308 ~faFieldDecomposer() = default;
309
310
311 // Member Functions
312
313 //- True if no mappers have been allocated
314 bool empty() const noexcept;
315
316 //- Remove all mappers
317 void clear();
319 //- Reset mappers using information from the complete mesh
320 void reset(const faMesh& completeMesh);
321
322 //- Reset mapper using information about the complete mesh
323 void reset
324 (
325 const label nTotalFaces,
326 const UList<labelRange>& boundaryRanges,
327 const labelUList& edgeOwner,
328 const labelUList& edgeNeigbour
329 );
330
331
332 // Mapping
333
334 //- Decompose area field
335 template<class Type>
338 (
340 ) const;
341
342 //- Decompose surface field
343 template<class Type>
346 (
348 ) const;
349
350 template<class GeoField>
351 void decomposeFields(const PtrList<GeoField>& fields) const;
352
353
354 // Reading helpers
356 //- Read the fields and store on the pointer list
357 template
358 <
359 class Type,
360 template<class> class PatchField,
361 class GeoMesh
362 >
363 static void readFields
364 (
365 const typename GeoMesh::Mesh& mesh,
366 const IOobjectList& objects,
367 PtrList<GeometricField<Type, PatchField, GeoMesh>>& fields,
368 const bool readOldTime
369 );
370
371 //- Read fields and store on the pointer list
372 template<class Mesh, class GeoField>
373 static void readFields
374 (
375 const Mesh& mesh,
376 const IOobjectList& objects,
377 PtrList<GeoField>& fields
378 );
379};
380
381
382
383/*---------------------------------------------------------------------------*\
384 Class faFieldDecomposer::fieldsCache Declaration
385\*---------------------------------------------------------------------------*/
387class faFieldDecomposer::fieldsCache
388{
389 // Private Data
390
391 class privateCache;
393 //- All field and field-field types for finiteArea
394 std::unique_ptr<privateCache> cache_;
395
396
397 // Private Member Functions
398
399 //- No copy construct
400 fieldsCache(const fieldsCache&) = delete;
401
402 //- No copy assignment
403 void operator=(const fieldsCache&) = delete;
404
405
406public:
407
408 // Constructors
409
410 //- Default construct
411 fieldsCache();
412
413
414 //- Destructor
415 ~fieldsCache();
416
417
418 // Member Functions
419
420 //- No fields
421 bool empty() const;
422
423 //- Number of fields
424 label size() const;
425
426 //- Clear out
427 void clear();
428
429
430 //- Read all fields given mesh and objects
431 void readAllFields
433 const faMesh& mesh,
434 const IOobjectList& objects
435 );
436
437 //- Read all fields given mesh and objects.
438 //- Supports reading/sending fields
439 void readAllFields
440 (
441 const bitSet& haveMeshOnProc,
442 const faMeshSubset* subsetter,
443 const faMesh& mesh,
444 IOobjectList& objects
445 );
446
447 //- Read all fields given mesh and objects.
448 //- Supports reading/sending fields
449 void readAllFields
450 (
451 const boolUList& haveMeshOnProc,
452 const faMeshSubset* subsetter,
453 const faMesh& mesh,
454 IOobjectList& objects
455 );
456
457 //- Decompose and write all fields
459 (
460 const faFieldDecomposer& decomposer,
461 bool report = false
462 ) const;
463};
465
466// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
467
468} // End namespace Foam
469
470// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
471
472#ifdef NoRepository
473 #include "faFieldDecomposer.txx"
474#endif
475
476// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
477
478#endif
479
480// ************************************************************************* //
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition GeoMesh.H:46
Generic GeometricField class.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Mesh data needed to do the Finite Area discretisation.
Definition areaFaMesh.H:50
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
Mesh data needed to do the Finite Area discretisation.
Definition edgeFaMesh.H:50
void readAllFields(const boolUList &haveMeshOnProc, const faMeshSubset *subsetter, const faMesh &mesh, IOobjectList &objects)
Read all fields given mesh and objects. Supports reading/sending fields.
void readAllFields(const bitSet &haveMeshOnProc, const faMeshSubset *subsetter, const faMesh &mesh, IOobjectList &objects)
Read all fields given mesh and objects. Supports reading/sending fields.
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 noexcept
Is it a direct (non-interpolating) mapper?
label size() const noexcept
The size of the mapper.
const labelUList & directAddressing() const noexcept
Return the direct addressing values.
patchFieldDecomposer(const label sizeBeforeMapping, const labelUList &addressingSlice, const label addressingOffset)
Construct given addressing.
virtual bool hasUnmapped() const
Any unmapped values?
processorAreaPatchFieldDecomposer(const label nTotalFaces, const labelUList &edgeOwner, const labelUList &edgeNeigbour, const labelUList &addressingSlice, const bitSet &flip)
Construct addressing from details.
bool direct() const noexcept
Is it a direct (non-interpolating) mapper?
label size() const noexcept
The size of the mapper.
const labelUList & directAddressing() const noexcept
Return the direct addressing values.
virtual bool hasUnmapped() const
Any unmapped values?
bool direct() const noexcept
Is it a direct (non-interpolating) mapper?
const scalarListList & weights() const noexcept
Return the interpolation weights.
const labelListList & addressing() const noexcept
Return the interpolation addressing.
label size() const noexcept
The size of the mapper.
processorEdgePatchFieldDecomposer(label sizeBeforeMapping, const labelUList &addressingSlice)
Construct given addressing.
Finite Area area and edge field decomposer.
tmp< GeometricField< Type, faPatchField, areaMesh > > decomposeField(const GeometricField< Type, faPatchField, areaMesh > &field) const
Decompose area 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 noexcept
True if no mappers have been allocated.
~faFieldDecomposer()=default
Destructor.
faFieldDecomposer(Foam::zero, const faMesh &procMesh, const labelUList &edgeAddressing, const labelUList &faceAddressing, const labelUList &boundaryAddressing)
Construct without mappers, added later with reset().
void reset(const faMesh &completeMesh)
Reset mappers using information from the complete mesh.
faFieldDecomposer(const label nTotalFaces, const UList< labelRange > &boundaryRanges, const labelUList &edgeOwner, const labelUList &edgeNeigbour, const faMesh &procMesh, const labelUList &edgeAddressing, const labelUList &faceAddressing, const labelUList &boundaryAddressing)
Construct from components without the complete mesh.
void clear()
Remove all mappers.
faFieldDecomposer(const faMesh &completeMesh, const faMesh &procMesh, const labelUList &edgeAddressing, const labelUList &faceAddressing, const labelUList &boundaryAddressing)
Construct from components using information from the complete mesh.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
A FieldMapper for finite-area patch fields.
faPatchFieldMapper()=default
Default construct.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
A range or interval of labels defined by a start and a size.
Definition labelRange.H:66
A class for managing temporary objects.
Definition tmp.H:75
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
rDeltaTY field()
dynamicFvMesh & mesh
Namespace for OpenFOAM.
List< scalarList > scalarListList
List of scalarList.
Definition scalarList.H:35
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
UList< bool > boolUList
A UList of bools.
Definition UList.H:73
const direction noexcept
Definition scalarImpl.H:265
UList< label > labelUList
A UList of labels.
Definition UList.H:75
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields