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
96 
97  //- Information on all patch faces
99 
100  //- Additional data to be passed into container
101  TrackingData& td_;
102 
103  //- Has edge changed
105 
106  //- List of changed edges
108 
109  //- Has face changed
111 
112  //- List of changed faces
114 
115  //- Number of evaluations
116  label nEvals_;
117 
118  //- Number of unvisited faces/edges
121 
122 
123  // Addressing between edges of patch_ and globalData.coupledPatch()
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,
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  {}
290 
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 // ************************************************************************* //
Foam::PatchEdgeFaceWave::allEdgeInfo
UList< Type > & allEdgeInfo() const
Access allEdgeInfo.
Definition: PatchEdgeFaceWave.H:211
Foam::updateOp
Update operation.
Definition: PatchEdgeFaceWave.H:267
Foam::PatchEdgeFaceWave::changedFaces_
DynamicList< label > changedFaces_
List of changed faces.
Definition: PatchEdgeFaceWave.H:112
Foam::PackedBoolList
A bit-packed bool list.
Definition: PackedBoolList.H:63
Foam::PatchEdgeFaceWave::nUnvisitedFaces_
label nUnvisitedFaces_
Definition: PatchEdgeFaceWave.H:119
Foam::PatchEdgeFaceWave::syncEdges
void syncEdges()
Update coupled edges.
Definition: PatchEdgeFaceWave.C:170
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
scalarField.H
Foam::updateOp::patch_
const PrimitivePatchType & patch_
Definition: PatchEdgeFaceWave.H:271
Foam::DynamicList< label >
Foam::vectorTensorTransform::R
const tensor & R() const
Definition: vectorTensorTransformI.H:73
Foam::transformOp
Transform operation.
Definition: PatchEdgeFaceWave.H:307
Foam::PatchEdgeFaceWave::updateEdge
bool updateEdge(const label edgeI, const label neighbourFaceI, const Type &neighbourInfo, Type &edgeInfo)
Updates edgeInfo with information from neighbour. Updates all.
Definition: PatchEdgeFaceWave.C:68
Foam::transformOp::td_
TrackingData & td_
Definition: PatchEdgeFaceWave.H:313
Foam::PatchEdgeFaceWave
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
Definition: PatchEdgeFaceWave.H:69
Foam::PatchEdgeFaceWave::allEdgeInfo_
UList< Type > & allEdgeInfo_
Wall information for all edges.
Definition: PatchEdgeFaceWave.H:94
Foam::PatchEdgeFaceWave::PatchEdgeFaceWave
PatchEdgeFaceWave(const PatchEdgeFaceWave &)
Disallow default bitwise copy construct.
Foam::PatchEdgeFaceWave::faceToEdge
label faceToEdge()
Propagate from face to edge. Returns total number of edges.
Definition: PatchEdgeFaceWave.C:491
Foam::PatchEdgeFaceWave::updateFace
bool updateFace(const label faceI, const label neighbourEdgeI, const Type &neighbourInfo, Type &faceInfo)
Updates faceInfo with information from neighbour. Updates all.
Definition: PatchEdgeFaceWave.C:122
Foam::PatchEdgeFaceWave::propagationTol_
static scalar propagationTol_
Relative tolerance. Stop propagation if relative changes.
Definition: PatchEdgeFaceWave.H:78
Foam::PatchEdgeFaceWave::nUnvisitedEdges_
label nUnvisitedEdges_
Number of unvisited faces/edges.
Definition: PatchEdgeFaceWave.H:118
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::PatchEdgeFaceWave::changedFace_
PackedBoolList changedFace_
Has face changed.
Definition: PatchEdgeFaceWave.H:109
Foam::PatchEdgeFaceWave::allFaceInfo
UList< Type > & allFaceInfo() const
Access allFaceInfo.
Definition: PatchEdgeFaceWave.H:217
Foam::updateOp::mesh_
const polyMesh & mesh_
Additional data to be passed into container.
Definition: PatchEdgeFaceWave.H:270
Foam::PatchEdgeFaceWave::patchEdges_
labelList patchEdges_
Definition: PatchEdgeFaceWave.H:123
Foam::label
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
Foam::PatchEdgeFaceWave::coupledEdges_
labelList coupledEdges_
Definition: PatchEdgeFaceWave.H:124
Foam::transformOp::tol_
const scalar tol_
Definition: PatchEdgeFaceWave.H:312
PrimitivePatch.H
Foam::PatchEdgeFaceWave::td_
TrackingData & td_
Additional data to be passed into container.
Definition: PatchEdgeFaceWave.H:100
Foam::PatchEdgeFaceWave::propagationTol
static scalar propagationTol()
Access to tolerance.
Definition: PatchEdgeFaceWave.H:165
PackedBoolList.H
Foam::transformOp::mesh_
const polyMesh & mesh_
Additional data to be passed into container.
Definition: PatchEdgeFaceWave.H:310
PatchEdgeFaceWave.C
Foam::PatchEdgeFaceWave::edgeToFace
label edgeToFace()
Propagate from edge to face. Returns total number of faces.
Definition: PatchEdgeFaceWave.C:554
Foam::TemplateName
TemplateName(blendedSchemeBase)
Foam::transformOp::patch_
const PrimitivePatchType & patch_
Definition: PatchEdgeFaceWave.H:311
Foam::PatchEdgeFaceWave::getUnsetFaces
label getUnsetFaces() const
Get number of unvisited faces, i.e. faces that were not (yet)
Definition: PatchEdgeFaceWave.C:437
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
fld
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))
Foam::PatchEdgeFaceWave::dummyTrackData_
static label dummyTrackData_
Used as default trackdata value to satisfy default template.
Definition: PatchEdgeFaceWave.H:82
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::updateOp::tol_
const scalar tol_
Definition: PatchEdgeFaceWave.H:272
Foam::PatchEdgeFaceWave::setEdgeInfo
void setEdgeInfo(const labelList &changedEdges, const List< Type > &changedEdgesInfo)
Copy initial data into allEdgeInfo_.
Definition: PatchEdgeFaceWave.C:452
Foam::PatchEdgeFaceWave::changedEdges_
DynamicList< label > changedEdges_
List of changed edges.
Definition: PatchEdgeFaceWave.H:106
Foam::PatchEdgeFaceWave::patch_
const PrimitivePatchType & patch_
Reference to patch.
Definition: PatchEdgeFaceWave.H:91
Foam::PatchEdgeFaceWave::operator=
void operator=(const PatchEdgeFaceWave &)
Disallow default bitwise assignment.
Foam::PatchEdgeFaceWave::nEvals_
label nEvals_
Number of evaluations.
Definition: PatchEdgeFaceWave.H:115
Foam::PatchEdgeFaceWave::mesh_
const polyMesh & mesh_
Reference to mesh.
Definition: PatchEdgeFaceWave.H:88
Foam::PatchEdgeFaceWave::changedEdge_
PackedBoolList changedEdge_
Has edge changed.
Definition: PatchEdgeFaceWave.H:103
Foam::PatchEdgeFaceWave::allFaceInfo_
UList< Type > & allFaceInfo_
Information on all patch faces.
Definition: PatchEdgeFaceWave.H:97
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::vectorTensorTransform
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: vectorTensorTransform.H:61
Foam::UList< Type >
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::PatchEdgeFaceWave::setPropagationTol
static void setPropagationTol(const scalar tol)
Change tolerance.
Definition: PatchEdgeFaceWave.H:171
Foam::transformOp::transformOp
transformOp(const polyMesh &mesh, const PrimitivePatchType &patch, const scalar tol, TrackingData &td)
Definition: PatchEdgeFaceWave.H:317
Foam::PatchEdgeFaceWave::iterate
label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
Definition: PatchEdgeFaceWave.C:616
Foam::updateOp::td_
TrackingData & td_
Definition: PatchEdgeFaceWave.H:273
vectorTensorTransform.H
Foam::PatchEdgeFaceWave::data
const TrackingData & data() const
Additional data to be passed into container.
Definition: PatchEdgeFaceWave.H:223
Foam::updateOp::operator()
void operator()(Type &x, const Type &y) const
Definition: PatchEdgeFaceWave.H:290
Foam::updateOp::updateOp
updateOp(const polyMesh &mesh, const PrimitivePatchType &patch, const scalar tol, TrackingData &td)
Definition: PatchEdgeFaceWave.H:277
Foam::PatchEdgeFaceWave::sameEdgeOrientation_
PackedBoolList sameEdgeOrientation_
Definition: PatchEdgeFaceWave.H:125
Foam::PatchEdgeFaceWave::getUnsetEdges
label getUnsetEdges() const
Definition: PatchEdgeFaceWave.C:424
y
scalar y
Definition: LISASMDCalcMethod1.H:14
Foam::Tensor::T
Tensor< Cmpt > T() const
Transpose.
Definition: TensorI.H:286