singleCellFvMesh.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-2019 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::singleCellFvMesh
26 
27 Description
28  fvMesh as subset of other mesh. Consists of one cell and all original
29  bounday faces. Useful when manipulating boundary data. Single internal
30  cell only needed to be able to manipulate in a standard way.
31 
32 SourceFiles
33  singleCellFvMesh.C
34  singleCellFvMeshInterpolate.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef singleCellFvMesh_H
39 #define singleCellFvMesh_H
40 
41 #include "fvPatchFieldMapper.H"
42 #include "fvMesh.H"
43 #include "labelListIOList.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class singleCellFvMesh Declaration
52 \*---------------------------------------------------------------------------*/
53 
54 class singleCellFvMesh
55 :
56  public fvMesh
57 {
58  // Private Data
59 
60  const labelListIOList patchFaceAgglomeration_;
61 
62  //- From patch faces back to agglomeration or fine mesh
63  labelListIOList patchFaceMap_;
64 
65  //- From fine mesh faces to coarse mesh
66  labelIOList reverseFaceMap_;
67 
68  //- From coarse points back to original mesh
69  labelIOList pointMap_;
70 
71  //- From fine points to coarse mesh
72  labelIOList reversePointMap_;
73 
74 
75  // Private Member Functions
76 
77  //- Calculate agglomerated mesh
78  void agglomerateMesh(const fvMesh&, const labelListList&);
79 
80 
81 public:
82 
83  //- Patch field mapper class for agglomerated meshes
85  :
87  {
88  // Private Data
89 
90  const labelListList& addressing_;
91  const scalarListList& weights_;
92  bool hasUnmapped_;
93 
94 
95  public:
96 
97  //- Construct given addressing
99  (
100  const labelListList& addressing,
101  const scalarListList& weights
102  )
103  :
104  addressing_(addressing),
105  weights_(weights),
106  hasUnmapped_(false)
107  {
108  forAll(addressing_, i)
109  {
110  if (addressing_[i].empty())
111  {
112  hasUnmapped_ = true;
113  break;
114  }
115  }
116  }
118  virtual label size() const
119  {
120  return addressing_.size();
121  }
123  virtual bool direct() const
124  {
125  return false;
126  }
128  bool hasUnmapped() const
129  {
130  return hasUnmapped_;
131  }
133  virtual const labelListList& addressing() const
134  {
135  return addressing_;
136  }
138  virtual const scalarListList& weights() const
139  {
140  return weights_;
141  }
142  };
143 
144 
145 
146  // Constructors
147 
148  //- Construct from fvMesh and no agglomeration
149  singleCellFvMesh(const IOobject& io, const fvMesh&);
150 
151  //- Construct from fvMesh and agglomeration of boundary faces.
152  // agglomeration is per patch, per patch face index the agglomeration
153  // the face goes into.
155  (
156  const IOobject& io,
157  const fvMesh&,
158  const labelListList& patchFaceAgglomeration
159  );
160 
161  //- Read from IOobject
162  singleCellFvMesh(const IOobject& io);
163 
164  //- Disallow default bitwise copy construction
165  singleCellFvMesh(const singleCellFvMesh&) = delete;
166 
167 
168  // Member Functions
170  bool agglomerate() const
171  {
172  return patchFaceAgglomeration_.size() > 0;
173  }
174 
175  //- From patchFace on this back to original mesh or agglomeration
176  const labelListList& patchFaceMap() const
177  {
178  return patchFaceMap_;
179  }
180 
181  //- From point on this back to original mesh
182  const labelList& pointMap() const
183  {
184  return pointMap_;
185  }
186 
187  //- From face on original mesh to face on this
188  const labelList& reverseFaceMap() const
189  {
190  return reverseFaceMap_;
191  }
192 
193  //- From point on original mesh to point on this (or -1 for removed
194  // points)
195  const labelList& reversePointMap() const
196  {
197  return reversePointMap_;
198  }
199 
200  //- Map volField. Internal field set to average, patch fields straight
201  // copies.
202  template<class Type>
205  (
207  ) const;
208 
209 
210  // Member Operators
211 
212  //- Disallow default bitwise assignment
213  void operator=(const singleCellFvMesh&) = delete;
214 };
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #ifdef NoRepository
225 #endif
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
fvMesh as subset of other mesh. Consists of one cell and all original bounday faces. Useful when manipulating boundary data. Single internal cell only needed to be able to manipulate in a standard way.
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
const labelListList & patchFaceMap() const
From patchFace on this back to original mesh or agglomeration.
agglomPatchFieldMapper(const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
virtual const scalarListList & weights() const
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
bool empty() const
Return true if the hash table is empty.
Definition: HashTableI.H:72
Patch field mapper class for agglomerated meshes.
tmp< GeometricField< Type, fvPatchField, volMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Map volField. Internal field set to average, patch fields straight.
Generic GeometricField class.
void operator=(const singleCellFvMesh &)=delete
Disallow default bitwise assignment.
const labelList & reversePointMap() const
From point on original mesh to point on this (or -1 for removed.
const labelList & pointMap() const
From point on this back to original mesh.
virtual const labelListList & addressing() const
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
singleCellFvMesh(const IOobject &io, const fvMesh &)
Construct from fvMesh and no agglomeration.
A class for managing temporary objects.
Definition: PtrList.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
const labelList & reverseFaceMap() const
From face on original mesh to face on this.
bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Namespace for OpenFOAM.