PatchEdgeFaceWave.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::PatchEdgeFaceWave
26 
27 Description
28  Wave propagation of information along patch. Every iteration
29  information goes through one layer of faces. Templated on information
30  that is transferred.
31 
32 SourceFiles
33  PatchEdgeFaceWave.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef PatchEdgeFaceWave_H
38 #define PatchEdgeFaceWave_H
39 
40 #include "scalarField.H"
41 #include "PackedBoolList.H"
42 #include "PrimitivePatch.H"
43 #include "transformer.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward declaration of classes
51 class polyMesh;
52 
53 /*---------------------------------------------------------------------------*\
54  Class PatchEdgeFaceWaveName Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 TemplateName(PatchEdgeFaceWave);
58 
59 
60 /*---------------------------------------------------------------------------*\
61  Class PatchEdgeFaceWave Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template
65 <
66  class PrimitivePatchType,
67  class Type,
68  class TrackingData = label
69 >
71 :
72  public PatchEdgeFaceWaveName
73 {
74  // Private static data
75 
76  //- Relative tolerance. Stop propagation if relative changes
77  // less than this tolerance (responsibility for checking this is
78  // up to Type implementation)
79  static scalar propagationTol_;
80 
81  //- Used as default trackdata value to satisfy default template
82  // argument.
83  static label dummyTrackData_;
84 
85 
86  // Private Data
87 
88  //- Reference to mesh
89  const polyMesh& mesh_;
90 
91  //- Reference to patch
92  const PrimitivePatchType& patch_;
93 
94  //- Wall information for all edges
95  UList<Type>& allEdgeInfo_;
96 
97  //- Information on all patch faces
98  UList<Type>& allFaceInfo_;
99 
100  //- Additional data to be passed into container
101  TrackingData& td_;
102 
103  //- Has edge changed
104  PackedBoolList changedEdge_;
105 
106  //- List of changed edges
107  DynamicList<label> changedEdges_;
108 
109  //- Has face changed
110  PackedBoolList changedFace_;
111 
112  //- List of changed faces
113  DynamicList<label> changedFaces_;
114 
115  //- Number of evaluations
116  label nEvals_;
117 
118  //- Number of unvisited faces/edges
119  label nUnvisitedEdges_;
120  label nUnvisitedFaces_;
121 
122 
123  // Addressing between edges of patch_ and globalData.coupledPatch()
124  labelList patchEdges_;
125  labelList coupledEdges_;
126  PackedBoolList sameEdgeOrientation_;
127 
128 
129  // Private Member Functions
130 
131  //- Updates edgeInfo with information from neighbour. Updates all
132  // statistics.
133  bool updateEdge
134  (
135  const label edgeI,
136  const label neighbourFacei,
137  const Type& neighbourInfo,
138  Type& edgeInfo
139  );
140 
141  //- Updates faceInfo with information from neighbour. Updates all
142  // statistics.
143  bool updateFace
144  (
145  const label facei,
146  const label neighbourEdgeI,
147  const Type& neighbourInfo,
148  Type& faceInfo
149  );
150 
151  //- Update coupled edges
152  void syncEdges();
153 
154 
155 public:
156 
157  // Static Functions
158 
159  //- Access to tolerance
160  static scalar propagationTol()
161  {
162  return propagationTol_;
163  }
164 
165  //- Change tolerance
166  static void setPropagationTol(const scalar tol)
167  {
168  propagationTol_ = tol;
169  }
170 
171 
172  // Constructors
173 
174  //- Construct from patch, list of changed edges with the Type
175  // for these edges. Gets work arrays to operate on, one of size
176  // number of patch edges, the other number of patch faces.
177  // Iterates until nothing changes or maxIter reached.
178  // (maxIter can be 0)
180  (
181  const polyMesh& mesh,
182  const PrimitivePatchType& patch,
183  const labelList& initialEdges,
184  const List<Type>& initialEdgesInfo,
187  const label maxIter,
188  TrackingData& td = dummyTrackData_
189  );
190 
191  //- Construct from patch. Use setEdgeInfo and iterate() to do
192  // actual calculation
194  (
195  const polyMesh& mesh,
196  const PrimitivePatchType& patch,
197  UList<Type>& allEdgeInfo,
198  UList<Type>& allFaceInfo,
199  TrackingData& td = dummyTrackData_
200  );
201 
202  //- Disallow default bitwise copy construction
203  PatchEdgeFaceWave(const PatchEdgeFaceWave&) = delete;
204 
205 
206  // Member Functions
207 
208  //- Access allEdgeInfo
209  UList<Type>& allEdgeInfo() const
210  {
211  return allEdgeInfo_;
212  }
213 
214  //- Access allFaceInfo
215  UList<Type>& allFaceInfo() const
216  {
217  return allFaceInfo_;
218  }
219 
220  //- Additional data to be passed into container
221  const TrackingData& data() const
222  {
223  return td_;
224  }
225 
226  //- Get number of unvisited faces, i.e. faces that were not (yet)
227  // reached from walking across patch. This can happen from
228  // - not enough iterations done
229  // - a disconnected patch
230  // - a patch without walls in it
231  label getUnsetFaces() const;
232 
233  label getUnsetEdges() const;
234 
235  //- Copy initial data into allEdgeInfo_
236  void setEdgeInfo
237  (
238  const labelList& changedEdges,
239  const List<Type>& changedEdgesInfo
240  );
241 
242  //- Propagate from edge to face. Returns total number of faces
243  // (over all processors) changed.
244  label edgeToFace();
245 
246  //- Propagate from face to edge. Returns total number of edges
247  // (over all processors) changed.
248  label faceToEdge();
249 
250  //- Iterate until no changes or maxIter reached. Returns actual
251  // number of iterations.
252  label iterate(const label maxIter);
253 
254 
255  // Member Operators
256 
257  //- Disallow default bitwise assignment
258  void operator=(const PatchEdgeFaceWave&) = delete;
259 };
260 
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 //- Update operation
265 template
266 <
267  class PrimitivePatchType,
268  class Type,
269  class TrackingData = int
270 >
271 class updateOp
272 {
273  //- Additional data to be passed into container
274  const polyMesh& mesh_;
275  const PrimitivePatchType& patch_;
276  const scalar tol_;
277  TrackingData& td_;
278 
279 public:
281  (
282  const polyMesh& mesh,
283  const PrimitivePatchType& patch,
284  const scalar tol,
285  TrackingData& td
286  )
287  :
288  mesh_(mesh),
289  patch_(patch),
290  tol_(tol),
291  td_(td)
292  {}
294  void operator()(Type& x, const Type& y) const
295  {
296  if (y.valid(td_))
297  {
298  x.updateEdge(mesh_, patch_, y, true, tol_, td_);
299  }
300  }
301 };
302 
303 
304 //- Transform operation
305 template
306 <
307  class PrimitivePatchType,
308  class Type,
309  class TrackingData = int
310 >
311 class transformOp
312 {
313  //- Additional data to be passed into container
314  const polyMesh& mesh_;
315  const PrimitivePatchType& patch_;
316  const scalar tol_;
317  TrackingData& td_;
318 
319 public:
321  (
322  const polyMesh& mesh,
323  const PrimitivePatchType& patch,
324  const scalar tol,
325  TrackingData& td
326  )
327  :
328  mesh_(mesh),
329  patch_(patch),
330  tol_(tol),
331  td_(td)
332  {}
333 
334  void operator()
335  (
336  const transformer& vt,
337  const bool forward,
338  List<Type>& fld
339  ) const
340  {
341  if (forward)
342  {
343  forAll(fld, i)
344  {
345  fld[i].transform(mesh_, patch_, vt.T(), tol_, td_);
346  }
347  }
348  else
349  {
350  forAll(fld, i)
351  {
352  fld[i].transform(mesh_, patch_, vt.T().T(), tol_, td_);
353  }
354  }
355  }
356 };
357 
358 } // End namespace Foam
359 
360 
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 
363 #ifdef NoRepository
364  #include "PatchEdgeFaceWave.C"
365 #endif
366 
367 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
368 
369 #endif
370 
371 // ************************************************************************* //
TemplateName(blendedSchemeBase)
Transform operation.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space...
Definition: transformer.H:83
const TrackingData & data() const
Additional data to be passed into container.
label getUnsetFaces() const
Get number of unvisited faces, i.e. faces that were not (yet)
static void setPropagationTol(const scalar tol)
Change tolerance.
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
label faceToEdge()
Propagate from face to edge. Returns total number of edges.
label edgeToFace()
Propagate from edge to face. Returns total number of faces.
PatchEdgeFaceWave(const polyMesh &mesh, const PrimitivePatchType &patch, const labelList &initialEdges, const List< Type > &initialEdgesInfo, UList< Type > &allEdgeInfo, UList< Type > &allFaceInfo, const label maxIter, TrackingData &td=dummyTrackData_)
Construct from patch, list of changed edges with the Type.
scalar y
dynamicFvMesh & mesh
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< ' ';}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< ' ';}gmvFile<< nl;forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void operator=(const PatchEdgeFaceWave &)=delete
Disallow default bitwise assignment.
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
static scalar propagationTol()
Access to tolerance.
void setEdgeInfo(const labelList &changedEdges, const List< Type > &changedEdgesInfo)
Copy initial data into allEdgeInfo_.
UList< Type > & allFaceInfo() const
Access allFaceInfo.
A bit-packed bool list.
Update operation.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
UList< Type > & allEdgeInfo() const
Access allEdgeInfo.