19 #ifndef __MESH_UTIL_BASE__
20 #define __MESH_UTIL_BASE__
26 #include <feel/feelcore/feel.hpp>
28 #include <feel/feelmesh/entities.hpp>
29 #include <feel/feelmesh/bareitems.hpp>
30 #include <feel/feelmesh/marker.hpp>
44 typedef std::map<BareFace, std::pair<size_type, size_type >, cmpBareItem<BareFace> > TempFaceContainer;
48 typedef std::map<BareEdge, std::pair<size_type, size_type>, cmpBareItem<BareEdge> > TempEdgeContainer;
50 template<
typename MeshType>
51 struct TempEntityContainer
53 typedef typename mpl::if_<mpl::equal_to<mpl::int_<MeshType::nDim>, mpl::int_<3> >,
54 mpl::identity<BareFace>,
55 mpl::identity<BareEdge> >::type::type entity_type;
56 typedef std::map<entity_type, std::pair<size_type, size_type >, cmpBareItem<entity_type> > type;
58 template<
typename Ele,
int Dim>
61 template<
typename Ele>
62 struct MakeBareEntity<Ele, 3>
64 typedef BareFace entity_type;
65 static const int numVertices = Ele::GeoBShape::numVertices;
67 MakeBareEntity( Ele
const& ele )
76 size_type i1 = ( M_element.point( 0 ) ).
id();
77 size_type i2 = ( M_element.point( 1 ) ).
id();
78 size_type i3 = ( M_element.point( 2 ) ).
id();
80 if ( Ele::face_type::numVertices == 4 )
82 size_type i4 = ( M_element.point( 3 ) ).
id();
94 operator()( uint16_type j )
const
101 i1 = ( M_element.point( i1 ) ).
id();
102 i2 = ( M_element.point( i2 ) ).
id();
103 i3 = ( M_element.point( i3 ) ).
id();
105 if ( numVertices == 4 )
108 i4 = ( M_element.point( i4 ) ).
id();
109 bface = ( makeBareItem( i1, i2, i3, i4 ) ).first;
114 bface = ( makeBareItem( i1, i2, i3 ) ).first;
119 Ele
const& M_element;
122 template<
typename Ele>
123 struct MakeBareEntity<Ele, 2>
125 typedef BareEdge entity_type;
127 MakeBareEntity( Ele
const& ele )
135 size_type i1 = ( M_element.point( 0 ) ).
id();
136 size_type i2 = ( M_element.point( 1 ) ).
id();
143 operator()( uint16_type j )
const
149 i1 = ( M_element.point( i1 ) ).
id();
150 i2 = ( M_element.point( i2 ) ).
id();
151 bface = ( makeBareItem( i1, i2 ) ).first;
154 Ele
const& M_element;
157 template<
typename Ele>
158 struct MakeBareEntity<Ele, 1>
160 typedef BarePoint entity_type;
162 MakeBareEntity( Ele
const& ele )
170 size_type i1 = ( M_element.point( 0 ) ).
id();
171 DVLOG(2) <<
"[mesh1d::updateFaces] point index in face " << i1 <<
"\n";
173 bface = makeBarePoint( i1 ).first;
177 operator()( uint16_type j )
const
180 size_type i1 = M_element.point( j ).id();
181 bface = makeBarePoint( i1 ).first;
184 Ele
const& M_element;
188 template<
typename Ele,
int Dim>
189 struct MakeBareEntityFromFace
192 template<
typename Ele>
193 struct MakeBareEntityFromFace<Ele, 3>
195 typedef BareFace entity_type;
196 static const int numVertices = Ele::numVertices;
198 MakeBareEntityFromFace( Ele
const& ele )
208 size_type i1 = ( M_element.point( 0 ) ).
id();
209 size_type i2 = ( M_element.point( 1 ) ).
id();
210 size_type i3 = ( M_element.point( 2 ) ).
id();
212 if ( numVertices == 4 )
214 size_type i4 = ( M_element.point( 3 ) ).
id();
215 bface = ( makeBareItem( i1, i2, i3, i4 ) ).first;
220 bface = ( makeBareItem( i1, i2, i3 ) ).first;
225 Ele
const& M_element;
228 template<
typename Ele>
229 struct MakeBareEntityFromFace<Ele, 2>
231 typedef BareEdge entity_type;
232 static const int numVertices = Ele::numVertices;
234 MakeBareEntityFromFace( Ele
const& ele )
244 size_type i1 = ( M_element.point( 0 ) ).
id();
245 size_type i2 = ( M_element.point( 1 ) ).
id();
246 bface = ( makeBareItem( i1, i2 ) ).first;
249 Ele
const& M_element;
262 typedef std::pair<Point, Point> MeshBoundingBox;
269 template<
typename MeshType>
272 boundingBox (
const MeshType& mesh )
276 return processorBoundingBox( mesh );
283 template<
typename MeshType>
286 boundingSphere (
const MeshType& mesh )
288 MeshBoundingBox bbox = boundingBox( mesh );
290 const double diag = Feel::distance( bbox.second, bbox.first );
291 const Point cent = Feel::middle( bbox.second, bbox.first );
293 return Sphere ( cent, .5*diag );
302 template<
typename MeshType>
305 processorBoundingBox (
const MeshType& mesh,
308 FEELPP_ASSERT ( mesh.numPoints() != 0 ).error(
"mesh has no points" );
310 Point min( 1.e30, 1.e30, 1.e30 );
311 Point max( -1.e30, -1.e30, -1.e30 );
317 DVLOG(2) <<
"[processorBoundingBox] np pid given\n";
319 for (
unsigned int n=0; n<mesh.numPoints(); n++ )
320 for (
unsigned int i=0; i<mesh.dimension(); i++ )
322 min( i ) = std::min( min( i ), mesh.point( n )( i ) );
323 max( i ) = std::max( max( i ), mesh.point( n )( i ) );
331 DVLOG(2) <<
"[processorBoundingBox] process bounding box on pid " << pid <<
"\n";
332 typename MeshType::element_iterator it = mesh.beginElementWithProcessId( pid );
333 typename MeshType::element_iterator en = mesh.endElementWithProcessId( pid );
335 for ( ; it != en; ++it )
336 for (
unsigned int n=0; n< MeshType::element_type::numPoints; n++ )
337 for (
unsigned int i=0; i<mesh.dimension(); i++ )
339 min( i ) = std::min( min( i ), mesh.point( n )( i ) );
340 max( i ) = std::max( max( i ), mesh.point( n )( i ) );
344 for (
unsigned int i=mesh.dimension(); i< min.node().size(); i++ )
350 DVLOG(2) <<
"[processorBoundingBox] min= " << min <<
"\n";
351 DVLOG(2) <<
"[processorBoundingBox] max= " << max <<
"\n";
352 const MeshBoundingBox ret_val( min, max );
360 template<
typename MeshType>
363 processorBoundingSphere (
const MeshType& mesh,
366 MeshBoundingBox bbox = processorBoundingBox( mesh,pid );
368 const Real diag = Feel::distance( bbox.second, bbox.first );
369 const Point cent = Feel::middle( bbox.second, bbox.first );
371 DVLOG(2) <<
"[processorBoundingSphere] processor " << mesh.comm().rank() <<
"\n";
372 DVLOG(2) <<
"[processorBoundingSphere] center " << cent <<
"\n";
373 DVLOG(2) <<
"[processorBoundingSphere] radius " << 0.5*diag <<
"\n";
374 return Sphere ( cent, .5*diag );
std::pair< BareFace, bool > makeBareFace(size_type const i, size_type const j, size_type const k)
It creates Bare Face objects from three Point size_type's.
Definition: bareitems.cpp:35
const size_type invalid_size_type_value
Definition: feelcore/feel.hpp:360
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319
std::pair< BareEdge, bool > makeBareEdge(size_type const i, size_type const j)
It creates a BareEdge end returns the orientation of the created edge with respect to the given data...
Definition: bareitems.hpp:234