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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::faFieldDecomposer
29 
30 Description
31  Finite Area area and edge field decomposer.
32 
33 Author
34  Zeljko Tukovic, FSB Zagreb
35  Hrvoje Jasak, Wikki Ltd.
36 
37 SourceFiles
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 "faMeshSubset.H"
49 #include "faPatchFieldMapper.H"
50 #include "edgeFields.H"
51 
52 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 
54 namespace Foam
55 {
56 
57 // Forward Declarations
58 class IOobjectList;
59 
60 /*---------------------------------------------------------------------------*\
61  Class faFieldDecomposer Declaration
62 \*---------------------------------------------------------------------------*/
63 
65 {
66 public:
67 
68  // Public Classes
69 
70  //- Patch field decomposer class
72  :
73  public faPatchFieldMapper
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
94 
95  label size() const
96  {
97  return directAddressing_.size();
98  }
99 
100  virtual label sizeBeforeMapping() const
101  {
102  return sizeBeforeMapping_;
103  }
105  bool direct() const
106  {
107  return true;
108  }
110  virtual bool hasUnmapped() const
111  {
112  return false;
113  }
115  const labelUList& directAddressing() const
116  {
117  return directAddressing_;
118  }
119  };
120 
121 
122  //- Processor patch field decomposer class
123  class processorAreaPatchFieldDecomposer
124  :
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
148  {
149  return directAddressing_.size();
150  }
151 
152  virtual label sizeBeforeMapping() const
153  {
154  return sizeBeforeMapping_;
155  }
156 
157  bool direct() const
158  {
159  return true;
160  }
161 
162  virtual bool hasUnmapped() const
163  {
164  return false;
165  }
166 
167  const labelUList& directAddressing() const
168  {
169  return directAddressing_;
170  }
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
196  {
197  return addressing_.size();
198  }
199 
200  virtual label sizeBeforeMapping() const
201  {
202  return sizeBeforeMapping_;
203  }
204 
205  bool direct() const
206  {
207  return false;
208  }
209 
210  virtual bool hasUnmapped() const
211  {
212  return false;
213  }
214 
215  const labelListList& addressing() const
216  {
217  return addressing_;
218  }
219 
220  const scalarListList& weights() const
221  {
222  return weights_;
223  }
224  };
225 
226 
227 private:
228 
229  // Private Data
230 
231  //- Reference to processor mesh
232  const faMesh& procMesh_;
233 
234  //- Reference to edge addressing
235  const labelList& edgeAddressing_;
236 
237  //- Reference to face addressing
238  const labelList& faceAddressing_;
239 
240  //- Reference to boundary addressing
241  const labelList& 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 
262 public:
263 
264  // Public Classes
265  class fieldsCache;
266 
267 
268  // Constructors
269 
270  //- Construct without mappers, added later with reset()
272  (
273  const Foam::zero,
274  const faMesh& procMesh, // Target mesh
275  const labelList& edgeAddressing,
276  const labelList& faceAddressing,
277  const labelList& boundaryAddressing
278  );
279 
280  //- Construct from components using information from the complete mesh
282  (
283  const faMesh& completeMesh, // Source mesh
284  const faMesh& procMesh, // Target mesh
285  const labelList& edgeAddressing,
286  const labelList& faceAddressing,
287  const labelList& boundaryAddressing
288  );
289 
290  //- Construct from components without the complete mesh
292  (
293  // Information about the complete mesh
294  const label nTotalFaces,
295  const List<labelRange>& boundaryRanges,
296  const labelUList& edgeOwner,
297  const labelUList& edgeNeigbour,
298 
299  // Addressing for processor mesh
300  const faMesh& procMesh, // Target mesh
301  const labelList& edgeAddressing,
302  const labelList& faceAddressing,
303  const labelList& boundaryAddressing
304  );
305 
306 
307  //- Destructor
308  ~faFieldDecomposer() = default;
309 
310 
311  // Member Functions
312 
313  //- True if no mappers have been allocated
314  bool empty() const;
315 
316  //- Remove all mappers
317  void clear();
318 
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 List<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
355 
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,
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,
378  );
379 };
380 
381 
382 
383 /*---------------------------------------------------------------------------*\
384  Class faFieldDecomposer::fieldsCache Declaration
385 \*---------------------------------------------------------------------------*/
386 
388 {
389  // Private Data
390 
391  class privateCache;
392 
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 
406 public:
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
432  (
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 boolList& haveMeshOnProc,
452  const faMeshSubset* subsetter,
453  const faMesh& mesh,
454  IOobjectList& objects
455  );
456 
457  //- Decompose and write all fields
458  void decomposeAllFields
459  (
460  const faFieldDecomposer& decomposer,
461  bool report = false
462  ) const;
463 };
464 
465 
466 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
467 
468 } // End namespace Foam
469 
470 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
471 
472 #ifdef NoRepository
474 #endif
475 
476 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
477 
478 #endif
479 
480 // ************************************************************************* //
bool direct() const
Is it a direct (non-interpolating) mapper?
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
const labelListList & addressing() const
Return the interpolation addressing.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
virtual bool hasUnmapped() const
Any unmapped values?
rDeltaTY field()
Finite Area area and edge field decomposer.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
~faFieldDecomposer()=default
Destructor.
void readAllFields(const faMesh &mesh, const IOobjectList &objects)
Read all fields given mesh and objects.
const labelUList & directAddressing() const
Return the direct addressing values.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Definition: faMeshSubset.H:61
Generic GeometricField class.
processorEdgePatchFieldDecomposer(label sizeBeforeMapping, const labelUList &addressingSlice)
Construct given addressing.
void decomposeFields(const PtrList< GeoField > &fields) const
const scalarListList & weights() const
Return the interpolation weights.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
virtual bool hasUnmapped() const
Any unmapped values?
bool direct() const
Is it a direct (non-interpolating) mapper?
processorAreaPatchFieldDecomposer(const label nTotalFaces, const labelUList &edgeOwner, const labelUList &edgeNeigbour, const labelUList &addressingSlice, const bitSet &flip)
Construct addressing from details.
virtual bool hasUnmapped() const
Any unmapped values?
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 reset(const faMesh &completeMesh)
Reset mappers using information from the complete mesh.
dynamicFvMesh & mesh
patchFieldDecomposer(const label sizeBeforeMapping, const labelUList &addressingSlice, const label addressingOffset)
Construct given addressing.
MESH Mesh
Definition: GeoMesh.H:61
void clear()
Remove all mappers.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:59
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:54
bool empty() const
True if no mappers have been allocated.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
label size() const
The size of the mapper.
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:45
A class for managing temporary objects.
Definition: HashPtrTable.H:50
A FieldMapper for finite-area patch fields.
label size() const
Number of fields.
tmp< GeometricField< Type, faPatchField, areaMesh > > decomposeField(const GeometricField< Type, faPatchField, areaMesh > &field) const
Decompose area field.
bool direct() const
Is it a direct (non-interpolating) mapper?
const labelUList & directAddressing() const
Return the direct addressing values.
Namespace for OpenFOAM.
void decomposeAllFields(const faFieldDecomposer &decomposer, bool report=false) const
Decompose and write all fields.