1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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/>.
25 Foam::PatchEdgeFaceWave
28 Wave propagation of information along patch. Every iteration
29 information goes through one layer of faces. Templated on information
35 \*---------------------------------------------------------------------------*/
37 #ifndef PatchEdgeFaceWave_H
38 #define PatchEdgeFaceWave_H
40 #include "scalarField.H"
41 #include "PackedBoolList.H"
42 #include "PrimitivePatch.H"
43 #include "vectorTensorTransform.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 // Forward declaration of classes
53 /*---------------------------------------------------------------------------*\
54 Class PatchEdgeFaceWaveName Declaration
55 \*---------------------------------------------------------------------------*/
57 TemplateName(PatchEdgeFaceWave);
60 /*---------------------------------------------------------------------------*\
61 Class PatchEdgeFaceWave Declaration
62 \*---------------------------------------------------------------------------*/
66 class PrimitivePatchType,
68 class TrackingData = int
70 class PatchEdgeFaceWave
72 public PatchEdgeFaceWaveName
74 // Private static data
76 //- Relative tolerance. Stop propagation if relative changes
77 // less than this tolerance (responsability for checking this is
78 // up to Type implementation)
79 static scalar propagationTol_;
81 //- Used as default trackdata value to satisfy default template
83 static label dummyTrackData_;
89 const polyMesh& mesh_;
91 //- Reference to patch
92 const PrimitivePatchType& patch_;
94 //- Wall information for all edges
95 UList<Type>& allEdgeInfo_;
97 //- Information on all patch faces
98 UList<Type>& allFaceInfo_;
100 //- Additional data to be passed into container
104 PackedBoolList changedEdge_;
106 //- List of changed edges
107 DynamicList<label> changedEdges_;
110 PackedBoolList changedFace_;
112 //- List of changed faces
113 DynamicList<label> changedFaces_;
115 //- Number of evaluations
118 //- Number of unvisited faces/edges
119 label nUnvisitedEdges_;
120 label nUnvisitedFaces_;
123 // Addressing between edges of patch_ and globalData.coupledPatch()
124 labelList patchEdges_;
125 labelList coupledEdges_;
126 PackedBoolList sameEdgeOrientation_;
129 // Private Member Functions
131 //- Updates edgeInfo with information from neighbour. Updates all
136 const label neighbourFaceI,
137 const Type& neighbourInfo,
141 //- Updates faceInfo with information from neighbour. Updates all
146 const label neighbourEdgeI,
147 const Type& neighbourInfo,
151 //- Update coupled edges
154 //- Disallow default bitwise copy construct
155 PatchEdgeFaceWave(const PatchEdgeFaceWave&);
157 //- Disallow default bitwise assignment
158 void operator=(const PatchEdgeFaceWave&);
165 //- Access to tolerance
166 static scalar propagationTol()
168 return propagationTol_;
172 static void setPropagationTol(const scalar tol)
174 propagationTol_ = tol;
180 //- Construct from patch, list of changed edges with the Type
181 // for these edges. Gets work arrays to operate on, one of size
182 // number of patch edges, the other number of patch faces.
183 // Iterates until nothing changes or maxIter reached.
184 // (maxIter can be 0)
187 const polyMesh& mesh,
188 const PrimitivePatchType& patch,
189 const labelList& initialEdges,
190 const List<Type>& initialEdgesInfo,
191 UList<Type>& allEdgeInfo,
192 UList<Type>& allFaceInfo,
194 TrackingData& td = dummyTrackData_
197 //- Construct from patch. Use setEdgeInfo and iterate() to do
198 // actual calculation
201 const polyMesh& mesh,
202 const PrimitivePatchType& patch,
203 UList<Type>& allEdgeInfo,
204 UList<Type>& allFaceInfo,
205 TrackingData& td = dummyTrackData_
211 //- Access allEdgeInfo
212 UList<Type>& allEdgeInfo() const
217 //- Access allFaceInfo
218 UList<Type>& allFaceInfo() const
223 //- Additional data to be passed into container
224 const TrackingData& data() const
229 //- Get number of unvisited faces, i.e. faces that were not (yet)
230 // reached from walking across patch. This can happen from
231 // - not enough iterations done
232 // - a disconnected patch
233 // - a patch without walls in it
234 label getUnsetFaces() const;
236 label getUnsetEdges() const;
238 //- Copy initial data into allEdgeInfo_
241 const labelList& changedEdges,
242 const List<Type>& changedEdgesInfo
245 //- Propagate from edge to face. Returns total number of faces
246 // (over all processors) changed.
249 //- Propagate from face to edge. Returns total number of edges
250 // (over all processors) changed.
253 //- Iterate until no changes or maxIter reached. Returns actual
254 // number of iterations.
255 label iterate(const label maxIter);
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264 class PrimitivePatchType,
266 class TrackingData = int
270 //- Additional data to be passed into container
271 const polyMesh& mesh_;
272 const PrimitivePatchType& patch_;
279 const polyMesh& mesh,
280 const PrimitivePatchType& patch,
291 void operator()(Type& x, const Type& y) const
295 x.updateEdge(mesh_, patch_, y, true, tol_, td_);
301 //- Transform operation
304 class PrimitivePatchType,
306 class TrackingData = int
310 //- Additional data to be passed into container
311 const polyMesh& mesh_;
312 const PrimitivePatchType& patch_;
319 const polyMesh& mesh,
320 const PrimitivePatchType& patch,
333 const vectorTensorTransform& vt,
342 fld[i].transform(mesh_, patch_, vt.R(), tol_, td_);
349 fld[i].transform(mesh_, patch_, vt.R().T(), tol_, td_);
355 } // End namespace Foam
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 # include "PatchEdgeFaceWave.C"
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 // ************************************************************************* //