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 cells. Templated on information
32 Handles parallel and cyclics and non-parallel cyclics.
34 Note: whether to propagate depends on the return value of Type::update
35 which returns true (i.e. propagate) if the value changes by more than a
37 This tolerance can be very strict for normal face-cell and parallel
38 cyclics (we use a value of 0.01 just to limit propagation of small changes)
39 but for non-parallel cyclics this tolerance can be critical and if chosen
40 too small can lead to non-convergence.
45 \*---------------------------------------------------------------------------*/
47 #ifndef FaceCellWave_H
48 #define FaceCellWave_H
51 #include "labelList.H"
52 #include "primitiveFieldsFwd.H"
54 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
59 // Forward declaration of classes
63 /*---------------------------------------------------------------------------*\
64 Class FaceCellWaveName Declaration
65 \*---------------------------------------------------------------------------*/
67 TemplateName(FaceCellWave);
70 /*---------------------------------------------------------------------------*\
71 Class FaceCellWave Declaration
72 \*---------------------------------------------------------------------------*/
74 template<class Type, class TrackingData = int>
77 public FaceCellWaveName
82 const polyMesh& mesh_;
84 //- Information for all faces
85 UList<Type>& allFaceInfo_;
87 //- Information for all cells
88 UList<Type>& allCellInfo_;
90 //- Additional data to be passed into container
94 boolList changedFace_;
96 //- List of changed faces
97 labelList changedFaces_;
99 //- Number of changed faces
100 label nChangedFaces_;
102 // Cells that have changed
103 boolList changedCell_;
104 labelList changedCells_;
105 label nChangedCells_;
108 bool hasCyclicPatches_;
110 //- Number of evaluations
113 //- Number of unvisited cells/faces
114 label nUnvisitedCells_;
115 label nUnvisitedFaces_;
118 // Private Member Functions
120 //- Disallow default bitwise copy construct
121 FaceCellWave(const FaceCellWave&);
123 //- Disallow default bitwise assignment
124 void operator=(const FaceCellWave&);
127 //- Updates cellInfo with information from neighbour. Updates all
132 const label neighbourFaceI,
133 const Type& neighbourInfo,
138 //- Updates faceInfo with information from neighbour. Updates all
143 const label neighbourCellI,
144 const Type& neighbourInfo,
149 //- Updates faceInfo with information from same face. Updates all
154 const Type& neighbourInfo,
162 //- Debugging: check info on both sides of cyclic
163 void checkCyclic(const polyPatch& pPatch) const;
165 //- Has cyclic patch?
166 bool hasCyclicPatch() const;
168 //- Merge received patch data into global data
171 const polyPatch& patch,
177 //- Extract info for single patch only
178 label getChangedPatchFaces
180 const polyPatch& patch,
181 const label startFaceI,
183 labelList& changedPatchFaces,
184 List<Type>& changedPatchFacesInfo
187 //- Handle leaving domain. Implementation referred to Type
190 const polyPatch& patch,
192 const labelList& faceLabels,
196 //- Handle leaving domain. Implementation referred to Type
199 const polyPatch& patch,
201 const labelList& faceLabels,
205 //- Offset face labels by constant value
208 const polyPatch& patch,
214 //- Apply transformation to Type
217 const tensorField& rotTensor,
222 //- Merge data from across processor boundaries
223 void handleProcPatches();
225 //- Merge data from across cyclics
226 void handleCyclicPatches();
229 // Private static data
231 static const scalar geomTol_;
232 static scalar propagationTol_;
234 //- Used as default trackdata value to satisfy default template
236 static label dummyTrackData_;
243 //- Access to tolerance
244 static scalar propagationTol()
246 return propagationTol_;
250 static void setPropagationTol(const scalar tol)
252 propagationTol_ = tol;
258 // Construct from mesh. Use setFaceInfo and iterate() to do actual
263 UList<Type>& allFaceInfo,
264 UList<Type>& allCellInfo,
265 TrackingData& td = dummyTrackData_
268 //- Construct from mesh and list of changed faces with the Type
269 // for these faces. Iterates until nothing changes or maxIter reached.
270 // (maxIter can be 0)
274 const labelList& initialChangedFaces,
275 const List<Type>& changedFacesInfo,
276 UList<Type>& allFaceInfo,
277 UList<Type>& allCellInfo,
279 TrackingData& td = dummyTrackData_
287 //- Access allFaceInfo
288 UList<Type>& allFaceInfo()
293 //- Access allCellInfo
294 UList<Type>& allCellInfo()
299 //- Additional data to be passed into container
300 const TrackingData& data() const
306 const polyMesh& mesh() const
311 //- Get number of unvisited cells, i.e. cells that were not (yet)
312 // reached from walking across mesh. This can happen from
313 // - not enough iterations done
314 // - a disconnected mesh
315 // - a mesh without walls in it
316 label getUnsetCells() const;
318 //- Get number of unvisited faces
319 label getUnsetFaces() const;
324 //- Set initial changed faces
327 const labelList& changedFaces,
328 const List<Type>& changedFacesInfo
331 //- Propagate from face to cell. Returns total number of cells
332 // (over all processors) changed.
335 //- Propagate from cell to face. Returns total number of faces
336 // (over all processors) changed. (Faces on processorpatches are
340 //- Iterate until no changes or maxIter reached. Returns actual
341 // number of iterations.
342 label iterate(const label maxIter);
347 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
349 } // End namespace Foam
352 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
355 # include "FaceCellWave.C"
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 // ************************************************************************* //