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 
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 
126  // Protected member functions
127 
128  //- ...
129  const Type& faceInfo(const labelPair& patchAndFacei) const;
130 
131  //- ...
132  Type& faceInfo(const labelPair& patchAndFacei);
133 
134  //- ...
135  bool faceChanged(const labelPair& patchAndFacei) const;
136 
137  //- ...
138  PackedBoolList::iteratorBase faceChanged(const labelPair&);
139 
140  //- Updates cellInfo with information from neighbour. Updates all
141  // statistics.
142  bool updateCell
143  (
144  const label celli,
145  const labelPair& neighbourPatchAndFacei,
146  const Type& neighbourInfo,
147  const scalar tol,
148  Type& cellInfo
149  );
150 
151  //- Updates faceInfo with information from neighbour. Updates all
152  // statistics.
153  bool updateFace
154  (
155  const labelPair& patchAndFacei,
156  const label neighbourCelli,
157  const Type& neighbourInfo,
158  const scalar tol,
159  Type& faceInfo
160  );
161 
162  //- Updates faceInfo with information from same face. Updates all
163  // statistics.
164  bool updateFace
165  (
166  const labelPair& patchAndFacei,
167  const Type& neighbourInfo,
168  const scalar tol,
169  Type& faceInfo
170  );
171 
172 
173  // Parallel, cyclic
174 
175  //- Debugging: check info on both sides of cyclic
176  void checkCyclic(const fvPatch& patch) const;
177 
178  //- Has cyclic patch?
179  template<class PatchType>
180  bool hasPatch() const;
181 
182  //- Merge received patch data into global data
183  void mergeFaceInfo
184  (
185  const fvPatch& patch,
186  const label nFaces,
187  const labelList&,
188  const List<Type>&
189  );
190 
191  //- Extract info for single patch only
193  (
194  const fvPatch& patch,
195  labelList& changedPatchFaces,
196  List<Type>& changedPatchFacesInfo
197  ) const;
198 
199  //- Transform across an interface
200  void transform
201  (
202  const fvPatch& patch,
203  const label nFaces,
204  const labelList& patchFaces,
205  const transformer& transform,
207  );
208 
209  //- Merge data from across processor boundaries
210  void handleProcPatches();
211 
212  //- Merge data from across cyclics
213  void handleCyclicPatches();
214 
215 
216 public:
217 
218  // Static Data
219 
220  //- Default tracking data to go with default template argument
221  static int defaultTrackingData_;
222 
223 
224  // Static Functions
225 
226  //- Access to tolerance
227  static scalar propagationTol()
228  {
229  return propagationTol_;
230  }
231 
232  //- Change tolerance
233  static void setPropagationTol(const scalar tol)
234  {
235  propagationTol_ = tol;
236  }
237 
238  //- ...
239  template<class ListList>
240  static labelList listListSizes(const ListList& ll);
241 
242  //- ...
243  template<class ListList, class Value>
244  static ListList sizesListList(const labelList& s, const Value& value);
245 
246 
247  // Constructors
248 
249  // Construct from mesh. Use setFaceInfo and iterate() to do actual
250  // calculation.
252  (
253  const fvMesh& mesh,
257  TrackingData& td = defaultTrackingData_
258  );
259 
260  //- Construct from mesh and list of changed faces with the Type
261  // for these faces. Iterates until nothing changes or maxIter reached.
262  // (maxIter can be 0)
264  (
265  const fvMesh& mesh,
266  const List<labelPair>& initialChangedPatchAndFaces,
267  const List<Type>& initialChangedFacesInfo,
271  const label maxIter,
272  TrackingData& td = defaultTrackingData_
273  );
274 
275  //- Disallow default bitwise copy construction
276  FvFaceCellWave(const FvFaceCellWave&) = delete;
277 
278 
279  //- Destructor
280  virtual ~FvFaceCellWave()
281  {}
282 
283 
284  // Member Functions
285 
286  // Access
287 
288  //- Access internalFaceInfo
290  {
291  return internalFaceInfo_;
292  }
293 
294  //- Access patchFaceInfo
296  {
297  return patchFaceInfo_;
298  }
299 
300  //- Access cellInfo
302  {
303  return cellInfo_;
304  }
305 
306  //- Additional data to be passed into container
307  const TrackingData& data() const
308  {
309  return td_;
310  }
311 
312  //- Additional data to be passed into container
313  TrackingData& data()
314  {
315  return td_;
316  }
317 
318  //- Access mesh
319  const fvMesh& mesh() const
320  {
321  return mesh_;
322  }
323 
324 
325  // Edit
326 
327  //- Set initial changed faces
328  void setFaceInfo
329  (
330  const List<labelPair>& changedPatchAndFaces,
331  const List<Type>& changedFacesInfo
332  );
333 
334  //- Propagate from face to cell. Returns total number of cells
335  // (over all processors) changed.
336  virtual label faceToCell();
337 
338  //- Propagate from cell to face. Returns total number of faces
339  // (over all processors) changed. (Faces on processorpatches are
340  // counted double)
341  virtual label cellToFace();
342 
343  //- Iterate until no changes or maxIter reached. Returns actual
344  // number of iterations.
345  virtual label iterate(const label maxIter);
346 
347 
348  // Member Operators
349 
350  //- Disallow default bitwise assignment
351  void operator=(const FvFaceCellWave&) = delete;
352 };
353 
354 
355 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
356 
357 } // End namespace Foam
358 
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 #ifdef NoRepository
363  #include "FvFaceCellWave.C"
364 #endif
365 
366 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
367 
368 #endif
369 
370 // ************************************************************************* //
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:78
Wave propagation of information through grid. Every iteration information goes through one layer of c...
DynamicList< labelPair > changedPatchAndFaces_
List of changed patch and faces.
PackedBoolList cellChanged_
Has cell changed?
List< List< Type > > & patchFaceInfo_
Information for patch faces.
DynamicList< label > changedCells_
List of changed cells.
void setFaceInfo(const List< labelPair > &changedPatchAndFaces, const List< Type > &changedFacesInfo)
Set initial changed faces.
void mergeFaceInfo(const fvPatch &patch, const label nFaces, const labelList &, const List< Type > &)
Merge received patch data into global data.
const fvMesh & mesh_
Reference to mesh.
label getChangedPatchFaces(const fvPatch &patch, labelList &changedPatchFaces, List< Type > &changedPatchFacesInfo) const
Extract info for single patch only.
void handleProcPatches()
Merge data from across processor boundaries.
const TrackingData & data() const
Additional data to be passed into container.
static labelList listListSizes(const ListList &ll)
...
bool updateFace(const labelPair &patchAndFacei, const label neighbourCelli, const Type &neighbourInfo, const scalar tol, Type &faceInfo)
Updates faceInfo with information from neighbour. Updates all.
List< PackedBoolList > patchFaceChanged_
Has patch face changed?
const fvMesh & mesh() const
Access mesh.
static scalar propagationTol()
Access to tolerance.
static scalar propagationTol_
...
PackedBoolList internalFaceChanged_
Has internal face changed?
bool hasPatch() const
Has cyclic patch?
TrackingData & td_
Additional data to be passed into container.
void checkCyclic(const fvPatch &patch) const
Debugging: check info on both sides of cyclic.
const Type & faceInfo(const labelPair &patchAndFacei) const
...
static const scalar geomTol_
...
bool faceChanged(const labelPair &patchAndFacei) const
...
static int defaultTrackingData_
Default tracking data to go with default template argument.
void transform(const fvPatch &patch, const label nFaces, const labelList &patchFaces, const transformer &transform, List< Type > &faceInfo)
Transform across an interface.
virtual label iterate(const label maxIter)
Iterate until no changes or maxIter reached. Returns actual.
void handleCyclicPatches()
Merge data from across cyclics.
FvFaceCellWave(const fvMesh &mesh, List< Type > &internalFaceInfo, List< List< Type >> &patchFaceInfo, List< Type > &cellInfo, TrackingData &td=defaultTrackingData_)
static ListList sizesListList(const labelList &s, const Value &value)
...
bool updateCell(const label celli, const labelPair &neighbourPatchAndFacei, const Type &neighbourInfo, const scalar tol, Type &cellInfo)
Updates cellInfo with information from neighbour. Updates all.
List< Type > & cellInfo()
Access cellInfo.
virtual label faceToCell()
Propagate from face to cell. Returns total number of cells.
List< Type > & internalFaceInfo_
Information for internal faces.
List< List< Type > > & patchFaceInfo()
Access patchFaceInfo.
virtual ~FvFaceCellWave()
Destructor.
List< Type > & cellInfo_
Information for all cells.
virtual label cellToFace()
Propagate from cell to face. Returns total number of faces.
List< Type > & internalFaceInfo()
Access internalFaceInfo.
void operator=(const FvFaceCellWave &)=delete
Disallow default bitwise assignment.
static void setPropagationTol(const scalar tol)
Change tolerance.
const bool hasCyclicPatches_
Contains cyclics.
A bit-packed bool list.
Holds information regarding type of cell. Used in inside/outside determination in cellClassification.
Definition: cellInfo.H:67
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:101
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
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.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Namespace for OpenFOAM.
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
TemplateName(FvFaceCellWave)
Foam::surfaceFields.