1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Wave propagation of information through grid. Every iteration
30 information goes through one layer of edges. Templated on information
33 Templated on information that is transferred.
34 Handles parallel and cyclics. Only parallel reasonably tested. Cyclics
37 Note: whether to propagate depends on the return value of Type::update
38 which returns true (i.e. propagate) if the value changes by more than a
41 Note: parallel is done in two steps:
42 -# transfer patch points in offset notation, i.e. every patch
43 point is denoted by a patchface label and an index in this face.
44 Receiving end uses that fact that f[0] is shared and order is
46 -# do all non-local shared points by means of reduce of data on them.
48 Note: cyclics is with offset in patchface as well. Patch is divided into
49 two sub patches and the point-point addressing is never explicitly
50 calculated but instead use is made of the face-face correspondence.
51 (it probably is more efficient to calculate a point-point
52 correspondence at the start and then reuse this; task to be done)
57 \*---------------------------------------------------------------------------*/
59 #ifndef PointEdgeWave_H
60 #define PointEdgeWave_H
64 #include "scalarField.H"
65 #include "pointFields.H"
67 #include "primitivePatch.H"
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 // Forward declaration of classes
79 /*---------------------------------------------------------------------------*\
80 Class PointEdgeWaveName Declaration
81 \*---------------------------------------------------------------------------*/
83 TemplateName(PointEdgeWave);
86 /*---------------------------------------------------------------------------*\
87 Class PointEdgeWave Declaration
88 \*---------------------------------------------------------------------------*/
93 public PointEdgeWaveName
95 // Private static data
97 //- Relative tolerance. Stop propagation if relative changes
98 // less than this tolerance (responsability for checking this is
99 // up to Type implementation)
100 static scalar propagationTol_;
105 //- Reference to mesh
106 const polyMesh& mesh_;
108 //- Wall information for all points
109 List<Type>& allPointInfo_;
111 //- Information on all mesh edges
112 List<Type>& allEdgeInfo_;
114 //- Has point changed
115 boolList changedPoint_;
117 //- List of changed points
118 labelList changedPoints_;
120 //- Number of changed points
121 label nChangedPoints_;
123 //- Edges that have changed
124 boolList changedEdge_;
125 labelList changedEdges_;
126 label nChangedEdges_;
128 //- Number of cyclic patches
129 bool nCyclicPatches_;
131 //- For every cyclic patch two primitivePatches
132 PtrList<primitivePatch> cycHalves_;
134 //- Number of evaluations
137 //- Number of unvisited edges/points
138 label nUnvisitedPoints_;
139 label nUnvisitedEdges_;
142 // Private Member Functions
144 //- Add value to all elements of labelList
145 static void offset(const label val, labelList& elems);
148 //- Adapt pointInfo for leaving domain
151 const polyPatch& meshPatch,
152 const primitivePatch& patch,
153 const List<label>& patchPointLabels,
154 List<Type>& pointInfo
157 //- Adapt pointInfo for entering domain
160 const polyPatch& meshPatch,
161 const primitivePatch& patch,
162 const List<label>& patchPointLabels,
163 List<Type>& pointInfo
166 //- Transform. Implementation referred to Type
169 const tensorField& rotTensor,
170 List<Type>& pointInfo
173 //- Updates pointInfo with information from neighbour. Updates all
178 const label neighbourEdgeI,
179 const Type& neighbourInfo,
184 //- Updates pointInfo with information from same point. Updates all
189 const Type& neighbourInfo,
194 //- Updates edgeInfo with information from neighbour. Updates all
199 const label neighbourPointI,
200 const Type& neighbourInfo,
207 //- Has patches of certain type?
208 template <class PatchType>
209 label countPatchType() const;
211 //- Get info on patch points
212 void getChangedPatchPoints
214 const primitivePatch& patch,
215 DynamicList<Type>& patchInfo,
216 DynamicList<label>& patchPoints,
217 DynamicList<label>& owner,
218 DynamicList<label>& ownerIndex
221 //- Merge data from patch into overall data
222 void updateFromPatchInfo
224 const polyPatch& meshPatch,
225 const primitivePatch& patch,
226 const labelList& owner,
227 const labelList& ownerIndex,
228 List<Type>& patchInfo
231 //- Merge data from across processor boundaries
232 void handleProcPatches();
234 //- Calculate cyclic halves addressing.
235 void calcCyclicAddressing();
237 //- Merge data from across cyclic boundaries
238 void handleCyclicPatches();
241 //- Disallow default bitwise copy construct
242 PointEdgeWave(const PointEdgeWave&);
244 //- Disallow default bitwise assignment
245 void operator=(const PointEdgeWave&);
251 //- Access to tolerance
252 static scalar propagationTol()
254 return propagationTol_;
258 static void setPropagationTol(const scalar tol)
260 propagationTol_ = tol;
267 //- Construct from mesh, list of changed points with the Type
268 // for these points. Gets work arrays to operate on, one of size
269 // number of mesh points, the other number of mesh edges.
270 // Iterates until nothing changes or maxIter reached.
271 // (maxIter can be 0)
274 const polyMesh& mesh,
275 const labelList& initialPoints,
276 const List<Type>& initialPointsInfo,
277 List<Type>& allPointInfo,
278 List<Type>& allEdgeInfo,
291 const List<Type>& allPointInfo() const
293 return allPointInfo_;
297 const List<Type>& allEdgeInfo() const
302 //- Get number of unvisited edges, i.e. edges that were not (yet)
303 // reached from walking across mesh. This can happen from
304 // - not enough iterations done
305 // - a disconnected mesh
306 // - a mesh without walls in it
307 label getUnsetEdges() const;
309 label getUnsetPoints() const;
311 //- Copy initial data into allPointInfo_
314 const labelList& changedPoints,
315 const List<Type>& changedPointsInfo
318 //- Propagate from point to edge. Returns total number of edges
319 // (over all processors) changed.
322 //- Propagate from edge to point. Returns total number of points
323 // (over all processors) changed.
326 //- Iterate until no changes or maxIter reached. Returns actual
327 // number of iterations.
328 label iterate(const label maxIter);
332 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
334 /*---------------------------------------------------------------------------*\
335 Class listUpdateOp Declaration
336 \*---------------------------------------------------------------------------*/
338 //- List update operation
339 template <class Type>
345 void operator()(List<Type>& x, const List<Type>& y) const
349 x[i].updatePoint(y[i], PointEdgeWave<Type>::propagationTol());
354 } // End namespace Foam
357 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
360 # include "PointEdgeWave.C"
363 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 // ************************************************************************* //