PatchEdgeFaceWave.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::PatchEdgeFaceWave
29
30Description
31 Wave propagation of information along patch. Every iteration
32 information goes through one layer of faces. Templated on information
33 that is transferred.
34
35SourceFiles
36 PatchEdgeFaceWave.C
37
38\*---------------------------------------------------------------------------*/
39
40#ifndef PatchEdgeFaceWave_H
41#define PatchEdgeFaceWave_H
42
43#include "bitSet.H"
44#include "scalarField.H"
45#include "PrimitivePatch.H"
47
48// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49
50namespace Foam
51{
52
53// Forward Declarations
54class polyMesh;
55
56/*---------------------------------------------------------------------------*\
57 Class PatchEdgeFaceWaveName Declaration
58\*---------------------------------------------------------------------------*/
61
62
63/*---------------------------------------------------------------------------*\
64 Class PatchEdgeFaceWave Declaration
65\*---------------------------------------------------------------------------*/
66
67template
68<
69 class PrimitivePatchType,
70 class Type,
71 class TrackingData = label
74:
75 public PatchEdgeFaceWaveName
76{
77 // Private Static Data
78
79 //- Relative tolerance.
80 // Stop propagation if relative changes less than this tolerance
81 // (responsibility for checking this is up to Type implementation)
82 static scalar propagationTol_;
83
84 //- Default trackdata value to satisfy default template argument.
85 static label dummyTrackData_;
86
87
88 // Private Data
89
90 //- Reference to mesh
91 const polyMesh& mesh_;
92
93 //- Reference to patch
94 const PrimitivePatchType& patch_;
95
96 //- Wall information for all edges
97 UList<Type>& allEdgeInfo_;
98
99 //- Information on all patch faces
100 UList<Type>& allFaceInfo_;
101
102 //- Additional data to be passed into container
103 TrackingData& td_;
104
105 //- Has edge changed
106 bitSet changedEdge_;
107
108 //- List of changed edges
109 DynamicList<label> changedEdges_;
110
111 //- Has face changed
112 bitSet changedFace_;
113
114 //- List of changed faces
115 DynamicList<label> changedFaces_;
116
117 //- Number of evaluations
118 label nEvals_;
119
120 //- Number of unvisited faces/edges
121 label nUnvisitedEdges_;
122 label nUnvisitedFaces_;
123
124
125 // Addressing between edges of patch_ and globalData.coupledPatch()
126 labelList patchEdges_;
127 labelList coupledEdges_;
128 bitSet sameEdgeOrientation_;
129
130
131 // Private Member Functions
132
133 //- Updates edgeInfo with information from neighbour.
134 // Updates all statistics.
135 bool updateEdge
136 (
137 const label edgeI,
138 const label neighbourFacei,
139 const Type& neighbourInfo,
140 Type& edgeInfo
141 );
142
143 //- Updates faceInfo with information from neighbour.
144 // Updates all statistics.
145 bool updateFace
146 (
147 const label facei,
148 const label neighbourEdgeI,
149 const Type& neighbourInfo,
150 Type& faceInfo
151 );
152
153 //- Update coupled edges
154 void syncEdges();
155
156 //- No copy construct
157 PatchEdgeFaceWave(const PatchEdgeFaceWave&) = delete;
158
159 //- No copy assignment
160 void operator=(const PatchEdgeFaceWave&) = delete;
161
162
163public:
164
165 // Static Functions
166
167 //- Access to tolerance
168 static scalar propagationTol()
169 {
170 return propagationTol_;
171 }
172
173 //- Change tolerance
174 static void setPropagationTol(const scalar tol)
175 {
176 propagationTol_ = tol;
177 }
178
179
180 // Constructors
181
182 //- Construct from patch, list of changed edges with the Type
183 //- for these edges.
184 // Obtains work arrays to operate on, one of size
185 // number of patch edges, the other number of patch faces.
186 // Iterates until nothing changes or maxIter reached.
187 // (maxIter can be 0)
189 (
190 const polyMesh& mesh,
191 const PrimitivePatchType& patch,
192 const labelList& initialEdges,
193 const List<Type>& initialEdgesInfo,
196 const label maxIter,
197 TrackingData& td = dummyTrackData_
198 );
199
200 //- Construct from patch.
201 // Use setEdgeInfo() and iterate() to do actual calculation
203 (
204 const polyMesh& mesh,
205 const PrimitivePatchType& patch,
208 TrackingData& td = dummyTrackData_
209 );
210
211
212 // Member Functions
213
214 //- Access allEdgeInfo
215 UList<Type>& allEdgeInfo() const
216 {
217 return allEdgeInfo_;
218 }
219
220 //- Access allFaceInfo
221 UList<Type>& allFaceInfo() const
222 {
223 return allFaceInfo_;
224 }
225
226 //- Additional data to be passed into container
227 const TrackingData& data() const
228 {
229 return td_;
230 }
231
232 //- Number of unvisited faces, i.e. faces that were not (yet)
233 //- reached from walking across patch.
234 //
235 // This can happen from
236 // - not enough iterations done
237 // - a disconnected patch
238 // - a patch without walls in it
239 label nUnvisitedFaces() const
240 {
241 return nUnvisitedFaces_;
242 }
244 label nUnvisitedEdges() const
245 {
246 return nUnvisitedEdges_;
247 }
248
249 //- Copy initial data into allEdgeInfo_
250 void setEdgeInfo
251 (
252 const labelList& changedEdges,
253 const List<Type>& changedEdgesInfo
254 );
255
256 //- Propagate from edge to face.
257 // \return total number of faces (over all processors) changed.
258 label edgeToFace();
259
260 //- Propagate from face to edge.
261 // \return total number of edges (over all processors) changed.
262 label faceToEdge();
263
264 //- Iterate until no changes or maxIter reached.
265 // \return actual number of iterations.
266 label iterate(const label maxIter);
267};
268
269
270// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271
272//- Update operation
273template
274<
275 class PrimitivePatchType,
276 class Type,
277 class TrackingData = int
279class updateOp
280{
281 //- Additional data to be passed into container
282 const polyMesh& mesh_;
283 const PrimitivePatchType& patch_;
284 const scalar tol_;
285 TrackingData& td_;
286
287public:
290 (
291 const polyMesh& mesh,
292 const PrimitivePatchType& patch,
293 const scalar tol,
294 TrackingData& td
295 )
296 :
297 mesh_(mesh),
298 patch_(patch),
299 tol_(tol),
300 td_(td)
301 {}
303 void operator()(Type& x, const Type& y) const
304 {
305 if (y.valid(td_))
306 {
307 x.updateEdge(mesh_, patch_, y, true, tol_, td_);
308 }
309 }
310};
311
312
313//- Transform operation
314template
315<
316 class PrimitivePatchType,
317 class Type,
318 class TrackingData = int
320class transformOp
321{
322 //- Additional data to be passed into container
323 const polyMesh& mesh_;
324 const PrimitivePatchType& patch_;
325 const scalar tol_;
326 TrackingData& td_;
327
328public:
331 (
332 const polyMesh& mesh,
333 const PrimitivePatchType& patch,
334 const scalar tol,
335 TrackingData& td
336 )
337 :
338 mesh_(mesh),
339 patch_(patch),
340 tol_(tol),
341 td_(td)
342 {}
344 void operator()
345 (
346 const vectorTensorTransform& vt,
347 const bool forward,
349 ) const
350 {
351 if (forward)
352 {
353 forAll(fld, i)
354 {
355 fld[i].transform(mesh_, patch_, vt.R(), tol_, td_);
356 }
357 }
358 else
359 {
360 forAll(fld, i)
361 {
362 fld[i].transform(mesh_, patch_, vt.R().T(), tol_, td_);
363 }
364 }
365 }
366};
367
368} // End namespace Foam
369
370
371// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
372
373#ifdef NoRepository
374 #include "PatchEdgeFaceWave.C"
375#endif
376
377// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
378
379#endif
380
381// ************************************************************************* //
scalar y
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
label edgeToFace()
Propagate from edge to face.
static scalar propagationTol()
Access to tolerance.
UList< Type > & allFaceInfo() const
Access allFaceInfo.
label iterate(const label maxIter)
Iterate until no changes or maxIter reached.
UList< Type > & allEdgeInfo() const
Access allEdgeInfo.
void setEdgeInfo(const labelList &changedEdges, const List< Type > &changedEdgesInfo)
Copy initial data into allEdgeInfo_.
label faceToEdge()
Propagate from face to edge.
const TrackingData & data() const
Additional data to be passed into container.
static void setPropagationTol(const scalar tol)
Change tolerance.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: UList.H:94
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:66
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
Transform operation.
transformOp(const polyMesh &mesh, const PrimitivePatchType &patch, const scalar tol, TrackingData &td)
Update operation.
updateOp(const polyMesh &mesh, const PrimitivePatchType &patch, const scalar tol, TrackingData &td)
void operator()(Type &x, const Type &y) const
Vector-tensor class used to perform translations and rotations in 3D space.
#define TemplateName(TemplateNameString)
Add typeName information from argument TypeNameString to a.
Definition: className.H:79
dynamicFvMesh & mesh
Namespace for OpenFOAM.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333