PointEdgeWave.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) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::PointEdgeWave
29
30Description
31 Wave propagation of information through grid. Every iteration
32 information goes through one layer of edges.
33
34 Templated on information that is transferred.
35
36 Handles parallel and cyclics. Only parallel reasonably tested. Cyclics
37 hardly tested.
38
39 Note: whether to propagate depends on the return value of Type::update
40 which returns true (i.e. propagate) if the value changes by more than a
41 certain tolerance.
42
43 Note: parallel is done in two steps:
44 -# transfer patch points in offset notation, i.e. every patch
45 point is denoted by a patchface label and an index in this face.
46 Receiving end uses that fact that f[0] is shared and order is
47 reversed.
48 -# do all non-local shared points by means of reduce of data on them.
49
50 Note: cyclics is with offset in patchface as well. Patch is divided into
51 two sub patches and the point-point addressing is never explicitly
52 calculated but instead use is made of the face-face correspondence.
53 (it probably is more efficient to calculate a point-point
54 correspondence at the start and then reuse this; task to be done)
55
56SourceFiles
57 PointEdgeWave.C
58
59\*---------------------------------------------------------------------------*/
60
61#ifndef PointEdgeWave_H
62#define PointEdgeWave_H
63
64#include "bitSet.H"
65#include "scalarField.H"
66#include "tensorField.H"
67
68// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69
70namespace Foam
71{
72
73// Forward Declarations
74class polyMesh;
75class polyPatch;
76
77/*---------------------------------------------------------------------------*\
78 Class PointEdgeWaveName Declaration
79\*---------------------------------------------------------------------------*/
82
83
84/*---------------------------------------------------------------------------*\
85 Class PointEdgeWave Declaration
86\*---------------------------------------------------------------------------*/
87
88template<class Type, class TrackingData = int>
89class PointEdgeWave
90:
91 public PointEdgeWaveName
92{
93 // Private Static Data
94
95 //- Relative tolerance. Stop propagation if relative changes
96 // less than this tolerance (responsibility for checking this is
97 // up to Type implementation)
98 static scalar propagationTol_;
99
100 //- Default trackdata value to satisfy default template argument.
101 static int dummyTrackData_;
102
103
104 // Private Data
105
106 //- Reference to mesh
107 const polyMesh& mesh_;
108
109 //- Wall information for all points
110 UList<Type>& allPointInfo_;
111
112 //- Information on all mesh edges
113 UList<Type>& allEdgeInfo_;
114
115 //- Additional data to be passed into container
116 TrackingData& td_;
117
118 //- Has point changed
119 bitSet changedPoint_;
120
121 //- List of changed points
122 labelList changedPoints_;
123
124 //- Number of changed points
125 label nChangedPoints_;
126
127 //- Edges that have changed
128 bitSet changedEdge_;
129
130 labelList changedEdges_;
131 label nChangedEdges_;
132
133 //- Number of cyclic patches
134 label nCyclicPatches_;
135
136 //- Number of evaluations
137 label nEvals_;
138
139 //- Number of unvisited edges/points
140 label nUnvisitedPoints_;
141 label nUnvisitedEdges_;
142
143
144 // Private Member Functions
145
146 //- Adapt pointInfo for leaving domain
147 void leaveDomain
148 (
149 const polyPatch&,
150 const List<label>& patchPointLabels,
151 List<Type>& pointInfo
152 ) const;
153
154 //- Adapt pointInfo for entering domain
155 void enterDomain
156 (
157 const polyPatch&,
158 const List<label>& patchPointLabels,
159 List<Type>& pointInfo
160 ) const;
161
162 //- Transform. Implementation referred to Type
163 void transform
164 (
165 const polyPatch& patch,
166 const tensorField& rotTensor,
167 List<Type>& pointInfo
168 ) const;
169
170 //- Updates pointInfo with information from neighbour.
171 // Updates all statistics.
172 bool updatePoint
173 (
174 const label pointi,
175 const label neighbourEdgeI,
176 const Type& neighbourInfo,
177 Type& pointInfo
178 );
179
180 //- Updates pointInfo with information from same point.
181 // Updates all statistics.
182 bool updatePoint
183 (
184 const label pointi,
185 const Type& neighbourInfo,
186 Type& pointInfo
187 );
188
189 //- Updates edgeInfo with information from neighbour.
190 // Updates all statistics.
191 bool updateEdge
192 (
193 const label edgeI,
194 const label neighbourPointi,
195 const Type& neighbourInfo,
196 Type& edgeInfo
197 );
198
199
200 // Parallel, cyclic
201
202 //- Has patches of certain type?
203 template<class PatchType>
204 label countPatchType() const;
205
206 //- Merge data from across processor boundaries
207 void handleProcPatches();
208
209 //- Merge data from across cyclic boundaries
210 void handleCyclicPatches();
211
212 //- Explicitly sync all collocated points
213 label handleCollocatedPoints();
214
215
216 //- No copy construct
217 PointEdgeWave(const PointEdgeWave&) = delete;
218
219 //- No copy assignment
220 void operator=(const PointEdgeWave&) = delete;
221
222
223public:
224
225 // Static Functions
226
227 //- Access to tolerance
228 static scalar propagationTol()
229 {
230 return propagationTol_;
231 }
232
233 //- Change tolerance
234 static void setPropagationTol(const scalar tol)
235 {
236 propagationTol_ = tol;
237 }
238
239
240 // Constructors
241
242 //- Construct from mesh, list of changed points with the Type
243 // for these points. Gets work arrays to operate on, one of size
244 // number of mesh points, the other number of mesh edges.
245 // Iterates until nothing changes or maxIter reached.
246 // (maxIter can be 0)
248 (
249 const polyMesh& mesh,
250 const labelList& initialPoints,
251 const List<Type>& initialPointsInfo,
254 const label maxIter,
255 TrackingData& td = dummyTrackData_
256 );
257
258 //- Construct from mesh. Use setPointInfo and iterate() to do
259 // actual calculation
261 (
262 const polyMesh& mesh,
265 TrackingData& td = dummyTrackData_
266 );
267
268
269 //- Destructor
270 ~PointEdgeWave() = default;
271
272
273 // Member Functions
274
275 //- Access allPointInfo
277 {
278 return allPointInfo_;
279 }
280
281 //- Access allEdgeInfo
282 UList<Type>& allEdgeInfo() const
283 {
284 return allEdgeInfo_;
285 }
286
287 //- Additional data to be passed into container
288 const TrackingData& data() const
289 {
290 return td_;
291 }
292
293 //- Number of unvisited edges, i.e. edges that were not (yet)
294 // reached from walking across mesh. This can happen from
295 // - not enough iterations done
296 // - a disconnected mesh
297 // - a mesh without walls in it
298 label nUnvisitedEdges() const;
299
300 label nUnvisitedPoints() const;
301
302 //- Copy initial data into allPointInfo_
303 void setPointInfo
304 (
305 const labelList& changedPoints,
306 const List<Type>& changedPointsInfo
307 );
308
309 //- Propagate from point to edge. Returns total number of edges
310 // (over all processors) changed.
311 label pointToEdge();
312
313 //- Propagate from edge to point. Returns total number of points
314 // (over all processors) changed.
315 label edgeToPoint();
316
317 //- Iterate until no changes or maxIter reached. Returns actual
318 // number of iterations.
319 label iterate(const label maxIter);
320};
321
322
323// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
324
325/*---------------------------------------------------------------------------*\
326 Class listUpdateOp Declaration
327\*---------------------------------------------------------------------------*/
328
329//- List update operation
330template<class Type, class TrackingData = int>
331class listUpdateOp
332{
333 //- Additional data to be passed into container
334
335 const scalar tol_;
336
337 TrackingData& td_;
338
339public:
341 listUpdateOp(const scalar tol, TrackingData& td)
342 :
343 tol_(tol),
344 td_(td)
345 {}
347 void operator()(List<Type>& x, const List<Type>& y) const
348 {
349 forAll(x, i)
350 {
351 if (y[i].valid(td_))
352 {
353 x[i].updatePoint(y[i], tol_, td_);
354 }
355 }
356 }
357};
358
359} // End namespace Foam
360
361
362// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
363
364#ifdef NoRepository
365 #include "PointEdgeWave.C"
366#endif
367
368// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
369
370#endif
371
372// ************************************************************************* //
scalar y
Wave propagation of information through grid. Every iteration information goes through one layer of e...
Definition: PointEdgeWave.H:91
label nUnvisitedEdges() const
Number of unvisited edges, i.e. edges that were not (yet)
void setPointInfo(const labelList &changedPoints, const List< Type > &changedPointsInfo)
Copy initial data into allPointInfo_.
static scalar propagationTol()
Access to tolerance.
~PointEdgeWave()=default
Destructor.
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
UList< Type > & allEdgeInfo() const
Access allEdgeInfo.
label pointToEdge()
Propagate from point to edge. Returns total number of edges.
label edgeToPoint()
Propagate from edge to point. Returns total number of points.
const TrackingData & data() const
Additional data to be passed into container.
static void setPropagationTol(const scalar tol)
Change tolerance.
label nUnvisitedPoints() const
UList< Type > & allPointInfo() const
Access allPointInfo.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
List update operation.
listUpdateOp(const scalar tol, TrackingData &td)
void operator()(List< Type > &x, const List< Type > &y) const
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
#define TemplateName(TemplateNameString)
Add typeName information from argument TypeNameString to a.
Definition: className.H:79
dynamicFvMesh & mesh
Namespace for OpenFOAM.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333