1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Wave propagation of information through grid. Every iteration
29 information goes through one layer of edges. Templated on information
32 Templated on information that is transferred.
33 Handles parallel and cyclics. Only parallel reasonably tested. Cyclics
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
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
45 -# do all non-local shared points by means of reduce of data on them.
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)
56 \*---------------------------------------------------------------------------*/
58 #ifndef PointEdgeWave_H
59 #define PointEdgeWave_H
62 #include "scalarField.H"
63 #include "tensorField.H"
65 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 // Forward declaration of classes
74 /*---------------------------------------------------------------------------*\
75 Class PointEdgeWaveName Declaration
76 \*---------------------------------------------------------------------------*/
78 TemplateName(PointEdgeWave);
81 /*---------------------------------------------------------------------------*\
82 Class PointEdgeWave Declaration
83 \*---------------------------------------------------------------------------*/
85 template <class Type, class TrackingData = int>
88 public PointEdgeWaveName
90 // Private static data
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_;
97 //- Used as default trackdata value to satisfy default template
99 static label dummyTrackData_;
104 //- Reference to mesh
105 const polyMesh& mesh_;
107 //- Wall information for all points
108 UList<Type>& allPointInfo_;
110 //- Information on all mesh edges
111 UList<Type>& allEdgeInfo_;
113 //- Additional data to be passed into container
116 //- Has point changed
117 boolList changedPoint_;
119 //- List of changed points
120 labelList changedPoints_;
122 //- Number of changed points
123 label nChangedPoints_;
125 //- Edges that have changed
126 boolList changedEdge_;
127 labelList changedEdges_;
128 label nChangedEdges_;
130 //- Number of cyclic patches
131 label nCyclicPatches_;
133 //- Number of evaluations
136 //- Number of unvisited edges/points
137 label nUnvisitedPoints_;
138 label nUnvisitedEdges_;
141 // Private Member Functions
143 //- Adapt pointInfo for leaving domain
147 const List<label>& patchPointLabels,
148 List<Type>& pointInfo
151 //- Adapt pointInfo for entering domain
155 const List<label>& patchPointLabels,
156 List<Type>& pointInfo
159 //- Transform. Implementation referred to Type
162 const polyPatch& patch,
163 const tensorField& rotTensor,
164 List<Type>& pointInfo
167 //- Updates pointInfo with information from neighbour. Updates all
172 const label neighbourEdgeI,
173 const Type& neighbourInfo,
177 //- Updates pointInfo with information from same point. Updates all
182 const Type& neighbourInfo,
186 //- Updates edgeInfo with information from neighbour. Updates all
191 const label neighbourPointI,
192 const Type& neighbourInfo,
198 //- Has patches of certain type?
199 template <class PatchType>
200 label countPatchType() const;
202 //- Merge data from across processor boundaries
203 void handleProcPatches();
205 //- Merge data from across cyclic boundaries
206 void handleCyclicPatches();
209 //- Disallow default bitwise copy construct
210 PointEdgeWave(const PointEdgeWave&);
212 //- Disallow default bitwise assignment
213 void operator=(const PointEdgeWave&);
220 //- Access to tolerance
221 static scalar propagationTol()
223 return propagationTol_;
227 static void setPropagationTol(const scalar tol)
229 propagationTol_ = tol;
235 //- Construct from mesh, list of changed points with the Type
236 // for these points. Gets work arrays to operate on, one of size
237 // number of mesh points, the other number of mesh edges.
238 // Iterates until nothing changes or maxIter reached.
239 // (maxIter can be 0)
242 const polyMesh& mesh,
243 const labelList& initialPoints,
244 const List<Type>& initialPointsInfo,
245 UList<Type>& allPointInfo,
246 UList<Type>& allEdgeInfo,
248 TrackingData& td = dummyTrackData_
251 //- Construct from mesh. Use setPointInfo and iterate() to do
252 // actual calculation
255 const polyMesh& mesh,
256 UList<Type>& allPointInfo,
257 UList<Type>& allEdgeInfo,
258 TrackingData& td = dummyTrackData_
268 //- Access allPointInfo
269 UList<Type>& allPointInfo() const
271 return allPointInfo_;
274 //- Access allEdgeInfo
275 UList<Type>& allEdgeInfo() const
280 //- Additional data to be passed into container
281 const TrackingData& data() const
286 //- Get number of unvisited edges, i.e. edges that were not (yet)
287 // reached from walking across mesh. This can happen from
288 // - not enough iterations done
289 // - a disconnected mesh
290 // - a mesh without walls in it
291 label getUnsetEdges() const;
293 label getUnsetPoints() const;
295 //- Copy initial data into allPointInfo_
298 const labelList& changedPoints,
299 const List<Type>& changedPointsInfo
302 //- Propagate from point to edge. Returns total number of edges
303 // (over all processors) changed.
306 //- Propagate from edge to point. Returns total number of points
307 // (over all processors) changed.
310 //- Iterate until no changes or maxIter reached. Returns actual
311 // number of iterations.
312 label iterate(const label maxIter);
316 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
318 /*---------------------------------------------------------------------------*\
319 Class listUpdateOp Declaration
320 \*---------------------------------------------------------------------------*/
322 //- List update operation
323 template <class Type, class TrackingData = int>
326 //- Additional data to be passed into container
333 listUpdateOp(const scalar tol, TrackingData& td)
339 void operator()(List<Type>& x, const List<Type>& y) const
345 x[i].updatePoint(y[i], tol_, td_);
351 } // End namespace Foam
354 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357 # include "PointEdgeWave.C"
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
364 // ************************************************************************* //