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 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  faFieldDecomposerFields.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef faFieldDecomposer_H
44 #define faFieldDecomposer_H
45 
46 #include "faMesh.H"
47 #include "faPatchFieldMapper.H"
48 #include "edgeFields.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // Forward Declarations
56 class IOobjectList;
57 
58 /*---------------------------------------------------------------------------*\
59  Class faFieldDecomposer Declaration
60 \*---------------------------------------------------------------------------*/
61 
63 {
64 public:
65 
66  //- Patch field decomposer class
68  :
69  public faPatchFieldMapper
70  {
71  // Private Data
72 
73  label sizeBeforeMapping_;
74  labelList directAddressing_;
75 
76  public:
77 
78  // Constructors
79 
80  //- Construct given addressing
82  (
83  const label sizeBeforeMapping,
84  const labelUList& addressingSlice,
85  const label addressingOffset
86  );
87 
88 
89  // Member functions
90 
91  label size() const
92  {
93  return directAddressing_.size();
94  }
95 
96  virtual label sizeBeforeMapping() const
97  {
98  return sizeBeforeMapping_;
99  }
100 
101  bool direct() const
102  {
103  return true;
104  }
105 
106  virtual bool hasUnmapped() const
107  {
108  return false;
109  }
110 
111  const labelUList& directAddressing() const
112  {
113  return directAddressing_;
114  }
115  };
116 
117 
118  //- Processor patch field decomposer class
120  :
121  public faPatchFieldMapper
122  {
123  // Private Data
124 
125  label sizeBeforeMapping_;
126  labelListList addressing_;
127  scalarListList weights_;
128 
129  public:
130 
131  //- Construct addressing from details
133  (
134  const label nTotalFaces,
135  const labelUList& edgeOwner,
136  const labelUList& edgeNeigbour,
137  const labelUList& addressingSlice,
138  const scalarField& edgeWeights = scalarField::null()
139  );
140 
141  //- Construct given addressing from complete mesh
143  (
144  const faMesh& mesh,
145  const labelUList& addressingSlice
146  );
147 
148 
149  // Member Functions
150 
151  label size() const
152  {
153  return addressing_.size();
154  }
155 
156  virtual label sizeBeforeMapping() const
157  {
158  return sizeBeforeMapping_;
159  }
160 
161  bool direct() const
162  {
163  return false;
164  }
165 
166  virtual bool hasUnmapped() const
167  {
168  return false;
169  }
170 
171  const labelListList& addressing() const
172  {
173  return addressing_;
174  }
175 
176  const scalarListList& weights() const
177  {
178  return weights_;
179  }
180  };
181 
182 
183  //- Processor patch field decomposer class
185  :
186  public faPatchFieldMapper
187  {
188  label sizeBeforeMapping_;
189  labelListList addressing_;
190  scalarListList weights_;
191 
192  public:
193 
194  //- Construct given addressing
196  (
197  label sizeBeforeMapping,
198  const labelUList& addressingSlice
199  );
200 
201 
202  // Member Functions
203 
204  label size() const
205  {
206  return addressing_.size();
207  }
208 
209  virtual label sizeBeforeMapping() const
210  {
211  return sizeBeforeMapping_;
212  }
213 
214  bool direct() const
215  {
216  return false;
217  }
218 
219  virtual bool hasUnmapped() const
220  {
221  return false;
222  }
223 
224  const labelListList& addressing() const
225  {
226  return addressing_;
227  }
228 
229  const scalarListList& weights() const
230  {
231  return weights_;
232  }
233  };
234 
235 
236 private:
237 
238  // Private Data
239 
240  //- Reference to processor mesh
241  const faMesh& procMesh_;
242 
243  //- Reference to edge addressing
244  const labelList& edgeAddressing_;
245 
246  //- Reference to face addressing
247  const labelList& faceAddressing_;
248 
249  //- Reference to boundary addressing
250  const labelList& boundaryAddressing_;
251 
252  //- List of patch field decomposers
253  PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
254 
256  processorAreaPatchFieldDecomposerPtrs_;
257 
259  processorEdgePatchFieldDecomposerPtrs_;
260 
261 
262  // Private Member Functions
263 
264  //- No copy construct
265  faFieldDecomposer(const faFieldDecomposer&) = delete;
266 
267  //- No copy assignment
268  void operator=(const faFieldDecomposer&) = delete;
269 
270 
271 public:
272 
273  // Constructors
274 
275  //- Construct without mappers, added later with reset()
277  (
278  const Foam::zero,
279  const faMesh& procMesh,
280  const labelList& edgeAddressing,
281  const labelList& faceAddressing,
282  const labelList& boundaryAddressing
283  );
284 
285  //- Construct from components using information from the complete mesh
287  (
288  const faMesh& completeMesh,
289  const faMesh& procMesh,
290  const labelList& edgeAddressing,
291  const labelList& faceAddressing,
292  const labelList& boundaryAddressing
293  );
294 
295  //- Construct from components without the complete mesh
297  (
298  // Information about the complete mesh
299  const label nTotalFaces,
300  const List<labelRange>& boundaryRanges,
301  const labelUList& edgeOwner,
302  const labelUList& edgeNeigbour,
303 
304  // Addressing for processor mesh
305  const faMesh& procMesh,
306  const labelList& edgeAddressing,
307  const labelList& faceAddressing,
308  const labelList& boundaryAddressing
309  );
310 
311 
312  //- Destructor
313  ~faFieldDecomposer() = default;
314 
315 
316  // Member Functions
317 
318  //- True if no mappers have been allocated
319  bool empty() const;
320 
321  //- Remove all mappers
322  void clear();
323 
324  //- Reset mappers using information from the complete mesh
325  void reset(const faMesh& completeMesh);
326 
327  //- Reset mapper using information about the complete mesh
328  void reset
329  (
330  const label nTotalFaces,
331  const List<labelRange>& boundaryRanges,
332  const labelUList& edgeOwner,
333  const labelUList& edgeNeigbour
334  );
335 
336 
337  // Mapping
338 
339  //- Decompose area field
340  template<class Type>
343  (
345  ) const;
346 
347  //- Decompose surface field
348  template<class Type>
351  (
353  ) const;
354 
355  template<class GeoField>
356  void decomposeFields(const PtrList<GeoField>& fields) const;
357 
358 
359  // Reading helpers
360 
361  //- Read the fields and hold on the pointer list
362  template
363  <
364  class Type,
365  template<class> class PatchField,
366  class GeoMesh
367  >
368  static void readFields
369  (
370  const typename GeoMesh::Mesh& mesh,
371  const IOobjectList& objects,
373  const bool readOldTime
374  );
375 
376  //- Read fields and hold on the pointer list
377  template<class Mesh, class GeoField>
378  static void readFields
379  (
380  const Mesh& mesh,
381  const IOobjectList& objects,
383  );
384 };
385 
386 
387 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
388 
389 } // End namespace Foam
390 
391 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
392 
393 #ifdef NoRepository
394  #include "faFieldDecomposerFields.C"
396 #endif
397 
398 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
399 
400 #endif
401 
402 // ************************************************************************* //
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer
Processor patch field decomposer class.
Definition: faFieldDecomposer.H:118
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::direct
bool direct() const
Definition: faFieldDecomposer.H:160
Foam::faFieldDecomposer::empty
bool empty() const
True if no mappers have been allocated.
Definition: faFieldDecomposer.C:228
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::addressing
const labelListList & addressing() const
Definition: faFieldDecomposer.H:170
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::faFieldDecomposer
Finite Area area and edge field decomposer.
Definition: faFieldDecomposer.H:61
Foam::faFieldDecomposer::decomposeField
tmp< GeometricField< Type, faPatchField, areaMesh > > decomposeField(const GeometricField< Type, faPatchField, areaMesh > &field) const
Decompose area field.
Foam::faFieldDecomposer::clear
void clear()
Remove all mappers.
Definition: faFieldDecomposer.C:234
faMesh.H
Foam::faFieldDecomposer::patchFieldDecomposer::size
label size() const
Definition: faFieldDecomposer.H:90
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::direct
bool direct() const
Definition: faFieldDecomposer.H:213
faPatchFieldMapper.H
faFieldDecomposerReadFields.C
Foam::faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
patchFieldDecomposer(const label sizeBeforeMapping, const labelUList &addressingSlice, const label addressingOffset)
Construct given addressing.
Definition: faFieldDecomposer.C:34
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::size
label size() const
Definition: faFieldDecomposer.H:150
Foam::faFieldDecomposer::patchFieldDecomposer::directAddressing
const labelUList & directAddressing() const
Definition: faFieldDecomposer.H:110
Foam::Field< scalar >
Foam::faFieldDecomposer::patchFieldDecomposer::sizeBeforeMapping
virtual label sizeBeforeMapping() const
Definition: faFieldDecomposer.H:95
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer
Processor patch field decomposer class.
Definition: faFieldDecomposer.H:183
edgeFields.H
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::processorEdgePatchFieldDecomposer
processorEdgePatchFieldDecomposer(label sizeBeforeMapping, const labelUList &addressingSlice)
Construct given addressing.
Definition: faFieldDecomposer.C:136
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::hasUnmapped
virtual bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: faFieldDecomposer.H:218
field
rDeltaTY field()
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::faFieldDecomposer::patchFieldDecomposer::direct
bool direct() const
Definition: faFieldDecomposer.H:100
Foam::faFieldDecomposer::patchFieldDecomposer::hasUnmapped
virtual bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: faFieldDecomposer.H:105
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::GeoMesh
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Definition: GeoMesh.H:48
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::weights
const scalarListList & weights() const
Definition: faFieldDecomposer.H:228
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::IOobjectList
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:55
Foam::faFieldDecomposer::readFields
static void readFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh >> &fields, const bool readOldTime)
Read the fields and hold on the pointer list.
Definition: faFieldDecomposerReadFields.C:37
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::sizeBeforeMapping
virtual label sizeBeforeMapping() const
Definition: faFieldDecomposer.H:155
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::weights
const scalarListList & weights() const
Definition: faFieldDecomposer.H:175
Foam::faFieldDecomposer::reset
void reset(const faMesh &completeMesh)
Reset mappers using information from the complete mesh.
Definition: faFieldDecomposer.C:304
Foam::faFieldDecomposer::patchFieldDecomposer
Patch field decomposer class.
Definition: faFieldDecomposer.H:66
Foam::List< label >
faFieldDecomposerFields.C
Foam::UList< label >
Foam::faFieldDecomposer::~faFieldDecomposer
~faFieldDecomposer()=default
Destructor.
Foam::faMesh
Finite area mesh. Used for 2-D non-Euclidian finite area method.
Definition: faMesh.H:82
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::size
label size() const
Definition: faFieldDecomposer.H:203
Foam::faFieldDecomposer::decomposeFields
void decomposeFields(const PtrList< GeoField > &fields) const
Definition: faFieldDecomposerFields.C:218
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::sizeBeforeMapping
virtual label sizeBeforeMapping() const
Definition: faFieldDecomposer.H:208
Foam::GeoMesh::Mesh
MESH Mesh
Definition: GeoMesh.H:62
fields
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
Foam::Field< scalar >::null
static const Field< scalar > & null()
Return nullObject reference Field.
Definition: FieldI.H:31
Foam::faFieldDecomposer::processorEdgePatchFieldDecomposer::addressing
const labelListList & addressing() const
Definition: faFieldDecomposer.H:223
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::hasUnmapped
virtual bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: faFieldDecomposer.H:165
Foam::faFieldDecomposer::processorAreaPatchFieldDecomposer::processorAreaPatchFieldDecomposer
processorAreaPatchFieldDecomposer(const label nTotalFaces, const labelUList &edgeOwner, const labelUList &edgeNeigbour, const labelUList &addressingSlice, const scalarField &edgeWeights=scalarField::null())
Construct addressing from details.
Definition: faFieldDecomposer.C:55