FvFaceCellWave.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-2022 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::FvFaceCellWave
26 
27 Description
28  Wave propagation of information through grid. Every iteration
29  information goes through one layer of cells. Templated on information
30  that is transferred.
31 
32  Handles parallel and cyclics and non-parallel cyclics.
33 
34  Note: whether to propagate depends on the return value of Type::update
35  which returns true (i.e. propagate) if the value changes by more than a
36  certain tolerance.
37  This tolerance can be very strict for normal face-cell and parallel
38  cyclics (we use a value of 0.01 just to limit propagation of small changes)
39  but for non-parallel cyclics this tolerance can be critical and if chosen
40  too small can lead to non-convergence.
41 
42 SourceFiles
43  FvFaceCellWave.C
44 
45 \*---------------------------------------------------------------------------*/
46 
47 #ifndef FvFaceCellWave_H
48 #define FvFaceCellWave_H
49 
50 #include "volFields.H"
51 #include "surfaceFields.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // Forward declaration of classes
59 class fvMesh;
60 class fvPatch;
61 class transformer;
62 
63 /*---------------------------------------------------------------------------*\
64  Class FvFaceCellWaveName Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 TemplateName(FvFaceCellWave);
68 
69 
70 /*---------------------------------------------------------------------------*\
71  Class FvFaceCellWave Declaration
72 \*---------------------------------------------------------------------------*/
73 
74 template<class Type, class TrackingData = int>
75 class FvFaceCellWave
76 :
77  public FvFaceCellWaveName
78 {
79 protected:
80 
81  // Protected static data
82 
83  //- ...
84  static const scalar geomTol_;
85 
86  //- ...
87  static scalar propagationTol_;
88 
89 
90  // Protected data
91 
92  //- Reference to mesh
93  const fvMesh& mesh_;
94 
95  //- Information for internal faces
97 
98  //- Information for patch faces
100 
101  //- Information for all cells
103 
104  //- Additional data to be passed into container
105  TrackingData& td_;
106 
107  //- Has internal face changed?
109 
110  //- Has patch face changed?
112 
113  //- Has cell changed?
115 
116  //- List of changed patch and faces
118 
119  //- List of changed cells
121 
122  //- Contains cyclics
123  const bool hasCyclicPatches_;
124 
125  //- Contains cyclicAMI
126  const bool hasCyclicAMIPatches_;
127 
128 
129  // Protected member functions
130 
131  //- ...
132  const Type& faceInfo(const labelPair& patchAndFacei) const;
133 
134  //- ...
135  Type& faceInfo(const labelPair& patchAndFacei);
136 
137  //- ...
138  bool faceChanged(const labelPair& patchAndFacei) const;
139 
140  //- ...
141  PackedBoolList::iteratorBase faceChanged(const labelPair&);
142 
143  //- Updates cellInfo with information from neighbour. Updates all
144  // statistics.
145  bool updateCell
146  (
147  const label celli,
148  const labelPair& neighbourPatchAndFacei,
149  const Type& neighbourInfo,
150  const scalar tol,
151  Type& cellInfo
152  );
153 
154  //- Updates faceInfo with information from neighbour. Updates all
155  // statistics.
156  bool updateFace
157  (
158  const labelPair& patchAndFacei,
159  const label neighbourCelli,
160  const Type& neighbourInfo,
161  const scalar tol,
162  Type& faceInfo
163  );
164 
165  //- Updates faceInfo with information from same face. Updates all
166  // statistics.
167  bool updateFace
168  (
169  const labelPair& patchAndFacei,
170  const Type& neighbourInfo,
171  const scalar tol,
172  Type& faceInfo
173  );
174 
175 
176  // Parallel, cyclic
177 
178  //- Debugging: check info on both sides of cyclic
179  void checkCyclic(const fvPatch& patch) const;
180 
181  //- Has cyclic patch?
182  template<class PatchType>
183  bool hasPatch() const;
184 
185  //- Merge received patch data into global data
186  void mergeFaceInfo
187  (
188  const fvPatch& patch,
189  const label nFaces,
190  const labelList&,
191  const List<Type>&
192  );
193 
194  //- Extract info for single patch only
196  (
197  const fvPatch& patch,
198  labelList& changedPatchFaces,
199  List<Type>& changedPatchFacesInfo
200  ) const;
201 
202  //- Transform across an interface
203  void transform
204  (
205  const fvPatch& patch,
206  const label nFaces,
207  const labelList& patchFaces,
208  const transformer& transform,
210  );
211 
212  //- Merge data from across processor boundaries
213  void handleProcPatches();
214 
215  //- Merge data from across cyclics
216  void handleCyclicPatches();
217 
218  //- Merge data from across AMI cyclics
219  void handleCyclicAMIPatches();
220 
221 
222 public:
223 
224  // Static Data
225 
226  //- Default tracking data to go with default template argument
227  static int defaultTrackingData_;
228 
229 
230  // Static Functions
231 
232  //- Access to tolerance
233  static scalar propagationTol()
234  {
235  return propagationTol_;
236  }
237 
238  //- Change tolerance
239  static void setPropagationTol(const scalar tol)
240  {
241  propagationTol_ = tol;
242  }
243 
244  //- ...
245  template<class ListList>
246  static labelList listListSizes(const ListList& ll);
247 
248  //- ...
249  template<class ListList, class Value>
250  static ListList sizesListList(const labelList& s, const Value& value);
251 
252 
253  // Constructors
254 
255  // Construct from mesh. Use setFaceInfo and iterate() to do actual
256  // calculation.
258  (
259  const fvMesh& mesh,
263  TrackingData& td = defaultTrackingData_
264  );
265 
266  //- Construct from mesh and list of changed faces with the Type
267  // for these faces. Iterates until nothing changes or maxIter reached.
268  // (maxIter can be 0)
270  (
271  const fvMesh& mesh,
272  const List<labelPair>& initialChangedPatchAndFaces,
273  const List<Type>& initialChangedFacesInfo,
274  List<Type>& internalFaceInfo,
276  List<Type>& cellInfo,
277  const label maxIter,
278  TrackingData& td = defaultTrackingData_
279  );
280 
281  //- Disallow default bitwise copy construction
282  FvFaceCellWave(const FvFaceCellWave&) = delete;
283 
284 
285  //- Destructor
286  virtual ~FvFaceCellWave()
287  {}
288 
289 
290  // Member Functions
291 
292  // Access
293 
294  //- Access internalFaceInfo
296  {
297  return internalFaceInfo_;
298  }
299 
300  //- Access patchFaceInfo
302  {
303  return patchFaceInfo_;
304  }
305 
306  //- Access cellInfo
308  {
309  return cellInfo_;
310  }
311 
312  //- Additional data to be passed into container
313  const TrackingData& data() const
314  {
315  return td_;
316  }
317 
318  //- Additional data to be passed into container
319  TrackingData& data()
320  {
321  return td_;
322  }
323 
324  //- Access mesh
325  const fvMesh& mesh() const
326  {
327  return mesh_;
328  }
329 
330 
331  // Edit
332 
333  //- Set initial changed faces
334  void setFaceInfo
335  (
336  const List<labelPair>& changedPatchAndFaces,
337  const List<Type>& changedFacesInfo
338  );
339 
340  //- Propagate from face to cell. Returns total number of cells
341  // (over all processors) changed.
342  virtual label faceToCell();
343 
344  //- Propagate from cell to face. Returns total number of faces
345  // (over all processors) changed. (Faces on processorpatches are
346  // counted double)
347  virtual label cellToFace();
348 
349  //- Iterate until no changes or maxIter reached. Returns actual
350  // number of iterations.
351  virtual label iterate(const label maxIter);
352 
353 
354  // Member Operators
355 
356  //- Disallow default bitwise assignment
357  void operator=(const FvFaceCellWave&) = delete;
358 };
359 
360 
361 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
362 
363 } // End namespace Foam
364 
365 
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 
368 #ifdef NoRepository
369  #include "FvFaceCellWave.C"
370 #endif
371 
372 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
373 
374 #endif
375 
376 // ************************************************************************* //
Foam::surfaceFields.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space...
Definition: transformer.H:83
List< Type > & cellInfo()
Access cellInfo.
List< PackedBoolList > patchFaceChanged_
Has patch face changed?
static const scalar geomTol_
...
const TrackingData & data() const
Additional data to be passed into container.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
static scalar propagationTol()
Access to tolerance.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification...
Definition: cellInfo.H:66
static labelList listListSizes(const ListList &ll)
...
bool updateCell(const label celli, const labelPair &neighbourPatchAndFacei, const Type &neighbourInfo, const scalar tol, Type &cellInfo)
Updates cellInfo with information from neighbour. Updates all.
static int defaultTrackingData_
Default tracking data to go with default template argument.
void handleCyclicAMIPatches()
Merge data from across AMI cyclics.
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){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
An ordered pair of two objects of type <T> with first() and second() elements.
Definition: contiguous.H:49
TrackingData & td_
Additional data to be passed into container.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Definition: DynamicList.H:56
const fvMesh & mesh_
Reference to mesh.
List< Type > & cellInfo_
Information for all cells.
TemplateName(FvFaceCellWave)
bool hasPatch() const
Has cyclic patch?
DynamicList< label > changedCells_
List of changed cells.
List< List< Type > > & patchFaceInfo()
Access patchFaceInfo.
void handleCyclicPatches()
Merge data from across cyclics.
label getChangedPatchFaces(const fvPatch &patch, labelList &changedPatchFaces, List< Type > &changedPatchFacesInfo) const
Extract info for single patch only.
List< Type > & internalFaceInfo()
Access internalFaceInfo.
void setFaceInfo(const List< labelPair > &changedPatchAndFaces, const List< Type > &changedFacesInfo)
Set initial changed faces.
static ListList sizesListList(const labelList &s, const Value &value)
...
void handleProcPatches()
Merge data from across processor boundaries.
bool updateFace(const labelPair &patchAndFacei, const label neighbourCelli, const Type &neighbourInfo, const scalar tol, Type &faceInfo)
Updates faceInfo with information from neighbour. Updates all.
FvFaceCellWave(const fvMesh &mesh, List< Type > &internalFaceInfo, List< List< Type >> &patchFaceInfo, List< Type > &cellInfo, TrackingData &td=defaultTrackingData_)
List< List< Type > > & patchFaceInfo_
Information for patch faces.
void mergeFaceInfo(const fvPatch &patch, const label nFaces, const labelList &, const List< Type > &)
Merge received patch data into global data.
const bool hasCyclicPatches_
Contains cyclics.
virtual label cellToFace()
Propagate from cell to face. Returns total number of faces.
A bit-packed bool list.
static void setPropagationTol(const scalar tol)
Change tolerance.
const bool hasCyclicAMIPatches_
Contains cyclicAMI.
void transform(const fvPatch &patch, const label nFaces, const labelList &patchFaces, const transformer &transform, List< Type > &faceInfo)
Transform across an interface.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
DynamicList< labelPair > changedPatchAndFaces_
List of changed patch and faces.
const Type & faceInfo(const labelPair &patchAndFacei) const
...
virtual label faceToCell()
Propagate from face to cell. Returns total number of cells.
const fvMesh & mesh() const
Access mesh.
void checkCyclic(const fvPatch &patch) const
Debugging: check info on both sides of cyclic.
List< Type > & internalFaceInfo_
Information for internal faces.
void operator=(const FvFaceCellWave &)=delete
Disallow default bitwise assignment.
PackedBoolList internalFaceChanged_
Has internal face changed?
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
PackedBoolList cellChanged_
Has cell changed?
virtual ~FvFaceCellWave()
Destructor.
static scalar propagationTol_
...
bool faceChanged(const labelPair &patchAndFacei) const
...
Namespace for OpenFOAM.