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 | Copyright (C) 2011-2014 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 "vectorTensorTransform.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 (responsability 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  //- Disallow default bitwise copy construct
156 
157  //- Disallow default bitwise assignment
158  void operator=(const PatchEdgeFaceWave&);
159 
160 
161 public:
162 
163  // Static Functions
164 
165  //- Access to tolerance
166  static scalar propagationTol()
167  {
168  return propagationTol_;
169  }
170 
171  //- Change tolerance
172  static void setPropagationTol(const scalar tol)
173  {
174  propagationTol_ = tol;
175  }
176 
177 
178  // Constructors
179 
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)
186  (
187  const polyMesh& mesh,
188  const PrimitivePatchType& patch,
189  const labelList& initialEdges,
190  const List<Type>& initialEdgesInfo,
193  const label maxIter,
194  TrackingData& td = dummyTrackData_
195  );
196 
197  //- Construct from patch. Use setEdgeInfo and iterate() to do
198  // actual calculation
200  (
201  const polyMesh& mesh,
202  const PrimitivePatchType& patch,
203  UList<Type>& allEdgeInfo,
204  UList<Type>& allFaceInfo,
205  TrackingData& td = dummyTrackData_
206  );
207 
208 
209  // Member Functions
210 
211  //- Access allEdgeInfo
212  UList<Type>& allEdgeInfo() const
213  {
214  return allEdgeInfo_;
215  }
216 
217  //- Access allFaceInfo
218  UList<Type>& allFaceInfo() const
219  {
220  return allFaceInfo_;
221  }
222 
223  //- Additional data to be passed into container
224  const TrackingData& data() const
225  {
226  return td_;
227  }
228 
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;
235 
236  label getUnsetEdges() const;
237 
238  //- Copy initial data into allEdgeInfo_
239  void setEdgeInfo
240  (
241  const labelList& changedEdges,
242  const List<Type>& changedEdgesInfo
243  );
244 
245  //- Propagate from edge to face. Returns total number of faces
246  // (over all processors) changed.
247  label edgeToFace();
248 
249  //- Propagate from face to edge. Returns total number of edges
250  // (over all processors) changed.
251  label faceToEdge();
252 
253  //- Iterate until no changes or maxIter reached. Returns actual
254  // number of iterations.
255  label iterate(const label maxIter);
256 };
257 
258 
259 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260 
261 //- Update operation
262 template
263 <
264  class PrimitivePatchType,
265  class Type,
266  class TrackingData = int
267 >
268 class updateOp
269 {
270  //- Additional data to be passed into container
271  const polyMesh& mesh_;
272  const PrimitivePatchType& patch_;
273  const scalar tol_;
274  TrackingData& td_;
275 
276 public:
278  (
279  const polyMesh& mesh,
280  const PrimitivePatchType& patch,
281  const scalar tol,
282  TrackingData& td
283  )
284  :
285  mesh_(mesh),
286  patch_(patch),
287  tol_(tol),
288  td_(td)
289  {}
291  void operator()(Type& x, const Type& y) const
292  {
293  if (y.valid(td_))
294  {
295  x.updateEdge(mesh_, patch_, y, true, tol_, td_);
296  }
297  }
298 };
299 
300 
301 //- Transform operation
302 template
303 <
304  class PrimitivePatchType,
305  class Type,
306  class TrackingData = int
307 >
308 class transformOp
309 {
310  //- Additional data to be passed into container
311  const polyMesh& mesh_;
312  const PrimitivePatchType& patch_;
313  const scalar tol_;
314  TrackingData& td_;
315 
316 public:
318  (
319  const polyMesh& mesh,
320  const PrimitivePatchType& patch,
321  const scalar tol,
322  TrackingData& td
323  )
324  :
325  mesh_(mesh),
326  patch_(patch),
327  tol_(tol),
328  td_(td)
329  {}
330 
331  void operator()
332  (
333  const vectorTensorTransform& vt,
334  const bool forward,
335  List<Type>& fld
336  ) const
337  {
338  if (forward)
339  {
340  forAll(fld, i)
341  {
342  fld[i].transform(mesh_, patch_, vt.R(), tol_, td_);
343  }
344  }
345  else
346  {
347  forAll(fld, i)
348  {
349  fld[i].transform(mesh_, patch_, vt.R().T(), tol_, td_);
350  }
351  }
352  }
353 };
354 
355 } // End namespace Foam
356 
357 
358 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
359 
360 #ifdef NoRepository
361 # include "PatchEdgeFaceWave.C"
362 #endif
363 
364 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
365 
366 #endif
367 
368 // ************************************************************************* //
UList< Type > & allFaceInfo() const
Access allFaceInfo.
A bit-packed bool list.
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
dynamicFvMesh & mesh
Namespace for OpenFOAM.
Update operation.
Transform operation.
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
label edgeToFace()
Propagate from edge to face. Returns total number of faces.
#define forAll(list, i)
Definition: UList.H:421
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 setEdgeInfo(const labelList &changedEdges, const List< Type > &changedEdgesInfo)
Copy initial data into allEdgeInfo_.
const TrackingData & data() const
Additional data to be passed into container.
Vector-tensor class used to perform translations and rotations in 3D space.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
scalar y
label getUnsetFaces() const
Get number of unvisited faces, i.e. faces that were not (yet)
static void setPropagationTol(const scalar tol)
Change tolerance.
UList< Type > & allEdgeInfo() const
Access allEdgeInfo.
TemplateName(blendedSchemeBase)
static scalar propagationTol()
Access to tolerance.
label faceToEdge()
Propagate from face to edge. Returns total number of edges.