1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | cfMesh: A library for mesh generation
5 \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6 \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of cfMesh.
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.
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
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/>.
28 Mesh smoothing without any topological changes
33 \*---------------------------------------------------------------------------*/
39 #include "labelLongList.H"
44 #include "labelledPoint.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // Forward declarations
56 /*---------------------------------------------------------------------------*\
57 Class partTetMesh Declaration
58 \*---------------------------------------------------------------------------*/
63 //- reference to the original mesh
64 polyMeshGen& origMesh_;
66 //- points in the tet mesh
67 LongList<point> points_;
69 //- tetrahedra making the mesh
70 LongList<partTet> tets_;
72 //- label of node in the polyMeshGen
73 labelLongList nodeLabelInOrigMesh_;
75 //- shall a node be used for smoothing or not
76 LongList<direction> smoothVertex_;
81 //- internal point ordering for parallel runs
82 mutable VRWGraph* internalPointsOrderPtr_;
84 //- boundary point ordering for parallel runs
85 mutable VRWGraph* boundaryPointsOrderPtr_;
87 // Private data for parallel runs
88 //- global point label
89 mutable labelLongList* globalPointLabelPtr_;
91 //- processor for containing points
92 mutable VRWGraph* pAtProcsPtr_;
94 //- mapping between global and local point labels
95 mutable Map<label>* globalToLocalPointAddressingPtr_;
97 //- processors which should communicate with the current one
98 mutable DynList<label>* neiProcsPtr_;
100 //- labels of points at parallel boundaries
101 mutable labelLongList* pAtParallelBoundariesPtr_;
103 //- labels of points serving as buffer layers on other processors
104 mutable labelLongList* pAtBufferLayersPtr_;
106 // Private member functions
108 //- create points and tets
109 void createPointsAndTets
111 const List<direction>& usedCells,
112 const boolList& lockedPoints
115 //- create parallel addressing
116 void createParallelAddressing
118 const labelLongList& nodeLabelForPoint,
119 const labelLongList& nodeLabelForFace,
120 const labelLongList& nodeLabelForCell
123 //- create buffer layers
124 void createBufferLayers();
126 //- create ordering of internal points for parallel execution
127 void createSMOOTHPointsOrdering() const;
129 //- create order of boundary points for parallel execution
130 void createBOUNDARYPointsOrdering() const;
135 //- construct from polyMeshGen and locked points
136 partTetMesh(polyMeshGen& mesh, const labelLongList& lockedPoints);
138 //- construct from polyMeshGen, locked points and the number of layers
139 //- from the boundary
143 const labelLongList& lockedPoints,
144 const direction nLayers = 2
147 //- construct from polyMeshGen, bad faces and the number
148 //- of additional layers
152 const labelLongList& lockedPoints,
153 labelHashSet& badFaces,
154 const direction additionalLayers = 0
165 PARALLELBOUNDARY = 8,
174 //- access to points, tets and other data
175 inline const LongList<point>& points() const
180 inline const LongList<partTet>& tets() const
185 inline const VRWGraph& pointTets() const
190 inline const LongList<direction>& smoothVertex() const
192 return smoothVertex_;
195 inline const labelLongList& nodeLabelInOrigMesh() const
197 return nodeLabelInOrigMesh_;
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;
207 //- return vertex ordering for boundary points
208 const VRWGraph& boundaryPointOrdering() const;
210 // Access to parallel data
211 inline const labelLongList& globalPointLabel() const
213 if( !Pstream::parRun() )
214 FatalError << "This is a serial run" << abort(FatalError);
216 return *globalPointLabelPtr_;
219 inline const VRWGraph& pointAtProcs() const
221 if( !Pstream::parRun() )
222 FatalError << "This is a serial run" << abort(FatalError);
224 return *pAtProcsPtr_;
227 inline const Map<label>& globalToLocalPointAddressing() const
229 if( !Pstream::parRun() )
230 FatalError << "This is a serial run" << abort(FatalError);
232 return *globalToLocalPointAddressingPtr_;
235 inline const DynList<label>& neiProcs() const
237 if( !Pstream::parRun() )
238 FatalError << "This is a serial run" << abort(FatalError);
240 return *neiProcsPtr_;
243 inline const labelLongList& pointsAtProcessorBoundaries() const
245 if( !Pstream::parRun() )
246 FatalError << "This is a serial run" << abort(FatalError);
248 return *pAtParallelBoundariesPtr_;
251 inline const labelLongList& bufferLayerPoints() const
253 if( !Pstream::parRun() )
254 FatalError << "This is a serial run" << abort(FatalError);
256 return *pAtBufferLayersPtr_;
261 //- move the vertex to a new position
262 void updateVertex(const label pointI, const point& newP);
264 //- move vertices to their new positions
265 //- intended for SMP parallelisation
266 void updateVerticesSMP(const List<LongList<labelledPoint> >&);
268 //- updates the vertices of the original polyMeshGen
269 void updateOrigMesh(boolList* changedFacePtr = NULL);
271 //- creates polyMeshGen from this partTetMesh
272 void createPolyMesh(polyMeshGen& pmg) const;
274 //- add the LOCKED flag to mesh points which shall not move
275 template<class labelListType>
276 void lockPoints(const labelListType& l)
279 smoothVertex_[l[pI]] |= LOCKED;
283 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
285 } // End namespace Foam
287 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
291 // ************************************************************************* //