25 #include <boost/operators.hpp>
27 #include <feel/feelcore/feel.hpp>
31 #include <feel/feelmesh/marker.hpp>
56 template<u
int16_type Dim,
typename T =
double>
59 public boost::equality_comparable<Geo0D<Dim,T> >,
60 public boost::less_than_comparable<Geo0D<Dim,T> >,
61 public boost::less_than_comparable<Geo0D<Dim,T>, size_type>,
63 public node<T, Dim>::type
66 typedef typename node<T, Dim>::type super2;
70 static const uint16_type nDim = Dim;
73 typedef super2 node_type;
91 explicit Geo0D(
size_type id,
bool boundary =
false,
bool is_vertex =
false );
105 explicit Geo0D(
size_type id, value_type x, value_type y, value_type z,
bool boundary =
false,
bool is_vertex =
false );
114 Geo0D( value_type x, value_type y, value_type z )
120 this->operator[]( 0 ) = x;
123 this->operator[]( 1 ) = y;
126 this->operator[]( 2 ) = z;
140 Geo0D(
size_type id, node_type
const& __x,
bool boundary =
false,
bool is_vertex =
false );
162 template<
typename AE>
163 Geo0D( ublas::vector_expression<AE>
const& __expr )
186 template<
typename AE>
192 template<
typename AE>
193 Geo0D & operator+=( ublas::vector_expression<AE>
const& expr )
195 super2::operator+=( expr );
199 value_type& operator()(
int i )
201 return this->operator[]( i );
204 value_type operator()(
int i )
const
206 return this->operator[]( i );
253 matrix_node_type
G()
const
255 matrix_node_type __G( Dim, 1 );
256 ublas::column( __G, 0 ) = *
this;
281 return M_is_parametric;
339 return this->id() == geo0d.id();
342 bool operator<(
Geo0D const& e )
const
344 return this->id() < e.id();
349 return this->id() < __i;
360 std::ostream &
showMe(
bool verbose =
false, std::ostream & c = std::cout )
const;
380 Marker1
const& marker()
const
388 void setMarker( flag_type
v )
390 return M_marker1.assign( v );
393 Marker2
const& marker2()
const
401 void setMarker2( flag_type v )
403 return M_marker2.assign( v );
406 Marker3
const& marker3()
const
414 void setMarker3( flag_type v )
416 return M_marker3.assign( v );
427 this->setMarker( tags[0] );
429 if ( tags.size() > 1 )
430 this->setMarker2( tags[1] );
432 if ( tags.size() > 2 )
436 std::vector<int> tags()
const
438 std::vector<int> thetags(3);
439 thetags[0] = M_marker1.value();
440 thetags[1] = M_marker2.value();
450 M_is_parametric =
true;
459 M_is_parametric =
true;
469 M_is_parametric =
true;
480 M_is_parametric =
true;
485 friend class boost::serialization::access;
486 template<
class Archive>
487 void serialize( Archive & ar,
const unsigned int version )
489 ar & boost::serialization::base_object<super>( *this );
490 ar & boost::serialization::base_object<super2>( *this );
505 bool M_is_parametric;
508 MeshBase
const* M_mesh;
517 parametric_node_type M_uv;
521 typedef Geo0D<3> Point;
527 template<u
int16_type Dim,
typename T>
532 M_is_vertex( false ),
533 M_is_parametric( false ),
544 template<u
int16_type Dim,
typename T>
549 M_is_vertex( is_vertex ),
561 template<u
int16_type Dim,
typename T>
566 M_is_vertex( is_vertex ),
567 M_is_parametric( false ),
575 this->operator[]( 0 ) = x;
578 this->operator[]( 1 ) = y;
581 this->operator[]( 2 ) = z;
586 template<u
int16_type Dim,
typename T>
591 M_is_vertex( is_vertex ),
592 M_is_parametric( false ),
600 FEELPP_ASSERT( __p.size() == Dim )( __p )( Dim ).error(
"invalid node" );
605 template<u
int16_type Dim,
typename T>
610 M_is_vertex( G.M_is_vertex ),
611 M_is_parametric( G.M_is_parametric ),
612 M_marker1( G.M_marker1 ),
613 M_marker2( G.M_marker2 ),
614 M_marker3( G.M_marker3 ),
621 template<u
int16_type Dim,
typename T>
630 M_is_vertex = G.M_is_vertex;
631 M_is_parametric = G.M_is_parametric;
632 M_marker1 = G.M_marker1;
633 M_marker2 = G.M_marker2;
634 M_marker3 = G.M_marker3;
641 template<u
int16_type Dim,
typename T>
645 out.setf( std::ios::scientific, std::ios::floatfield );
646 out <<
"----- BEGIN of Geo0D ---\n";
647 out <<
"id = " << this->id() <<
" node:" << this->
node() <<
"\n";
648 out <<
"is a vertex = " << isVertex() <<
"\n";
649 out <<
"----- END OF Geo0D ---\n";
653 template<u
int16_type Dim,
typename T>
656 operator<<( DebugStream& __os, Geo0D<Dim, T>
const& __n )
658 if ( __os.doPrint() )
660 std::ostringstream __str;
662 __str << __n.showMe(
true, __str );
664 __os << __str.str() <<
"\n";
669 template<u
int16_type Dim,
typename T>
672 operator<<( NdebugStream& __os, Geo0D<Dim, T>
const& __n )
681 distance( Geo0D<1,T>
const& p1, Geo0D<1,T>
const& p2 )
683 return ublas::norm_2( p1-p2 );
689 distance( Geo0D<2,T>
const& p1, Geo0D<2,T>
const& p2 )
691 return ublas::norm_2( p1-p2 );
697 distance( Geo0D<3,T>
const& p1, Geo0D<3,T>
const& p2 )
699 return ublas::norm_2( p1-p2 );
704 middle( Geo0D<1,T>
const& p1, Geo0D<1,T>
const& p2 )
712 middle( Geo0D<2,T>
const& p1, Geo0D<2,T>
const& p2 )
720 middle( Geo0D<3,T>
const& p1, Geo0D<3,T>
const& p2 )
725 template<
typename E1,
typename E2>
727 ublas::vector<double>
728 cross( ublas::vector_expression<E1> _p1,
729 ublas::vector_expression<E2> _p2 )
731 ublas::vector<double> v( 3 );
732 ublas::vector<double> p1( _p1 );
733 ublas::vector<double> p2( _p2 );
734 v( 0 ) = p1( 1 )*p2( 2 )-p1( 2 )*p2( 1 );
735 v( 1 ) = p1( 2 )*p2( 0 )-p1( 0 )*p2( 2 );
736 v( 2 ) = p1( 0 )*p2( 1 )-p1( 1 )*p2( 0 );
742 ublas::vector<double>
743 cross( Geo0D<3,T> p1,
746 ublas::vector<double> v( 3 );
747 v( 0 ) = p1( 1 )*p2( 2 ) - p1( 2 )*p2( 1 );
748 v( 1 ) = p1( 2 )*p2( 0 ) - p1( 0 )*p2( 2 );
749 v( 2 ) = p1( 0 )*p2( 1 ) - p1( 1 )*p2( 0 );