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  bounday 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 singleCellFvMesh_H
42 #define 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  const labelListIOList patchFaceAgglomeration_;
64 
65  //- From patch faces back to agglomeration or fine mesh
66  labelListIOList patchFaceMap_;
67 
68  //- From fine mesh faces to coarse mesh
69  labelIOList reverseFaceMap_;
70 
71  //- From coarse points back to original mesh
72  labelIOList pointMap_;
73 
74  //- From fine points to coarse mesh
75  labelIOList reversePointMap_;
76 
77 
78  // Private Member Functions
79 
80  //- Calculate agglomerated mesh
81  void agglomerateMesh(const fvMesh&, const labelListList&);
82 
83 
84  //- No copy construct
85  singleCellFvMesh(const singleCellFvMesh&) = delete;
86 
87  //- No copy assignment
88  void operator=(const singleCellFvMesh&) = delete;
89 
90 
91 public:
92 
93  //- Patch field mapper class for agglomerated meshes
95  :
96  public fvPatchFieldMapper
97  {
98  // Private data
99 
100  const labelListList& addressing_;
101  const scalarListList& weights_;
102  bool hasUnmapped_;
103 
104  public:
106  //- Construct given addressing
108  (
109  const labelListList& addressing,
110  const scalarListList& weights
111  )
112  :
113  addressing_(addressing),
114  weights_(weights),
115  hasUnmapped_(false)
116  {
117  for (const labelList& addr : addressing)
118  {
119  if (addr.empty())
120  {
121  hasUnmapped_ = true;
122  break;
123  }
124  }
125  }
126 
127  virtual label size() const
128  {
129  return addressing_.size();
130  }
131 
132  virtual bool direct() const
133  {
134  return false;
135  }
136 
137  bool hasUnmapped() const
138  {
139  return hasUnmapped_;
140  }
141 
142  virtual const labelListList& addressing() const
143  {
144  return addressing_;
145  }
146 
147  virtual const scalarListList& weights() const
148  {
149  return weights_;
150  }
151  };
152 
153 
154 
155  // Constructors
156 
157  //- Construct from fvMesh and no agglomeration
159  (
160  const IOobject& io,
161  const fvMesh&,
162  const bool doInit=true
163  );
164 
165  //- Construct from fvMesh and agglomeration of boundary faces.
166  // Agglomeration is per patch, per patch face index the agglomeration
167  // the face goes into.
169  (
170  const IOobject& io,
171  const fvMesh&,
172  const labelListList& patchFaceAgglomeration,
173  const bool doInit=true
174  );
175 
176  //- Read from IOobject
177  singleCellFvMesh(const IOobject& io, const bool doInit=true);
178 
179 
180  // Member Functions
181 
182  bool agglomerate() const
183  {
184  return patchFaceAgglomeration_.size() > 0;
185  }
186 
187  //- From patchFace on this back to original mesh or agglomeration
188  const labelListList& patchFaceMap() const
189  {
190  return patchFaceMap_;
191  }
192 
193  //- From point on this back to original mesh
194  const labelList& pointMap() const
195  {
196  return pointMap_;
197  }
198 
199  //- From face on original mesh to face on this
200  const labelList& reverseFaceMap() const
201  {
202  return reverseFaceMap_;
203  }
204 
205  //- From point on original mesh to point on this (or -1 for removed
206  //- points)
207  const labelList& reversePointMap() const
208  {
209  return reversePointMap_;
210  }
211 
212  //- Map volField. Internal field set to average, patch fields straight
213  //- copies.
214  template<class Type>
217  (
219  ) const;
220 
221 };
222 
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 } // End namespace Foam
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #ifdef NoRepository
232 #endif
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 #endif
237 
238 // ************************************************************************* //
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 bounday faces. Useful when manipulating boundary data. Single internal cell only needed to be able to manipulate in a standard way.
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
Return the interpolation weights.
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 copies.
Generic GeometricField class.
Definition: areaFieldsFwd.H:50
const labelList & reversePointMap() const
From point on original mesh to point on this (or -1 for removed points)
A FieldMapper for finite-volume patch fields.
const labelList & pointMap() const
From point on this back to original mesh.
virtual const labelListList & addressing() const
Return the interpolation addressing.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
virtual label size() const
The size of the mapper.
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:172
const labelList & reverseFaceMap() const
From face on original mesh to face on this.
bool hasUnmapped() const
Any unmapped values?
Namespace for OpenFOAM.