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 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:
105 
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
158  singleCellFvMesh(const IOobject& io, const fvMesh&);
159 
160  //- Construct from fvMesh and agglomeration of boundary faces.
161  // Agglomeration is per patch, per patch face index the agglomeration
162  // the face goes into.
164  (
165  const IOobject& io,
166  const fvMesh&,
167  const labelListList& patchFaceAgglomeration
168  );
169 
170  //- Read from IOobject
171  singleCellFvMesh(const IOobject& io);
172 
173  // Member Functions
174 
175  bool agglomerate() const
176  {
177  return patchFaceAgglomeration_.size() > 0;
178  }
179 
180  //- From patchFace on this back to original mesh or agglomeration
181  const labelListList& patchFaceMap() const
182  {
183  return patchFaceMap_;
184  }
185 
186  //- From point on this back to original mesh
187  const labelList& pointMap() const
188  {
189  return pointMap_;
190  }
191 
192  //- From face on original mesh to face on this
193  const labelList& reverseFaceMap() const
194  {
195  return reverseFaceMap_;
196  }
197 
198  //- From point on original mesh to point on this (or -1 for removed
199  //- points)
200  const labelList& reversePointMap() const
201  {
202  return reversePointMap_;
203  }
204 
205  //- Map volField. Internal field set to average, patch fields straight
206  //- copies.
207  template<class Type>
210  (
212  ) const;
213 
214 };
215 
216 
217 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
218 
219 } // End namespace Foam
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 #ifdef NoRepository
225 #endif
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
Foam::singleCellFvMesh::agglomPatchFieldMapper::hasUnmapped
bool hasUnmapped() const
Are there unmapped values? I.e. do all size() elements get.
Definition: singleCellFvMesh.H:136
singleCellFvMeshInterpolate.C
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::singleCellFvMesh::agglomPatchFieldMapper::direct
virtual bool direct() const
Definition: singleCellFvMesh.H:131
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::singleCellFvMesh::agglomPatchFieldMapper::size
virtual label size() const
Definition: singleCellFvMesh.H:126
Foam::singleCellFvMesh::reverseFaceMap
const labelList & reverseFaceMap() const
From face on original mesh to face on this.
Definition: singleCellFvMesh.H:192
Foam::singleCellFvMesh::agglomPatchFieldMapper
Patch field mapper class for agglomerated meshes.
Definition: singleCellFvMesh.H:93
fvPatchFieldMapper.H
Foam::singleCellFvMesh::pointMap
const labelList & pointMap() const
From point on this back to original mesh.
Definition: singleCellFvMesh.H:186
labelListIOList.H
Foam::singleCellFvMesh::agglomPatchFieldMapper::addressing
virtual const labelListList & addressing() const
Definition: singleCellFvMesh.H:141
Foam::singleCellFvMesh::agglomPatchFieldMapper::weights
virtual const scalarListList & weights() const
Definition: singleCellFvMesh.H:146
Foam::singleCellFvMesh
fvMesh as subset of other mesh. Consists of one cell and all original bounday faces....
Definition: singleCellFvMesh.H:56
Foam::singleCellFvMesh::interpolate
tmp< GeometricField< Type, fvPatchField, volMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Definition: singleCellFvMeshInterpolate.C:42
Foam::singleCellFvMesh::agglomPatchFieldMapper::agglomPatchFieldMapper
agglomPatchFieldMapper(const labelListList &addressing, const scalarListList &weights)
Construct given addressing.
Definition: singleCellFvMesh.H:107
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::singleCellFvMesh::patchFaceMap
const labelListList & patchFaceMap() const
From patchFace on this back to original mesh or agglomeration.
Definition: singleCellFvMesh.H:180
Foam::singleCellFvMesh::agglomerate
bool agglomerate() const
Definition: singleCellFvMesh.H:174
Foam::List< labelList >
Foam::IOList
A List of objects of type <T> with automated input and output.
Definition: IOList.H:53
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::GeometricField< Type, fvPatchField, volMesh >
Foam::singleCellFvMesh::reversePointMap
const labelList & reversePointMap() const
Definition: singleCellFvMesh.H:199