1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 cells. Templated on information
33 Handles parallel and cyclics and non-parallel cyclics.
35 Note: whether to propagate depends on the return value of Type::update
36 which returns true (i.e. propagate) if the value changes by more than a
38 This tolerance can be very strict for normal face-cell and parallel
39 cyclics (we use a value of 0.01 just to limit propagation of small changes)
40 but for non-parallel cyclics this tolerance can be critical and if chosen
41 too small can lead to non-convergence.
46 \*---------------------------------------------------------------------------*/
48 #ifndef FaceCellWave_H
49 #define FaceCellWave_H
52 #include "labelList.H"
53 #include "primitiveFieldsFwd.H"
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 // Forward declaration of classes
64 /*---------------------------------------------------------------------------*\
65 Class FaceCellWaveName Declaration
66 \*---------------------------------------------------------------------------*/
68 TemplateName(FaceCellWave);
71 /*---------------------------------------------------------------------------*\
72 Class FaceCellWave Declaration
73 \*---------------------------------------------------------------------------*/
78 public FaceCellWaveName
83 const polyMesh& mesh_;
85 //- Information for all faces
86 UList<Type>& allFaceInfo_;
88 //- Information for all cells
89 UList<Type>& allCellInfo_;
92 boolList changedFace_;
94 //- List of changed faces
95 labelList changedFaces_;
97 //- Number of changed faces
100 // Cells that have changed
101 boolList changedCell_;
102 labelList changedCells_;
103 label nChangedCells_;
106 bool hasCyclicPatches_;
108 //- Number of evaluations
111 //- Number of unvisited cells/faces
112 label nUnvisitedCells_;
113 label nUnvisitedFaces_;
115 //- Iteration counter
122 static Ostream& writeFaces
125 const labelList& faceLabels,
126 const List<Type>& faceInfo,
131 static Istream& readFaces
134 labelList& faceLabels,
135 List<Type>& faceInfo,
140 // Private Member Functions
142 //- Disallow default bitwise copy construct
143 FaceCellWave(const FaceCellWave&);
145 //- Disallow default bitwise assignment
146 void operator=(const FaceCellWave&);
149 //- Updates cellInfo with information from neighbour. Updates all
154 const label neighbourFaceI,
155 const Type& neighbourInfo,
160 //- Updates faceInfo with information from neighbour. Updates all
165 const label neighbourCellI,
166 const Type& neighbourInfo,
171 //- Updates faceInfo with information from same face. Updates all
176 const Type& neighbourInfo,
184 //- Debugging: check info on both sides of cyclic
185 void checkCyclic(const polyPatch& pPatch) const;
187 //- Has patches of certain type?
188 bool hasPatchType(const word& nameOfType);
190 //- Merge received patch data into global data
193 const polyPatch& patch,
197 const bool isParallel
200 //- Extract info for single patch only
201 label getChangedPatchFaces
203 const polyPatch& patch,
204 const label startFaceI,
206 labelList& changedPatchFaces,
207 List<Type>& changedPatchFacesInfo
210 //- Handle leaving domain. Implementation referred to Type
213 const polyPatch& patch,
215 const labelList& faceLabels,
219 //- Handle leaving domain. Implementation referred to Type
222 const polyPatch& patch,
224 const labelList& faceLabels,
228 //- Send info to neighbour
231 const label neighbour,
237 //- Receive info from neighbour. Returns number of faces received.
238 label receivePatchInfo
240 const label neighbour,
245 //- Offset face labels by constant value
248 const polyPatch& patch,
254 //- Apply transformation to Type
257 const tensorField& rotTensor,
262 //- Merge data from across processor boundaries
263 void handleProcPatches();
265 //- Merge data from across cyclics
266 void handleCyclicPatches();
269 // Private static data
271 static const scalar geomTol_;
272 static const scalar propagationTol_;
278 //- Access to tolerance
279 static scalar propagationTol()
281 return propagationTol_;
285 static void setPropagationTol(const scalar tol)
287 propagationTol_ = tol;
293 // Construct from mesh. Use setFaceInfo and iterate() to do actual
298 UList<Type>& allFaceInfo,
299 UList<Type>& allCellInfo
302 //- Construct from mesh and list of changed faces with the Type
303 // for these faces. Iterates until nothing changes or maxIter reached.
304 // (maxIter can be 0)
308 const labelList& initialChangedFaces,
309 const List<Type>& changedFacesInfo,
310 UList<Type>& allFaceInfo,
311 UList<Type>& allCellInfo,
320 //- Access allFaceInfo
321 UList<Type>& allFaceInfo()
326 //- Access allCellInfo
327 UList<Type>& allCellInfo()
333 const polyMesh& mesh() const
338 //- Get number of unvisited cells, i.e. cells that were not (yet)
339 // reached from walking across mesh. This can happen from
340 // - not enough iterations done
341 // - a disconnected mesh
342 // - a mesh without walls in it
343 label getUnsetCells() const;
345 //- Get number of unvisited faces
346 label getUnsetFaces() const;
351 //- Set initial changed faces
354 const labelList& changedFaces,
355 const List<Type>& changedFacesInfo
358 //- Propagate from face to cell. Returns total number of cells
359 // (over all processors) changed.
362 //- Propagate from cell to face. Returns total number of faces
363 // (over all processors) changed. (Faces on processorpatches are
367 //- Iterate until no changes or maxIter reached. Returns number of
368 // unset cells (see getUnsetCells)
369 label iterate(const label maxIter);
374 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
376 } // End namespace Foam
379 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
382 # include "FaceCellWave.C"
385 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 // ************************************************************************* //