25 #include <gsMatrix/gsSparseRows.hpp>
34 typename gsTensorBSplineBasis<1,T>::Self_t *
35 gsTensorBSplineBasis<1,T>::New(std::vector<gsBasis<T>*> & bb )
37 GISMO_ASSERT( bb.size() == 1,
"Expecting one component");
38 Self_t * c =
dynamic_cast<Self_t*
>(bb.front());
46 gsWarn<<
"Something went wrong during BSpline construction.\n";
54 return m_knots.uFind(u(0,0)).uIndex();
60 return m_knots.uFind( u ).uIndex();
66 typename KnotVectorType::smart_iterator it = m_knots.sbegin() + j;
67 index_t v = ( (it+m_knots.degree()+1).uIndex() - it.uIndex() ) / 2 ;
70 rvo(0,0) = it.value();
72 rvo(0,1) = it.value();
95 mesh.addVertex( nodes.row(0).transpose() );
100 mesh.addVertex( nodes.row(i).transpose() );
101 mesh.addEdge( i-1, i );
105 mesh.addEdge( sz-1, 0);
114 if (
const TensorSelf_t * _other = dynamic_cast<const TensorSelf_t*>(&other) )
116 bndThis .resize(1,1);
117 bndOther.resize(1,1);
118 bndThis (0,0) = bi.
first() .side() == 1 ? 0 : m_knots.size() -m_p-2;
119 bndOther(0,0) = bi.
second().side() == 1 ? 0 : _other->m_knots.size()-_other->m_p-2;
123 gsWarn<<
"Cannot match with "<< other <<
"\n";
130 result.resize(m_p+1, u.cols());
138 for (
index_t j = 0; j < u.cols(); ++j)
140 unsigned first = firstActive(u(0,j));
141 for (
int i = 0; i != m_p+1; ++i)
142 result(i,j) = (first++) % s;
147 for (
index_t j = 0; j < u.cols(); ++j)
149 unsigned first = firstActive(u(0,j));
150 for (
int i = 0; i != m_p+1; ++i)
151 result(i,j) = first++;
161 return( (u.value() >= m_knots[i]) && (u.value() <= m_knots[i+m_p+1]) );
169 gsWarn <<
"Periodic basis does not have such things as boundaries.\n";
178 res(1,0) = m_knots.size()-m_p-2;
189 gsWarn <<
"Periodic basis does not have such things as boundaries.\n";
192 GISMO_ASSERT(offset+m_p+1 < static_cast<index_t>(m_knots.size()),
193 "Offset cannot be bigger than the amount of basis functions orthogonal to Boxside s!");
195 case boundary::left :
198 case boundary::right :
199 res(0,0)= m_knots.size()-m_p-2-offset;
202 GISMO_ERROR(
"gsBSplineBasis: valid sides is left(west) and right(east).");
223 res << domainStart() , domainEnd() ;
237 GISMO_ASSERT( static_cast<size_t>(i) < m_knots.size()-m_p-1,
238 "Invalid index of basis function." );
240 res << ( i > m_p ? m_knots[i] : m_knots[m_p] ),
241 ( static_cast<size_t>(i) < (m_knots.size()-2*m_p-2) ? m_knots[i+m_p+1] :
242 m_knots[m_knots.size()-m_p-1] );
249 if( m_periodic == 0 )
252 if ( i < static_cast<index_t>(m_periodic) )
262 result.resize(m_p+1, u.cols() );
266 typename KnotVectorType::const_iterator kspan;
276 for (
index_t v = 0; v < u.cols(); ++v)
277 if ( ! inDomain( u(0,v) ) )
278 result.col(v).setZero();
281 kspan = m_knots.findspanIter ( u(0,v) );
286 for (
index_t v = 0; v < u.cols(); ++v)
287 if ( ! inDomain( u(0,v) ) )
288 result.col(v).setZero();
291 kspan = m_knots.findspanIter ( u(0,v) );
296 for (
index_t v = 0; v < u.cols(); ++v)
297 if ( ! inDomain( u(0,v) ) )
298 result.col(v).setZero();
301 kspan = m_knots.findspanIter ( u(0,v) );
307 STACK_ARRAY(T, left, m_p + 1);
308 STACK_ARRAY(T, right, m_p + 1);
310 for (
index_t v = 0; v < u.cols(); ++v)
313 if ( ! inDomain( u(0,v) ) )
316 result.col(v).setZero();
320 kspan = m_knots.findspanIter ( u(0,v) );
328 STACK_ARRAY(T, left, m_p + 1);
329 STACK_ARRAY(T, right, m_p + 1);
331 for (
index_t v = 0; v < u.cols(); ++v)
334 if ( ! inDomain( u(0,v) ) )
337 result.col(v).setZero();
344 unsigned span = m_knots.iFind( u(0,v) ) - m_knots.begin() ;
349 for(
int j=1; j<= m_p; ++j)
351 left[j] = u(0,v) - m_knots[span+1-j];
352 right[j] = m_knots[span+j] - u(0,v);
355 for(
int r=0; r!=j ; ++r)
361 const T temp = result(r,v) / ( right[r+1] + left[j-r] );
364 result(r,v) = saved + right[r+1] * temp ;
365 saved = left[j-r] * temp ;
381 GISMO_ASSERT( static_cast<size_t>(i) < m_knots.size()-m_p-1,
"Invalid index of basis function." );
383 result.resize(1, u.cols() );
384 STACK_ARRAY(T, N, m_p + 1);
386 for (
index_t s=0;s<u.cols(); ++s)
395 if( static_cast<int>(i) <= m_periodic )
398 if( u(0,s) < supp(0) || u(0,s) > supp(1))
404 if ( (static_cast<size_t>(i) == m_knots.size()-m_p-2) &&
405 (u(0,s) == m_knots.last()) && (u(0,s)== m_knots[m_knots.size()-m_p-1]) )
407 result(0,s)= (T)(1.0);
412 if ( (u(0,s) < m_knots[i]) || (u(0,s) >= m_knots[i+m_p+1]) )
414 result(0,s)= (T)(0.0);
422 for (
int j=0;j<=m_p; ++j)
423 if ( u(0,s) >= m_knots[i+j] && u(0,s) < m_knots[i+j+1] )
428 for (
int k=1;k<=m_p; ++k)
431 if (N[0] == (T)(0.0))
434 saved= ((u(0,s) - m_knots[i] )* N[0]) / (m_knots[k+i] - m_knots[i]);
435 for (
int j=0;j<m_p-k+1; ++j)
437 const T kleft = m_knots[i+j+1];
438 const T kright = m_knots[i+j+k+1];
439 if ( N[j+1] == (T)(0.0) )
446 const T temp = N[j+1] / ( kright - kleft );
447 N[j]= saved + ( kright-u(0,s) )*temp;
448 saved= (u(0,s) -kleft ) * temp;
462 GISMO_ASSERT( u.rows() == 1 ,
"gsBSplineBasis accepts points with one coordinate.");
477 const unsigned int table_size = m_p + 1;
478 STACK_ARRAY(T, N, table_size*table_size);
479 STACK_ARRAY(T, ND, table_size);
481 result.resize(1, u.cols());
484 for(
index_t s = 0; s < u.cols(); s++ )
488 if( (
int)(i) <= m_periodic )
491 if( u(0,s) < supp(0) || u(0,s) > supp(1))
495 if( u(0,s) == m_knots.last() )
496 gsWarn <<
"evalDerSingle_into sometimes gives strange results for the last knot.\n";
498 if( u(0,s) < m_knots[i] || u(0,s) >= m_knots[i+m_p+1])
541 result(0,s) = N[ m_p ];
545 for(
int j = 0; j <= n; j++ )
546 ND[j] = N[ j*table_size + (m_p-n) ];
547 for(
int jj = 1; jj <= n; jj++ )
552 saved = ND[0]/(m_knots[ i+m_p-n+jj ] - m_knots[i]);
553 for(
int j = 0; j < n-jj+1; j++ )
555 Uleft = m_knots[i+j+1];
556 Uright = m_knots[i+j+m_p-n+jj+1];
559 ND[j] =
static_cast<T
>(m_p-n+jj)*saved;
564 temp = ND[j+1]/(Uright - Uleft);
565 ND[j] =
static_cast<T
>(m_p-n+jj)*(saved - temp);
577 template <
class T>
inline
582 GISMO_ASSERT( u.rows() == 1 ,
"gsBSplineBasis accepts points with one coordinate (got "
584 if( m_periodic == 0 )
585 gsDeboor(u, m_knots, m_p, coefs, result);
594 template <
class T>
inline
597 GISMO_ASSERT( u.rows() == 1 ,
"gsBSplineBasis accepts points with one coordinate.");
599 const int pk = m_p-1 ;
600 const int p1 = m_p + 1;
601 STACK_ARRAY(T, ndu , m_p);
602 STACK_ARRAY(T, left , p1 );
603 STACK_ARRAY(T, right, p1 );
605 result.resize( m_p + 1, u.cols() ) ;
607 for (
index_t v = 0; v < u.cols(); ++v)
610 if ( ! inDomain( u(0,v) ) )
613 result.col(v).setZero();
620 typename KnotVectorType::iterator span = m_knots.iFind( u(0,v) );
625 for(
int j=1; j<m_p ; j++)
628 left[j] = u(0,v) - *(span+1-j);
629 right[j] = *(span+j) - u(0,v);
633 for(
int r=0; r<j ; r++)
635 const T temp = ndu[r] / ( right[r+1] + left[j-r] ) ;
636 ndu[r] = saved + right[r+1] * temp ;
637 saved = left[j-r] * temp ;
643 left[m_p] = u(0,v) - *(span+1-m_p);
644 right[m_p] = *(span+m_p) - u(0,v);
647 right[0] = right[1]+left[m_p] ;
648 result(0 , v) = -
static_cast<T
>(m_p) * ndu[0] / right[0] ;
649 for(
int r = 1; r < m_p; r++)
652 right[r] = right[r+1]+left[m_p-r] ;
653 result(r, v) =
static_cast<T
>(m_p) * ( ndu[r-1] / right[r-1] - ndu[r] / right[r] );
655 result(m_p, v) =
static_cast<T
>(m_p) * ndu[pk] / right[pk];
660 template <
class T>
inline
664 std::vector<gsMatrix<T> > ev;
669 template <
class T>
inline
675 result.resize(1, u.cols() );
679 for (
index_t j = 0; j < u.cols(); ++j)
681 const index_t first = firstActive(u(0,j));
682 if ( (i>= first) && (i<= first + m_p) )
683 result(0,j) = tmp(i-first,j);
685 result(0,j) = (T)(0.0);
689 template <
class T>
inline
696 GISMO_ASSERT( u.rows() == 1 ,
"gsBSplineBasis accepts points with one coordinate.");
703 T saved, Uleft, Uright, temp;
704 const unsigned int p1 = m_p + 1;
706 STACK_ARRAY(T, N, p1*p1);
707 STACK_ARRAY(T, ND, p1);
709 result.setZero(n + 1, u.cols());
710 n = ( n>m_p ? m_p : n );
712 for(
index_t s = 0; s < u.cols(); s++ )
715 if( (
int)(i) <= m_periodic )
718 if( u(0,s) < supp(0) || u(0,s) > supp(1))
722 if( u(0,s) < m_knots[i] || u(0,s) >= m_knots[i+m_p+1])
723 if( u( 0,s ) != m_knots[m_knots.size()-m_p-1] )
727 if ( u(0,s) == m_knots[m_knots.size()-m_p-1] )
729 for(
int j = 0; j <= m_p; j++ )
730 N[ j*p1 ] = (T)( u(0,s) > m_knots[i+j] && u(0,s) <= m_knots[i+j+1] );
734 for(
int j = 0; j <= m_p; j++ )
735 N[ j*p1 ] = (T)( u(0,s) >= m_knots[i+j] && u(0,s) < m_knots[i+j+1] );
738 for(
int k = 1; k <= m_p; k++ )
740 saved = (N[(k-1)] == 0 ? (T)(0) :
741 ((u(0,s)-m_knots[i])*N[ k-1 ])/(m_knots[i+k]-m_knots[i]) );
743 for(
int j = 0; j < m_p-k+1; j++)
745 Uleft = m_knots[i+j+1];
746 Uright = m_knots[i+j+k+1];
747 if( N[ (j+1)*p1 + (k-1) ] == 0 )
749 N[ j*p1 + k ] = saved;
754 temp = N[ (j+1)*p1 + (k-1) ]/(Uright-Uleft);
755 N[ j*p1 + k ] = saved + (Uright-u(0,s))*temp;
756 saved = (u(0,s)-Uleft)*temp;
761 result(0,s) = N[ m_p ];
763 for(
int k = 1; k <= n; k++ )
765 for(
int j = 0; j <= k; j++ )
766 ND[j] = N[ j*p1 + (m_p-k) ];
767 for(
int jj = 1; jj <= k; jj++ )
772 saved = ND[0]/(m_knots[ i+m_p-k+jj ] - m_knots[i]);
773 for(
int j = 0; j < k-jj+1; j++ )
775 Uleft = m_knots[i+j+1];
776 Uright = m_knots[i + m_p-k+jj + j+1];
779 ND[j] =
static_cast<T
>(m_p-k+jj)*saved;
784 temp = ND[j+1]/(Uright - Uleft);
785 ND[j] =
static_cast<T
>(m_p-k+jj)*(saved - temp);
795 template <
class T>
inline
799 if( m_periodic == 0 )
805 template <
class T>
inline
809 if( m_periodic == 0 )
815 template <
class T>
inline
819 result.resize(1, u.cols() );
823 for (
index_t j = 0; j < u.cols(); ++j)
825 const index_t first = firstActive(u(0,j));
826 if ( (i>= first) && (i<= first + m_p) )
827 result(0,j) = tmp(i-first,j);
829 result(0,j) = (T)(0.0);
833 template <
class T>
inline
836 std::vector<gsMatrix<T> > ev;
838 return ev[2].colwise().sum();
851 gsWarn<<
"gsTensorBSplineBasis::tensorize: Invalid basis "<< other <<
"\n";
866 bool sameElement)
const
871 GISMO_ASSERT( u.rows() == 1 ,
"gsBSplineBasis accepts points with one coordinate.");
873 const int p1 = m_p + 1;
875 STACK_ARRAY(T, ndu, p1 * p1 );
876 STACK_ARRAY(T, left, p1);
877 STACK_ARRAY(T, right, p1);
878 STACK_ARRAY(T, a, 2 * p1);
881 for(
int k=0; k<=n; k++)
882 result[k].resize(m_p + 1, u.cols());
886 const int pn = m_p - n;
889 for (
index_t v = 0; v < u.cols(); ++v)
891 if (!sameElement || 0==v)
895 if ( ! inDomain( u(0,v) ) )
898 for(
int k=0; k<=n; k++)
899 result[k].col(v).setZero();
904 span = m_knots.findspan( u(0,v) ) ;
907 for(
int j=1; j<= m_p; j++)
910 left[j] = u(0,v) - m_knots[span+1-j];
911 right[j] = m_knots[span+j] - u(0,v);
917 for(
int r=0; r<pn ; r++)
919 const T temp = ndu[r*p1 + pn -1] / ( right[r+1] + left[pn-r] ) ;
920 ndu[r*p1 + pn] = saved + right[r+1] * temp ;
921 saved = left[pn-r] * temp ;
923 ndu[pn*p1 + pn] = saved ;
927 for(
int r=0; r<pn ; r++)
930 ndu[j*p1 + r] = right[r+1]+left[j-r] ;
931 const T temp = ndu[r*p1 + j-1] / ndu[j*p1 + r] ;
933 ndu[r*p1 + j] = saved + right[r+1] * temp ;
934 saved = left[j-r] * temp ;
937 ndu[j*p1 + j] = saved ;
942 typename KnotVectorType::iterator span;
944 for (
index_t v = 0; v < u.cols(); ++v)
947 if (!sameElement || 0==v)
950 if ( ! inDomain( u(0,v) ) )
954 for(
int k=0; k<=n; k++)
955 result[k].col(v).setZero();
960 span = m_knots.iFind( u(0,v) );
964 for(
int j=1; j<= m_p; j++)
967 left[j] = u(0,v) - *(span+1-j);
968 right[j] = *(span+j) - u(0,v);
972 for(
int r=0; r<j ; r++)
975 ndu[j*p1 + r] = right[r+1]+left[j-r] ;
976 const T temp = ndu[r*p1 + j-1] / ndu[j*p1 + r] ;
978 ndu[r*p1 + j] = saved + right[r+1] * temp ;
979 saved = left[j-r] * temp ;
982 ndu[j*p1 + j] = saved ;
987 for (
int j=0; j <= m_p ; ++j )
988 result.front()(j,v) = ndu[j*p1 + m_p];
991 for(
int r = 0; r <= m_p; r++)
1000 for(
int k=1; k<=n; k++)
1004 rk = r-k ; pk = m_p-k ;
1008 a2[0] = a1[0] / ndu[ (pk+1)*p1 + rk] ;
1009 d = a2[0] * ndu[rk*p1 + pk] ;
1012 j1 = ( rk >= -1 ? 1 : -rk );
1013 j2 = ( r-1 <= pk ? k-1 : m_p - r );
1015 for(
int j = j1; j <= j2; j++)
1017 a2[j] = (a1[j] - a1[j-1]) / ndu[(pk+1)*p1 + rk+j] ;
1018 d += a2[j] * ndu[(rk+j)*p1 + pk] ;
1023 a2[k] = -a1[k-1] / ndu[(pk+1)*p1 + r] ;
1024 d += a2[k] * ndu[r*p1 + pk] ;
1027 result[k](r, v) = d;
1036 for(
int k=1; k<=n; k++)
1038 result[k].array() *= (T)(r) ;
1049 gsBoehmRefine(this->knots(), coefs, m_p, knots.begin(), knots.end());
1058 trans.setIdentity( this->
size() );
1059 gsBoehmRefine(this->knots(), trans, m_p, knots.begin(), knots.end());
1060 trans.toSparseMatrix( transfer );
1068 std::vector<T> newKnots;
1069 this->knots().getUniformRefinementKnots(numKnots, newKnots,mul);
1078 std::vector<T> newKnots;
1079 this->knots().getUniformRefinementKnots(numKnots, newKnots,mul);
1088 std::vector<T> removedKnots = m_knots.coarsen(numKnots);
1089 this->
clone()->refine_withTransfer( transfer, removedKnots );
1096 return ( c == 1 ? 0 : this->
size()-1);
1102 os <<
"BSplineBasis: deg=" <<
degree()
1103 <<
", size="<<
size() <<
", knot vector:\n";
1104 os << this->knots();
1105 if( m_periodic > 0 )
1106 os <<
",\n m_periodic= " << m_periodic;
1112 std::stringstream os;
1113 os <<
"BSplineBasis: deg=" <<
degree()
1114 <<
", size="<<
size() <<
", knot vector:\n";
1115 os << this->knots().detail();
1116 if( m_periodic > 0 )
1117 os <<
",\n m_periodic= " << m_periodic;
1125 int borderKnotMult = this->borderKnotMult();
1126 std::vector<T> newKnots(m_knots.begin(), m_knots.end());
1127 for(
int i = 0; i <= m_p - borderKnotMult; i++ )
1129 newKnots[i] = newKnots[ newKnots.size() - 2 * m_p - 2 + i + borderKnotMult ] - _activeLength();
1130 newKnots[ newKnots.size() - i - 1 ] = newKnots[ 2 * m_p - borderKnotMult + 1 - i ] + _activeLength();
1132 m_knots=KnotVectorType(m_p, newKnots.begin(), newKnots.end());
1138 gsWarn <<
"gsBSplineBasis: Converting basis to periodic"<< *
this<<
"\n";
1140 int borderKnotMult = this->borderKnotMult();
1141 if( m_knots.size() <
static_cast<size_t>(2 * m_p + 2) )
1143 gsWarn <<
"Your basis cannot be changed into periodic:\n Not enough internal control points for our construction of periodic basis.\n";
1147 else if( isClamped() )
1151 m_periodic = m_p + 2 - borderKnotMult;
1156 m_periodic = m_p + 1 - borderKnotMult;
1159 for(
int i = 2; i <= 2 * m_p + 1 - borderKnotMult; i ++ )
1162 i1 = m_knots[i] - m_knots[i-1];
1163 i2 = m_knots[m_knots.size() - (2*m_p) + i - 2 + borderKnotMult] - m_knots[m_knots.size() - (2*m_p) + i - 3 + borderKnotMult];
1166 gsWarn <<
"Your basis cannot be changed into periodic:\n Trouble stretching interior knots.\n";
1184 int lastBlueId = m_knots.
size() - m_p - 1;
1186 for(
int i = 0; i < m_p; i++ )
1188 if( m_knots[m_p - i] == m_knots[m_p])
1194 for(
int i = 0; i < m_p; i++ )
1196 if( m_knots[lastBlueId + i] == m_knots[ lastBlueId ])
1202 if( multiFirst == multiLast )
1206 gsWarn <<
"Different multiplicity of the blue knots.\n";
1215 GISMO_ASSERT( isClamped(),
"_stretchEndKnots() is intended for use only to knot vectors with clamped end knots.");
1216 T curFirst=m_knots[0];
1217 T curLast=m_knots[m_knots.size() - 1];
1218 m_knots.remove(curFirst); m_knots.insert(m_knots[m_knots.size() - m_p - 2] - _activeLength());
1219 m_knots.remove(curLast); m_knots.insert(m_knots[m_p + 1] + _activeLength());
1228 GISMO_ASSERT(i==0,
"gsBSplineBasis has only one component");
1236 GISMO_ASSERT(i==0,
"gsBSplineBasis has only one component");
1251 GSXML_COMMON_FUNCTIONS(gsBSplineBasis<T>);
1252 static std::string tag () {
return "Basis"; }
1253 static std::string type () {
return "BSplineBasis"; }
1255 static gsBSplineBasis<T> *
get (gsXmlNode * node)
1257 GISMO_ASSERT( !strcmp( node->name(),
"Basis"),
"Wrong tag." );
1259 if (!strcmp(node->first_attribute(
"type")->value(),
"TensorBSplineBasis1"))
1260 node = node->first_node(
"BSplineBasis");
1262 GISMO_ASSERT( !strcmp(node->first_attribute(
"type")->value(),
"BSplineBasis"),
1263 "Wrong XML type, expected BSplineBasis." );
1265 gsXmlNode * tmp = node->first_node(
"KnotVector");
1267 GISMO_ASSERT(tmp,
"Did not find a KnotVector tag in the Xml file.");
1269 gsXml<gsKnotVector<T> >::get_into(tmp, kv);
1271 return new gsBSplineBasis<T>( kv );
1274 static gsXmlNode * put (
const gsBSplineBasis<T> & obj,
1279 bs_node->append_attribute(
makeAttribute(
"type",
"BSplineBasis", data) );
1283 internal::gsXml<gsKnotVector<T> >::put(obj.knots(), data );
1284 bs_node->append_node(tmp);
short_t degree(short_t i) const
Returns the degree of the basis wrt variable i.
Definition: gsTensorBasis.h:465
void evalSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the i-th basis function at points u into result.
Definition: gsTensorBasis.hpp:410
Class defining a dummy basis of constant functions. This is used for compatibility reasons...
Definition: gsConstantBasis.h:34
virtual void evalAllDersSingle_into(index_t i, const gsMatrix< T > &u, int n, gsMatrix< T > &result) const
Evaluate the basis function i and its derivatives up to order n at points u into result.
Definition: gsBasis.hpp:471
Implementation of deBoor and tensor deBoor algorithm.
index_t size() const
Returns the number of elements in the basis.
Definition: gsTensorBasis.h:108
void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Returns the indices of active basis functions at points u, as a list of indices, in result...
Definition: gsTensorBSplineBasis.hpp:166
virtual void deriv2Single_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the (partial) derivatives of the i-th basis function at points u into result.
Definition: gsTensorBasis.hpp:454
void uniformCoarsen_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1)
Coarsen the basis uniformly and produce a sparse matrix which maps coarse coefficient vectors to refi...
Definition: gsTensorBasis.hpp:876
#define short_t
Definition: gsConfig.h:35
void evalDeg3Basis(const T &u, const KnotIterator knot, MatrixType &result)
Evaluation for degree 3 B-spline basis.
Definition: gsBSplineAlgorithms.h:94
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition: gsTensorBSpline.h:44
virtual void evalDerSingle_into(index_t i, const gsMatrix< T > &u, int n, gsMatrix< T > &result) const
Evaluate the (partial) derivative(s) of order n the i-th basis function at points u into result...
Definition: gsBasis.hpp:476
void evalDeg2Basis(const T &u, const KnotIterator knot, gsEigen::MatrixBase< Derived > const &result)
Evaluation for degree 2 B-spline basis.
Definition: gsBSplineAlgorithms.h:85
Boehm's algorithm for knot insertion.
void gsBoehmRefine(KnotVectorType &knots, Mat &coefs, int p, ValIt valBegin, ValIt valEnd, bool update_knots=true)
Definition: gsBoehm.hpp:163
virtual void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition: gsTensorBasis.hpp:163
memory::unique_ptr< gsGeometry< T > > makeGeometry(gsMatrix< T > coefs) const
Create a gsGeometry of proper type for this basis with the given coefficient matrix.
Definition: gsBSplineBasis.hpp:857
virtual void derivFunc_into(const gsMatrix< T > &u, const gsMatrix< T > &coefs, gsMatrix< T > &result) const
Evaluate the derivatives of the function described by coefs at points u.
Definition: gsBasis.hpp:84
S give(S &x)
Definition: gsMemory.h:266
#define index_t
Definition: gsConfig.h:32
size_t elementIndex(const gsVector< T > &u) const
Returns an index for the element which contains point u.
Definition: gsTensorBasis.h:141
void gsDeboor(const gsMatrix< T > &u, const KnotVectorType &knots, int deg, const gsMatrix< T > &coefs, gsMatrix< T > &result)
Definition: gsDeboor.hpp:30
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsTensorBSplineBasis.h:223
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
gsMatrix< T > elementInSupportOf(index_t j) const
Returns (the coordinates of) an element in the support of basis function j.
Definition: gsTensorBasis.hpp:1066
Implementation of common algorithms for B-splines.
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition: gsTensorBasis.hpp:502
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
virtual void evalAllDers_into(const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const
Evaluate the nonzero functions and their derivatives up to order n at points u into result...
Definition: gsTensorBasis.hpp:634
#define gsWarn
Definition: gsDebug.h:50
void refine_withCoefs(gsMatrix< T > &coefs, const std::vector< std::vector< T > > &refineKnots)
Takes a vector of coordinate wise knot values and inserts these values to the basis.
Definition: gsTensorBSplineBasis.hpp:83
virtual void derivSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the (partial) derivatives of the i-th basis function at points u into result.
Definition: gsTensorBasis.hpp:429
gsXmlAttribute * makeAttribute(const std::string &name, const std::string &value, gsXmlTree &data)
Helper to allocate XML attribute.
Definition: gsXml.cpp:37
bool isActive(const index_t i, const gsVector< T > &u) const
Returns true if there the point u with non-zero value or derivatives when evaluated at the basis func...
Definition: gsTensorBasis.hpp:239
gsXmlNode * makeNode(const std::string &name, gsXmlTree &data)
Helper to allocate XML node.
Definition: gsXml.cpp:54
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
void refine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, const std::vector< std::vector< T > > &refineKnots)
Takes a vector of coordinate wise knot values and inserts these values to the basis.
Definition: gsTensorBSplineBasis.hpp:66
gsMatrix< T > support() const
Returns (a bounding box for) the domain of the whole basis.
Definition: gsTensorBasis.hpp:390
void evalBasis(T u, KnotIterator knot, int deg, gsEigen::MatrixBase< Derived > const &result)
Definition: gsBSplineAlgorithms.h:34
Provides declaration of the Mesh class.
uPtr clone()
Clone methode. Produceds a deep copy inside a uPtr.
memory::unique_ptr< gsGeometry > uPtr
Unique pointer for gsGeometry.
Definition: gsGeometry.h:100
Self_t & component(short_t i)
For a tensor product basis, return the 1-d basis for the i-th parameter component.
Definition: gsBSplineBasis.hpp:1225
void deBoorTriangle(T u, KnotIterator knot, int deg, T N[])
Definition: gsBSplineAlgorithms.h:107
Represents a B-spline curve/function with one parameter.
gsMatrix< T > perCoefs(const gsMatrix< T > &originalCoefs, short_t dir) const
Sets the coefficients so that the resulting TensorBSpline is periodic in direction dir...
Definition: gsTensorBSplineBasis.h:447
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition: gsBasis.h:89
virtual gsBasis::uPtr tensorize(const gsBasis &other) const
Return a tensor basis of this and other.
Definition: gsBasis.hpp:488
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the first partial derivatives of the nonzero basis function.
Definition: gsTensorBasis.hpp:594
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition: gsTensorBSplineBasis.h:69
gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition: gsTensorBasis.hpp:304
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the second derivatives of all active basis function at points u.
Definition: gsTensorBasis.hpp:731
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
virtual std::string detail() const
Prints the object as a string with extended details.
Definition: gsBasis.h:727
gsMatrix< index_t > allBoundary() const
Definition: gsTensorBasis.hpp:283
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
patchSide & second()
second, returns the second patchSide of this interface
Definition: gsBoundary.h:782
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4488
void uniformRefine_withCoefs(gsMatrix< T > &coefs, int numKnots=1, int mul=1, int dir=-1)
Definition: gsTensorBasis.hpp:824
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
void uniformRefine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1, int mul=1)
Definition: gsTensorBasis.hpp:861
A specialized sparse matrix class which stores each row as a separate sparse vector.
Definition: gsSparseRows.hpp:24
virtual void evalFunc_into(const gsMatrix< T > &u, const gsMatrix< T > &coefs, gsMatrix< T > &result) const
Evaluate the function described by coefs at points u, i.e., evaluates a linear combination of coefs x...
Definition: gsBasis.hpp:37
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
Provides declaration of input/output XML utilities struct.
virtual gsMatrix< T > laplacian(const gsMatrix< T > &u) const
Compute the Laplacian of all nonzero basis functions at points u.
Definition: gsBasis.hpp:184
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
virtual void deriv2Func_into(const gsMatrix< T > &u, const gsMatrix< T > &coefs, gsMatrix< T > &result) const
Evaluates the second derivatives of the function described by coefs at points u.
Definition: gsBasis.hpp:101
Provides declaration of TensorBSplineBasis abstract interface.
patchSide & first()
first, returns the first patchSide of this interface
Definition: gsBoundary.h:776
void evalDeg1Basis(const T &u, const KnotIterator knot, gsEigen::MatrixBase< Derived > const &result)
Evaluation for degree 1 B-spline basis.
Definition: gsBSplineAlgorithms.h:72