35template<
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 )
108 :
Base( new Basis_t(
give(KV1)), new Basis_t(
give(KV2)) )
122 :
Base( new Basis_t(
give(KV1)), new Basis_t(
give(KV2)), new Basis_t(
give(KV3)) )
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]) );
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)
291 void refine_withCoefs(gsMatrix<T> & coefs,
const std::vector< std::vector<T> >& refineKnots);
300 { this->knots(dir).insert( knot, mult); }
305 { this->knots(dir).remove( knot, mult); }
313 void insertKnots(
const std::vector< std::vector<T> >& refineKnots)
315 GISMO_ASSERT( refineKnots.size() == d,
"refineKnots vector has wrong size" );
316 for (
short_t j = 0; j < d; ++j)
317 this->knots(j).insert(refineKnots[j]);
360 GISMO_MAKE_GEOMETRY_NEW
366 for (
short_t j = 0; j < d; ++j)
379 for (
short_t dim = 0; dim < d; ++dim)
382 kv.supportIndex_into(ti[dim], tmp_vec);
383 result.row(dim).noalias() =
384 tmp_vec.cwiseMax(0).cwiseMin(kv.numElements());
409 for (
short_t dm = 0; dm != d; ++dm)
418 for (
short_t dm = 1; dm != d; ++dm)
419 result = result.replicate(1,sz[dm]) +
431 for (
short_t dm = 0; dm != d; ++dm)
457 std::vector<index_t> sourceSliceIndices;
458 std::vector<index_t> targetSliceIndices;
462 for(
index_t i = 0; i < numPeriodic; i++ )
467 for(
index_t j = 0; j != currentSourceSlice.size(); j++ )
469 sourceSliceIndices.push_back(
static_cast<index_t>( currentSourceSlice(j) ) );
470 targetSliceIndices.push_back(
static_cast<index_t>( currentTargetSlice(j) ) );
476 for(
size_t i = 0; i != sourceSliceIndices.size(); i++ )
480 result.row( targetSliceIndices[ i ] ) = originalCoefs.row( sourceSliceIndices[ i ] );
498 for(
short_t i = 0; i < this->dim(); i++ )
505 gsWarn <<
"Cannot handle a basis that is periodic in more than one direction.\n";
518#ifdef GISMO_WITH_PYBIND11
523 void pybind11_init_gsTensorBSplineBasis2(pybind11::module &m);
524 void pybind11_init_gsTensorBSplineBasis3(pybind11::module &m);
525 void pybind11_init_gsTensorBSplineBasis4(pybind11::module &m);
533#ifndef GISMO_BUILD_LIB
534#include GISMO_HPP_HEADER(gsTensorBSplineBasis.hpp)
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
A univariate B-spline basis.
Definition gsBSplineBasis.h:700
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
Class for representing a knot vector.
Definition gsKnotVector.h:80
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
void k_refine(Self_t &other, int const &i=1)
Perform k-refinement coordinate-wise, in all directions.
Definition gsTensorBSplineBasis.h:241
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
gsBSplineTraits< static_cast< short_t >(d-1), T >::Basis::uPtr boundaryBasis(boxSide const &s)
Returns the boundary basis for side s.
GISMO_MAKE_GEOMETRY_NEW void reduceContinuity(int const &i=1)
Reduces spline continuity (in all directions) at interior knots by i.
Definition gsTensorBSplineBasis.h:364
gsBSplineTraits< d, T >::Geometry GeometryType
Associated Boundary basis type.
Definition gsTensorBSplineBasis.h:57
void setPeriodic(const int dir)
Converts.
Definition gsTensorBSplineBasis.h:446
std::vector< std::vector< T > > _boxToKnots(gsMatrix< T > const &boxes)
Definition gsTensorBSplineBasis.hpp:106
void setIsPeriodic()
Definition gsTensorBSplineBasis.h:495
gsTensorBSplineBasis()
Default constructor.
Definition gsTensorBSplineBasis.h:74
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:313
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 refine_p(int const &i=1)
p-refinement (essentially degree elevation in all directions)
Definition gsTensorBSplineBasis.h:249
gsBSplineTraits< static_cast< short_t >(d-1), T >::Basis BoundaryBasisType
Associated Boundary basis type.
Definition gsTensorBSplineBasis.h:60
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:454
gsBSplineBasis< T > CoordinateBasis
Coordinate basis type.
Definition gsTensorBSplineBasis.h:50
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
memory::unique_ptr< Self_t > uPtr
Smart pointer for gsTensorBSplineBasis.
Definition gsTensorBSplineBasis.h:69
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:373
T Scalar_t
Coefficient type.
Definition gsTensorBSplineBasis.h:54
void insertKnot(T knot, index_t dir, int mult=1)
Definition gsTensorBSplineBasis.h:299
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:176
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
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
void removeKnot(T knot, index_t dir, int mult=1)
Definition gsTensorBSplineBasis.h:304
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
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:390
memory::shared_ptr< Self_t > Ptr
Smart pointer for gsTensorBSplineBasis.
Definition gsTensorBSplineBasis.h:66
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:400
gsBSplineBasis< T > Family_t
Family type.
Definition gsTensorBSplineBasis.h:45
gsTensorBasis< d, T > Base
Base type.
Definition gsTensorBSplineBasis.h:42
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsTensorBSplineBasis.h:223
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
bool isPeriodic() const
Tells, whether there is a coordinate direction in which the basis is periodic.
Definition gsTensorBSplineBasis.h:440
int periodicDirection() const
Gives the value of m_isPeriodic.
Definition gsTensorBSplineBasis.h:443
void active_cwise(const gsMatrix< T > &u, gsVector< index_t, d > &low, gsVector< index_t, d > &upp) const
Definition gsTensorBSplineBasis.hpp:50
short_t m_isPeriodic
Definition gsTensorBSplineBasis.h:514
A tensor product of d B-spline functions, with arbitrary target dimension.
Definition gsTensorBSpline.h:45
Abstract base class for tensor product bases.
Definition gsTensorBasis.h:34
gsMatrix< index_t > coefSlice(short_t dir, index_t k) const
Returns all the basis functions with tensor-numbering.
Definition gsTensorBasis.hpp:250
void stride_cwise(gsVector< index_t, d > &result) const
Returns the strides for all dimensions.
Definition gsTensorBasis.h:512
short_t degree(short_t i) const
Returns the degree of the basis wrt variable i.
Definition gsTensorBasis.h:465
index_t size() const
Returns the number of elements in the basis.
Definition gsTensorBasis.h:108
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
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
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
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
void refine(gsMatrix< T > const &boxes, int refExt=0)
Refinement of the tensor basis on the area defined by boxes.
Definition gsTensorBSplineBasis.hpp:156
Provides declaration of BSplineBasis class.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define gsWarn
Definition gsDebug.h:50
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Represents a tensor-product B-spline patch.
Provides declaration of TensorBasis class.
The G+Smo namespace, containing all definitions for the library.
S give(S &x)
Definition gsMemory.h:266
Traits for BSplineBasis in more dimensions.
Definition gsBSplineBasis.h:32