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 scalarList & mappingDistance
111 //- calculate face metric
112 scalar faceMetricInPatch(const label bfI, const label patchI) const;
114 // Private member functions needed for parallel execution
116 //- check if nodes at parallel boundaries are selected at all processors
117 void selectNodesAtParallelBnd(const labelLongList&);
119 //- map to the smallest distance
120 //- makes sense for parallel calculations, only
121 void mapToSmallestDistance(LongList<parMapperHelper>&);
123 //- Disallow default bitwise copy construct
124 meshSurfaceMapper(const meshSurfaceMapper&);
126 //- Disallow default bitwise assignment
127 void operator=(const meshSurfaceMapper&);
133 //- Construct from meshSurfaceEngine and octree
134 meshSurfaceMapper(const meshSurfaceEngine&, const meshOctree&);
136 //- Construct from meshSurfacePartitioner and octree
137 meshSurfaceMapper(const meshSurfacePartitioner&, const meshOctree&);
141 ~meshSurfaceMapper();
144 //- map the given surface node on the selected patch
145 //- this does not make sense for vertices at parallel boundaries
146 void mapNodeToPatch(const label bpI, const label patchI = -1);
148 //- projects surface vertices onto their nearest location
149 //- on the surface mesh
150 void mapVerticesOntoSurface();
152 //- projects selected surface vertices to their nearest location
153 //- on the surface mesh
154 void mapVerticesOntoSurface(const labelLongList& nodesToMap);
156 //- projects corner and edge vertices onto their nearest location
157 //- on the surface mesh
158 void mapCornersAndEdges();
160 //- projects selected edge vertices onto their nearest
161 //- locations on the surface mesh
162 void mapEdgeNodes(const labelLongList& nodesToMap);
164 //- projects surface vertices onto the surface with respect
165 //- to the surface patch they belong to. Edges and corner are respected
166 void mapVerticesOntoSurfacePatches();
168 //- projects selected surface vertices onto the surface with respect
169 //- to the surface patch they belong to. Edges and corner are respected
170 void mapVerticesOntoSurfacePatches(const labelLongList& nodesToMap);
172 //- a combination of mapping and smoothing intended for better
173 //- feature capturing
174 void preMapVertices(const label nIterations = 3);
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 } // End namespace Foam
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 // ************************************************************************* //