fvFieldDecomposer.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-2016 OpenFOAM Foundation
9  Copyright (C) 2021-2026 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::fvFieldDecomposer
29 
30 Description
31  Finite Volume volume and surface field decomposer.
32 
33 SourceFiles
34  fvFieldDecomposer.cxx
35  fvFieldDecomposer.txx
36  fvFieldDecomposerCache.cxx
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_fvFieldDecomposer_H
41 #define Foam_fvFieldDecomposer_H
42 
43 #include "fvMesh.H"
44 #include "fvPatchFieldMapper.H"
45 #include "volFields.H"
46 #include "surfaceFields.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward Declarations
54 class IOobjectList;
55 
56 /*---------------------------------------------------------------------------*\
57  Class fvFieldDecomposer Declaration
58 \*---------------------------------------------------------------------------*/
59 
61 {
62 public:
63 
64  // Public Classes
65 
66  //- Internal caching for field reading
67  class fieldsCache;
68 
69  //- Patch field decomposer class
71  :
72  public fvPatchFieldMapper
73  {
74  // Private Data
75 
76  labelList directAddressing_;
77 
78  public:
79 
80  // Constructors
81 
82  //- Construct given addressing
84  (
85  const labelUList& addressingSlice,
86  const label addressingOffset
87  );
88 
89 
90  // Member Functions
91 
92  label size() const noexcept
93  {
94  return directAddressing_.size();
95  }
96 
97  bool direct() const noexcept
98  {
99  return true;
100  }
101 
102  //- Are there unmapped values
103  bool hasUnmapped() const noexcept
104  {
105  return false;
106  }
107 
108  const labelUList& directAddressing() const noexcept
109  {
110  return directAddressing_;
111  }
112  };
113 
114 
115  //- Processor patch field decomposer class. Maps either owner or
116  // neighbour data (no interpolate anymore - processorFvPatchField
117  // holds neighbour data)
118  class processorVolPatchFieldDecomposer
119  :
120  public fvPatchFieldMapper
121  {
122  // Private Data
123 
124  labelList directAddressing_;
125 
126  public:
127 
128  //- Construct addressing from details
130  (
131  const labelUList& faceOwner,
132  const labelUList& faceNeigbour,
133  const labelUList& addressingSlice
134  );
135 
136  //- Construct given addressing from complete mesh
138  (
139  const polyMesh& mesh,
140  const labelUList& addressingSlice
141  );
142 
143 
144  // Member Functions
145 
146  label size() const noexcept
147  {
148  return directAddressing_.size();
149  }
150 
151  bool direct() const noexcept
152  {
153  return true;
154  }
155 
156  //- Are there unmapped values
157  bool hasUnmapped() const noexcept
158  {
159  return false;
160  }
162  const labelUList& directAddressing() const noexcept
163  {
164  return directAddressing_;
165  }
166  };
167 
168 
169  //- Processor patch field decomposer class. Surface field is assumed
170  // to have direction (so manipulates sign when mapping)
172  :
173  public fvPatchFieldMapper
174  {
175  labelListList addressing_;
176  scalarListList weights_;
177 
178  public:
179 
180  //- Construct given addressing
182  (
183  const labelUList& addressingSlice
184  );
185 
187  // Member Functions
188 
189  label size() const noexcept
190  {
191  return addressing_.size();
192  }
193 
194  bool direct() const noexcept
195  {
196  return false;
197  }
198 
199  //- Are there unmapped values
200  bool hasUnmapped() const noexcept
201  {
202  return false;
203  }
204 
205  const labelListList& addressing() const noexcept
206  {
207  return addressing_;
208  }
209 
210  const scalarListList& weights() const noexcept
211  {
212  return weights_;
213  }
214  };
215 
216 
217 private:
218 
219  // Private Data
220 
221  //- Reference to processor mesh
222  const fvMesh& procMesh_;
223 
224  //- Reference to face addressing
225  const labelUList& faceAddressing_;
226 
227  //- Reference to cell addressing
228  const labelUList& cellAddressing_;
230  //- Reference to boundary addressing
231  const labelUList& boundaryAddressing_;
232 
233  //- Patch field decomposers for regular patches
234  PtrList<patchFieldDecomposer> patchFieldDecomposers_;
235 
236  //- Processor-patch field decomposers (volume fields)
238  processorVolPatchFieldDecomposers_;
239 
240  //- Processor-patch field decomposers (surface fields)
242  processorSurfacePatchFieldDecomposers_;
243 
244  //- Processor-patch surface field flipping (as -1/+1 multipliers)
245  PtrList<scalarField> faceSigns_;
246 
247 
248  // Private Member Functions
249 
250  //- No copy construct
251  fvFieldDecomposer(const fvFieldDecomposer&) = delete;
252 
253  //- No copy assignment
254  void operator=(const fvFieldDecomposer&) = delete;
255 
256 public:
257 
258  // Static Data
259 
260  //- Output verbosity when writing
261  static int verbose_;
262 
263 
264  // Constructors
265 
266  //- Construct without mappers, added later with reset()
268  (
269  Foam::zero,
270  const fvMesh& procMesh,
271  const labelUList& faceAddressing,
272  const labelUList& cellAddressing,
273  const labelUList& boundaryAddressing
274  );
275 
276  //- Construct from components using information from the complete mesh
278  (
279  const fvMesh& completeMesh,
280  const fvMesh& procMesh,
281  const labelUList& faceAddressing,
282  const labelUList& cellAddressing,
283  const labelUList& boundaryAddressing
284  );
285 
286  //- Construct from components without the complete mesh
288  (
289  // Information about the complete mesh
290  const UList<labelRange>& boundaryRanges,
291  const labelUList& faceOwner,
292  const labelUList& faceNeigbour,
293 
294  // Addressing for processor mesh
295  const fvMesh& procMesh,
296  const labelUList& faceAddressing,
297  const labelUList& cellAddressing,
298  const labelUList& boundaryAddressing
299  );
300 
301 
302  //- Destructor
303  ~fvFieldDecomposer() = default;
304 
305 
306  // Member Functions
307 
308  //- True if no mappers have been allocated
309  bool empty() const noexcept;
310 
311  //- Remove all mappers
312  void clear();
313 
314  //- Reset mappers using information from the complete mesh
315  void reset(const fvMesh& completeMesh);
316 
317  //- Reset mapper using information about the complete mesh
318  void reset
319  (
320  const UList<labelRange>& boundaryRanges,
321  const labelUList& faceOwner,
322  const labelUList& faceNeigbour
323  );
324 
325 
326  // Mapping
327 
328  //- Decompose internal field
329  template<class Type>
332  (
333  const DimensionedField<Type, volMesh>& field
334  ) const;
335 
336  //- Decompose volume field
337  template<class Type>
340  (
341  const GeometricField<Type, fvPatchField, volMesh>& field,
342  const bool allowUnknownPatchFields = false
343  ) const;
344 
345  //- Decompose surface field
346  template<class Type>
349  (
351  ) const;
352 
353  //- Decompose list of fields
354  template<class GeoField>
355  void decomposeFields(const UPtrList<GeoField>& fields) const;
356 };
357 
358 
359 /*---------------------------------------------------------------------------*\
360  Class fvFieldDecomposer::fieldsCache Declaration
361 \*---------------------------------------------------------------------------*/
362 
364 {
365  class privateCache;
366  std::unique_ptr<privateCache> cache_;
367 
368  //- No copy construct
369  fieldsCache(const fieldsCache&) = delete;
370 
371  //- No copy assignment
372  void operator=(const fieldsCache&) = delete;
373 
374 
375 public:
376 
377  // Constructors
378 
379  //- Default construct
380  fieldsCache();
381 
382 
383  //- Destructor
384  ~fieldsCache();
385 
386 
387  // Member Functions
388 
389  //- No fields
390  bool empty() const noexcept;
391 
392  //- Total number of fields
393  label size() const noexcept;
394 
395  //- Clear out
396  void clear();
397 
398 
399  //- Read all fields given mesh and objects
400  void readAllFields
401  (
402  const fvMesh& mesh,
403  const IOobjectList& objects
404  );
405 
406  //- Decompose and write all fields
407  void decomposeAllFields
408  (
409  const fvFieldDecomposer& decomposer,
410  bool report = false
411  ) const;
412 };
413 
414 
415 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
416 
417 } // End namespace Foam
418 
419 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
420 
421 #ifdef NoRepository
422  #include "fvFieldDecomposer.txx"
423 #endif
424 
425 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
426 
427 #endif
429 // ************************************************************************* //
Foam::surfaceFields.
const labelUList & directAddressing() const noexcept
Return the direct addressing values.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:119
label size() const noexcept
The size of the mapper.
rDeltaTY field()
static int verbose_
Output verbosity when writing.
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
Mesh data needed to do the Finite Volume discretisation.
Definition: surfaceMesh.H:44
bool direct() const noexcept
Is it a direct (non-interpolating) mapper?
processorSurfacePatchFieldDecomposer(const labelUList &addressingSlice)
Construct given addressing.
A range or interval of labels defined by a start and a size.
Definition: labelRange.H:63
void clear()
Remove all mappers.
bool hasUnmapped() const noexcept
Are there unmapped values.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Generic GeometricField class.
List< labelList > labelListList
List of labelList.
Definition: labelList.H:38
bool direct() const noexcept
Is it a direct (non-interpolating) mapper?
const labelListList & addressing() const noexcept
Return the interpolation addressing.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
void reset(const fvMesh &completeMesh)
Reset mappers using information from the complete mesh.
const labelUList & directAddressing() const noexcept
Return the direct addressing values.
tmp< DimensionedField< Type, volMesh > > decomposeField(const DimensionedField< Type, volMesh > &field) const
Decompose internal field.
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:44
dynamicFvMesh & mesh
const scalarListList & weights() const noexcept
Return the interpolation weights.
void decomposeFields(const UPtrList< GeoField > &fields) const
Decompose list of fields.
~fvFieldDecomposer()=default
Destructor.
A FieldMapper for finite-volume patch fields.
Processor patch field decomposer class. Surface field is assumed.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
label size() const noexcept
The size of the mapper.
const direction noexcept
Definition: scalarImpl.H:265
Finite Volume volume and surface field decomposer.
bool direct() const noexcept
Is it a direct (non-interpolating) mapper?
patchFieldDecomposer(const labelUList &addressingSlice, const label addressingOffset)
Construct given addressing.
decomposeUsingBbs false
Use bounding boxes (default) or unique decomposition of triangles (i.e. do not duplicate triangles) ...
bool hasUnmapped() const noexcept
Are there unmapped values.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: PtrList.H:56
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
bool hasUnmapped() const noexcept
Are there unmapped values.
bool empty() const noexcept
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
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
A class for managing temporary objects.
Definition: HashPtrTable.H:50
processorVolPatchFieldDecomposer(const labelUList &faceOwner, const labelUList &faceNeigbour, const labelUList &addressingSlice)
Construct addressing from details.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Namespace for OpenFOAM.
label size() const noexcept
The size of the mapper.