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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::PatchEdgeFaceWave
29 
30 Description
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 
35 SourceFiles
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"
46 #include "vectorTensorTransform.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 // Forward Declarations
54 class polyMesh;
55 
56 /*---------------------------------------------------------------------------*\
57  Class PatchEdgeFaceWaveName Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 TemplateName(PatchEdgeFaceWave);
61 
62 
63 /*---------------------------------------------------------------------------*\
64  Class PatchEdgeFaceWave Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 template
68 <
69  class PrimitivePatchType,
70  class Type,
71  class TrackingData = label
72 >
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 
163 public:
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  }
243 
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
273 template
274 <
275  class PrimitivePatchType,
276  class Type,
277  class TrackingData = int
278 >
279 class 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 
287 public:
288 
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  {}
302 
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
314 template
315 <
316  class PrimitivePatchType,
317  class Type,
318  class TrackingData = int
319 >
320 class 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 
328 public:
329 
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  {}
343 
344  void operator()
345  (
346  const vectorTensorTransform& vt,
347  const bool forward,
348  List<Type>& fld
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 // ************************************************************************* //
Foam::PatchEdgeFaceWave::allEdgeInfo
UList< Type > & allEdgeInfo() const
Access allEdgeInfo.
Definition: PatchEdgeFaceWave.H:214
Foam::updateOp
Update operation.
Definition: PatchEdgeFaceWave.H:278
Foam::bitSet
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:63
scalarField.H
Foam::DynamicList< label >
Foam::transformOp
Transform operation.
Definition: PatchEdgeFaceWave.H:319
Foam::PatchEdgeFaceWave
Wave propagation of information along patch. Every iteration information goes through one layer of fa...
Definition: PatchEdgeFaceWave.H:72
Foam::PatchEdgeFaceWave::faceToEdge
label faceToEdge()
Propagate from face to edge.
Definition: PatchEdgeFaceWave.C:466
Foam::PatchEdgeFaceWave::nUnvisitedFaces
label nUnvisitedFaces() const
Definition: PatchEdgeFaceWave.H:238
bitSet.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::PatchEdgeFaceWave::allFaceInfo
UList< Type > & allFaceInfo() const
Access allFaceInfo.
Definition: PatchEdgeFaceWave.H:220
PrimitivePatch.H
Foam::PatchEdgeFaceWave::propagationTol
static scalar propagationTol()
Access to tolerance.
Definition: PatchEdgeFaceWave.H:167
PatchEdgeFaceWave.C
Foam::PatchEdgeFaceWave::edgeToFace
label edgeToFace()
Propagate from edge to face.
Definition: PatchEdgeFaceWave.C:529
Foam::TemplateName
TemplateName(blendedSchemeBase)
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::PatchEdgeFaceWave::setEdgeInfo
void setEdgeInfo(const labelList &changedEdges, const List< Type > &changedEdgesInfo)
Copy initial data into allEdgeInfo_.
Definition: PatchEdgeFaceWave.C:427
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::PatchEdgeFaceWave::nUnvisitedEdges
label nUnvisitedEdges() const
Definition: PatchEdgeFaceWave.H:243
Foam::vectorTensorTransform
Vector-tensor class used to perform translations and rotations in 3D space.
Definition: vectorTensorTransform.H:63
Foam::vectorTensorTransform::R
const tensor & R() const
Definition: vectorTensorTransformI.H:75
Foam::UList< Type >
x
x
Definition: LISASMDCalcMethod2.H:52
Foam::Tensor::T
Tensor< Cmpt > T() const
Return non-Hermitian transpose.
Definition: TensorI.H:504
Foam::PatchEdgeFaceWave::setPropagationTol
static void setPropagationTol(const scalar tol)
Change tolerance.
Definition: PatchEdgeFaceWave.H:173
Foam::transformOp::transformOp
transformOp(const polyMesh &mesh, const PrimitivePatchType &patch, const scalar tol, TrackingData &td)
Definition: PatchEdgeFaceWave.H:330
Foam::PatchEdgeFaceWave::iterate
label iterate(const label maxIter)
Iterate until no changes or maxIter reached.
Definition: PatchEdgeFaceWave.C:591
vectorTensorTransform.H
Foam::PatchEdgeFaceWave::data
const TrackingData & data() const
Additional data to be passed into container.
Definition: PatchEdgeFaceWave.H:226
Foam::updateOp::operator()
void operator()(Type &x, const Type &y) const
Definition: PatchEdgeFaceWave.H:302
Foam::updateOp::updateOp
updateOp(const polyMesh &mesh, const PrimitivePatchType &patch, const scalar tol, TrackingData &td)
Definition: PatchEdgeFaceWave.H:289
y
scalar y
Definition: LISASMDCalcMethod1.H:14