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 | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::PointEdgeWave
26 
27 Description
28  Wave propagation of information through grid. Every iteration
29  information goes through one layer of edges.
30 
31  Templated on information that is transferred.
32 
33  Handles parallel and cyclics. Only parallel reasonably tested. Cyclics
34  hardly tested.
35 
36  Note: whether to propagate depends on the return value of Type::update
37  which returns true (i.e. propagate) if the value changes by more than a
38  certain tolerance.
39 
40  Note: parallel is done in two steps:
41  -# transfer patch points in offset notation, i.e. every patch
42  point is denoted by a patchface label and an index in this face.
43  Receiving end uses that fact that f[0] is shared and order is
44  reversed.
45  -# do all non-local shared points by means of reduce of data on them.
46 
47  Note: cyclics is with offset in patchface as well. Patch is divided into
48  two sub patches and the point-point addressing is never explicitly
49  calculated but instead use is made of the face-face correspondence.
50  (it probably is more efficient to calculate a point-point
51  correspondence at the start and then reuse this; task to be done)
52 
53 SourceFiles
54  PointEdgeWave.C
55 
56 \*---------------------------------------------------------------------------*/
57 
58 #ifndef PointEdgeWave_H
59 #define PointEdgeWave_H
60 
61 #include "boolList.H"
62 #include "scalarField.H"
63 #include "tensorField.H"
64 
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
66 
67 namespace Foam
68 {
69 
70 // Forward declaration of classes
71 class polyMesh;
72 class polyPatch;
73 
74 /*---------------------------------------------------------------------------*\
75  Class PointEdgeWaveName Declaration
76 \*---------------------------------------------------------------------------*/
77 
78 TemplateName(PointEdgeWave);
79 
80 
81 /*---------------------------------------------------------------------------*\
82  Class PointEdgeWave Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 template<class Type, class TrackingData = int>
86 class PointEdgeWave
87 :
88  public PointEdgeWaveName
89 {
90  // Private static data
91 
92  //- Relative tolerance. Stop propagation if relative changes
93  // less than this tolerance (responsability for checking this is
94  // up to Type implementation)
95  static scalar propagationTol_;
96 
97  //- Used as default trackdata value to satisfy default template
98  // argument.
99  static int dummyTrackData_;
100 
101 
102  // Private data
103 
104  //- Reference to mesh
105  const polyMesh& mesh_;
106 
107  //- Wall information for all points
109 
110  //- Information on all mesh edges
112 
113  //- Additional data to be passed into container
114  TrackingData& td_;
115 
116  //- Has point changed
118 
119  //- List of changed points
121 
122  //- Number of changed points
124 
125  //- Edges that have changed
129 
130  //- Number of cyclic patches
132 
133  //- Number of evaluations
134  label nEvals_;
135 
136  //- Number of unvisited edges/points
139 
140 
141  // Private Member Functions
142 
143  //- Adapt pointInfo for leaving domain
144  void leaveDomain
145  (
146  const polyPatch&,
147  const List<label>& patchPointLabels,
148  List<Type>& pointInfo
149  ) const;
150 
151  //- Adapt pointInfo for entering domain
152  void enterDomain
153  (
154  const polyPatch&,
155  const List<label>& patchPointLabels,
156  List<Type>& pointInfo
157  ) const;
158 
159  //- Transform. Implementation referred to Type
160  void transform
161  (
162  const polyPatch& patch,
163  const tensorField& rotTensor,
164  List<Type>& pointInfo
165  ) const;
166 
167  //- Updates pointInfo with information from neighbour. Updates all
168  // statistics.
169  bool updatePoint
170  (
171  const label pointI,
172  const label neighbourEdgeI,
173  const Type& neighbourInfo,
174  Type& pointInfo
175  );
176 
177  //- Updates pointInfo with information from same point. Updates all
178  // statistics.
179  bool updatePoint
180  (
181  const label pointI,
182  const Type& neighbourInfo,
183  Type& pointInfo
184  );
185 
186  //- Updates edgeInfo with information from neighbour. Updates all
187  // statistics.
188  bool updateEdge
189  (
190  const label edgeI,
191  const label neighbourPointI,
192  const Type& neighbourInfo,
193  Type& edgeInfo
194  );
195 
196  // Parallel, cyclic
197 
198  //- Has patches of certain type?
199  template<class PatchType>
200  label countPatchType() const;
201 
202  //- Merge data from across processor boundaries
203  void handleProcPatches();
204 
205  //- Merge data from across cyclic boundaries
206  void handleCyclicPatches();
207 
208  //- Explicitly sync all collocated points
210 
211 
212  //- Disallow default bitwise copy construct
214 
215  //- Disallow default bitwise assignment
216  void operator=(const PointEdgeWave&);
217 
218 
219 public:
220 
221  // Static Functions
222 
223  //- Access to tolerance
224  static scalar propagationTol()
225  {
226  return propagationTol_;
227  }
228 
229  //- Change tolerance
230  static void setPropagationTol(const scalar tol)
231  {
232  propagationTol_ = tol;
233  }
234 
235 
236  // Constructors
237 
238  //- Construct from mesh, list of changed points with the Type
239  // for these points. Gets work arrays to operate on, one of size
240  // number of mesh points, the other number of mesh edges.
241  // Iterates until nothing changes or maxIter reached.
242  // (maxIter can be 0)
244  (
245  const polyMesh& mesh,
246  const labelList& initialPoints,
247  const List<Type>& initialPointsInfo,
250  const label maxIter,
251  TrackingData& td = dummyTrackData_
252  );
253 
254  //- Construct from mesh. Use setPointInfo and iterate() to do
255  // actual calculation
257  (
258  const polyMesh& mesh,
261  TrackingData& td = dummyTrackData_
262  );
263 
264 
265  //- Destructor
266  ~PointEdgeWave();
267 
268 
269  // Member Functions
270 
271  //- Access allPointInfo
272  UList<Type>& allPointInfo() const
273  {
274  return allPointInfo_;
275  }
276 
277  //- Access allEdgeInfo
278  UList<Type>& allEdgeInfo() const
279  {
280  return allEdgeInfo_;
281  }
282 
283  //- Additional data to be passed into container
284  const TrackingData& data() const
285  {
286  return td_;
287  }
288 
289  //- Get number of unvisited edges, i.e. edges that were not (yet)
290  // reached from walking across mesh. This can happen from
291  // - not enough iterations done
292  // - a disconnected mesh
293  // - a mesh without walls in it
294  label getUnsetEdges() const;
295 
296  label getUnsetPoints() const;
297 
298  //- Copy initial data into allPointInfo_
299  void setPointInfo
300  (
301  const labelList& changedPoints,
302  const List<Type>& changedPointsInfo
303  );
304 
305  //- Propagate from point to edge. Returns total number of edges
306  // (over all processors) changed.
307  label pointToEdge();
308 
309  //- Propagate from edge to point. Returns total number of points
310  // (over all processors) changed.
311  label edgeToPoint();
312 
313  //- Iterate until no changes or maxIter reached. Returns actual
314  // number of iterations.
315  label iterate(const label maxIter);
316 };
317 
318 
319 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
320 
321 /*---------------------------------------------------------------------------*\
322  Class listUpdateOp Declaration
323 \*---------------------------------------------------------------------------*/
324 
325 //- List update operation
326 template<class Type, class TrackingData = int>
327 class listUpdateOp
328 {
329  //- Additional data to be passed into container
330 
331  const scalar tol_;
332 
333  TrackingData& td_;
334 
335 public:
336  listUpdateOp(const scalar tol, TrackingData& td)
337  :
338  tol_(tol),
339  td_(td)
340  {}
341 
342  void operator()(List<Type>& x, const List<Type>& y) const
343  {
344  forAll(x, i)
345  {
346  if (y[i].valid(td_))
347  {
348  x[i].updatePoint(y[i], tol_, td_);
349  }
350  }
351  }
352 };
353 
354 } // End namespace Foam
355 
356 
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
358 
359 #ifdef NoRepository
360 # include "PointEdgeWave.C"
361 #endif
362 
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 
365 #endif
366 
367 // ************************************************************************* //
Foam::PointEdgeWave::getUnsetEdges
label getUnsetEdges() const
Get number of unvisited edges, i.e. edges that were not (yet)
Definition: PointEdgeWave.C:724
Foam::PointEdgeWave::td_
TrackingData & td_
Additional data to be passed into container.
Definition: PointEdgeWave.H:113
boolList.H
Foam::PointEdgeWave::pointToEdge
label pointToEdge()
Propagate from point to edge. Returns total number of edges.
Definition: PointEdgeWave.C:845
Foam::PointEdgeWave::changedPoints_
labelList changedPoints_
List of changed points.
Definition: PointEdgeWave.H:119
Foam::PointEdgeWave::setPointInfo
void setPointInfo(const labelList &changedPoints, const List< Type > &changedPointsInfo)
Copy initial data into allPointInfo_.
Definition: PointEdgeWave.C:733
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::PointEdgeWave::countPatchType
label countPatchType() const
Has patches of certain type?
Foam::PointEdgeWave::mesh_
const polyMesh & mesh_
Reference to mesh.
Definition: PointEdgeWave.H:104
scalarField.H
Foam::PointEdgeWave::changedEdge_
boolList changedEdge_
Edges that have changed.
Definition: PointEdgeWave.H:125
Foam::listUpdateOp::listUpdateOp
listUpdateOp(const scalar tol, TrackingData &td)
Definition: PointEdgeWave.H:335
Foam::PointEdgeWave
Wave propagation of information through grid. Every iteration information goes through one layer of e...
Definition: PointEdgeWave.H:85
Foam::PointEdgeWave::propagationTol
static scalar propagationTol()
Access to tolerance.
Definition: PointEdgeWave.H:223
Foam::PointEdgeWave::nChangedEdges_
label nChangedEdges_
Definition: PointEdgeWave.H:127
Foam::PointEdgeWave::allPointInfo
UList< Type > & allPointInfo() const
Access allPointInfo.
Definition: PointEdgeWave.H:271
Foam::PointEdgeWave::transform
void transform(const polyPatch &patch, const tensorField &rotTensor, List< Type > &pointInfo) const
Transform. Implementation referred to Type.
Definition: PointEdgeWave.C:120
Foam::PointEdgeWave::nUnvisitedEdges_
label nUnvisitedEdges_
Definition: PointEdgeWave.H:137
Foam::listUpdateOp
List update operation.
Definition: PointEdgeWave.H:326
Foam::PointEdgeWave::edgeToPoint
label edgeToPoint()
Propagate from edge to point. Returns total number of points.
Definition: PointEdgeWave.C:769
Foam::PointEdgeWave::propagationTol_
static scalar propagationTol_
Relative tolerance. Stop propagation if relative changes.
Definition: PointEdgeWave.H:94
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::listUpdateOp::td_
TrackingData & td_
Definition: PointEdgeWave.H:332
Foam::PointEdgeWave::changedPoint_
boolList changedPoint_
Has point changed.
Definition: PointEdgeWave.H:116
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::PointEdgeWave::iterate
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
Definition: PointEdgeWave.C:914
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
Foam::PointEdgeWave::handleCyclicPatches
void handleCyclicPatches()
Merge data from across cyclic boundaries.
Definition: PointEdgeWave.C:423
Foam::TemplateName
TemplateName(blendedSchemeBase)
Foam::PointEdgeWave::nChangedPoints_
label nChangedPoints_
Number of changed points.
Definition: PointEdgeWave.H:122
PointEdgeWave.C
Foam::PointEdgeWave::dummyTrackData_
static int dummyTrackData_
Used as default trackdata value to satisfy default template.
Definition: PointEdgeWave.H:98
Foam::PointEdgeWave::~PointEdgeWave
~PointEdgeWave()
Destructor.
Definition: PointEdgeWave.C:709
Foam::PointEdgeWave::getUnsetPoints
label getUnsetPoints() const
Definition: PointEdgeWave.C:717
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::PointEdgeWave::data
const TrackingData & data() const
Additional data to be passed into container.
Definition: PointEdgeWave.H:283
Foam::PointEdgeWave::operator=
void operator=(const PointEdgeWave &)
Disallow default bitwise assignment.
Foam::PointEdgeWave::PointEdgeWave
PointEdgeWave(const PointEdgeWave &)
Disallow default bitwise copy construct.
Foam::PointEdgeWave::leaveDomain
void leaveDomain(const polyPatch &, const List< label > &patchPointLabels, List< Type > &pointInfo) const
Adapt pointInfo for leaving domain.
Definition: PointEdgeWave.C:76
tensorField.H
Foam::PointEdgeWave::allPointInfo_
UList< Type > & allPointInfo_
Wall information for all points.
Definition: PointEdgeWave.H:107
Foam::PointEdgeWave::nEvals_
label nEvals_
Number of evaluations.
Definition: PointEdgeWave.H:133
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::UList< Type >
Foam::PointEdgeWave::changedEdges_
labelList changedEdges_
Definition: PointEdgeWave.H:126
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::PointEdgeWave::allEdgeInfo
UList< Type > & allEdgeInfo() const
Access allEdgeInfo.
Definition: PointEdgeWave.H:277
Foam::PointEdgeWave::allEdgeInfo_
UList< Type > & allEdgeInfo_
Information on all mesh edges.
Definition: PointEdgeWave.H:110
Foam::PointEdgeWave::handleProcPatches
void handleProcPatches()
Merge data from across processor boundaries.
Definition: PointEdgeWave.C:310
Foam::listUpdateOp::operator()
void operator()(List< Type > &x, const List< Type > &y) const
Definition: PointEdgeWave.H:341
Foam::PointEdgeWave::updatePoint
bool updatePoint(const label pointI, const label neighbourEdgeI, const Type &neighbourInfo, Type &pointInfo)
Updates pointInfo with information from neighbour. Updates all.
Definition: PointEdgeWave.C:158
Foam::PointEdgeWave::updateEdge
bool updateEdge(const label edgeI, const label neighbourPointI, const Type &neighbourInfo, Type &edgeInfo)
Updates edgeInfo with information from neighbour. Updates all.
Definition: PointEdgeWave.C:250
Foam::PointEdgeWave::enterDomain
void enterDomain(const polyPatch &, const List< label > &patchPointLabels, List< Type > &pointInfo) const
Adapt pointInfo for entering domain.
Definition: PointEdgeWave.C:98
Foam::PointEdgeWave::setPropagationTol
static void setPropagationTol(const scalar tol)
Change tolerance.
Definition: PointEdgeWave.H:229
Foam::listUpdateOp::tol_
const scalar tol_
Additional data to be passed into container.
Definition: PointEdgeWave.H:330
Foam::PointEdgeWave::handleCollocatedPoints
label handleCollocatedPoints()
Explicitly sync all collocated points.
Definition: PointEdgeWave.C:514
Foam::PointEdgeWave::nUnvisitedPoints_
label nUnvisitedPoints_
Number of unvisited edges/points.
Definition: PointEdgeWave.H:136
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::PointEdgeWave::nCyclicPatches_
label nCyclicPatches_
Number of cyclic patches.
Definition: PointEdgeWave.H:130