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 Maps vertices of a 2D onto the nearest points on the geometry
33 \*---------------------------------------------------------------------------*/
35 #ifndef meshSurfaceMapper2D_H
36 #define meshSurfaceMapper2D_H
38 #include "labelList.H"
39 #include "pointField.H"
40 #include "labelLongList.H"
41 #include "parMapperHelper.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // Forward declarations
54 class polyMeshGen2DEngine;
55 class meshSurfaceEngine;
56 class meshSurfacePartitioner;
57 class triSurfacePartitioner;
59 /*---------------------------------------------------------------------------*\
60 Class meshSurfaceMapper2D Declaration
61 \*---------------------------------------------------------------------------*/
63 class meshSurfaceMapper2D
66 //- reference to mesh surface
67 const meshSurfaceEngine& surfaceEngine_;
69 //- reference to the octree
70 const meshOctree& meshOctree_;
73 mutable polyMeshGen2DEngine* mesh2DEnginePtr_;
75 //- triSurface partitioner
76 mutable triSurfacePartitioner* surfPartitionerPtr_;
78 //- mesh surface partitioner
79 mutable meshSurfacePartitioner* meshPartitionerPtr_;
81 //- labels of edges which are at the boundary which shall be mapped
83 labelLongList activeBoundaryEdges_;
85 // Private member functions
86 //- find active boundary edges
87 void findActiveBoundaryEdges();
89 //- create a 2D engine
90 void create2DEngine() const;
92 //- create and return mesh 2D engine
93 inline const polyMeshGen2DEngine& mesh2DEngine() const
95 if( !mesh2DEnginePtr_ )
98 return *mesh2DEnginePtr_;
101 //- create surface partitioner
102 void createTriSurfacePartitioner() const;
104 //- create and reurn surface partitioner
105 inline const triSurfacePartitioner& surfacePartitioner() const
107 if( !surfPartitionerPtr_ )
108 createTriSurfacePartitioner();
110 return *surfPartitionerPtr_;
113 //- create mesh surface partitioner
114 void createMeshSurfacePartitioner() const;
116 //- create and return mesh surface partitioner
117 inline const meshSurfacePartitioner& meshPartitioner() const
119 if( !meshPartitionerPtr_ )
120 createMeshSurfacePartitioner();
122 return *meshPartitionerPtr_;
125 //- delete dynamically allocated data
128 // Private member functions needed for parallel execution
129 //- find mapping distance for corner points
130 void findMappingDistance
132 const labelLongList&,
133 std::map<label, scalar>&
136 //- map to the location with the smallest distance
137 void mapToSmallestDistance(LongList<parMapperHelper>&);
139 //- Disallow default bitwise copy construct
140 meshSurfaceMapper2D(const meshSurfaceMapper2D&);
142 //- Disallow default bitwise assignment
143 void operator=(const meshSurfaceMapper2D&);
149 //- Construct from meshSurfaceEngine and octree
150 meshSurfaceMapper2D(const meshSurfaceEngine&, const meshOctree&);
154 ~meshSurfaceMapper2D();
158 //- adjust z coordinates of the mesh to the ones in the surface mesh
159 void adjustZCoordinates();
161 //- projects surface vertices onto their nearest location
162 //- on the surface mesh
163 void mapVerticesOntoSurface();
165 //- projects selected edge to their nearest location
166 //- on the surface mesh
167 void mapVerticesOntoSurface(const labelLongList& edgesToMap);
169 //- projects edges with corners onto their nearest location
170 //- on the surface mesh
173 //- projects selected edges with corners onto their nearest
174 //- locations on the surface mesh
175 void mapCorners(const labelLongList& edgesToMap);
177 //- projects surface edges onto the surface with respect
178 //- to the surface patch they belong to. Corners are respected
179 void mapVerticesOntoSurfacePatches();
181 //- projects selected surface edges onto the surface with respect
182 //- to the surface patch they belong to. Corners are respected
183 void mapVerticesOntoSurfacePatches(const labelLongList& edgesToMap);
185 //- a combination of mapping and smoothing intended for better
186 //- feature capturing
187 void preMapVertices(const label nIterations = 2);
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 } // End namespace Foam
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 // ************************************************************************* //