void PointSetToMesh<Convex, T>::visit( pointset_type* pset, mpl::int_<1> ) { DVLOG(2) << "[PointSetToMesh::visit(<1>)] pointset to mesh\n"; M_mesh = mesh_ptrtype( new mesh_type( Environment::worldComm().subWorldCommSeq() ) ); size_type __npts = pset->nPoints(); for ( uint __i = 0; __i < __npts; ++__i ) { node_type __nd( 1 ); __nd = pset->point( __i ); point_type __pt( __i,__nd, false ); __pt.marker() = 0; if ( __nd[0] == -1 || __nd[0] == 1 ) { __pt.setOnBoundary( true ); } else { __pt.setOnBoundary( false ); } M_mesh->addPoint( __pt ); } size_type n_faces = 0; // Add Boundary faces face_type* pf0 = new face_type; pf0->marker() = 0; pf0->setPoint( 0, M_mesh->point( 0 ) ); pf0->setId( n_faces++ ); pf0->setOnBoundary( true ); M_mesh->addFace( *pf0 ); delete pf0; face_type* pf1 = new face_type; pf1->marker() = 0; pf1->setPoint( 0, M_mesh->point( 1 ) ); pf1->setId( n_faces++ ); pf1->setOnBoundary( true ); M_mesh->addFace( *pf1 ); delete pf1; size_type __nele = __npts-1; for ( uint __i = 0; __i < __nele; ++__i ) { element_type pf; pf.setId( __i ); pf.marker() = 0; if ( __nele == 1 ) { pf.setPoint( 0, M_mesh->point( __i ) ); pf.setPoint( 1, M_mesh->point( __i+1 ) ); } else if ( __i == 0 ) { pf.setPoint( 0, M_mesh->point( __i ) ); pf.setPoint( 1, M_mesh->point( __i+2 ) ); } else if ( __i == __nele-1 ) { pf.setPoint( 0, M_mesh->point( __i+1 ) ); pf.setPoint( 1, M_mesh->point( 1 ) ); } else { pf.setPoint( 0, M_mesh->point( __i+1 ) ); pf.setPoint( 1, M_mesh->point( __i+2 ) ); } element_type const& e = M_mesh->addElement( pf ); DVLOG(2) << "o element " << e.id() << "\n" << " p1 = " << e.point( 0 ).node() << "\n" << " p2 = " << e.point( 1 ).node() << "\n"; } FEELPP_ASSERT( n_faces == M_mesh->numFaces() )( n_faces )( M_mesh->numFaces() ).error( "invalid face container size" ); DVLOG(2) <<"[PointSetToMesh<1>] done with element accumulation !\n"; M_mesh->setNumVertices( __npts ); DVLOG(2) <<"[PointSetToMesh<1>] Face Update !\n"; //// do not renumber the M_mesh entities //M_mesh->updateForUse( MESH_ALL_COMPONENTS & (~MESH_RENUMBER) ); DVLOG(2) <<"[PointSetToMesh<1>] Face Update Successful !\n"; DVLOG(2) << "[PointSetToMesh::visit(<1>)] done\n"; }
std::vector<__gnu_cxx::__quadrature_point_t<_Tp>> __lobatto_zeros(unsigned int __l, _Tp proto = _Tp{}) { const auto _S_eps = __gnu_cxx::__epsilon(proto); const auto _S_pi = __gnu_cxx::__const_pi(proto); const unsigned int _S_maxit = 1000u; std::vector<__gnu_cxx::__quadrature_point_t<_Tp>> __pt(__l); auto __m = __l / 2; // Treat the central zero for odd order specially. if (__l & 1) { auto __lm = __l - 1; auto __lmfact = std::__detail::__factorial<_Tp>(__lm); auto __mm = __lm / 2; auto __mmfact = std::__detail::__factorial<_Tp>(__mm); auto __Plm1 = (__lm & 1 ? -1 : 1) * __lmfact / __mmfact / __mmfact / std::pow(_Tp{2}, __lm); auto __Ppl = __l * __Plm1; __pt[__m].__zero = _Tp{0}; __pt[__m].__weight = _Tp{2} / __Ppl / __Ppl; } for (auto __i = 1u; __i <= __m; ++__i) { // Clever approximation of root. auto __z = std::cos(_S_pi * (__i - _Tp{1} / _Tp{4}) / (__l + _Tp{1} / _Tp{2})); auto __z1 = __z; auto __w = _Tp{0}; for (auto __its = 0u; __its < _S_maxit; ++__its) { // Compute __P, __P1, and __P2 the Legendre polynomials of order // l, l-1, l-2 respectively by iterating through the recursion // relation for the Legendre polynomials. // Compute __Pp the derivative of the Legendre polynomial of order l. auto __P1 = _Tp{0}; auto __P = _Tp{1}; for (auto __k = 1u; __k <= __l; ++__k) { auto __P2 = __P1; __P1 = __P; // Recursion for Legendre polynomials. __P = ((_Tp{2} * __k - _Tp{1}) * __z * __P1 - (__k - _Tp{1}) * __P2) / __k; } // Recursion for the derivative of The Legendre polynomial. auto __Pp = __l * (__z * __P - __P1) / (__z * __z - _Tp{1}); __z1 = __z; // Converge on root by Newton's method. __z = __z1 - __P / __Pp; if (std::abs(__z - __z1) < _S_eps) { __w = _Tp{2} / ((_Tp{1} - __z * __z) * __Pp * __Pp); break; } if (__its > _S_maxit) std::__throw_logic_error("__lobatto_zeros: " "Too many iterations"); } __pt[__i - 1].__zero = -__z; __pt[__l - __i].__zero = __z; __pt[__i - 1].__weight = __w; __pt[__l - __i].__weight = __w; } return __pt; }