singleCellFvMesh.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) 2019,2022 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::singleCellFvMesh
29 
30 Description
31  fvMesh as subset of other mesh. Consists of one cell and all original
32  boundary faces. Useful when manipulating boundary data. Single internal
33  cell only needed to be able to manipulate in a standard way.
34 
35 SourceFiles
36  singleCellFvMesh.C
37  singleCellFvMeshInterpolate.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef Foam_singleCellFvMesh_H
42 #define Foam_singleCellFvMesh_H
43 
44 #include "fvPatchFieldMapper.H"
45 #include "fvMesh.H"
46 #include "labelListIOList.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class singleCellFvMesh Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class singleCellFvMesh
58 :
59  public fvMesh
60 {
61  // Private Data
62 
63  //- Fine patch face to agglomeration index addressing
64  const labelListIOList patchFaceAgglomeration_;
65 
66  //- From patch faces back to agglomeration or fine mesh
67  labelListIOList patchFaceMap_;
68 
69  //- From fine mesh faces to coarse mesh
70  labelIOList reverseFaceMap_;
71 
72  //- From coarse points back to original mesh
73  labelIOList pointMap_;
74 
75  //- From fine points to coarse mesh
76  labelIOList reversePointMap_;
77 
78 
79  // Private Member Functions
80 
81  //- Calculate agglomerated mesh
82  void agglomerateMesh(const fvMesh&, const labelListList&);
83 
84 
85  //- No copy construct
86  singleCellFvMesh(const singleCellFvMesh&) = delete;
87 
88  //- No copy assignment
89  void operator=(const singleCellFvMesh&) = delete;
90 
91 
92 public:
93 
94  //- Patch field mapper class for agglomerated meshes
96  :
97  public fvPatchFieldMapper
98  {
99  // Private data
100 
101  const labelListList& addressing_;
102  const scalarListList& weights_;
103  bool hasUnmapped_;
104 
105  public:
106 
107  //- Construct given addressing
109  (
110  const labelListList& addressing,
111  const scalarListList& weights
112  )
113  :
114  addressing_(addressing),
115  weights_(weights),
116  hasUnmapped_(false)
117  {
118  for (const labelList& addr : addressing)
119  {
120  if (addr.empty())
121  {
122  hasUnmapped_ = true;
123  break;
124  }
125  }
126  }
127 
128  virtual label size() const
129  {
130  return addressing_.size();
131  }
132 
133  virtual bool direct() const
134  {
135  return false;
136  }
137 
138  bool hasUnmapped() const
139  {
140  return hasUnmapped_;
141  }
142 
143  virtual const labelListList& addressing() const
144  {
145  return addressing_;
146  }
147 
148  virtual const scalarListList& weights() const
149  {
150  return weights_;
151  }
152  };
154 
155 
156  // Constructors
157 
158  //- Construct from fvMesh and no agglomeration
160  (
161  const IOobject& io,
162  const fvMesh&,
163  const bool doInit=true
164  );
165 
166  //- Construct from fvMesh and agglomeration of boundary faces.
167  // Agglomeration is per patch, per patch face index the agglomeration
168  // the face goes into.
170  (
171  const IOobject& io,
172  const fvMesh&,
174  const bool doInit=true
175  );
176 
177  //- Read from IOobject
178  singleCellFvMesh(const IOobject& io, const bool doInit=true);
179 
180 
181  // Member Functions
182 
183  bool agglomerate() const noexcept
184  {
185  return !patchFaceAgglomeration_.empty();
186  }
187 
188  //- Fine patch face to agglomeration index addressing
190  {
191  return patchFaceAgglomeration_;
192  }
193 
194  //- From patchFace on this back to original mesh or agglomeration
195  const labelListList& patchFaceMap() const noexcept
196  {
197  return patchFaceMap_;
198  }
199 
200  //- From point on this back to original mesh
201  const labelList& pointMap() const noexcept
202  {
203  return pointMap_;
204  }
206  //- From face on original mesh to face on this
207  const labelList& reverseFaceMap() const noexcept
208  {
209  return reverseFaceMap_;
210  }
211 
212  //- From point on original mesh to point on this (or -1 for removed
213  //- points)
214  const labelList& reversePointMap() const noexcept
215  {
216  return reversePointMap_;
217  }
218 
219  //- Interpolate for overset (unused)
220  using fvMesh::interpolate;
222  //- Map volField. Internal field set to average, patch fields straight
223  //- copies.
224  template<class Type>
227  (
229  ) const;
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #ifdef NoRepository
241 #endif
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #endif
247 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
fvMesh as subset of other mesh. Consists of one cell and all original boundary faces. Useful when manipulating boundary data. Single internal cell only needed to be able to manipulate in a standard way.
tmp< GeometricField< Type, fvPatchField, volMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Map volField. Internal field set to average, patch fields straight copies.
agglomPatchFieldMapper(const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
virtual const scalarListList & weights() const
Return the interpolation weights.
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:675
Patch field mapper class for agglomerated meshes.
Generic GeometricField class.
virtual void interpolate(volScalarField &) const
Interpolate interpolationCells only.
Definition: fvMesh.H:459
const labelList & reverseFaceMap() const noexcept
From face on original mesh to face on this.
A FieldMapper for finite-volume patch fields.
const labelList & pointMap() const noexcept
From point on this back to original mesh.
const labelListList & patchFaceAgglomeration() const noexcept
Fine patch face to agglomeration index addressing.
const direction noexcept
Definition: Scalar.H:258
bool agglomerate() const noexcept
virtual const labelListList & addressing() const
Return the interpolation addressing.
const labelListList & patchFaceMap() const noexcept
From patchFace on this back to original mesh or agglomeration.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual label size() const
The size of the mapper.
const labelList & reversePointMap() const noexcept
From point on original mesh to point on this (or -1 for removed points)
List< label > labelList
A List of labels.
Definition: List.H:62
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual bool direct() const
Is it a direct (non-interpolating) mapper?
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:180
bool hasUnmapped() const
Any unmapped values?
Namespace for OpenFOAM.