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 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.C
35  fvFieldDecomposerFields.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef fvFieldDecomposer_H
40 #define fvFieldDecomposer_H
41 
42 #include "fvMesh.H"
43 #include "fvPatchFieldMapper.H"
44 #include "surfaceFields.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class fvFieldDecomposer Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 {
57 public:
58 
59  //- Patch field decomposer class
61  :
62  public fvPatchFieldMapper
63  {
64  // Private Data
65 
66  labelList directAddressing_;
67 
68  public:
69 
70  // Constructors
71 
72  //- Construct given addressing
74  (
75  const labelUList& addressingSlice,
76  const label addressingOffset
77  );
78 
79 
80  // Member Functions
81 
82  label size() const
83  {
84  return directAddressing_.size();
85  }
86 
87  bool direct() const
88  {
89  return true;
90  }
91 
92  //- Are there unmapped values
93  bool hasUnmapped() const
94  {
95  return false;
96  }
97 
98  const labelUList& directAddressing() const
99  {
100  return directAddressing_;
101  }
102  };
103 
104 
105  //- Processor patch field decomposer class. Maps either owner or
106  // neighbour data (no interpolate anymore - processorFvPatchField
107  // holds neighbour data)
109  :
110  public fvPatchFieldMapper
111  {
112  // Private Data
113 
114  labelList directAddressing_;
115 
116  public:
117 
118  //- Construct addressing from details
120  (
121  const labelUList& faceOwner,
122  const labelUList& faceNeigbour,
123  const labelUList& addressingSlice
124  );
125 
126  //- Construct given addressing from complete mesh
128  (
129  const fvMesh& mesh,
130  const labelUList& addressingSlice
131  );
132 
133 
134  // Member Functions
135 
136  label size() const
137  {
138  return directAddressing_.size();
139  }
140 
141  bool direct() const
142  {
143  return true;
144  }
145 
146  //- Are there unmapped values
147  bool hasUnmapped() const
148  {
149  return false;
150  }
151 
152  const labelUList& directAddressing() const
153  {
154  return directAddressing_;
155  }
156  };
157 
158 
159  //- Processor patch field decomposer class. Surface field is assumed
160  // to have direction (so manipulates sign when mapping)
162  :
163  public fvPatchFieldMapper
164  {
165  labelListList addressing_;
166  scalarListList weights_;
167 
168  public:
169 
170  //- Construct given addressing
172  (
173  const labelUList& addressingSlice
174  );
175 
176 
177  // Member functions
178 
179  label size() const
180  {
181  return addressing_.size();
182  }
183 
184  bool direct() const
185  {
186  return false;
187  }
188 
189  //- Are there unmapped values
190  bool hasUnmapped() const
191  {
192  return false;
193  }
194 
195  const labelListList& addressing() const
196  {
197  return addressing_;
198  }
199 
200  const scalarListList& weights() const
201  {
202  return weights_;
203  }
204  };
205 
206 
207 private:
208 
209  // Private Data
210 
211  //- Reference to processor mesh
212  const fvMesh& procMesh_;
213 
214  //- Reference to face addressing
215  const labelList& faceAddressing_;
216 
217  //- Reference to cell addressing
218  const labelList& cellAddressing_;
219 
220  //- Reference to boundary addressing
221  const labelList& boundaryAddressing_;
222 
223  //- List of patch field decomposers
224  PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
225 
227  processorVolPatchFieldDecomposerPtrs_;
228 
230  processorSurfacePatchFieldDecomposerPtrs_;
231 
232  PtrList<scalarField> faceSign_;
233 
234 
235 public:
236 
237  //- No copy construct
238  fvFieldDecomposer(const fvFieldDecomposer&) = delete;
239 
240  //- No copy assignment
241  void operator=(const fvFieldDecomposer&) = delete;
242 
243 
244  // Constructors
245 
246  //- Construct without mappers, added later with reset()
248  (
249  const Foam::zero,
250  const fvMesh& procMesh,
251  const labelList& faceAddressing,
252  const labelList& cellAddressing,
253  const labelList& boundaryAddressing
254  );
255 
256  //- Construct from components using information from the complete mesh
258  (
259  const fvMesh& completeMesh,
260  const fvMesh& procMesh,
261  const labelList& faceAddressing,
262  const labelList& cellAddressing,
263  const labelList& boundaryAddressing
264  );
265 
266  //- Construct from components without the complete mesh
268  (
269  // Information about the complete mesh
270  const List<labelRange>& boundaryRanges,
271  const labelUList& faceOwner,
272  const labelUList& faceNeigbour,
273 
274  // Addressing for processor mesh
275  const fvMesh& procMesh,
276  const labelList& faceAddressing,
277  const labelList& cellAddressing,
278  const labelList& boundaryAddressing
279  );
280 
281 
282  //- Destructor
283  ~fvFieldDecomposer() = default;
284 
285 
286  // Member Functions
287 
288  //- True if no mappers have been allocated
289  bool empty() const;
290 
291  //- Remove all mappers
292  void clear();
293 
294  //- Reset mappers using information from the complete mesh
295  void reset(const fvMesh& completeMesh);
296 
297  //- Reset mapper using information about the complete mesh
298  void reset
299  (
300  const List<labelRange>& boundaryRanges,
301  const labelUList& faceOwner,
302  const labelUList& faceNeigbour
303  );
304 
305 
306  // Mapping
307 
308  //- Decompose internal field
309  template<class Type>
312  (
314  ) const;
315 
316  //- Decompose volume field
317  template<class Type>
320  (
322  const bool allowUnknownPatchFields = false
323  ) const;
324 
325  //- Decompose surface field
326  template<class Type>
329  (
331  ) const;
332 
333  //- Decompose list of fields
334  template<class GeoField>
335  void decomposeFields(const PtrList<GeoField>& fields) const;
336 };
337 
338 
339 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
340 
341 } // End namespace Foam
342 
343 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
344 
345 #ifdef NoRepository
346  #include "fvFieldDecomposerFields.C"
347 #endif
348 
349 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
350 
351 #endif
352 
353 // ************************************************************************* //
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer::size
label size() const
Definition: fvFieldDecomposer.H:135
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::hasUnmapped
bool hasUnmapped() const
Are there unmapped values.
Definition: fvFieldDecomposer.H:189
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::size
label size() const
Definition: fvFieldDecomposer.H:178
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fvFieldDecomposer::patchFieldDecomposer::size
label size() const
Definition: fvFieldDecomposer.H:81
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::processorSurfacePatchFieldDecomposer
processorSurfacePatchFieldDecomposer(const labelUList &addressingSlice)
Construct given addressing.
Definition: fvFieldDecomposer.C:113
surfaceFields.H
Foam::surfaceFields.
fvPatchFieldMapper.H
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::weights
const scalarListList & weights() const
Definition: fvFieldDecomposer.H:199
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer
Processor patch field decomposer class. Maps either owner or.
Definition: fvFieldDecomposer.H:107
Foam::fvFieldDecomposer::patchFieldDecomposer
Patch field decomposer class.
Definition: fvFieldDecomposer.H:59
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer::hasUnmapped
bool hasUnmapped() const
Are there unmapped values.
Definition: fvFieldDecomposer.H:146
Foam::fvFieldDecomposer::decomposeFields
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose list of fields.
Definition: fvFieldDecomposerFields.C:368
Foam::fvFieldDecomposer::patchFieldDecomposer::hasUnmapped
bool hasUnmapped() const
Are there unmapped values.
Definition: fvFieldDecomposer.H:92
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
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvFieldDecomposer::empty
bool empty() const
True if no mappers have been allocated.
Definition: fvFieldDecomposer.C:201
Foam::fvFieldDecomposer::fvFieldDecomposer
fvFieldDecomposer(const fvFieldDecomposer &)=delete
No copy construct.
fvFieldDecomposerFields.C
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer::directAddressing
const labelUList & directAddressing() const
Definition: fvFieldDecomposer.H:151
Foam::fvFieldDecomposer
Finite Volume volume and surface field decomposer.
Definition: fvFieldDecomposer.H:54
Foam::fvFieldDecomposer::patchFieldDecomposer::directAddressing
const labelUList & directAddressing() const
Definition: fvFieldDecomposer.H:97
Foam::fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
patchFieldDecomposer(const labelUList &addressingSlice, const label addressingOffset)
Construct given addressing.
Definition: fvFieldDecomposer.C:34
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer::processorVolPatchFieldDecomposer
processorVolPatchFieldDecomposer(const labelUList &faceOwner, const labelUList &faceNeigbour, const labelUList &addressingSlice)
Construct addressing from details.
Definition: fvFieldDecomposer.C:51
Foam::List< label >
Foam::fvFieldDecomposer::clear
void clear()
Remove all mappers.
Definition: fvFieldDecomposer.C:207
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::direct
bool direct() const
Definition: fvFieldDecomposer.H:183
Foam::UList< label >
Foam::fvFieldDecomposer::processorVolPatchFieldDecomposer::direct
bool direct() const
Definition: fvFieldDecomposer.H:140
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer
Processor patch field decomposer class. Surface field is assumed.
Definition: fvFieldDecomposer.H:160
Foam::fvFieldDecomposer::reset
void reset(const fvMesh &completeMesh)
Reset mappers using information from the complete mesh.
Definition: fvFieldDecomposer.C:292
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::fvFieldDecomposer::patchFieldDecomposer::direct
bool direct() const
Definition: fvFieldDecomposer.H:86
Foam::fvFieldDecomposer::operator=
void operator=(const fvFieldDecomposer &)=delete
No copy assignment.
Foam::fvFieldDecomposer::~fvFieldDecomposer
~fvFieldDecomposer()=default
Destructor.
Foam::fvFieldDecomposer::processorSurfacePatchFieldDecomposer::addressing
const labelListList & addressing() const
Definition: fvFieldDecomposer.H:194
fields
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
Foam::fvFieldDecomposer::decomposeField
tmp< DimensionedField< Type, volMesh > > decomposeField(const DimensionedField< Type, volMesh > &field) const
Decompose internal field.
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::zero
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:62