pointFieldDecomposer.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-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::pointFieldDecomposer
29 
30 Description
31  Point field decomposer.
32 
33 SourceFiles
34  pointFieldDecomposer.C
35  pointFieldDecomposerCache.C
36  pointFieldDecomposerTemplates.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_pointFieldDecomposer_H
41 #define Foam_pointFieldDecomposer_H
42 
43 #include "pointMesh.H"
45 #include "pointFields.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward Declarations
53 class IOobjectList;
54 
55 /*---------------------------------------------------------------------------*\
56  Class pointFieldDecomposer Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 {
61 public:
62 
63  // Public Classes
64 
65  //- Point patch field decomposer class
67  :
69  {
70  // Private data
71 
72  labelList directAddressing_;
73 
74  //- Does map contain any unmapped values
75  bool hasUnmapped_;
76 
77  public:
78 
79  // Constructors
80 
81  //- Construct given addressing
83  (
84  const pointPatch& completeMeshPatch,
85  const pointPatch& procMeshPatch,
86  const labelList& directAddr
87  );
88 
89 
90  // Member functions
91 
92  label size() const
93  {
94  return directAddressing_.size();
95  }
96 
97  bool direct() const
98  {
99  return true;
100  }
101 
102  bool hasUnmapped() const
103  {
104  return hasUnmapped_;
105  }
106 
107  const labelUList& directAddressing() const
108  {
109  return directAddressing_;
110  }
111  };
112 
113 
114 private:
115 
116  // Private Data
117 
118  //- Reference to processor mesh
119  const pointMesh& procMesh_;
120 
121  //- Reference to point addressing
122  const labelList& pointAddressing_;
123 
124  //- Reference to boundary addressing
125  const labelList& boundaryAddressing_;
126 
127  //- List of patch field decomposers
128  PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
129 
130 
131  // Private Member Functions
132 
133  //- No copy construct
135 
136  //- No copy assignment
137  void operator=(const pointFieldDecomposer&) = delete;
138 
139 public:
140 
141  // Public Classes
142  class fieldsCache;
143 
144 
145  // Constructors
146 
147  //- Construct without mappers, added later with reset()
149  (
150  const Foam::zero,
151  const pointMesh& procMesh,
152  const labelList& pointAddressing,
153  const labelList& boundaryAddressing
154  );
155 
156  //- Construct from components
158  (
159  const pointMesh& completeMesh,
160  const pointMesh& procMesh,
161  const labelList& pointAddressing,
162  const labelList& boundaryAddressing
163  );
164 
165 
166  //- Destructor
167  ~pointFieldDecomposer() = default;
168 
169 
170  // Member Functions
171 
172  //- True if no mappers have been allocated
173  bool empty() const;
174 
175  //- Remove all mappers
176  void clear();
177 
178  //- Reset mappers using information from the complete mesh
179  void reset(const pointMesh& completeMesh);
180 
181 
182  // Mapping
183 
184  //- Decompose point field
185  template<class Type>
188  (
190  ) const;
191 
192  //- Decompose list of fields
193  template<class GeoField>
194  void decomposeFields(const PtrList<GeoField>& fields) const;
195 };
196 
197 
198 /*---------------------------------------------------------------------------*\
199  Class pointFieldDecomposer::fieldsCache Declaration
200 \*---------------------------------------------------------------------------*/
201 
202 class pointFieldDecomposer::fieldsCache
203 {
204  // Private Data
205 
206  class privateCache;
207 
208  //- All field and field-field types for lagrangian
209  std::unique_ptr<privateCache> cache_;
210 
211 
212  // Private Member Functions
213 
214  //- No copy construct
215  fieldsCache(const fieldsCache&) = delete;
216 
217  //- No copy assignment
218  void operator=(const fieldsCache&) = delete;
219 
220 
221 public:
222 
223  // Constructors
224 
225  //- Default construct
226  fieldsCache();
227 
228 
229  //- Destructor
230  ~fieldsCache();
232 
233  // Member Functions
234 
235  //- No fields
236  bool empty() const;
237 
238  //- Total number of fields
239  label size() const;
240 
241  //- Clear out
242  void clear();
243 
244 
245  //- Read all fields given mesh and objects
246  void readAllFields
247  (
248  const pointMesh& mesh,
249  const IOobjectList& objects
250  );
251 
252  //- Decompose and write all fields
253  void decomposeAllFields
254  (
255  const pointFieldDecomposer& decomposer,
256  bool report = false
257  ) const;
258 };
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace Foam
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #ifdef NoRepository
269 #endif
270 
271 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
272 
273 #endif
274 
275 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
bool empty() const
True if no mappers have been allocated.
const labelUList & directAddressing() const
Return the direct addressing values.
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
void reset(const pointMesh &completeMesh)
Reset mappers using information from the complete mesh.
bool direct() const
Is it a direct (non-interpolating) mapper?
void clear()
Remove all mappers.
void readAllFields(const pointMesh &mesh, const IOobjectList &objects)
Read all fields given mesh and objects.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:45
dynamicFvMesh & mesh
~pointFieldDecomposer()=default
Destructor.
tmp< GeometricField< Type, pointPatchField, pointMesh > > decomposeField(const GeometricField< Type, pointPatchField, pointMesh > &) const
Decompose point field.
Point field decomposer.
label size() const
The size of the mapper.
void decomposeAllFields(const pointFieldDecomposer &decomposer, bool report=false) const
Decompose and write all fields.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:61
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
patchFieldDecomposer(const pointPatch &completeMeshPatch, const pointPatch &procMeshPatch, const labelList &directAddr)
Construct given addressing.
label size() const
Total number of fields.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Foam::pointPatchFieldMapperPatchRef.
Namespace for OpenFOAM.
void decomposeFields(const PtrList< GeoField > &fields) const
Decompose list of fields.