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 to the nearest point on the geometry surface
33 \*---------------------------------------------------------------------------*/
35 #ifndef meshSurfaceMapper_H
36 #define meshSurfaceMapper_H
38 #include "labelList.H"
39 #include "pointField.H"
40 #include "labelLongList.H"
41 #include "parMapperHelper.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 // Forward declarations
52 class meshSurfaceEngine;
53 class meshSurfacePartitioner;
54 class triSurfacePartitioner;
56 /*---------------------------------------------------------------------------*\
57 Class meshSurfaceMapper Declaration
58 \*---------------------------------------------------------------------------*/
60 class meshSurfaceMapper
64 const meshSurfaceEngine& surfaceEngine_;
66 //- reference to the octree
67 const meshOctree& meshOctree_;
69 //- mesh surface partitioner
70 mutable const meshSurfacePartitioner* surfaceEnginePartitionerPtr_;
71 const bool deletePartitioner_;
73 //- triSurface partitioner
74 mutable triSurfacePartitioner* surfPartitionerPtr_;
76 // Private member functions
77 //- create and return mesh surface partitioner
78 void createMeshSurfacePartitioner() const;
79 inline const meshSurfacePartitioner& meshPartitioner() const
81 if( !surfaceEnginePartitionerPtr_ )
82 createMeshSurfacePartitioner();
84 return *surfaceEnginePartitionerPtr_;
87 //- create and return triSurfacePartitioner
88 void createTriSurfacePartitioner() const;
89 inline const triSurfacePartitioner& surfacePartitioner() const
91 if( !surfPartitionerPtr_ )
92 createTriSurfacePartitioner();
94 return *surfPartitionerPtr_;
97 //- delete surfaceEnginePartitionerPtr_ and surfPartitionerPtr_
100 // Private member functions
101 //- map corner nodes to the boundary
102 void mapCorners(const labelLongList& nodesToMap);
104 //- find mapping distance for selected points
105 void findMappingDistance
107 const labelLongList& nodesToMap,
108 std::map<label, scalar>& mappingDistance
111 // Private member functions needed for parallel execution
113 //- check if nodes at parallel boundaries are selected at all processors
114 void selectNodesAtParallelBnd(const labelLongList&);
116 //- map to the smallest distance
117 //- makes sense for parallel calculations, only
118 void mapToSmallestDistance(LongList<parMapperHelper>&);
120 //- Disallow default bitwise copy construct
121 meshSurfaceMapper(const meshSurfaceMapper&);
123 //- Disallow default bitwise assignment
124 void operator=(const meshSurfaceMapper&);
130 //- Construct from meshSurfaceEngine and octree
131 meshSurfaceMapper(const meshSurfaceEngine&, const meshOctree&);
133 //- Construct from meshSurfacePartitioner and octree
134 meshSurfaceMapper(const meshSurfacePartitioner&, const meshOctree&);
138 ~meshSurfaceMapper();
141 //- map the given surface node on the selected patch
142 //- this does not make sense for vertices at parallel boundaries
143 void mapNodeToPatch(const label bpI, const label patchI = -1);
145 //- projects surface vertices onto their nearest location
146 //- on the surface mesh
147 void mapVerticesOntoSurface();
149 //- projects selected surface vertices to their nearest location
150 //- on the surface mesh
151 void mapVerticesOntoSurface(const labelLongList& nodesToMap);
153 //- projects corner and edge vertices onto their nearest location
154 //- on the surface mesh
155 void mapCornersAndEdges();
157 //- projects selected edge vertices onto their nearest
158 //- locations on the surface mesh
159 void mapEdgeNodes(const labelLongList& nodesToMap);
161 //- projects surface vertices onto the surface with respect
162 //- to the surface patch they belong to. Edges and corner are respected
163 void mapVerticesOntoSurfacePatches();
165 //- projects selected surface vertices onto the surface with respect
166 //- to the surface patch they belong to. Edges and corner are respected
167 void mapVerticesOntoSurfacePatches(const labelLongList& nodesToMap);
169 //- a combination of mapping and smoothing intended for better
170 //- feature capturing
171 void preMapVertices(const label nIterations = 2);
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 } // End namespace Foam
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 // ************************************************************************* //