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-2025 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.cxx
35  pointFieldDecomposer.txx
36  pointFieldDecomposerCache.cxx
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_pointFieldDecomposer_H
41 #define Foam_pointFieldDecomposer_H
42 
43 #include "pointMesh.H"
44 #include "pointFields.H"
45 #include "pointPatchFieldMapper.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  //- Internal caching for field reading
66  class fieldsCache;
67 
68  //- Point patch field decomposer class
70  :
72  {
73  // Private Data
74 
75  labelList directAddressing_;
76 
77  //- Does map contain any unmapped values
78  bool hasUnmapped_;
79 
80  public:
81 
82  // Constructors
83 
84  //- Construct given addressing
86  (
87  const pointPatch& completeMeshPatch,
88  const pointPatch& procMeshPatch,
89  const labelUList& directAddr
90  );
91 
92 
93  // Member Functions
94 
95  label size() const noexcept
96  {
97  return directAddressing_.size();
98  }
99 
100  bool direct() const noexcept
101  {
102  return true;
103  }
104 
105  bool hasUnmapped() const noexcept
106  {
107  return hasUnmapped_;
108  }
109 
110  const labelUList& directAddressing() const noexcept
111  {
112  return directAddressing_;
113  }
114  };
115 
116 
117 private:
118 
119  // Private Data
120 
121  //- Reference to processor mesh
122  const pointMesh& procMesh_;
123 
124  //- Reference to point addressing
125  const labelUList& pointAddressing_;
126 
127  //- Reference to boundary addressing
128  const labelUList& boundaryAddressing_;
129 
130  //- List of patch field decomposers
131  PtrList<patchFieldDecomposer> patchFieldDecomposerPtrs_;
132 
133 
134 public:
135 
136  //- No copy construct
138 
139  //- No copy assignment
140  void operator=(const pointFieldDecomposer&) = delete;
141 
142 
143  // Constructors
144 
145  //- Construct without mappers, added later with reset()
147  (
148  Foam::zero,
149  const pointMesh& procMesh,
150  const labelUList& pointAddressing,
151  const labelUList& boundaryAddressing
152  );
153 
154  //- Construct from components
156  (
157  const pointMesh& completeMesh,
158  const pointMesh& procMesh,
159  const labelUList& pointAddressing,
160  const labelUList& boundaryAddressing
161  );
162 
163 
164  //- Destructor
165  ~pointFieldDecomposer() = default;
166 
167 
168  // Member Functions
169 
170  //- True if no mappers have been allocated
171  bool empty() const noexcept;
172 
173  //- Remove all mappers
174  void clear();
175 
176  //- Reset mappers using information from the complete mesh
177  void reset(const pointMesh& completeMesh);
178 
179 
180  // Mapping
181 
182  //- Decompose point field
183  template<class Type>
186  (
188  ) const;
189 
190  //- Decompose list of fields
191  template<class GeoField>
192  void decomposeFields(const UPtrList<GeoField>& fields) const;
193 };
194 
195 
196 /*---------------------------------------------------------------------------*\
197  Class pointFieldDecomposer::fieldsCache Declaration
198 \*---------------------------------------------------------------------------*/
199 
200 class pointFieldDecomposer::fieldsCache
201 {
202  class privateCache;
203  std::unique_ptr<privateCache> cache_;
204 
205  //- No copy construct
206  fieldsCache(const fieldsCache&) = delete;
207 
208  //- No copy assignment
209  void operator=(const fieldsCache&) = delete;
210 
211 
212 public:
213 
214  // Constructors
215 
216  //- Default construct
217  fieldsCache();
218 
219 
220  //- Destructor
221  ~fieldsCache();
222 
223 
224  // Member Functions
225 
226  //- No fields
227  bool empty() const noexcept;
228 
229  //- Total number of fields
230  label size() const noexcept;
232  //- Clear out
233  void clear();
234 
235 
236  //- Read all fields given mesh and objects
237  void readAllFields
238  (
239  const pointMesh& mesh,
240  const IOobjectList& objects
241  );
242 
243  //- Decompose and write all fields
244  void decomposeAllFields
245  (
246  const pointFieldDecomposer& decomposer,
247  bool report = false
248  ) const;
249 };
250 
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #ifdef NoRepository
259  #include "pointFieldDecomposer.txx"
260 #endif
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:119
void decomposeFields(const UPtrList< GeoField > &fields) const
Decompose list of fields.
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
pointFieldDecomposer(const pointFieldDecomposer &)=delete
No copy construct.
Foam::pointPatchFieldMapper.
void reset(const pointMesh &completeMesh)
Reset mappers using information from the complete mesh.
Generic GeometricField class.
patchFieldDecomposer(const pointPatch &completeMeshPatch, const pointPatch &procMeshPatch, const labelUList &directAddr)
Construct given addressing.
void clear()
Remove all mappers.
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97
Mesh representing a set of points created from polyMesh.
Definition: pointMesh.H:45
Abstract base class for point-mesh patch fields.
dynamicFvMesh & mesh
~pointFieldDecomposer()=default
Destructor.
tmp< GeometricField< Type, pointPatchField, pointMesh > > decomposeField(const GeometricField< Type, pointPatchField, pointMesh > &) const
Decompose point field.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
const direction noexcept
Definition: scalarImpl.H:265
Point field decomposer.
void operator=(const pointFieldDecomposer &)=delete
No copy assignment.
const labelUList & directAddressing() const noexcept
Return the direct addressing values.
bool direct() const noexcept
Is it a direct (non-interpolating) mapper?
decomposeUsingBbs false
Use bounding boxes (default) or unique decomposition of triangles (i.e. do not duplicate triangles) ...
bool empty() const noexcept
True if no mappers have been allocated.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: PtrList.H:56
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
label size() const noexcept
The size of the mapper.
bool hasUnmapped() const noexcept
Any unmapped values?
Namespace for OpenFOAM.