35 template<
short_t d,
class T>
63 typedef typename Base::const_iterator const_iterator;
66 typedef memory::shared_ptr< Self_t >
Ptr;
69 typedef memory::unique_ptr< Self_t >
uPtr;
77 this->m_bases[i] =
new Basis_t();
82 this->Base::swap(static_cast<Base&>(other));
86 #if !EIGEN_HAS_RVALUE_REFERENCES
88 { gsTensorBSplineBasis::swap(other);
return *
this;}
107 typename util::enable_if<d==2,U>::type * = NULL )
130 new Basis_t(
give(KV3)), new Basis_t(
give(KV4)) )
135 GISMO_ENSURE(d == KV.size(),
"Invalid number of knot-vectors given." );
137 this->m_bases[i] =
new Basis_t(
give(KV[i]) );
165 typename gsBSplineTraits<static_cast<short_t>(d-1),T>::Basis::uPtr
boundaryBasis(boxSide
const & s);
170 std::vector<gsBasis<T>*> rr;
172 return BoundaryBasisType::New(rr);
177 static Self_t * New(std::vector<gsBasis<T>*> & bb )
178 {
return new Self_t(bb); }
180 static Self_t * New(std::vector<Basis_t*> & bb )
181 {
return new Self_t(bb); }
183 static uPtr make(std::vector<gsBasis<T>*> & bb )
184 {
return uPtr(
new Self_t(bb) ); }
186 static uPtr make(std::vector<Basis_t*> & bb )
187 {
return uPtr(
new Self_t(bb) ); }
191 KnotVectorType & knots (
int i)
194 const KnotVectorType & knots (
int i)
const
198 T knot(
int i,
int k)
const
223 std::ostream &
print(std::ostream &os)
const
225 os <<
"TensorBSplineBasis: dim=" << this->dim()<<
", size="<< this->
size() <<
".";
227 os <<
"Periodic in " <<
m_isPeriodic <<
"-th direction.\n";
228 for (
short_t i = 0; i!=d; ++i )
243 for (
short_t j = 0; j < d; ++j)
251 for (
short_t j = 0; j < d; ++j)
259 for (
short_t j = 0; j < d; ++j)
293 { this->knots(dir).insert( knot, mult); }
298 { this->knots(dir).remove( knot, mult); }
306 void insertKnots(
const std::vector< std::vector<T> >& refineKnots)
308 GISMO_ASSERT( refineKnots.size() == d,
"refineKnots vector has wrong size" );
309 for (
short_t j = 0; j < d; ++j)
310 this->knots(j).insert(refineKnots[j]);
353 GISMO_MAKE_GEOMETRY_NEW
359 for (
short_t j = 0; j < d; ++j)
372 for (
short_t dim = 0; dim < d; ++dim)
376 result.row(dim).noalias() =
402 for (
short_t dm = 0; dm != d; ++dm)
411 for (
short_t dm = 1; dm != d; ++dm)
412 result = result.replicate(1,sz[dm]) +
424 for (
short_t dm = 0; dm != d; ++dm)
450 std::vector<index_t> sourceSliceIndices;
451 std::vector<index_t> targetSliceIndices;
455 for(
index_t i = 0; i < numPeriodic; i++ )
460 for(
index_t j = 0; j != currentSourceSlice.size(); j++ )
462 sourceSliceIndices.push_back( static_cast<index_t>( currentSourceSlice(j) ) );
463 targetSliceIndices.push_back( static_cast<index_t>( currentTargetSlice(j) ) );
469 for(
size_t i = 0; i != sourceSliceIndices.size(); i++ )
473 result.row( targetSliceIndices[ i ] ) = originalCoefs.row( sourceSliceIndices[ i ] );
486 for(
short_t i = 0; i < this->dim(); i++ )
493 gsWarn <<
"Cannot handle a basis that is periodic in more than one direction.\n";
506 #ifdef GISMO_WITH_PYBIND11
511 void pybind11_init_gsTensorBSplineBasis2(pybind11::module &m);
512 void pybind11_init_gsTensorBSplineBasis3(pybind11::module &m);
513 void pybind11_init_gsTensorBSplineBasis4(pybind11::module &m);
515 #endif // GISMO_WITH_PYBIND11
521 #ifndef GISMO_BUILD_LIB
522 #include GISMO_HPP_HEADER(gsTensorBSplineBasis.hpp)
void k_refine(Self_t &other, int const &i=1)
Perform k-refinement coordinate-wise, in all directions.
Definition: gsTensorBSplineBasis.h:241
short_t degree(short_t i) const
Returns the degree of the basis wrt variable i.
Definition: gsTensorBasis.h:465
void removeKnot(T knot, index_t dir, int mult=1)
Definition: gsTensorBSplineBasis.h:297
void insertKnot(T knot, index_t dir, int mult=1)
Definition: gsTensorBSplineBasis.h:292
void refine(gsMatrix< T > const &boxes, int refExt=0)
Refinement of the tensor basis on the area defined by boxes.
Definition: gsTensorBSplineBasis.hpp:106
Traits for BSplineBasis in more dimensions.
Definition: gsBSplineBasis.h:31
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
int periodicDirection() const
Gives the value of m_isPeriodic.
Definition: gsTensorBSplineBasis.h:436
#define short_t
Definition: gsConfig.h:35
size_t numElements() const
Number of knot intervals inside domain.
Definition: gsKnotVector.h:268
gsMatrix< index_t, d, 2 > elementSupport(const index_t &i) const
Returns span (element) indices of the beginning and end of the support of the i-th basis function...
Definition: gsTensorBSplineBasis.h:383
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition: gsTensorBSpline.h:44
Basis_t ** iterator
Iterators on coordinate bases.
Definition: gsTensorBasis.h:52
void supportIndex_into(const mult_t &i, gsMatrix< index_t > &result) const
Definition: gsKnotVector.hpp:1066
Represents a tensor-product B-spline patch.
gsTensorBSplineBasis(KnotVectorType KV1, gsKnotVector< U > KV2, typename util::enable_if< d==2, U >::type *=NULL)
Constructs a 2D tensor product B-spline basis. Assumes that the tamplate parameter d is equal to 2...
Definition: gsTensorBSplineBasis.h:106
gsBSplineBasis< T > CoordinateBasis
Coordinate basis type.
Definition: gsTensorBSplineBasis.h:50
S give(S &x)
Definition: gsMemory.h:266
gsBSplineBasis< T > Family_t
Family type.
Definition: gsTensorBSplineBasis.h:45
void elementSupport_into(const index_t i, gsMatrix< index_t, _Rows, 2 > &result) const
Returns span (element) indices of the beginning and end of the support of the i-th basis function...
Definition: gsTensorBSplineBasis.h:366
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
gsTensorBSplineBasis()
Default constructor.
Definition: gsTensorBSplineBasis.h:74
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsTensorBSplineBasis.h:223
void refine_h(int const &i=1)
Uniform h-refinement (placing i new knots inside each knot-span, for all directions.
Definition: gsTensorBSplineBasis.h:257
gsBSplineTraits< d, T >::Geometry GeometryType
Associated Boundary basis type.
Definition: gsTensorBSplineBasis.h:57
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
void active_cwise(const gsMatrix< T > &u, gsVector< index_t, d > &low, gsVector< index_t, d > &upp) const
Definition: gsTensorBSplineBasis.hpp:50
GISMO_MAKE_GEOMETRY_NEW void reduceContinuity(int const &i=1)
Reduces spline continuity (in all directions) at interior knots by i.
Definition: gsTensorBSplineBasis.h:357
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
void setPeriodic(const int dir)
Converts.
Definition: gsTensorBSplineBasis.h:439
#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
void insertKnots(const std::vector< std::vector< T > > &refineKnots)
Takes a vector of coordinate wise knot values and inserts these values to the basis.
Definition: gsTensorBSplineBasis.h:306
Provides declaration of BSplineBasis class.
Basis_t & component(short_t dir)
For a tensor product basis, return the 1-d basis for the i-th parameter component.
Definition: gsTensorBasis.h:596
gsBSplineTraits< static_cast< short_t >d-1), T >::Basis BoundaryBasisType
Associated Boundary basis type.
Definition: gsTensorBSplineBasis.h:60
void setIsPeriodic()
Definition: gsTensorBSplineBasis.h:483
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
Abstract base class for tensor product bases.
Definition: gsTensorBasis.h:33
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
void getComponentsForSide(boxSide const &s, std::vector< Basis_t * > &rr) const
Returns the components for a basis on the face s.
Definition: gsTensorBasis.hpp:377
void refine_p(int const &i=1)
p-refinement (essentially degree elevation in all directions)
Definition: gsTensorBSplineBasis.h:249
memory::shared_ptr< Self_t > Ptr
Smart pointer for gsTensorBSplineBasis.
Definition: gsTensorBSplineBasis.h:66
T Scalar_t
Coefficient type.
Definition: gsTensorBSplineBasis.h:54
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
void stride_cwise(gsVector< index_t, d > &result) const
Returns the strides for all dimensions.
Definition: gsTensorBasis.h:512
gsTensorBasis< d, T > Base
Base type.
Definition: gsTensorBSplineBasis.h:42
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition: gsTensorBSplineBasis.h:69
gsMatrix< index_t > coefSlice(short_t dir, index_t k) const
Returns all the basis functions with tensor-numbering.
Definition: gsTensorBasis.hpp:250
void elementActive_into(const gsMatrix< index_t, _Rows, 2 > &box, gsMatrix< index_t > &result) const
Returns the indices of active basis functions in the given input element box.
Definition: gsTensorBSplineBasis.h:393
gsVector< index_t, d > tensorIndex(const index_t &m) const
Returns the tensor index of the basis function with global index m.
Definition: gsTensorBasis.h:527
short_t m_isPeriodic
Definition: gsTensorBSplineBasis.h:502
Class for representing a knot vector.
Definition: gsKnotVector.h:79
Basis_t & component(short_t dir)
For a tensor product basis, return the 1-d basis for the i-th parameter component.
Definition: gsTensorBSplineBasis.h:207
Provides declaration of TensorBasis class.
gsBSplineTraits< static_cast< short_t >d-1), T >::Basis::uPtr boundaryBasis(boxSide const &s)
Returns the boundary basis for side s.
const Basis_t & component(short_t dir) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsTensorBSplineBasis.h:202
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
bool isPeriodic() const
Tells, whether there is a coordinate direction in which the basis is periodic.
Definition: gsTensorBSplineBasis.h:433
gsTensorBSplineBasis(KnotVectorType KV1, KnotVectorType KV2, KnotVectorType KV3)
Constructs a 3D tensor product B-spline basis. Assumes that the tamplate parameter d is equal to 3...
Definition: gsTensorBSplineBasis.h:119