1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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"
53 #include "tolerancesSwitch.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 debug::tolerancesSwitch geomTol_;
272 static debug::tolerancesSwitch 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 // ************************************************************************* //