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 | Copyright (C) 2011-2014 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  //- Disallow default bitwise copy construct
83 
84  //- Disallow default bitwise assignment
85  void operator=(const singleCellFvMesh&);
86 
87 
88 public:
89 
90  //- Patch field mapper class for agglomerated meshes
92  :
93  public fvPatchFieldMapper
94  {
95  // Private data
96 
97  const labelListList& addressing_;
98  const scalarListList& weights_;
99  bool hasUnmapped_;
100 
101  public:
102 
103  //- Construct given addressing
105  (
106  const labelListList& addressing,
107  const scalarListList& weights
108  )
109  :
110  addressing_(addressing),
111  weights_(weights),
112  hasUnmapped_(false)
113  {
114  forAll(addressing_, i)
115  {
116  if (addressing_[i].empty())
117  {
118  hasUnmapped_ = true;
119  break;
120  }
121  }
122  }
124  virtual label size() const
125  {
126  return addressing_.size();
127  }
129  virtual bool direct() const
130  {
131  return false;
132  }
134  bool hasUnmapped() const
135  {
136  return hasUnmapped_;
137  }
139  virtual const labelListList& addressing() const
140  {
141  return addressing_;
142  }
144  virtual const scalarListList& weights() const
145  {
146  return weights_;
147  }
148  };
149 
150 
151 
152  // Constructors
153 
154  //- Construct from fvMesh and no agglomeration
155  singleCellFvMesh(const IOobject& io, const fvMesh&);
156 
157  //- Construct from fvMesh and agglomeration of boundary faces.
158  // agglomeration is per patch, per patch face index the agglomeration
159  // the face goes into.
161  (
162  const IOobject& io,
163  const fvMesh&,
164  const labelListList& patchFaceAgglomeration
165  );
166 
167  //- Read from IOobject
168  singleCellFvMesh(const IOobject& io);
169 
170  // Member Functions
172  bool agglomerate() const
173  {
174  return patchFaceAgglomeration_.size() > 0;
175  }
176 
177  //- From patchFace on this back to original mesh or agglomeration
178  const labelListList& patchFaceMap() const
179  {
180  return patchFaceMap_;
181  }
182 
183  //- From point on this back to original mesh
184  const labelList& pointMap() const
185  {
186  return pointMap_;
187  }
188 
189  //- From face on original mesh to face on this
190  const labelList& reverseFaceMap() const
191  {
192  return reverseFaceMap_;
193  }
194 
195  //- From point on original mesh to point on this (or -1 for removed
196  // points)
197  const labelList& reversePointMap() const
198  {
199  return reversePointMap_;
200  }
201 
202  //- Map volField. Internal field set to average, patch fields straight
203  // copies.
204  template<class Type>
207  (
209  ) const;
210 
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #ifdef NoRepository
222 #endif
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
const labelList & reverseFaceMap() const
From face on original mesh to face on this.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Patch field mapper class for agglomerated meshes.
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Foam::fvPatchFieldMapper.
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.
Namespace for OpenFOAM.
const labelList & reversePointMap() const
From point on original mesh to point on this (or -1 for removed.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
#define forAll(list, i)
Definition: UList.H:421
const labelList & pointMap() const
From point on this back to original mesh.
Generic GeometricField class.
agglomPatchFieldMapper(const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
tmp< GeometricField< Type, fvPatchField, volMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Map volField. Internal field set to average, patch fields straight.
bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
bool empty() const
Return true if the hash table is empty.
A class for managing temporary objects.
Definition: PtrList.H:118
const labelListList & patchFaceMap() const
From patchFace on this back to original mesh or agglomeration.
virtual const scalarListList & weights() const
virtual const labelListList & addressing() const