37 template<
short_t d,
class T>
66 typedef memory::shared_ptr< gsTensorNurbsBasis >
Ptr;
69 typedef memory::unique_ptr< gsTensorNurbsBasis >
uPtr;
81 gsTensorNurbsBasis(
const KnotVectorType& KV1,
const KnotVectorType& KV2,
const KnotVectorType& KV3 )
93 gsTensorNurbsBasis() :
Base() { };
105 GISMO_CLONE_FUNCTION(gsTensorNurbsBasis)
110 GISMO_MAKE_GEOMETRY_NEW
115 std::ostream &
print(std::ostream &os)
const
117 os <<
"TensorNurbsBasis: dim=" << this->dim()<<
", size="<< this->
size() <<
".";
118 for (
unsigned i = 0; i!=d; ++i )
119 os <<
"\n Direction "<< i <<
": "<< this->m_src->component(i).knots() <<
" ";
125 {
return m_src->knots(i); }
127 const gsKnotVector<T> & knots (
int i)
const
128 {
return m_src->knots(i); }
131 T knot(
int i,
int k)
const
132 {
return m_src->knot(i, k); }
138 m_src->size_cwise(result);
145 m_src->stride_cwise(result);
148 void swapDirections(
const unsigned i,
const unsigned j)
157 m_src->swapDirections(i, j);
160 void uniformRefine_withCoefs(gsMatrix<T>& coefs,
int numKnots=1,
int mul=1,
int dir=-1)
163 "Invalid dimensions" );
165 gsSparseMatrix<T, RowMajor> transfer;
168 m_src->uniformRefine_withTransfer(transfer, numKnots, mul);
170 coefs = transfer * ( m_weights.asDiagonal() * coefs);
171 m_weights = transfer * m_weights;
179 coefs.array().colwise() /= m_weights.col(0).array();
186 GISMO_ASSERT( dir >= 0 && static_cast<unsigned>(dir) < d,
187 "Invalid basis component "<< dir <<
" requested for degree elevation" );
189 gsVector<index_t,d> sz;
190 m_src->size_cwise(sz);
191 m_src->component(dir).uniformRefine_withTransfer( transfer, numKnots, mul );
193 const index_t coefs_cols = coefs.cols();
194 const index_t weights_cols = m_weights.cols();
196 coefs = m_weights.asDiagonal() * coefs;
198 coefs.resize( sz[0], coefs_cols * sz.template tail<static_cast<short_t>(d-1)>().prod() );
199 coefs = transfer * coefs;
202 m_weights.resize( sz[0], weights_cols * sz.template tail<static_cast<short_t>(d-1)>().prod() );
203 m_weights = transfer * m_weights;
205 sz[0] = coefs.rows();
207 coefs.resize( sz.prod(), coefs_cols );
208 m_weights.resize( sz.prod(), weights_cols );
212 coefs.array().colwise() /= m_weights.col(0).array();
224 gsMatrix<index_t> ind = m_src->boundary(n1);
226 gsMatrix<T> ww( ind.size(),1);
227 for (
index_t i=0; i<ind.size(); ++i)
228 ww(i,0) = m_weights( (ind)(i,0), 0);
233 void matchWith(
const boundaryInterface & bi,
const gsBasis<T> & other,
234 gsMatrix<index_t> & bndThis, gsMatrix<index_t> & bndOther)
const
236 this->matchWith(bi,other,bndThis,bndOther,0);
240 void matchWith(
const boundaryInterface & bi,
const gsBasis<T> & other,
241 gsMatrix<index_t> & bndThis, gsMatrix<index_t> & bndOther,
index_t offset)
const
243 if (
const gsTensorNurbsBasis<d,T> * _other =
dynamic_cast<const gsTensorNurbsBasis<d,T> *
>(&other) )
244 m_src->matchWith(bi,_other->source(),bndThis,bndOther,offset);
245 else if (
const gsTensorBasis<d,T> * __other =
dynamic_cast<const gsTensorBasis<d,T> *
>(&other) )
246 m_src->matchWith(bi,*__other,bndThis,bndOther,offset);
248 gsWarn<<
"Cannot match with "<<other<<
"\n";
254 using Base::m_weights;
memory::unique_ptr< gsTensorNurbsBasis > uPtr
Unique pointer for gsTensorNurbsBasis.
Definition: gsTensorNurbsBasis.h:69
gsBSplineBasis< T > Family_t
Family type.
Definition: gsTensorNurbsBasis.h:48
memory::shared_ptr< gsTensorNurbsBasis > Ptr
Shared pointer for gsTensorNurbsBasis.
Definition: gsTensorNurbsBasis.h:66
Represents a NURBS basis with one parameter.
gsBSplineTraits< d, T >::Basis Src_t
Source basis type.
Definition: gsTensorNurbsBasis.h:51
Represents a NURBS curve/function with one parameter.
index_t size() const
size
Definition: gsRationalBasis.h:137
Traits for BSplineBasis in more dimensions.
Definition: gsBSplineBasis.h:31
Class that creates a rational counterpart for a given basis.
Definition: gsRationalBasis.h:47
T Scalar_t
Coefficient type.
Definition: gsTensorNurbsBasis.h:57
A tensor product Non-Uniform Rational B-spline function (NURBS) of parametric dimension d...
Definition: gsTensorNurbs.h:40
void swapTensorDirection(int k1, int k2, gsVector< index_t, d > &sz, gsMatrix< T > &coefs)
Definition: gsTensorTools.h:129
void stride_cwise(gsVector< index_t, d > &result) const
Returns the strides for all dimensions.
Definition: gsTensorNurbsBasis.h:142
S give(S &x)
Definition: gsMemory.h:266
#define index_t
Definition: gsConfig.h:32
Src_t::Basis_t Basis_t
Coordinate basis type.
Definition: gsTensorNurbsBasis.h:54
gsRationalBasis< typename gsBSplineTraits< d, T >::Basis > Base
Base type.
Definition: gsTensorNurbsBasis.h:45
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
short_t degree(short_t i=0) const
Degree with respect to the i-th variable. If the basis is a tensor product of (piecewise) polynomial ...
Definition: gsRationalBasis.h:162
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsTensorNurbsBasis.h:115
BoundaryBasisType::uPtr boundaryBasis(boxSide const &s)
Gives back the boundary basis at boxSide s.
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
gsBSplineTraits< d, T >::RatGeometry GeometryType
Associated geometry type.
Definition: gsTensorNurbsBasis.h:60
#define gsWarn
Definition: gsDebug.h:50
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition: gsFunctionSet.hpp:33
gsTensorNurbsBasis(const KnotVectorType &KV1, const KnotVectorType &KV2)
Constructors for gsTensorNurbsBasis.
Definition: gsTensorNurbsBasis.h:77
A tensor product Non-Uniform Rational B-spline (NURBS) basis.
Definition: gsTensorNurbsBasis.h:38
gsBSplineTraits< static_cast< short_t >d-1), T >::RatBasis BoundaryBasisType
Associated Boundary basis type.
Definition: gsTensorNurbsBasis.h:63
Provides declaration of RationalBasis class.
void size_cwise(gsVector< index_t, d > &result) const
The number of basis functions in the direction of the k-th parameter component.
Definition: gsTensorNurbsBasis.h:135
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition: gsTensorBSplineBasis.h:69
Class for representing a knot vector.
Definition: gsKnotVector.h:79
Provides declaration of TensorBSplineBasis abstract interface.