oversetFvMeshBase.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-2022,2024 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::oversetFvMeshBase
28 
29 Description
30  Support for overset functionality.
31 
32 SourceFiles
33  oversetFvMeshBase.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef oversetFvMeshBase_H
38 #define oversetFvMeshBase_H
39 
42 #include "volFieldsFwd.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 class lduPrimitiveProcessorInterface;
50 class GAMGAgglomeration;
51 
52 /*---------------------------------------------------------------------------*\
53  Class oversetFvMeshBase Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 {
58  // Private Member Functions
59 
60  //- No copy construct
61  oversetFvMeshBase(const oversetFvMeshBase&) = delete;
62 
63  //- No copy assignment
64  void operator=(const oversetFvMeshBase&) = delete;
65 
66 
67 protected:
68 
69  // Protected Data
70 
71  //- Reference to mesh
72  const fvMesh& mesh_;
73 
74  //- Select base addressing (false) or locally stored extended
75  // lduAddressing (true)
76  mutable bool active_;
77 
78  //- Extended addressing (extended with local interpolation stencils)
80 
81  //- Added (processor)lduInterfaces for remote bits of stencil.
84 
85  //- Interfaces for above mesh. Contains both original and
86  //- above added processorLduInterfaces
88 
89  //- Corresponding faces (in above lduPtr) to the stencil
91 
92  //- Corresponding patches (in above lduPtr) to the stencil
94 
95  //- From old to new face labels
96  mutable labelList reverseFaceMap_;
97 
98 
99  // Protected Member Functions
100 
101  //- Calculate the extended lduAddressing
102  virtual bool updateAddressing() const;
103 
104  //- Debug: print matrix
105  template<class Type>
106  void write
107  (
108  Ostream&,
109  const fvMatrix<Type>&,
110  const lduAddressing&,
111  const lduInterfacePtrsList&
112  ) const;
113 
114  //- Freeze values at holes
115  //template<class Type>
116  //void freezeHoles(fvMatrix<Type>&) const;
117 
118  //- Scale coefficient depending on cell type
119  template<class Type>
120  void scaleConnection
121  (
122  Field<Type>& coeffs,
123  const labelUList& types,
124  const scalarList& factor,
125  const bool setHoleCellValue,
126  const label celli,
127  const label facei
128  ) const;
129 
130  //- Solve given dictionary with settings
131  template<class Type>
133  (
134  fvMatrix<Type>& m,
135  const dictionary&
136  ) const;
137 
138  //- Debug: correct coupled bc
139  template<class GeoField>
140  static void correctCoupledBoundaryConditions(GeoField& fld);
141 
142  //- Average norm of valid neighbours
143  scalar cellAverage
144  (
145  const labelUList& types,
146  const labelUList& nbrTypes,
147  const scalarField& norm,
148  const scalarField& nbrNorm,
149  const label celli,
150  bitSet& isFront
151  ) const;
152 
153  //- Debug: dump agglomeration
154  void writeAgglomeration
155  (
156  const GAMGAgglomeration& agglom
157  ) const;
158 
159 
160 public:
161 
162  //- Runtime type information
163  TypeName("oversetFvMeshBase");
164 
165 
166  // Constructors
167 
168  //- Construct from IOobject
169  oversetFvMeshBase(const fvMesh& mesh, const bool doInit=true);
170 
171 
172  //- Destructor
173  virtual ~oversetFvMeshBase();
174 
175 
176  // Member Functions
177 
178  // Extended addressing
179 
180  //- Return extended ldu addressing
182 
183  //- Return ldu addressing. If active: is (extended)
184  // primitiveLduAddr
185  virtual const lduAddressing& lduAddr() const;
186 
187  //- Return a list of pointers for each patch
188  // with only those pointing to interfaces being set. If active:
189  // return additional remoteStencilInterfaces_
190  virtual lduInterfacePtrsList interfaces() const;
191 
192  //- Return old to new face addressing
193  const labelList& reverseFaceMap() const
194  {
195  return reverseFaceMap_;
196  }
197 
198  //- Return true if using extended addressing
199  bool active() const
200  {
201  return active_;
202  }
203 
204  //- Enable/disable extended addressing
205  void active(const bool f) const
206  {
207  active_ = f;
208 
209  if (active_)
210  {
211  DebugInfo<< "Switching to extended addressing with nFaces:"
213  << " nInterfaces:" << allInterfaces_.size()
214  << endl;
215  }
216  else
217  {
218  DebugInfo<< "Switching to base addressing with nFaces:"
219  << mesh_.fvMesh::lduAddr().lowerAddr().size()
220  << " nInterfaces:" << mesh_.fvMesh::interfaces().size()
221  << endl;
222  }
223  }
224 
225 
226  // Overset
227 
228  //- Manipulate the matrix to add the interpolation/set hole
229  // values
230  template<class Type>
231  void addInterpolation
232  (
233  fvMatrix<Type>& m,
234  const scalarField& normalisation,
235  const bool setHoleCellValue,
236  const Type& holeCellValue
237  ) const;
238 
239 
240  //- Clear out local storage
241  void clearOut();
243  //- Update the mesh for both mesh motion and topology change
244  virtual bool update();
245 
246  //- Update fields when mesh is updated
247  virtual bool interpolateFields();
248 
249  //- Write using stream options
250  virtual bool writeObject
251  (
252  IOstreamOption streamOpt,
253  const bool writeOnProc
254  ) const;
255 
256  //- Debug: check halo swap is ok
257  template<class GeoField>
258  static void checkCoupledBC(const GeoField& fld);
259 
260  //- Correct boundary conditions of certain type (TypeOnly = true)
261  //- or explicitly not of the type (TypeOnly = false)
262  template<class GeoField, class PatchType, bool TypeOnly>
263  static void correctBoundaryConditions
264  (
265  typename GeoField::Boundary& bfld
266  );
267 
268  //- Determine normalisation for interpolation. This equals the
269  //- original diagonal except stabilised for zero diagonals (possible
270  //- in hole cells)
271  template<class Type>
273 };
274 
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 } // End namespace Foam
279 
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 
282 #ifdef NoRepository
284 #endif
285 
286 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
287 
288 #endif
289 
290 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:119
TypeName("oversetFvMeshBase")
Runtime type information.
Forwards and collection of common volume field types.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
static void checkCoupledBC(const GeoField &fld)
Debug: check halo swap is ok.
virtual bool writeObject(IOstreamOption streamOpt, const bool writeOnProc) const
Write using stream options.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:518
const fvMeshPrimitiveLduAddressing & primitiveLduAddr() const
Return extended ldu addressing.
lduInterfacePtrsList allInterfaces_
Interfaces for above mesh. Contains both original and above added processorLduInterfaces.
void scaleConnection(Field< Type > &coeffs, const labelUList &types, const scalarList &factor, const bool setHoleCellValue, const label celli, const label facei) const
Freeze values at holes.
A simple container for options an IOstream can normally have.
tmp< scalarField > normalisation(const fvMatrix< Type > &m) const
Determine normalisation for interpolation. This equals the original diagonal except stabilised for ze...
static void correctCoupledBoundaryConditions(GeoField &fld)
Debug: correct coupled bc.
SolverPerformance< Type > solveOverset(fvMatrix< Type > &m, const dictionary &) const
Solve given dictionary with settings.
labelList reverseFaceMap_
From old to new face labels.
labelListList stencilFaces_
Corresponding faces (in above lduPtr) to the stencil.
virtual const labelUList & lowerAddr() const noexcept
Return lower addressing (i.e. lower label = upper triangle)
label size() const noexcept
The number of elements in table.
Definition: HashTable.H:358
dynamicFvMesh & mesh
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition: Field.H:69
bool active() const
Return true if using extended addressing.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
SolverPerformance is the class returned by the LduMatrix solver containing performance statistics...
void addInterpolation(fvMatrix< Type > &m, const scalarField &normalisation, const bool setHoleCellValue, const Type &holeCellValue) const
Manipulate the matrix to add the interpolation/set hole.
static void correctBoundaryConditions(typename GeoField::Boundary &bfld)
Correct boundary conditions of certain type (TypeOnly = true) or explicitly not of the type (TypeOnly...
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
#define DebugInfo
Report an information message using Foam::Info.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
labelList f(nPoints)
virtual bool interpolateFields()
Update fields when mesh is updated.
scalar cellAverage(const labelUList &types, const labelUList &nbrTypes, const scalarField &norm, const scalarField &nbrNorm, const label celli, bitSet &isFront) const
Average norm of valid neighbours.
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))
void clearOut()
Clear out local storage.
Support for overset functionality.
virtual bool update()
Update the mesh for both mesh motion and topology change.
autoPtr< fvMeshPrimitiveLduAddressing > lduPtr_
Extended addressing (extended with local interpolation stencils)
labelListList stencilPatches_
Corresponding patches (in above lduPtr) to the stencil.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition: bitSet.H:58
virtual const lduAddressing & lduAddr() const
Return ldu addressing. If active: is (extended)
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: PtrList.H:56
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
PtrList< const lduPrimitiveProcessorInterface > remoteStencilInterfaces_
Added (processor)lduInterfaces for remote bits of stencil.
virtual lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
void writeAgglomeration(const GAMGAgglomeration &agglom) const
Debug: dump agglomeration.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
The class contains the addressing required by the lduMatrix: upper, lower and losort.
const labelList & reverseFaceMap() const
Return old to new face addressing.
virtual ~oversetFvMeshBase()
Destructor.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
void write(Ostream &, const fvMatrix< Type > &, const lduAddressing &, const lduInterfacePtrsList &) const
Debug: print matrix.
virtual bool updateAddressing() const
Calculate the extended lduAddressing.
Geometric agglomerated algebraic multigrid agglomeration class.
bool active_
Select base addressing (false) or locally stored extended.
const fvMesh & mesh_
Reference to mesh.
Variant of fvMeshLduAddressing that contains addressing instead of slices.
Namespace for OpenFOAM.