dynamicOversetFvMesh.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) 2015-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::dynamicOversetFvMesh
28 
29 Description
30  dynamicFvMesh with support for overset meshes.
31 
32 SourceFiles
33  dynamicOversetFvMesh.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef dynamicOversetFvMesh_H
38 #define dynamicOversetFvMesh_H
39 
41 #include "labelIOList.H"
44 #include "volFields.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 class mapDistribute;
52 class lduPrimitiveProcessorInterface;
53 class GAMGAgglomeration;
54 
55 /*---------------------------------------------------------------------------*\
56  Class dynamicOversetFvMesh Declaration
57 \*---------------------------------------------------------------------------*/
58 
60 :
62 {
63 protected:
64 
65  // Protected data
66 
67  //- Select base addressing (false) or locally stored extended
68  // lduAddressing (true)
69  mutable bool active_;
70 
71  //- Extended addressing (extended with local interpolation stencils)
73 
74  //- Added (processor)lduInterfaces for remote bits of stencil.
75  //PtrList<const lduInterface> remoteStencilInterfaces_;
78 
79  //- Interfaces for above mesh. Contains both original and
80  // above added processorLduInterfaces
82 
83  //- Corresponding faces (in above lduPtr) to the stencil
85 
86  //- Corresponding patches (in above lduPtr) to the stencil
88 
89  //- From old to new face labels
90  mutable labelList reverseFaceMap_;
91 
92 
93  // Protected Member Functions
94 
95  //- Calculate the extended lduAddressing
96  virtual bool updateAddressing() const;
97 
98  //- Debug: print matrix
99  template<class Type>
100  void write
101  (
102  Ostream&,
103  const fvMatrix<Type>&,
104  const lduAddressing&,
105  const lduInterfacePtrsList&
106  ) const;
107 
108  //- Explicit interpolation of acceptor cells from donor cells
109  template<class T>
110  void interpolate(Field<T>& psi) const;
111 
112  //- Explicit interpolation of acceptor cells from donor cells with
113  // boundary condition handling
114  template<class GeoField>
115  void interpolate(GeoField& psi) const;
116 
117  //- Helper: strip off trailing _0
118  static word baseName(const word& name);
119 
120  //- Explicit interpolation of all registered fields. Excludes
121  // selected fields (and their old-time fields)
122  template<class GeoField>
123  void interpolate(const wordHashSet& suppressed);
124 
125  //- Freeze values at holes
126  //template<class Type>
127  //void freezeHoles(fvMatrix<Type>&) const;
128 
129  //- Get scalar interfaces of certain type
130  //template<class GeoField, class PatchType>
131  //lduInterfaceFieldPtrsList scalarInterfaces(const GeoField& psi) const;
132 
133  //- Determine normalisation for interpolation. This equals the
134  // original diagonal except stabilised for zero diagonals (possible
135  // in hole cells)
136  template<class Type>
138 
139  //- Add interpolation to matrix (coefficients)
140  template<class Type>
141  void addInterpolation(fvMatrix<Type>&, const scalarField& norm) const;
142 
143  //- Solve given dictionary with settings
144  template<class Type>
146 
147  //- Debug: correct coupled bc
148  template<class GeoField>
149  static void correctCoupledBoundaryConditions(GeoField& fld);
150 
151  //- Average norm of valid neighbours
152  scalar cellAverage
153  (
154  const labelList& types,
155  const labelList& nbrTypes,
156  const scalarField& norm,
157  const scalarField& nbrNorm,
158  const label celli,
159  bitSet& isFront
160  ) const;
161 
162  //- Debug: dump agglomeration
163  void writeAgglomeration
164  (
165  const GAMGAgglomeration& agglom
166  ) const;
167 
168 
169 private:
170 
171  // Private Member Functions
172 
173  //- No copy construct
175 
176  //- No copy assignment
177  void operator=(const dynamicOversetFvMesh&) = delete;
178 
179 
180 public:
181 
182  //- Runtime type information
183  TypeName("dynamicOversetFvMesh");
184 
185 
186  // Constructors
187 
188  //- Construct from IOobject
189  dynamicOversetFvMesh(const IOobject& io, const bool doInit=true);
190 
191 
192  //- Destructor
193  virtual ~dynamicOversetFvMesh();
194 
195 
196  // Member Functions
197 
198 
199  // Extended addressing
200 
201  //- Return extended ldu addressing
203 
204  //- Return ldu addressing. If active: is (extended)
205  // primitiveLduAddr
206  virtual const lduAddressing& lduAddr() const;
207 
208  //- Return a list of pointers for each patch
209  // with only those pointing to interfaces being set. If active:
210  // return additional remoteStencilInterfaces_
211  virtual lduInterfacePtrsList interfaces() const;
212 
213  //- Return old to new face addressing
214  const labelList& reverseFaceMap() const
215  {
216  return reverseFaceMap_;
217  }
218 
219  //- Return true if using extended addressing
220  bool active() const
221  {
222  return active_;
223  }
224 
225  //- Enable/disable extended addressing
226  void active(const bool f) const
227  {
228  active_ = f;
229 
230  if (active_)
231  {
232  DebugInfo<< "Switching to extended addressing with nFaces:"
234  << endl;
235  }
236  else
237  {
238  DebugInfo<< "Switching to base addressing with nFaces:"
240  << endl;
241  }
242  }
243 
244 
245  // Overset
246 
247  // Explicit interpolation
248 
249  virtual void interpolate(scalarField& psi) const
250  {
251  interpolate<scalar>(psi);
252  }
253 
254  virtual void interpolate(vectorField& psi) const
255  {
256  interpolate<vector>(psi);
257  }
258 
259  virtual void interpolate(sphericalTensorField& psi) const
260  {
261  interpolate<sphericalTensor>(psi);
262  }
263 
264  virtual void interpolate(symmTensorField& psi) const
265  {
266  interpolate<symmTensor>(psi);
267  }
268 
269  virtual void interpolate(tensorField& psi) const
270  {
271  interpolate<tensor>(psi);
272  }
273 
274  virtual void interpolate(volScalarField& psi) const
275  {
276  interpolate<volScalarField>(psi);
277  }
278 
279  virtual void interpolate(volVectorField& psi) const
280  {
281  interpolate<volVectorField>(psi);
282  }
283 
284  virtual void interpolate(volSphericalTensorField& psi) const
285  {
286  interpolate<volSphericalTensorField>(psi);
287  }
288 
289  virtual void interpolate(volSymmTensorField& psi) const
290  {
291  interpolate<volSymmTensorField>(psi);
292  }
293 
294  virtual void interpolate(volTensorField& psi) const
295  {
296  interpolate<volTensorField>(psi);
297  }
298 
299 
300  // Implicit interpolation (matrix manipulation)
301 
302  //- Solve returning the solution statistics given convergence
303  // tolerance. Use the given solver controls
305  (
306  fvMatrix<scalar>& m,
307  const dictionary& dict
308  ) const
309  {
310  return solve<scalar>(m, dict);
311  }
312 
313  //- Solve returning the solution statistics given convergence
314  // tolerance. Use the given solver controls
316  (
317  fvMatrix<vector>& m,
318  const dictionary& dict
319  ) const
320  {
321  return solve<vector>(m, dict);
322  }
323 
324  //- Solve returning the solution statistics given convergence
325  // tolerance. Use the given solver controls
327  (
329  const dictionary& dict
330  ) const
331  {
332  return solve<symmTensor>(m, dict);
333  }
334 
335  //- Solve returning the solution statistics given convergence
336  // tolerance. Use the given solver controls
338  (
339  fvMatrix<tensor>& m,
340  const dictionary& dict
341  ) const
342  {
343  return solve<tensor>(m, dict);
344  }
345 
346 
347  //- Initialise all non-demand-driven data
348  virtual bool init(const bool doInit);
349 
350  //- Update the mesh for both mesh motion and topology change
351  virtual bool update();
352 
353  //- Update fields when mesh is updated
354  virtual bool interpolateFields();
355 
356  //- Write using stream options
357  virtual bool writeObject
358  (
359  IOstreamOption streamOpt,
360  const bool valid
361  ) const;
362 
363  //- Debug: check halo swap is ok
364  template<class GeoField>
365  static void checkCoupledBC(const GeoField& fld);
366 
367  //- Correct boundary conditions of certain type (typeOnly = true)
368  // or explicitly not of the type (typeOnly = false)
369  template<class GeoField, class PatchType>
370  static void correctBoundaryConditions
371  (
372  typename GeoField::Boundary& bfld,
373  const bool typeOnly
374  );
375 };
376 
377 
378 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
379 
380 } // End namespace Foam
381 
382 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
383 
384 #ifdef NoRepository
386 #endif
387 
388 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
389 
390 #endif
391 
392 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
volFields.H
Foam::dynamicOversetFvMesh::stencilPatches_
labelListList stencilPatches_
Corresponding patches (in above lduPtr) to the stencil.
Definition: dynamicOversetFvMesh.H:86
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::dynamicOversetFvMesh::TypeName
TypeName("dynamicOversetFvMesh")
Runtime type information.
Foam::dynamicOversetFvMesh::correctBoundaryConditions
static void correctBoundaryConditions(typename GeoField::Boundary &bfld, const bool typeOnly)
Correct boundary conditions of certain type (typeOnly = true)
Definition: dynamicOversetFvMeshTemplates.C:117
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(volVectorField &psi) const
Interpolate interpolationCells only.
Definition: dynamicOversetFvMesh.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
Foam::GAMGAgglomeration
Geometric agglomerated algebraic multigrid agglomeration class.
Definition: GAMGAgglomeration.H:64
Foam::dynamicOversetFvMesh::interfaces
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
Definition: dynamicOversetFvMesh.C:586
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::dynamicOversetFvMesh::update
virtual bool update()
Update the mesh for both mesh motion and topology change.
Definition: dynamicOversetFvMesh.C:615
Foam::dynamicOversetFvMesh::reverseFaceMap_
labelList reverseFaceMap_
From old to new face labels.
Definition: dynamicOversetFvMesh.H:89
Foam::dynamicOversetFvMesh::active
void active(const bool f) const
Enable/disable extended addressing.
Definition: dynamicOversetFvMesh.H:225
Foam::dynamicOversetFvMesh::writeAgglomeration
void writeAgglomeration(const GAMGAgglomeration &agglom) const
Debug: dump agglomeration.
Definition: dynamicOversetFvMesh.C:429
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dynamicOversetFvMesh::interpolate
void interpolate(Field< T > &psi) const
Explicit interpolation of acceptor cells from donor cells.
Definition: dynamicOversetFvMeshTemplates.C:40
lduInterfaceFieldPtrsList.H
Foam::HashSet< word, Hash< word > >
Foam::dynamicOversetFvMesh::lduPtr_
autoPtr< fvMeshPrimitiveLduAddressing > lduPtr_
Extended addressing (extended with local interpolation stencils)
Definition: dynamicOversetFvMesh.H:71
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(scalarField &psi) const
Interpolate interpolationCells only. No bcs.
Definition: dynamicOversetFvMesh.H:248
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(volScalarField &psi) const
Interpolate interpolationCells only.
Definition: dynamicOversetFvMesh.H:273
Foam::dynamicOversetFvMesh::writeObject
virtual bool writeObject(IOstreamOption streamOpt, const bool valid) const
Write using stream options.
Definition: dynamicOversetFvMesh.C:673
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(volSphericalTensorField &psi) const
Interpolate interpolationCells only.
Definition: dynamicOversetFvMesh.H:283
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(symmTensorField &psi) const
Interpolate interpolationCells only. No bcs.
Definition: dynamicOversetFvMesh.H:263
Foam::dynamicOversetFvMesh::remoteStencilInterfaces_
PtrList< const lduPrimitiveProcessorInterface > remoteStencilInterfaces_
Added (processor)lduInterfaces for remote bits of stencil.
Definition: dynamicOversetFvMesh.H:76
dynamicMotionSolverListFvMesh.H
Foam::Field< T >
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(tensorField &psi) const
Interpolate interpolationCells only. No bcs.
Definition: dynamicOversetFvMesh.H:268
Foam::fvMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Return ldu addressing.
Definition: fvMesh.C:691
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(vectorField &psi) const
Interpolate interpolationCells only. No bcs.
Definition: dynamicOversetFvMesh.H:253
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(sphericalTensorField &psi) const
Interpolate interpolationCells only. No bcs.
Definition: dynamicOversetFvMesh.H:258
Foam::dynamicOversetFvMesh::addInterpolation
void addInterpolation(fvMatrix< Type > &, const scalarField &norm) const
Add interpolation to matrix (coefficients)
Definition: dynamicOversetFvMeshTemplates.C:330
Foam::IOstreamOption
The IOstreamOption is a simple container for options an IOstream can normally have.
Definition: IOstreamOption.H:63
Foam::fvMeshPrimitiveLduAddressing
Variant of fvMeshLduAddressing that contains addressing instead of slices.
Definition: fvMeshPrimitiveLduAddressing.H:57
Foam::UPtrList< const lduInterface >
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
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
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dynamicOversetFvMesh::interpolateFields
virtual bool interpolateFields()
Update fields when mesh is updated.
Definition: dynamicOversetFvMesh.C:646
Foam::dynamicOversetFvMesh::~dynamicOversetFvMesh
virtual ~dynamicOversetFvMesh()
Destructor.
Definition: dynamicOversetFvMesh.C:564
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::dynamicOversetFvMesh::correctCoupledBoundaryConditions
static void correctCoupledBoundaryConditions(GeoField &fld)
Debug: correct coupled bc.
Definition: dynamicOversetFvMeshTemplates.C:898
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fvMeshPrimitiveLduAddressing::lowerAddr
virtual const labelUList & lowerAddr() const noexcept
Return lower addressing (i.e. lower label = upper triangle)
Definition: fvMeshPrimitiveLduAddressing.H:113
Foam::dynamicOversetFvMesh::updateAddressing
virtual bool updateAddressing() const
Calculate the extended lduAddressing.
Definition: dynamicOversetFvMesh.C:47
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::dynamicOversetFvMesh::lduAddr
virtual const lduAddressing & lduAddr() const
Return ldu addressing. If active: is (extended)
Definition: dynamicOversetFvMesh.C:570
Foam::dynamicOversetFvMesh::allInterfaces_
lduInterfacePtrsList allInterfaces_
Interfaces for above mesh. Contains both original and.
Definition: dynamicOversetFvMesh.H:80
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::dynamicOversetFvMesh
dynamicFvMesh with support for overset meshes.
Definition: dynamicOversetFvMesh.H:58
f
labelList f(nPoints)
Foam::dynamicOversetFvMesh::stencilFaces_
labelListList stencilFaces_
Corresponding faces (in above lduPtr) to the stencil.
Definition: dynamicOversetFvMesh.H:83
Foam::dynamicOversetFvMesh::checkCoupledBC
static void checkCoupledBC(const GeoField &fld)
Debug: check halo swap is ok.
Definition: dynamicOversetFvMeshTemplates.C:931
Foam::lduAddressing::lowerAddr
virtual const labelUList & lowerAddr() const =0
Return lower addressing.
Foam::dynamicOversetFvMesh::normalisation
tmp< scalarField > normalisation(const fvMatrix< Type > &m) const
Freeze values at holes.
Foam::List< labelList >
Foam::dynamicOversetFvMesh::init
virtual bool init(const bool doInit)
Initialise all non-demand-driven data.
Definition: dynamicOversetFvMesh.C:545
Foam::dynamicOversetFvMesh::active_
bool active_
Select base addressing (false) or locally stored extended.
Definition: dynamicOversetFvMesh.H:68
Foam::dynamicOversetFvMesh::primitiveLduAddr
const fvMeshPrimitiveLduAddressing & primitiveLduAddr() const
Return extended ldu addressing.
Definition: dynamicOversetFvMesh.C:603
labelIOList.H
Foam::dynamicOversetFvMesh::write
void write(Ostream &, const fvMatrix< Type > &, const lduAddressing &, const lduInterfacePtrsList &) const
Debug: print matrix.
Definition: dynamicOversetFvMeshTemplates.C:772
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::dynamicOversetFvMesh::solve
SolverPerformance< Type > solve(fvMatrix< Type > &, const dictionary &) const
Solve given dictionary with settings.
dynamicOversetFvMeshTemplates.C
Foam::dynamicMotionSolverListFvMesh
Dynamic mesh able to handle multiple motion solvers. NOTE: If the word entry "solvers" is not found i...
Definition: dynamicMotionSolverListFvMesh.H:55
fvMeshPrimitiveLduAddressing.H
Foam::dynamicOversetFvMesh::reverseFaceMap
const labelList & reverseFaceMap() const
Return old to new face addressing.
Definition: dynamicOversetFvMesh.H:213
Foam::dynamicOversetFvMesh::baseName
static word baseName(const word &name)
Helper: strip off trailing _0.
Definition: dynamicOversetFvMesh.C:635
Foam::UList::size
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< scalar, fvPatchField, volMesh >
psi
const volScalarField & psi
Definition: createFieldRefs.H:1
Foam::SolverPerformance
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics.
Definition: SolverPerformance.H:52
Foam::dynamicOversetFvMesh::cellAverage
scalar cellAverage(const labelList &types, const labelList &nbrTypes, const scalarField &norm, const scalarField &nbrNorm, const label celli, bitSet &isFront) const
Average norm of valid neighbours.
Definition: dynamicOversetFvMesh.C:364
Foam::dynamicOversetFvMesh::active
bool active() const
Return true if using extended addressing.
Definition: dynamicOversetFvMesh.H:219
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(volSymmTensorField &psi) const
Interpolate interpolationCells only.
Definition: dynamicOversetFvMesh.H:288
Foam::fvMesh::name
const word & name() const
Return reference to name.
Definition: fvMesh.H:300
Foam::dynamicOversetFvMesh::interpolate
virtual void interpolate(volTensorField &psi) const
Interpolate interpolationCells only.
Definition: dynamicOversetFvMesh.H:293