29template<
short_t d,
class T>
33 GISMO_ASSERT( checkVectorPtrCast<Basis_t>(bb),
"Invalid vector of basis pointers.");
34 GISMO_ENSURE( d == bb.size(),
"Wrong d in the constructor of gsTensorBSplineBasis." );
39template<
short_t d,
class T>
40gsTensorBSplineBasis<d,T>::gsTensorBSplineBasis(std::vector<gsBasis<T>*> & bb )
43 GISMO_ENSURE( d == bb.size(),
"Wrong d in the constructor of gsTensorBSplineBasis." );
48template<
short_t d,
class T>
54 for (
index_t j = 0; j < u.cols(); ++j)
58 low[i] = component(i).firstActive( u(i,j) );
59 upp[i] = low[i] + component(i).degree();
64template<
short_t d,
class T>
67 const std::vector< std::vector<T> >& refineKnots)
69 GISMO_ASSERT( refineKnots.size() == d,
"refineKnots vector has wrong size" );
73 for (
unsigned i = 0; i < d; ++i)
75 this->component(i).refine_withTransfer( B[i], refineKnots[i] );
78 tensorCombineTransferMatrices<d, T>( B, transfer );
81template<
short_t d,
class T>
85 GISMO_ASSERT( refineKnots.size() == d,
"refineKnots vector has wrong size" );
87 for (
unsigned j = 0; j < d; ++j)
89 strides[j]=this->stride(j);
91 for (
unsigned i = 0; i < d; ++i)
93 if(refineKnots[i].size()>0)
96 refineKnots[i].begin(), refineKnots[i].end(),
true);
98 for (
index_t j = i+1; j<strides.rows(); ++j)
99 strides[j]=this->stride(j);
105template<
short_t d,
class T>
108 std::vector<std::vector<T>> result(d);
110 "Number of rows of refinement boxes must equal dimension of parameter space.");
112 "Refinement boxes must have even number of columns.");
114 const T tol = 0.000000001;
117 for(
short_t di = 0; di < this->dim(); di++)
121 KnotVectorType kold_di = Self_t::component(di).knots();
124 std::vector<bool> flagInsertKt( kold_di.size(),
false);
131 for(
size_t i=1; i < kold_di.size(); i++ )
132 if( kold_di[i]-kold_di[i-1] > tol)
134 const T midpt = (kold_di[i] + kold_di[i-1])/(T)(2);
135 for(
index_t j=0; j < boxes.cols(); j+=2 )
138 flagInsertKt[i] = boxes(di,j) < midpt && midpt < boxes(di,j+1);
144 for(
size_t i=1; i < kold_di.size(); i++ )
145 if( flagInsertKt[i] )
147 T midpt = (kold_di[i] + kold_di[i-1])/(T)(2);
148 result[di].push_back(midpt);
155template<
short_t d,
class T>
159 std::vector<std::vector<T>> knots = this->_boxToKnots(boxes);
160 for(
short_t di = 0; di < d; di++)
161 for(
size_t i=1; i < knots[di].size(); i++ )
162 Self_t::component(di).insertKnot(knots[di][i]);
174template<
short_t d,
class T>
178 GISMO_ASSERT( u.rows() ==
static_cast<index_t>(d),
"Invalid point dimension: "<<u.rows()<<
", expected "<< d);
180 unsigned firstAct[d];
185 for (
unsigned i = 0; i < d; ++i)
187 size[i] = component(i).numActive();
191 result.resize( numAct, u.cols() );
194 for (
index_t j = 0; j < u.cols(); ++j)
197 for (
short_t i = 0; i < d; ++i)
199 firstAct[i] = component(i).firstActive( u(i,j) );
207 index_t gidx = firstAct[d-1] + v(d-1);
208 for (
short_t i=d-2; i>=0; --i )
209 gidx = gidx * this->size(i) + firstAct[i] + v(i);
222template<
short_t d,
class T>
229 GSXML_COMMON_FUNCTIONS(Object);
230 static std::string tag () {
return "Basis"; }
231 static std::string type () {
return "TensorBSplineBasis"+to_string(d); }
233 static Object * get (gsXmlNode * node)
238 && ( !strcmp(node->first_attribute(
"type")->value(),
239 internal::gsXml<Object>::type().c_str() ) ),
240 "Something is wrong with the XML data: There should be a node with a "
241 <<internal::gsXml<Object>::type().c_str()<<
" Basis.");
246 && ( !strcmp(node->first_attribute(
"type")->value(),
247 internal::gsXml<Object>::type().c_str())
248 || !strcmp(node->first_attribute(
"type")->value(),
"BSplineBasis") ),
249 "Something is wrong with the XML data: There should be a node with a "
250 <<internal::gsXml<Object>::type().c_str()<<
" Basis.");
253 return getTensorBasisFromXml<Object >( node );
256 static gsXmlNode * put (
const Object & obj,
259 return putTensorBasisToXml<Object >(obj,data);
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition gsSparseMatrix.h:139
A tensor product B-spline basis.
Definition gsTensorBSplineBasis.h:37
gsTensorBSplineBasis()
Default constructor.
Definition gsTensorBSplineBasis.h:74
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
void gsTensorBoehmRefine(KnotVectorType &knots, Mat &coefs, int direction, gsVector< unsigned > str, ValIt valBegin, ValIt valEnd, bool update_knots=true)
Definition gsBoehm.hpp:372
bool nextLexicographic(Vec &cur, const Vec &size)
Iterates through a tensor lattice with the given size. Updates cur and returns true if another entry ...
Definition gsCombinatorics.h:196
Boehm's algorithm for knot insertion.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Knot vector for B-splines.
Provides declaration of TensorBSplineBasis abstract interface.
Provides implementation of generic XML functions.
Provides declaration of input/output XML utilities struct.
The G+Smo namespace, containing all definitions for the library.
std::vector< Base * > castVectorPtr(std::vector< Derived * > pVec)
Casts a vector of pointers.
Definition gsMemory.h:344