partTetMesh.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  partTetMesh
26 
27 Description
28  Mesh smoothing without any topological changes
29 
30 SourceFiles
31  partTetMesh.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef partTetMesh_H
36 #define partTetMesh_H
37 
38 #include "boolList.H"
39 #include "labelLongList.H"
40 #include "VRWGraph.H"
41 #include "DynList.H"
42 #include "partTet.H"
43 #include "HashSet.H"
44 #include "labelledPoint.H"
45 #include "Map.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward declarations
53 class polyMeshGen;
54 class VRWGraph;
55 
56 /*---------------------------------------------------------------------------*\
57  Class partTetMesh Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class partTetMesh
61 {
62  // Private data
63  //- reference to the original mesh
65 
66  //- points in the tet mesh
68 
69  //- tetrahedra making the mesh
71 
72  //- label of node in the polyMeshGen
74 
75  //- shall a node be used for smoothing or not
77 
78  //- addressing data
80 
81  //- internal point ordering for parallel runs
83 
84  //- boundary point ordering for parallel runs
86 
87  // Private data for parallel runs
88  //- global point label
90 
91  //- processor for containing points
92  mutable VRWGraph* pAtProcsPtr_;
93 
94  //- mapping between global and local point labels
96 
97  //- processors which should communicate with the current one
99 
100  //- labels of points at parallel boundaries
102 
103  //- labels of points serving as buffer layers on other processors
105 
106  // Private member functions
107 
108  //- create points and tets
110  (
111  const List<direction>& usedCells,
112  const boolList& lockedPoints
113  );
114 
115  //- create parallel addressing
117  (
118  const labelLongList& nodeLabelForPoint,
119  const labelLongList& nodeLabelForFace,
120  const labelLongList& nodeLabelForCell
121  );
122 
123  //- create buffer layers
124  void createBufferLayers();
125 
126  //- create ordering of internal points for parallel execution
127  void createSMOOTHPointsOrdering() const;
128 
129  //- create order of boundary points for parallel execution
130  void createBOUNDARYPointsOrdering() const;
131 
132 public:
133 
134  // Constructors
135  //- construct from polyMeshGen and locked points
136  partTetMesh(polyMeshGen& mesh, const labelLongList& lockedPoints);
137 
138  //- construct from polyMeshGen, locked points and the number of layers
139  //- from the boundary
141  (
142  polyMeshGen& mesh,
143  const labelLongList& lockedPoints,
144  const direction nLayers = 2
145  );
146 
147  //- construct from polyMeshGen, bad faces and the number
148  //- of additional layers
150  (
151  polyMeshGen& mesh,
152  const labelLongList& lockedPoints,
153  labelHashSet& badFaces,
154  const direction additionalLayers = 0
155  );
156 
157  // Enumerators
158 
159  enum vertexTypes
160  {
161  NONE = 0,
162  SMOOTH = 1,
166  BOUNDARY = 16,
167  LOCKED = 32
168  };
169 
170  // Destructor
171  ~partTetMesh();
172 
173  // Member functions
174  //- access to points, tets and other data
175  inline const LongList<point>& points() const
176  {
177  return points_;
178  }
179 
180  inline const LongList<partTet>& tets() const
181  {
182  return tets_;
183  }
184 
185  inline const VRWGraph& pointTets() const
186  {
187  return pointTets_;
188  }
189 
190  inline const LongList<direction>& smoothVertex() const
191  {
192  return smoothVertex_;
193  }
194 
195  inline const labelLongList& nodeLabelInOrigMesh() const
196  {
197  return nodeLabelInOrigMesh_;
198  }
199 
200  // Access to point ordering for Gauss-Seidel type of iteration
201  //- return vertex ordering which can be executed in parallel
202  //- the points in each row can be treated in parallel
203  //- make sure that points added to different rows of this graph are
204  //- not treated concurrently
205  const VRWGraph& internalPointOrdering() const;
206 
207  //- return vertex ordering for boundary points
208  const VRWGraph& boundaryPointOrdering() const;
209 
210  // Access to parallel data
211  inline const labelLongList& globalPointLabel() const
212  {
213  if( !Pstream::parRun() )
214  FatalError << "This is a serial run" << abort(FatalError);
215 
216  return *globalPointLabelPtr_;
217  }
218 
219  inline const VRWGraph& pointAtProcs() const
220  {
221  if( !Pstream::parRun() )
222  FatalError << "This is a serial run" << abort(FatalError);
223 
224  return *pAtProcsPtr_;
225  }
226 
227  inline const Map<label>& globalToLocalPointAddressing() const
228  {
229  if( !Pstream::parRun() )
230  FatalError << "This is a serial run" << abort(FatalError);
231 
233  }
234 
235  inline const DynList<label>& neiProcs() const
236  {
237  if( !Pstream::parRun() )
238  FatalError << "This is a serial run" << abort(FatalError);
239 
240  return *neiProcsPtr_;
241  }
242 
243  inline const labelLongList& pointsAtProcessorBoundaries() const
244  {
245  if( !Pstream::parRun() )
246  FatalError << "This is a serial run" << abort(FatalError);
247 
249  }
250 
251  inline const labelLongList& bufferLayerPoints() const
252  {
253  if( !Pstream::parRun() )
254  FatalError << "This is a serial run" << abort(FatalError);
255 
256  return *pAtBufferLayersPtr_;
257  }
258 
259  // Modifiers
260 
261  //- move the vertex to a new position
262  void updateVertex(const label pointI, const point& newP);
263 
264  //- move vertices to their new positions
265  //- intended for SMP parallelisation
267 
268  //- updates the vertices of the original polyMeshGen
269  void updateOrigMesh(boolList* changedFacePtr = NULL);
270 
271  //- creates polyMeshGen from this partTetMesh
272  void createPolyMesh(polyMeshGen& pmg) const;
273 
274  //- add the LOCKED flag to mesh points which shall not move
275  template<class labelListType>
276  void lockPoints(const labelListType& l)
277  {
278  forAll(l, pI)
279  smoothVertex_[l[pI]] |= LOCKED;
280  }
281 };
282 
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
284 
285 } // End namespace Foam
286 
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 
289 #endif
290 
291 // ************************************************************************* //
Foam::partTetMesh::vertexTypes
vertexTypes
Definition: partTetMesh.H:158
Foam::partTetMesh::createParallelAddressing
void createParallelAddressing(const labelLongList &nodeLabelForPoint, const labelLongList &nodeLabelForFace, const labelLongList &nodeLabelForCell)
create parallel addressing
Definition: partTetMeshParallelAddressing.C:47
Foam::partTetMesh::createBufferLayers
void createBufferLayers()
create buffer layers
Definition: partTetMeshParallelAddressing.C:318
Foam::partTetMesh::neiProcsPtr_
DynList< label > * neiProcsPtr_
processors which should communicate with the current one
Definition: partTetMesh.H:97
Foam::partTetMesh::FACECENTRE
@ FACECENTRE
Definition: partTetMesh.H:162
Foam::partTetMesh::smoothVertex_
LongList< direction > smoothVertex_
shall a node be used for smoothing or not
Definition: partTetMesh.H:75
boolList.H
Foam::partTetMesh::createPolyMesh
void createPolyMesh(polyMeshGen &pmg) const
creates polyMeshGen from this partTetMesh
Definition: partTetMesh.C:634
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::partTetMesh::NONE
@ NONE
Definition: partTetMesh.H:160
Foam::partTetMesh::pAtParallelBoundariesPtr_
labelLongList * pAtParallelBoundariesPtr_
labels of points at parallel boundaries
Definition: partTetMesh.H:100
Foam::partTetMesh::boundaryPointsOrderPtr_
VRWGraph * boundaryPointsOrderPtr_
boundary point ordering for parallel runs
Definition: partTetMesh.H:84
VRWGraph.H
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::Map< label >
Foam::polyMeshGen
Definition: polyMeshGen.H:46
Foam::partTetMesh::tets_
LongList< partTet > tets_
tetrahedra making the mesh
Definition: partTetMesh.H:69
Foam::partTetMesh::globalPointLabelPtr_
labelLongList * globalPointLabelPtr_
global point label
Definition: partTetMesh.H:88
polyMeshGen
Mesh with selections.
Foam::HashSet< label, Hash< label > >
Foam::partTetMesh::pointTets
const VRWGraph & pointTets() const
Definition: partTetMesh.H:184
Foam::partTetMesh::partTetMesh
partTetMesh(polyMeshGen &mesh, const labelLongList &lockedPoints)
construct from polyMeshGen and locked points
Definition: partTetMesh.C:50
Foam::LongList
Definition: LongList.H:55
Map.H
Foam::partTetMesh::internalPointsOrderPtr_
VRWGraph * internalPointsOrderPtr_
internal point ordering for parallel runs
Definition: partTetMesh.H:81
Foam::partTetMesh::pointAtProcs
const VRWGraph & pointAtProcs() const
Definition: partTetMesh.H:218
Foam::label
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
Foam::partTetMesh::globalToLocalPointAddressing
const Map< label > & globalToLocalPointAddressing() const
Definition: partTetMesh.H:226
Foam::partTetMesh::pAtProcsPtr_
VRWGraph * pAtProcsPtr_
processor for containing points
Definition: partTetMesh.H:91
Foam::partTetMesh::updateOrigMesh
void updateOrigMesh(boolList *changedFacePtr=NULL)
updates the vertices of the original polyMeshGen
Definition: partTetMesh.C:535
Foam::partTetMesh::tets
const LongList< partTet > & tets() const
Definition: partTetMesh.H:179
Foam::partTetMesh::createSMOOTHPointsOrdering
void createSMOOTHPointsOrdering() const
create ordering of internal points for parallel execution
Definition: partTetMeshAddressing.C:403
Foam::partTetMesh::~partTetMesh
~partTetMesh()
Definition: partTetMesh.C:330
Foam::partTetMesh::lockPoints
void lockPoints(const labelListType &l)
add the LOCKED flag to mesh points which shall not move
Definition: partTetMesh.H:275
HashSet.H
Foam::partTetMesh::createPointsAndTets
void createPointsAndTets(const List< direction > &usedCells, const boolList &lockedPoints)
create points and tets
Definition: partTetMeshAddressing.C:45
Foam::FatalError
error FatalError
labelledPoint.H
Foam::partTetMesh::SMOOTH
@ SMOOTH
Definition: partTetMesh.H:161
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::partTetMesh::pAtBufferLayersPtr_
labelLongList * pAtBufferLayersPtr_
labels of points serving as buffer layers on other processors
Definition: partTetMesh.H:103
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::DynList< label >
Foam::partTetMesh::globalToLocalPointAddressingPtr_
Map< label > * globalToLocalPointAddressingPtr_
mapping between global and local point labels
Definition: partTetMesh.H:94
Foam::partTetMesh::PARALLELBOUNDARY
@ PARALLELBOUNDARY
Definition: partTetMesh.H:164
Foam::partTetMesh::bufferLayerPoints
const labelLongList & bufferLayerPoints() const
Definition: partTetMesh.H:250
Foam::partTetMesh
Definition: partTetMesh.H:59
Foam::partTetMesh::BOUNDARY
@ BOUNDARY
Definition: partTetMesh.H:165
Foam::partTetMesh::createBOUNDARYPointsOrdering
void createBOUNDARYPointsOrdering() const
create order of boundary points for parallel execution
Definition: partTetMeshAddressing.C:478
Foam::partTetMesh::CELLCENTRE
@ CELLCENTRE
Definition: partTetMesh.H:163
Foam::partTetMesh::pointsAtProcessorBoundaries
const labelLongList & pointsAtProcessorBoundaries() const
Definition: partTetMesh.H:242
Foam::partTetMesh::nodeLabelInOrigMesh
const labelLongList & nodeLabelInOrigMesh() const
Definition: partTetMesh.H:194
Foam::partTetMesh::pointTets_
VRWGraph pointTets_
addressing data
Definition: partTetMesh.H:78
Foam::Vector< scalar >
Foam::List< direction >
Foam::partTetMesh::origMesh_
polyMeshGen & origMesh_
reference to the original mesh
Definition: partTetMesh.H:63
VRWGraph
This class is an implementation of a graph with variable column width. The imoplementation is memory ...
Foam::partTetMesh::nodeLabelInOrigMesh_
labelLongList nodeLabelInOrigMesh_
label of node in the polyMeshGen
Definition: partTetMesh.H:72
labelLongList.H
Foam::partTetMesh::boundaryPointOrdering
const VRWGraph & boundaryPointOrdering() const
return vertex ordering for boundary points
Definition: partTetMesh.C:363
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::partTetMesh::internalPointOrdering
const VRWGraph & internalPointOrdering() const
Definition: partTetMesh.C:344
Foam::partTetMesh::points_
LongList< point > points_
points in the tet mesh
Definition: partTetMesh.H:66
Foam::partTetMesh::updateVerticesSMP
void updateVerticesSMP(const List< LongList< labelledPoint > > &)
Definition: partTetMesh.C:454
Foam::partTetMesh::neiProcs
const DynList< label > & neiProcs() const
Definition: partTetMesh.H:234
Foam::partTetMesh::points
const LongList< point > & points() const
access to points, tets and other data
Definition: partTetMesh.H:174
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::partTetMesh::LOCKED
@ LOCKED
Definition: partTetMesh.H:166
Foam::partTetMesh::smoothVertex
const LongList< direction > & smoothVertex() const
Definition: partTetMesh.H:189
DynList.H
Foam::partTetMesh::updateVertex
void updateVertex(const label pointI, const point &newP)
move the vertex to a new position
Definition: partTetMesh.C:381
Foam::partTetMesh::globalPointLabel
const labelLongList & globalPointLabel() const
Definition: partTetMesh.H:210
partTet.H