G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsTHBSplineBasis< d, T > Class Template Referenceabstract

Detailed Description

template<short_t d, class T>
class gismo::gsTHBSplineBasis< d, T >

Truncated hierarchical B-spline basis.

Parameters
dthe dimension of the parameter domain
Tthe coefficient type
+ Inheritance diagram for gsTHBSplineBasis< d, T >:
+ Collaboration diagram for gsTHBSplineBasis< d, T >:

Public Types

typedef util::conditional< d==1,
gsConstantBasis< T >
, gsTHBSplineBasis
< static_cast< short_t >d-1),
T > >::type 
BoundaryBasisType
 Associated Boundary basis type.
 
typedef gsTHBSpline< d, T > GeometryType
 Associated geometry type.
 
typedef memory::shared_ptr
< gsTHBSplineBasis
Ptr
 Shared pointer for gsTHBSplineBasis.
 
typedef memory::unique_ptr
< gsTHBSplineBasis
uPtr
 Unique pointer for gsTHBSplineBasis.
 

Public Member Functions

gsMatrix< index_tactive (const gsMatrix< T > &u) const
 Returns the indices of active (nonzero) functions at points u, as a list of indices. More...
 
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. A function is said to be active in a point if this point lies in the closure of the function's support. More...
 
void activeBoundaryFunctionsOfLevel (const unsigned level, const boxSide &s, std::vector< bool > &actives) const
 
void addLevel (const gsTensorBSplineBasis< d, T > &next_basis)
 Adds a level, only if manual levels are activated.
 
gsMatrix< index_tallBoundary () const
 Returns the indices of the basis functions that are nonzero at the domain boundary.
 
virtual void anchor_into (index_t i, gsMatrix< T > &result) const
 Returns the anchor point for member i of the basis.
 
gsMatrix< T > anchors () const
 Returns the anchor points that represent the members of the basis. There is exactly one anchor point per basis function. More...
 
virtual void anchors_into (gsMatrix< T > &result) const
 
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.
 
BoundaryBasisTypebasisSlice (index_t dir_fixed, T par) const
 Gives back the basis at a slice in dir_fixed at par.
 
gsMatrix< index_tboundary (boxSide const &s) const
 Returns the indices of the basis functions that are nonzero at the domain boundary as single-column-matrix.
 
BoundaryBasisType::uPtr boundaryBasis (boxSide const &s)
 Gives back the boundary basis at boxSide s.
 
gsMatrix< index_tboundaryOffset (boxSide const &s, index_t offset) const
 
uPtr clone ()
 Clone methode. Produceds a deep copy inside a uPtr.
 
gsSparseMatrix< T > collocationMatrix (gsMatrix< T > const &u) const
 Computes the collocation matrix w.r.t. points u. More...
 
virtual gsBSplineBasis< T > & component (short_t i)
 The 1-d basis for the i-th parameter component at the highest level.
 
virtual const gsBSplineBasis< T > & component (short_t i) const
 The 1-d basis for the i-th parameter component at the highest level.
 
virtual uPtr componentBasis (boxComponent b) const
 Returns the basis that corresponds to the component.
 
virtual uPtr componentBasis_withIndices (boxComponent b, gsMatrix< index_t > &indices, bool noBoundary=true) const
 Returns the basis that corresponds to the component. More...
 
virtual void compute (const gsMatrix< T > &in, gsFuncData< T > &out) const
 Computes function data. More...
 
virtual void connectivity (const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
 
virtual void connectivityAtAnchors (gsMesh< T > &mesh) const
 
virtual gsBasis::uPtr create () const
 Create an empty basis of the derived type and return a pointer to it.
 
void decomposeDomain (typename gsTHBSplineBasis::AxisAlignedBoundingBox &boundaryAABB, typename gsTHBSplineBasis::TrimmingCurves &trimCurves) const
 Decomposes domain of the THB-Spline-Basis into partitions. More...
 
virtual short_t degree (short_t i) const
 If the basis is a tensor product of (piecewise) polynomial bases, then this function returns the polynomial degree of the i-th component.
 
virtual void degreeDecrease (short_t const &i=1, short_t const dir=-1)
 Lower the degree of the basis by the given amount, preserving knots multiplicity.
 
virtual void degreeElevate (short_t const &i=1, short_t const dir=-1)
 Elevate the degree of the basis by the given amount, preserve smoothness.
 
virtual void degreeIncrease (short_t const &i=1, short_t const dir=-1)
 Elevate the degree of the basis by the given amount, preserve knots multiplicity.
 
virtual void degreeReduce (short_t const &i=1, short_t const dir=-1)
 Reduce the degree of the basis by the given amount, preserve smoothness.
 
gsMatrix< T > deriv (const gsMatrix< T > &u) const
 Evaluate the derivatives,. More...
 
gsMatrix< T > deriv2 (const gsMatrix< T > &u) const
 Evaluates the second derivatives of active (i.e., non-zero) functions at points u. More...
 
void deriv2_into (const gsMatrix< T > &u, gsMatrix< T > &result) const
 Evaluate the second derivatives of all active basis function at points u. More...
 
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.
 
void deriv_into (const gsMatrix< T > &u, gsMatrix< T > &result) const
 Evaluates the first partial derivatives of the nonzero basis function. More...
 
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. More...
 
virtual std::string detail () const
 Prints the object as a string with extended details.
 
virtual short_t dim () const
 Returns the dimension of the parameter space.
 
virtual gsDomain< T > * domain () const
 
std::vector< std::vector
< std::vector< index_t > > > 
domainBoundariesIndices (std::vector< std::vector< std::vector< std::vector< index_t > > > > &result) const
 Gives polylines on the boundaries between different levels of the mesh. More...
 
std::vector< std::vector
< std::vector< index_t > > > 
domainBoundariesParams (std::vector< std::vector< std::vector< std::vector< T > > > > &result) const
 Gives polylines on the boundaries between different levels of the mesh. More...
 
short_t domainDim () const
 Returns the dimension of the parameter space.
 
virtual size_t elementIndex (const gsVector< T > &u) const
 Returns an index for the element which contains point u.
 
gsMatrix< T > elementInSupportOf (index_t j) const
 Returns (the coordinates of) an element in the support of basis function j.
 
virtual void elevateContinuity (int const &i=1)
 Elevates the continuity of the basis along element boundaries.
 
gsMatrix< T > eval (const gsMatrix< T > &u) const
 Evaluate the function,. More...
 
void eval_into (const gsMatrix< T > &u, gsMatrix< T > &result) const
 Evaluates nonzero basis functions at point u into result. More...
 
std::vector< gsMatrix< T > > evalAllDers (const gsMatrix< T > &u, int n, bool sameElement=false) const
 Evaluate all derivatives upto order n,. More...
 
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. More...
 
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.
 
void flatTensorIndexesToHierachicalIndexes (gsSortedVector< int > &indexes, const int level) const
 transformes a sortedVector indexes of flat tensor index of the bspline basis of level to hierachical indexes in place. If a flat tensor index is not found, it will transform to -1. More...
 
index_t flatTensorIndexOf (const index_t i) const
 Returns the tensor index of the function indexed i (in continued indices). More...
 
index_t flatTensorIndexOf (const index_t i, const index_t level) const
 Returns the tensor index of the function indexed i (in continued indices). More...
 
int flatTensorIndexToHierachicalIndex (index_t index, const int level) const
 takes a flat tensor index of the bspline basis of level and gives back the hierachical index. If a flat tensor index is not found, it will return -1. More...
 
gsBasisFun< T > function (index_t i) const
 Returns the i-th basis function as a gsFunction. More...
 
const std::vector< tensorBasis * > & getBases () const
 Returns the tensor B-spline space of all levels. More...
 
gsTensorBSpline< d, T > getBSplinePatch (const std::vector< index_t > &boundingBox, const unsigned level, const gsMatrix< T > &geomCoefs) const
 Returns a tensor B-Spline patch defined by boundingBox. More...
 
void getBsplinePatches (const gsMatrix< T > &geom_coef, gsMatrix< T > &cp, gsMatrix< index_t > &b1, gsMatrix< index_t > &b2, gsVector< index_t > &level, gsMatrix< index_t > &nvertices) const
 Return the list of B-spline patches to represent a THB-spline geometry. More...
 
void getBsplinePatches_trimming (const gsMatrix< T > &geom_coef, gsMatrix< T > &cp, gsMatrix< index_t > &b1, gsMatrix< index_t > &b2, gsVector< index_t > &level, gsMatrix< index_t > &nvertices, std::vector< std::vector< std::vector< std::vector< T > > > > &trim_curves) const
 Return the list of B-spline patches to represent a THB-spline geometry. More...
 
gsMultiPatch< T > getBsplinePatchesToMultiPatch (const gsMatrix< T > &geom_coef) const
 Return a multipatch structure of B-splines. More...
 
gsMultiPatch< T > getBsplinePatchesToMultiPatch_trimming (const gsMatrix< T > &geom_coef, std::vector< std::vector< std::vector< std::vector< T > > > > &trim_curves) const
 Return a multipatch structure of B-splines. More...
 
GISMO_MAKE_GEOMETRY_NEW void getBsplinePatchGlobal (gsVector< index_t > b1, gsVector< index_t > b2, unsigned level, const gsMatrix< T > &geom_coef, gsMatrix< T > &cp, gsKnotVector< T > &k1, gsKnotVector< T > &k2) const
 Returns the B-spline representation of a THB-spline subpatch. More...
 
const gsSparseVector< T > & getCoefs (unsigned i) const
 Returns sparse representation of the i-th basis function.
 
index_t getLevelAtIndex (const point &Pt) const
 Returns the level(s) at indexes in the parameter domain. More...
 
index_t getLevelAtPoint (const gsMatrix< T > &Pt) const
 Returns the level(s) at point(s) in the parameter domain. More...
 
void getLevelUniqueSpanAtPoints (const gsMatrix< T > &Pt, gsVector< index_t > &lvl, gsMatrix< index_t > &loIdx) const
 Returns the level(s) and knot span(s) at point(s) in the parameter domain. More...
 
virtual T getMaxCellLength () const
 Get the maximum mesh size, as expected for approximation error estimates.
 
virtual T getMinCellLength () const
 Get the minimum mesh size, as expected for inverse inequalities.
 
 gsTHBSplineBasis (gsBasis< T > const &tbasis, bool manualLevels=false)
 Constructor out of a tensor BSpline Basis.
 
virtual void increaseMultiplicity (index_t lvl, int dir, T knotValue, int mult=1)
 Increases the multiplicity of a knot with the value knotValue in level lvl in direction dir by mult. If knotValue is not currently in the given knot vector its not added. More...
 
virtual void increaseMultiplicity (index_t lvl, int dir, const std::vector< T > &knotValue, int mult=1)
 Increases the multiplicity of several knots with the value knotValue in level lvl in direction dir by mult. If knotValue is not currently in the given knot vector its not added. More...
 
virtual memory::unique_ptr
< gsGeometry< T > > 
interpolateAtAnchors (gsMatrix< T > const &vals) const
 Applies interpolation of values pts using the anchors as parameter points. May be reimplemented in derived classes with more efficient algorithms. (by default uses interpolateData(pts,vals)
 
memory::unique_ptr< gsGeometry
< T > > 
interpolateData (gsMatrix< T > const &vals, gsMatrix< T > const &pts) const
 Applies interpolation given the parameter values pts and values vals.
 
virtual bool isRational () const
 Returns false, since all bases that inherit from gsBasis are not rational.
 
knot (int lvl, int k, int i) const
 Returns the i-th knot in direction k at level lvl.
 
index_t levelOf (index_t i) const
 Returns the level of the function indexed i (in continued indices)
 
void makeCompressed ()
 Cleans the basis, removing any inactive levels.
 
gsBasis< T >::domainIter makeDomainIterator () const
 Create a domain iterator for the computational mesh of this basis, that points to the first element of the domain.
 
gsBasis< T >::domainIter makeDomainIterator (const boxSide &s) const
 Create a boundary domain iterator for the computational mesh this basis, that points to the first element on the boundary of the domain.
 
virtual memory::unique_ptr
< gsGeometry< T > > 
makeGeometry (gsMatrix< T > coefs) const =0
 Create a gsGeometry of proper type for this basis with the given coefficient matrix.
 
virtual memory::unique_ptr
< gsBasis< T > > 
makeNonRational () const
 
bool manualLevels () const
 Returns true if levels are assigned manually.
 
void matchWith (const boundaryInterface &bi, const gsBasis< T > &other, gsMatrix< index_t > &bndThis, gsMatrix< index_t > &bndOther, index_t offset) const
 Computes the indices of DoFs that match on the interface bi. The interface is assumed to be a common face between this patch and other, with an offset offset. The output is two lists of indices bndThis and bndOther, with indices that match one-to-one on the boundary bi. More...
 
short_t maxDegree () const
 If the basis is of polynomial or piecewise polynomial type, then this function returns the maximum polynomial degree.
 
unsigned maxLevel () const
 Returns the level in which the indices are stored internally.
 
short_t minDegree () const
 If the basis is of polynomial or piecewise polynomial type, then this function returns the minimum polynomial degree.
 
virtual index_t nPieces () const
 Number of pieces in the domain of definition.
 
void numActive_into (const gsMatrix< T > &u, gsVector< index_t > &result) const
 The number of active basis functions at points u.
 
int numBreaks (int lvl, int k) const
 
size_t numElements (boxSide const &s=0) const
 The number of elements on side s.
 
int numKnots (int lvl, int k) const
 Returns the number of knots in direction k of level lvl.
 
index_t numLevels () const
 Returns the number of levels.
 
unsigned numTruncated () const
 Returns the number of truncated basis functions.
 
void only_insert_box (point const &k1, point const &k2, int lvl)
 Inserts a domain into the basis.
 
const gsBasis< T > & piece (const index_t k) const
 Returns the piece(s) of the function(s) at subdomain k.
 
std::ostream & print (std::ostream &os) const
 Prints the object as a string.
 
void printBases (std::ostream &os=gsInfo) const
 Prints the spline-space hierarchy.
 
void printBasic (std::ostream &os=gsInfo) const
 Prints the spline-space hierarchy.
 
void printSpaces (std::ostream &os=gsInfo) const
 Prints the spline-space hierarchy.
 
void reduceContinuity (int const &i=1)
 Reduces spline continuity at interior knots by i.
 
virtual void refine (gsMatrix< T > const &boxes, int refExt)
 Refine the basis to levels and in the areas defined by boxes with an extension. More...
 
virtual void refine (gsMatrix< T > const &boxes)
 Refine the basis to levels and in the areas defined by boxes. More...
 
void refineBasisFunction (const index_t i)
 Refines the basis function with (hierarchical) index i.
 
virtual void refineElements (std::vector< index_t > const &boxes)
 Insert the given boxes into the quadtree. More...
 
void refineElements_withCoefs (gsMatrix< T > &coefs, std::vector< index_t > const &boxes)
 
void refineSide (const boxSide side, index_t lvl)
 Refines all the cells on the side side up to level lvl.
 
virtual void reverse ()
 Reverse the basis.
 
void setActiveToLvl (int level, std::vector< CMatrix > &x_matrix_lvl) const
 Creates characteristic matrices for basis where "level" is the maximum level i.e. ignoring higher level refinements.
 
void setDegree (short_t const &i)
 Set the degree of the basis (either elevate or reduce) in order to have degree equal to i wrt to each variable.
 
void setDegreePreservingMultiplicity (short_t const &i)
 Set the degree of the basis (either increase or decrecee) in order to have degree equal to i.
 
index_t size () const
 The number of basis functions in this basis.
 
virtual const gsBasissource () const
 
virtual gsBasissource ()
 
gsMatrix< T > support () const
 Returns the boundary basis for side s. More...
 
gsMatrix< T > support (const index_t &i) const
 Returns (a bounding box for) the support of the i-th basis function. More...
 
gsMatrix< T > supportInterval (index_t dir) const
 Returns an interval that contains the parameter values in direction dir. More...
 
virtual short_t targetDim () const
 Dimension of the target space. More...
 
virtual gsBasis::uPtr tensorize (const gsBasis &other) const
 Return a tensor basis of this and other.
 
tensorBasistensorLevel (index_t i) const
 Returns the tensor basis member of level i.
 
bool testPartitionOfUnity (const index_t npts=100, const T tol=1e-12) const
 Test the partition of unity. More...
 
virtual short_t totalDegree () const
 If the basis is of polynomial or piecewise polynomial type, then this function returns the total polynomial degree.
 
void transfer (const std::vector< gsSortedVector< index_t > > &old, gsSparseMatrix< T > &result)
 Returns transfer matrix between the hirarchical spline given by the characteristic matrix "old" and this.
 
void transferbyLvl (std::vector< gsSparseMatrix< T > > &result)
 returns transfer matrices betweend the levels of the given hierarchical spline
 
const gsHDomain< d > & tree () const
 Returns a reference to m_tree.
 
gsHDomain< d > & tree ()
 Returns a reference to m_tree.
 
int treeSize () const
 The number of nodes in the tree representation.
 
std::map< index_t,
gsSparseVector< T >
>::const_iterator 
truncatedBegin () const
 Returns an iterator to the representation of the first truncated basis function.
 
std::map< index_t,
gsSparseVector< T >
>::const_iterator 
truncatedEnd () const
 Returns an iterator past the last truncated basis function.
 
virtual void uniformCoarsen (int numKnots=1)
 Coarsen the basis uniformly by removing groups of numKnots consecutive knots, each knot removed mul times. More...
 
void uniformCoarsen_withCoefs (gsMatrix< T > &coefs, int numKnots=1)
 Coarsen the basis uniformly. More...
 
virtual 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 refined ones. More...
 
virtual void uniformRefine (int numKnots=1, int mul=1, int dir=-1)
 Refine the basis uniformly by inserting numKnots new knots with multiplicity mul on each knot span.
 
void uniformRefine_withCoefs (gsMatrix< T > &coefs, int numKnots=1, int mul=1, int dir=-1)
 Refine the basis uniformly. More...
 
virtual void uniformRefine_withTransfer (gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1, int mul=1)
 Refine the basis uniformly. More...
 
virtual void unrefineElements (std::vector< index_t > const &boxes)
 Clear the given boxes into the quadtree. More...
 
virtual const gsMatrix< T > & weights () const
 Only for compatibility reasons, with gsRationalBasis. It returns an empty matrix.
 
virtual gsMatrix< T > & weights ()
 Only for compatibility reasons, with gsRationalBasis. It returns an empty matrix.
 
Evaluation functions
gsMatrix< T > evalSingle (index_t i, const gsMatrix< T > &u) const
 Evaluate a single basis function i at points u.
 
gsMatrix< T > derivSingle (index_t i, const gsMatrix< T > &u) const
 Evaluate a single basis function i derivative at points u.
 
gsMatrix< T > deriv2Single (index_t i, const gsMatrix< T > &u) const
 Evaluate the second derivative of a single basis function i at points u.
 
gsVector< index_tnumActive (const gsMatrix< T > &u) const
 Number of active basis functions at an arbitrary parameter value. More...
 
virtual 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 function i.
 
virtual void activeCoefs_into (const gsVector< T > &u, const gsMatrix< T > &coefs, gsMatrix< T > &result) const
 Returns the matrix result of active coefficients at points u, each row being one coefficient. The order of the rows is the same as active_into and eval_into functions. More...
 
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.
 
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.
 
virtual gsMatrix< T > laplacian (const gsMatrix< T > &u) const
 Compute the Laplacian of all nonzero basis functions at points u.
 

Static Public Attributes

static const short_t Dim
 Dimension of the parameter domain.
 

Protected Member Functions

void _diadicIndexToKnotIndex (const index_t level, gsVector< index_t, d > &diadicIndex) const
 Transfers the diadicIndex in the knot span in direction on level level to knot indices. More...
 
void _knotIndexToDiadicIndex (const index_t level, const index_t dir, index_t &knotIndex) const
 Transfers the knotIndex in the knot span in direction dir on level level to diadic indices. More...
 
void createMoreLevels (int numLevels) const
 Creates numLevels extra grids in the hierarchy.
 
void getBoxesAlongSlice (int dir, T par, std::vector< index_t > &boxes) const
 
void needLevel (int maxLevel) const
 Makes sure that there are numLevels grids computed in the hierarachy.
 

Protected Attributes

std::vector< tensorBasis * > m_bases
 The list of nested spaces. More...
 
hdomain_type m_tree
 The tree structure of the index space.
 
std::vector< std::vector
< std::vector< index_t > > > 
m_uIndices
 Store the indices of the element boundaries for each level (only if m_manualLevels==true)
 
std::vector< CMatrixm_xmatrix
 The characteristic matrices for each level. More...
 
std::vector< index_tm_xmatrix_offset
 Stores the offsets of active functions for all levels. More...
 

Private Member Functions

unsigned _basisFunIndexOnLevel (const gsVector< index_t, d > &index, const unsigned level, const gsVector< index_t, d > &fin_low, const unsigned new_level)
 Computes tensor index of a basis function on a finer level (new_level) which is presented with tensor index (index) at a coarse level (level). More...
 
void _representBasisFunction (const unsigned j, const unsigned pres_level, const gsVector< index_t, d > &finest_low, const gsVector< index_t, d > &finest_high)
 Computes representation of j-th basis function on pres_level and saves it. More...
 
void _saveNewBasisFunPresentation (const gsMatrix< T > &coefs, const gsVector< index_t, d > &act_size_of_coefs, const unsigned j, const unsigned pres_level, const gsVector< index_t, d > &finest_low)
 Saves a presentation of the j-th basis function. Presentation is given by the coefficients coefs. The coefficients corresponds to the apropriate BSplines at presentation level. More...
 
void _truncate (gsMatrix< T > &coefs, const gsVector< index_t, d > &act_size_of_coefs, const gsVector< index_t, d > &size_of_coefs, const unsigned level, const gsVector< index_t, d > &bspl_vec_ti, const unsigned bspl_vec_ti_level, const gsVector< index_t, d > &finest_low)
 Performs truncation. More...
 
unsigned _updateSizeOfCoefs (const unsigned clevel, const unsigned flevel, const gsVector< index_t, d > &finest_low, const gsVector< index_t, d > &finest_high, gsVector< index_t, d > &size_of_coefs)
 We get current size of the coefficients. Function updates this sizes accordingly to the refinement from coarser to finer grid. Assumption is that we are doing refinement from the index finest_low till the index highest_low. More...
 
bool areBoxesTheSame (const std::vector< index_t > &firstBox, const std::vector< index_t > &secondBox) const
 Checks if the boxes are the same. More...
 
void breakCycles (typename gsTHBSplineBasis::AxisAlignedBoundingBox &aabb, typename gsTHBSplineBasis::Polylines &polylines) const
 Breaks the cycles of polylines and returns updated polylines. More...
 
void breakPolylineIntoTwoParts (const std::vector< std::vector< T > > &polyline, const index_t segment, const std::pair< T, T > &pt, std::vector< std::vector< T > > &part1, std::vector< std::vector< T > > &part2) const
 Breaks polyline into two parts. More...
 
gsSparseMatrix< T > coarsening (const std::vector< gsSortedVector< index_t > > &old, const std::vector< gsSortedVector< index_t > > &n, const gsSparseMatrix< T, RowMajor > &transfer) const
 returns a transfer matrix using the characteristic matrix of the old and new basis
 
void findNewAABB (const std::vector< std::vector< T > > &polyline, std::vector< index_t > &aabb) const
 Finds new axis aligned bounding box for given polyline.
 
void globalRefinement (const gsMatrix< T > &thbCoefs, int level, gsMatrix< T > &lvlCoefs) const
 Returns a representation of thbCoefs as tensor-product B-spline coefficientes lvlCoefs at level level. More...
 
index_t identifyCycle (const std::vector< std::vector< T > > &polyline, std::pair< T, T > &pt) const
 Identify if the polyline can be split into two cycles. More...
 
bool isFirstBoxCompletelyInsideSecond (const std::vector< index_t > &firstBox, const std::vector< index_t > &secondBox) const
 Checks if the first box is completely inside second box. More...
 
void representBasis ()
 Computes and saves representation of all basis functions.
 
void update_structure ()
 Initialize the characteristic and coefficient matrices and the internal bspline representations.
 

Geometry evaluation functions

These functions evaluate not the individual basis functions of the basis, but a geometry object which is represented by a coefficient matrix w.r.t. this basis object. For the format of the coefficient matrix, see gsGeometry.

These functions have default implementations which simply compute the basis function values and perform linear combination, but they may be overridden in derived classes if a higher-performance implementation is possible.

gsMatrix< T > evalFunc (const gsMatrix< T > &u, const gsMatrix< T > &coefs) const
 Evaluate the function described by coefs at points u. More...
 
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 BasisFunctions, into result. More...
 
gsMatrix< T > derivFunc (const gsMatrix< T > &u, const gsMatrix< T > &coefs) const
 Evaluate the derivatives of the function described by coefs at points u. More...
 
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. More...
 
virtual void jacobianFunc_into (const gsMatrix< T > &u, const gsMatrix< T > &coefs, gsMatrix< T > &result) const
 Evaluate the Jacobian of the function described by coefs at points u. Jacobian matrices are stacked in blocks.
 
gsMatrix< T > deriv2Func (const gsMatrix< T > &u, const gsMatrix< T > &coefs) const
 Evaluates the second derivatives of the function described by coefs at points u. More...
 
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. More...
 
virtual void evalAllDersFunc_into (const gsMatrix< T > &u, const gsMatrix< T > &coefs, const unsigned n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const
 Evaluates all derivatives up to order n of the function described by coefs at points u. More...
 
static void linearCombination_into (const gsMatrix< T > &coefs, const gsMatrix< index_t > &actives, const gsMatrix< T > &values, gsMatrix< T > &result, bool sameElement=false)
 Computes the linear combination coefs * values( actives ) More...
 

Member Function Documentation

unsigned _basisFunIndexOnLevel ( const gsVector< index_t, d > &  index,
const unsigned  level,
const gsVector< index_t, d > &  fin_low,
const unsigned  new_level 
)
private

Computes tensor index of a basis function on a finer level (new_level) which is presented with tensor index (index) at a coarse level (level).

Parameters
indextensor index of the basis function on a coarse level
levelcoarse level
fin_low"low index" of the support of the basis function
new_levelfiner level
Returns
global tensor index of a basis function on the finer level
void _diadicIndexToKnotIndex ( const index_t  level,
gsVector< index_t, d > &  diadicIndex 
) const
protectedinherited

Transfers the diadicIndex in the knot span in direction on level level to knot indices.

Parameters
[in]levelThe level
diadicIndexThe diadic index
void _knotIndexToDiadicIndex ( const index_t  level,
const index_t  dir,
index_t knotIndex 
) const
protectedinherited

Transfers the knotIndex in the knot span in direction dir on level level to diadic indices.

Parameters
[in]levelThe level
[in]dirThe dir
knotIndexThe knot index
void _representBasisFunction ( const unsigned  j,
const unsigned  pres_level,
const gsVector< index_t, d > &  finest_low,
const gsVector< index_t, d > &  finest_high 
)
private

Computes representation of j-th basis function on pres_level and saves it.

Parameters
jindex of basis function
pres_levellevet at which we want to present j-th basis function
finest_low"low index" of support of j-th basis function (finest grid)
finest_high"high index" of support of j-th basis function (finest grid)
void _saveNewBasisFunPresentation ( const gsMatrix< T > &  coefs,
const gsVector< index_t, d > &  act_size_of_coefs,
const unsigned  j,
const unsigned  pres_level,
const gsVector< index_t, d > &  finest_low 
)
private

Saves a presentation of the j-th basis function. Presentation is given by the coefficients coefs. The coefficients corresponds to the apropriate BSplines at presentation level.

Parameters
coefscoefficients
act_size_of_coefssize of the coefficients
jglobal tensor index of a basis function
pres_levelpresentation level
finest_low"low index" of support of j-th basis function (at the finest grid)
void _truncate ( gsMatrix< T > &  coefs,
const gsVector< index_t, d > &  act_size_of_coefs,
const gsVector< index_t, d > &  size_of_coefs,
const unsigned  level,
const gsVector< index_t, d > &  bspl_vec_ti,
const unsigned  bspl_vec_ti_level,
const gsVector< index_t, d > &  finest_low 
)
private

Performs truncation.

Parameters
coefscoefficients refined from level - 1 to level
act_size_of_coefsactuall size of the coefficients
size_of_coefssize of the non-zero coeffs
levelat which we truncate
bspl_vec_tiB-Spline tensor index vector of the original function (we want to trancate this basis function)
bspl_vec_ti_levellevel of the basis function given with vector bspl_vec_ti
finest_low"low index" of the support of the basis function
unsigned _updateSizeOfCoefs ( const unsigned  clevel,
const unsigned  flevel,
const gsVector< index_t, d > &  finest_low,
const gsVector< index_t, d > &  finest_high,
gsVector< index_t, d > &  size_of_coefs 
)
private

We get current size of the coefficients. Function updates this sizes accordingly to the refinement from coarser to finer grid. Assumption is that we are doing refinement from the index finest_low till the index highest_low.

Parameters
clevelcoarse level
flevelfiner level
finest_low"low index" of the support of a basis function (finest grid)
finest_high"high index" of the support of a basis function (finest grid)
size_of_coefssize of the coefficients
Returns
number of all new coefficients
gsMatrix<index_t> active ( const gsMatrix< T > &  u) const
inlineinherited

Returns the indices of active (nonzero) functions at points u, as a list of indices.

See Also
active_into()
void active_into ( const gsMatrix< T > &  u,
gsMatrix< index_t > &  result 
) const
virtual

Returns the indices of active basis functions at points u, as a list of indices, in result. A function is said to be active in a point if this point lies in the closure of the function's support.

Parameters
[in]ugsMatrix containing evaluation points. Each column represents one evaluation point.
[out]resultFor every column i of u, a column containing the indices of the active basis functions at evaluation point u.col(i).

Reimplemented from gsHTensorBasis< d, T >.

void activeBoundaryFunctionsOfLevel ( const unsigned  level,
const boxSide s,
std::vector< bool > &  actives 
) const
inherited

Fills the vector actives with booleans, that determine if a function of the given level is active. The functions on the boundary are ordered in ascending patchindex order.

Parameters
[in]level: level of the boundary functions
[in]s: boundary side
[out]actives: the result, true if its active, false if not
void activeCoefs_into ( const gsVector< T > &  u,
const gsMatrix< T > &  coefs,
gsMatrix< T > &  result 
) const
virtualinherited

Returns the matrix result of active coefficients at points u, each row being one coefficient. The order of the rows is the same as active_into and eval_into functions.

Parameters
[in]ugsVector containing an evaluation point.
[in]coefsgsMatrix is a coefficient matrix with as many rows as the size of the basis
[out]resultFor every column i of u, a column containing the indices of the active basis functions at evaluation point u.col(i).
gsMatrix<T> anchors ( ) const
inlineinherited

Returns the anchor points that represent the members of the basis. There is exactly one anchor point per basis function.

The exact definition of the anchor points depends on the particular basis. For instance, for a Bspline basis these are the Greville abscissae. In general, evaluating a function at the anchor points should provide enough information to interpolate that function using this basis.

virtual void anchors_into ( gsMatrix< T > &  result) const
inlinevirtualinherited

Returns the anchors points that represent the members of the basis

Reimplemented from gsBasis< T >.

bool areBoxesTheSame ( const std::vector< index_t > &  firstBox,
const std::vector< index_t > &  secondBox 
) const
inlineprivate

Checks if the boxes are the same.

Utility function for the decomposeDomain member function.

gsMatrix< index_t > boundaryOffset ( boxSide const &  s,
index_t  offset 
) const
virtual

Returns the indices of the basis functions that are nonzero at the domain boundary. If an offset is provided (the default is zero), it will return the indizes of the basis functions having this offset to the provided boxSide. Note that the offset cannot be bigger than the size of the basis in the direction orthogonal to boxSide.

Reimplemented from gsHTensorBasis< d, T >.

void breakCycles ( typename gsTHBSplineBasis< d, T >::AxisAlignedBoundingBox &  aabb,
typename gsTHBSplineBasis< d, T >::Polylines &  polylines 
) const
private

Breaks the cycles of polylines and returns updated polylines.

domainBoundaryParams can return polylines with cycles, this function decomposes the cycles and returns polylines without cycles. Look above for the definition of types (AxisAlignedBoundingBox, TrimmingCurves).

Parameters
aabbaxis aligned bounding boxes each polyline has it own box
polylinespolyline describing area with the same level
void breakPolylineIntoTwoParts ( const std::vector< std::vector< T > > &  polyline,
const index_t  segment,
const std::pair< T, T > &  pt,
std::vector< std::vector< T > > &  part1,
std::vector< std::vector< T > > &  part2 
) const
private

Breaks polyline into two parts.

Function splits input polyline (with al least two cycles) at given point into two cycles (part1 and part2).

Parameters
[in]polylineinput polyline with at least two cycles
[in]segmentthe index of the segment of the polyline where the point is
[in]ptthe point where two cyles in polyline meet
[out]part1first cycle of polyline
[out]part2second cycle of polyline
gsSparseMatrix< T > collocationMatrix ( gsMatrix< T > const &  u) const
inlineinherited

Computes the collocation matrix w.r.t. points u.

The collocation matrix is a sparse matrix with u.cols rows and size() columns. The entry (i,j) is the value of basis function j at evaluation point i.

gsBasis< T >::uPtr componentBasis_withIndices ( boxComponent  b,
gsMatrix< index_t > &  indices,
bool  noBoundary = true 
) const
virtualinherited

Returns the basis that corresponds to the component.

Parameters
bThe component
indicesThe row vector where the indices are stored to
noBoundaryIf true, the transfer matrix does not include parts belonging to lower-order components (i.e., edges without corners or faces without corners and edges)
void compute ( const gsMatrix< T > &  in,
gsFuncData< T > &  out 
) const
virtualinherited

Computes function data.

This function evaluates the functions and their derivatives at the points in and writes them in the corresponding fields of out. Which field to write (and what to compute) is controlled by the out.flags (see also gsFuncData).

The input points in are expected to be compatible with the implementation/representation of the function, i.e. they should be points inside the domain of definitition of the function

Parameters
[in]in
[out]out

Reimplemented in gsGeometry< T >, and gsConstantFunction< T >.

void connectivity ( const gsMatrix< T > &  nodes,
gsMesh< T > &  mesh 
) const
virtualinherited

Returns the connectivity structure of the basis The returned mesh has vertices the rows of matrix nodes

Reimplemented from gsBasis< T >.

void connectivityAtAnchors ( gsMesh< T > &  mesh) const
inlinevirtualinherited

Returns the connectivity structure of the basis The returned mesh has the anchor points as vertices

void decomposeDomain ( typename gsTHBSplineBasis< d, T >::AxisAlignedBoundingBox &  boundaryAABB,
typename gsTHBSplineBasis< d, T >::TrimmingCurves &  trimCurves 
) const

Decomposes domain of the THB-Spline-Basis into partitions.

Each partiotion describes an area of the same level, this area is contained in a bounding box (boundaryAABB) and has its own trimming curves (trimmCurves). Look above for the definition of types (AxisAlignedBoundingBox, TrimmingCurves).

Parameters
[out]boundaryAABBaxis aligned bounding boxes – "each" trimCurve has it own box
[out]trimCurvestrimming curves, each trimming curve describes a region of the same level
gsMatrix< T > deriv ( const gsMatrix< T > &  u) const
inherited

Evaluate the derivatives,.

See Also
deriv_into()
gsMatrix< T > deriv2 ( const gsMatrix< T > &  u) const
inherited

Evaluates the second derivatives of active (i.e., non-zero) functions at points u.

See documentation for deriv2_into() (the one without input parameter coefs) for details.

See Also
deriv2_into()
Parameters
[in]uEvaluation points in columns.
Returns
For every column of u, a column containing the second derivatives. See documentation for deriv2_into() (the one without input parameter coefs) for details.
void deriv2_into ( const gsMatrix< T > &  u,
gsMatrix< T > &  result 
) const
virtual

Evaluate the second derivatives of all active basis function at points u.

Input parameter u is a gsMatrix of size d x N, where
d is the dimension of the parameter domain and
N is the number of evaluation points.
Each column of u corresponds to the coordinates of one evaluation point.

result is a gsMatrix of size (K * d) x N, where
K is the number of active basis functions at the evaluation point.
Each column of result corresponds to a column of u. It contains the "pure" and the mixed derivatives for each active basis function, "above" each other.

Example (bivariate): Let \(B_i(x,y)\), d = 2 be bivariate basis functions, and let the functions with indices 3,4,7, and 8 (K = 4) be active at an evaluation point u. Then, the corresponding column of result represents:
\( ( \partial_{xx}\, B_3(u), \partial_{yy}\, B_3(u), \partial_{xy}\, B_3(u), \partial_{xx}\, B_4(u), \partial_{yy}\, B_4(u), \partial_{xy}\, B_4(u), \partial_{xx}\, B_7(u), ... , \partial_{xy}\, B_8(u) )^T \)

Example (trivariate): Let \(B_i(x,y,z)\), d = 3 be trivariate basis functions, and let the functions with indices 3,4,7, and 8 be active at an evaluation point u. Then, the corresponding column of result represents:
\(( \partial_{xx}\, B_3(u), \partial_{yy}\, B_3(u), \partial_{zz}\, B_3(u), \partial_{xy}\, B_3(u), \partial_{xz}\, B_3(u), \partial_{yz}\, B_3(u), \partial_{xx}\, B_4(u), ... , \partial_{yz}\, B_8(u) )^T \)

Parameters
[in]uEvaluation points in columns (see above for format).
[in,out]resultFor every column of u, a column containing the second derivatives as described above.

See also deriv2() (the one without input parameter coefs).

Reimplemented from gsBasis< T >.

gsMatrix<T> deriv2Func ( const gsMatrix< T > &  u,
const gsMatrix< T > &  coefs 
) const
inlineinherited

Evaluates the second derivatives of the function described by coefs at points u.

See documentation for deriv2_into() (the one with input parameter coefs) for details.

Parameters
[in]uEvaluation points in columns.
[in]coefsCoefficient matrix describing the geometry in this basis.
Returns
For every column of u, a column containing the second derivatives. See documentation for deriv2_into() (the one with input parameter coefs) for details.
void deriv2Func_into ( const gsMatrix< T > &  u,
const gsMatrix< T > &  coefs,
gsMatrix< T > &  result 
) const
virtualinherited

Evaluates the second derivatives of the function described by coefs at points u.

...i.e., evaluates a linear combination of coefs * (2nd derivatives of basis functions), into result.

Evaluation points u are given as gsMatrix of size d x N, where
d is the dimension of the parameter domain and
N is the number of evaluation points.
Each column of u corresponds to the coordinates of one evaluation point.

The coefficients coefs are given as gsMatrix of size N x n, where
N is the number of points = number of basis functions and
n is the dimension of the physical domain.
Each row of coefs corresponds to the coordinates of one control point.

Let the function \( f: \mathbb R^3 \to \mathbb R^3\) be given by

\[ f = ( f_1, f_2, f_3)^T = \sum_{i=1}^N c_i B_i(x,y,z), \]

where \( B_i(x,y,z)\) are scalar basis functions and \(c_i\) are the corresponding (m-dimensional) control points. Then, for each column in u, the corresponding column in result represents

\[ ( \partial_{xx}\ f_1, \partial_{yy}\ f_1, \partial_{zz}\ f_1, \partial_{xy}\ f_1, \partial_{xz}\ f_1, \partial_{yz}\ f_1, \partial_{xx}\ f_2, \partial_{yy}\ f_2, \ldots , \partial_{xz}\ f_3, \partial_{yz}\ f_3)^T. \]

at the respective evaluation point.

Parameters
[in]uEvaluation points in columns (see above for format).
[in]coefsCoefficient matrix describing the geometry in this basis.
[out]resultFor every column of u, a column containing the second derivatives at the respective point in the format described above.

This function has a default implementation that may be overridden in derived classes for higher performance.
See also deriv2() (the one with input parameter coefs).

void deriv_into ( const gsMatrix< T > &  u,
gsMatrix< T > &  result 
) const
virtual

Evaluates the first partial derivatives of the nonzero basis function.

Let
d denote the dimension of the parameter domain.
K denote the number of active (i.e., non-zero) basis functions (see active_into()).
N denote the number of evaluation points.
The N evaluation points u are given in a gsMatrix of size d x N. Each column of u represents one evaluation point.

The gsMatrix result contains the computed derivatives in the following form:
Column j of result corresponds to one evaluation point (specified by the j-th column of u). The column contains the gradients of all active functions "above" each other.
For example, for scalar basis functions \(B_i : (x,y,z)-> R\), a column represents
\((dx B_1, dy B_1, dz B_1, dx B_2, dy B_2, dz B_2, ... , dx B_n, dy B_N, dz B_N)^T\),
where the order the basis functions \(B_i\) is as returned by active() and active_into().

Parameters
[in]uEvaluation points given as gsMatrix of size d x N. See above for details.
[in,out]resultgsMatrix of size (K*d) x N. See above for details.
Todo:
Rename to _ grad_into

Reimplemented from gsBasis< T >.

gsMatrix<T> derivFunc ( const gsMatrix< T > &  u,
const gsMatrix< T > &  coefs 
) const
inlineinherited

Evaluate the derivatives of the function described by coefs at points u.

Parameters
uevaluation points as N column vectors
coefscoefficient matrix describing the geometry in this basis, n columns
Returns
For every column of u, the result matrix will contain one Jacobian matrix of size d * n, such that the total size of the result is n x (d * n) x N
void derivFunc_into ( const gsMatrix< T > &  u,
const gsMatrix< T > &  coefs,
gsMatrix< T > &  result 
) const
virtualinherited

Evaluate the derivatives of the function described by coefs at points u.

Evaluates a linear combination of coefs*BasisFunctionDerivatives, into result.

This function has a default implementation that may be overridden in derived classes for higher performance.

Let the function \(f: \mathbb R^d \to \mathbb R^m \) be described by the coefficients coefs, i.e.,
each evaluation point is in \(\mathbb R^d\), and
each coefficient is a point in \(\mathbb R^m\).

The N evaluation points u are given in a gsMatrix of size d x N. Each column of u represents one evaluation point.

The K coefficients coefs are given as a gsMatrix of size K x m. Each row of coefs represents one coefficient in \(\mathbb R^m\).

The gsMatrix result contains the following data:
For every column of u, the corresponding column in the matrix result contains the gradients of the m components of the function above each other. Hence, the size of result is (d*m) x N.

Example 1:
Let \(f(s,t)\) be a bivariate scalar function, \(f:\mathbb R^2 \to \mathbb R\) (i.e., d=2, m=1), and let the evaluation point \( u_i\) be represented by the i-th column of u.
Then, result has the form

\[ \left( \begin{array}{cccc} \partial_s f(u_1) & \partial_s f(u_2) & \ldots & \partial_t f(u_{N}) \\ \partial_t f(u_1) & \partial_t f(u_2) & \ldots & \partial_t f(u_{N}) \end{array} \right) \]

Example 2:
Let \(f(s,t) = ( f_1(s,t), f_2(s,t), f_3(s,t) )\) represent a surface in space, \(f:\mathbb R^2 \to \mathbb R^3\) (i.e., d=2, m=3), and let the evaluation point \( u_i\) be represented by the i-th column of u.
Then, result has the form

\[ \left( \begin{array}{ccccccc} \partial_s f_1(u_1) & \partial_s f_1(u_2) & \ldots & \partial_s f_1(u_N) \\ \partial_t f_1(u_1) & \partial_t f_1(u_2) & \ldots & \partial_t f_1(u_N) \\ \partial_s f_2(u_1) & \partial_s f_2(u_2) & \ldots & \partial_s f_2(u_N) \\ \partial_t f_2(u_1) & \partial_t f_2(u_2) & \ldots & \partial_t f_2(u_N) \\ \partial_s f_3(u_1) & \partial_s f_3(u_2) & \ldots & \partial_s f_3(u_N) \\ \partial_t f_3(u_1) & \partial_t f_3(u_2) & \ldots & \partial_t f_3(u_N) \\ \end{array} \right) \]

Parameters
[in]uEvaluation points as d x N-matrix.
[in]coefsCoefficient matrix describing the geometry in this basis as K x m-matrix.
K should equal the size() of the basis, i.e., the number basis functions.
[in,out]resultgsMatrix of size d*m x N, see above for format.

where
d is the dimension of the parameter domain
m is the dimension of the physical domain
N is the number of evaluation points
K is the number of coefficients

void derivSingle_into ( index_t  i,
const gsMatrix< T > &  u,
gsMatrix< T > &  result 
) const
virtual

Evaluates the (partial) derivatives of the i-th basis function at points u into result.

See deriv_into() for detailed documentation.

Todo:
rename grad_into

Reimplemented from gsBasis< T >.

gsDomain< T > * domain ( ) const
virtualinherited
std::vector< std::vector< std::vector< index_t > > > domainBoundariesIndices ( std::vector< std::vector< std::vector< std::vector< index_t > > > > &  result) const
inherited

Gives polylines on the boundaries between different levels of the mesh.

Parameters
resultvariable where to write the polylines in the form < levels < polylines_in_one_level < one_polyline < one_segment (x1, y1, x2, y2) > > > > where <x1, y1, x2, y2 > are so that (x1, y1) <=LEX (x2, y2) and where x1, y1, x2 and y2 are indices of the knots with respect to m_maxInsLevel.
Returns
bounding boxes of the polylines in the form < levels < polylines_in_one_level < x_ll, y_ll, x_ur, y_ur > > >, where "ur" stands for "upper right" and "ll" for "lower left".
std::vector< std::vector< std::vector< index_t > > > domainBoundariesParams ( std::vector< std::vector< std::vector< std::vector< T > > > > &  result) const
inherited

Gives polylines on the boundaries between different levels of the mesh.

Parameters
resultvariable where to write the polylines in the form < levels < polylines_in_one_level < one_polyline < one_segment (x1, y1, x2, y2) > > > > , where <x1, y1, x2, y2 > are so that (x1, y1) <=LEX (x2, y2) and where x1, y1, x2 and y2 are parameters (knots).
Returns
bounding boxes of the polylines in the form < levels < polylines_in_one_level < x_ll, y_ll, x_ur, y_ur > > >, where "ur" stands for "upper right" and "ll" for "lower left".
gsMatrix< T > eval ( const gsMatrix< T > &  u) const
inherited

Evaluate the function,.

See Also
eval_into()
void eval_into ( const gsMatrix< T > &  u,
gsMatrix< T > &  result 
) const
virtual

Evaluates nonzero basis functions at point u into result.

Let...
d denote the dimension of the parameter domain.
K denote the number of active (i.e., non-zero) basis functions (see active_into()). N denote the number of evaluation points.
The n evaluation points u are given in a gsMatrix of size d x N. Each column of u represents one evaluation point.

The gsMatrix result contains the computed function values in the following form:
Column j of result corresponds to one evaluation point (specified by the j-th column of u). The column contains the values of all active functions "above" each other.
For example, for scalar basis functions Bi : (x,y,z)-> R, a column represents
(B1, B2, ... , BN)^T,
where the order the basis functions Bi is as returned by active() and active_into().

Parameters
[in]uEvaluation points given as gsMatrix of size d x N. See above for details.
[in,out]resultgsMatrix of size K x N. See above for details.

Reimplemented from gsBasis< T >.

std::vector< gsMatrix< T > > evalAllDers ( const gsMatrix< T > &  u,
int  n,
bool  sameElement = false 
) const
inherited

Evaluate all derivatives upto order n,.

See Also
evalAllDers_into
void evalAllDers_into ( const gsMatrix< T > &  u,
int  n,
std::vector< gsMatrix< T > > &  result,
bool  sameElement = false 
) const
virtual

Evaluate the nonzero functions and their derivatives up to order n at points u into result.

The derivatives (the 0-th derivative is the function value) are stored in a result. result is a std::vector, where result[i] is a gsMatrix which contains the i-th derivatives.

The entries in result[0], result[1], and result[2] are ordered as in eval_into(), deriv_into(), and deriv2_into(), respectively. For i > 2, the derivatives are stored in lexicographical order, e.g. for order i = 3 and dimension 2 the derivatives are stored as follows: \( \partial_{xxx}, \, \partial_{xxy}, \, \partial_{xyy}, \, \partial_{yyy}.\, \)

Parameters
[in]uEvaluation points, each column corresponds to one evaluation point.
[in]nAll derivatives up to order n are computed and stored in result.
[in,out]resultSee above for format.

Reimplemented from gsFunctionSet< T >.

void evalAllDersFunc_into ( const gsMatrix< T > &  u,
const gsMatrix< T > &  coefs,
const unsigned  n,
std::vector< gsMatrix< T > > &  result,
bool  sameElement = false 
) const
virtualinherited

Evaluates all derivatives up to order n of the function described by coefs at points u.

Evaluation points u are given as gsMatrix of size d x N, where
d is the dimension of the parameter domain and
N is the number of evaluation points.
Each column of u corresponds to the coordinates of one evaluation point.

The coefficients coefs are given as gsMatrix of size K x n, where
K is the number of (active) basis functions (=size()) and
n is the dimension of the physical domain.
Each row of coefs corresponds to the coordinates of one control point.

result is a std::vector, where the entry result[i] contains the gsMatrix corresponding to the i-th derivatives. The format of the respective entry is as in
evalFunc_into()
derivFunc_into()
deriv2Func_into()

Todo:
finish documentation
Parameters
[in]u
[in]coefs
[in]n
[out]result
gsMatrix<T> evalFunc ( const gsMatrix< T > &  u,
const gsMatrix< T > &  coefs 
) const
inlineinherited

Evaluate the function described by coefs at points u.

This function has a default implementation that may be overridden in derived classes for higher performance.

Parameters
uevaluation points as m column vectors
coefscoefficient matrix describing the geometry in this basis, n columns
Returns
a matrix of size n x m with one function value as a column vector per evaluation point
void evalFunc_into ( const gsMatrix< T > &  u,
const gsMatrix< T > &  coefs,
gsMatrix< T > &  result 
) const
virtualinherited

Evaluate the function described by coefs at points u, i.e., evaluates a linear combination of coefs x BasisFunctions, into result.

This function has a default implementation that may be overridden in derived classes for higher performance.

Parameters
uevaluation points as N column vectors
coefscoefficient matrix describing the geometry in this basis, n columns
[out]resulta matrix of size n x N with one function value as a column vector per evaluation point

Reimplemented in gsRationalBasis< SrcT >, gsTensorBSplineBasis< 1, T >, and gsMonomialBasis< T >.

void flatTensorIndexesToHierachicalIndexes ( gsSortedVector< int > &  indexes,
const int  level 
) const
inherited

transformes a sortedVector indexes of flat tensor index of the bspline basis of level to hierachical indexes in place. If a flat tensor index is not found, it will transform to -1.

Parameters
[in]indexesflat tensor indexes of the function in level
levelLevel of the basis.
index_t flatTensorIndexOf ( const index_t  i) const
inlineinherited

Returns the tensor index of the function indexed i (in continued indices).

Parameters
[in]iGlobal (continued) index of a basis function of the hierarchical basis.
Returns
The tensor index of this basis function with respect to the tensor-product basis of the corresponding level.
index_t flatTensorIndexOf ( const index_t  i,
const index_t  level 
) const
inlineinherited

Returns the tensor index of the function indexed i (in continued indices).

Parameters
[in]iGlobal (continued) index of a basis function of the hierarchical basis.
levelLevel of the i-th basis function.
Returns
The tensor index of this basis function with respect to the tensor-product basis of level.
int flatTensorIndexToHierachicalIndex ( index_t  index,
const int  level 
) const
inherited

takes a flat tensor index of the bspline basis of level and gives back the hierachical index. If a flat tensor index is not found, it will return -1.

Parameters
[in]indexflat tensor index of the function in level
levelLevel of the basis.
Returns
hierachical index, or -1 if it was not found
gsBasisFun< T > function ( index_t  i) const
inherited

Returns the i-th basis function as a gsFunction.

Note that the gsBasisFun object only holds a reference to the current basis, so it is invalidated when the basis is destroyed.

const std::vector<tensorBasis*>& getBases ( ) const
inlineinherited

Returns the tensor B-spline space of all levels.

Returns
void getBoxesAlongSlice ( int  dir,
par,
std::vector< index_t > &  boxes 
) const
protectedinherited

gets all the boxes along a slice in direction dir at parameter par. the boxes are given back in a std::vector<index_t> and are in the right format to be given to refineElements().

gsTensorBSpline< d, T > getBSplinePatch ( const std::vector< index_t > &  boundingBox,
const unsigned  level,
const gsMatrix< T > &  geomCoefs 
) const

Returns a tensor B-Spline patch defined by boundingBox.

The B-Spline patch knots are the same as the THB-Spline-Basis knots from the input level. Geometry of the patch is defined via input coefficients.

void getBsplinePatches ( const gsMatrix< T > &  geom_coef,
gsMatrix< T > &  cp,
gsMatrix< index_t > &  b1,
gsMatrix< index_t > &  b2,
gsVector< index_t > &  level,
gsMatrix< index_t > &  nvertices 
) const

Return the list of B-spline patches to represent a THB-spline geometry.

Parameters
geom_coefcontrol points of the THB-spline geometry
[out]cpcontrol points of all B-spline patches stacked on top of each other
[out]b1bottom left corners of the box (vector of indices with respect to the gsKnotVector of the highest possible level)
[out]b2top right corners of the box (vector of indices with respect to the gsKnotVector of the highest possible level)
[out]levellevels of the boxes (level[i]: level of the i-th box,)
[out]nverticesnumber of control points (nvertices[i,j]: number of control points in j-direction for the i-th box)
void getBsplinePatches_trimming ( const gsMatrix< T > &  geom_coef,
gsMatrix< T > &  cp,
gsMatrix< index_t > &  b1,
gsMatrix< index_t > &  b2,
gsVector< index_t > &  level,
gsMatrix< index_t > &  nvertices,
std::vector< std::vector< std::vector< std::vector< T > > > > &  trim_curves 
) const

Return the list of B-spline patches to represent a THB-spline geometry.

Parameters
geom_coefcontrol points of the THB-spline geometry
[out]cpcontrol points of all B-spline patches stacked on top of each other
[out]b1bottom left corners of the box (vector of indices with respect to the gsKnotVector of the highest possible level)
[out]b2top right corners of the box (vector of indices with respect to the gsKnotVector of the highest possible level)
[out]levellevels of the boxes (level[i]: level of the i-th box,)
[out]nverticesnumber of control points (nvertices[i,j]: number of control points in j-direction for the i-th box)
[out]trim_curvesthe trimming curves for parasolid vector<connected_component<polylines<segments<T> > > > where the first polyline is the outer curve and the rest are holes
gsMultiPatch< T > getBsplinePatchesToMultiPatch ( const gsMatrix< T > &  geom_coef) const

Return a multipatch structure of B-splines.

Parameters
geom_coefcontrol points of the THB-spline geometry
gsMultiPatch< T > getBsplinePatchesToMultiPatch_trimming ( const gsMatrix< T > &  geom_coef,
std::vector< std::vector< std::vector< std::vector< T > > > > &  trim_curves 
) const

Return a multipatch structure of B-splines.

Parameters
geom_coefcontrol points of the THB-spline geometry
[out]trim_curvesthe trimming curves for parasolid vector<connected_component<polylines<segments<T> > > > where the first polyline is the outer curve and the rest are holes
void getBsplinePatchGlobal ( gsVector< index_t b1,
gsVector< index_t b2,
unsigned  level,
const gsMatrix< T > &  geom_coef,
gsMatrix< T > &  cp,
gsKnotVector< T > &  k1,
gsKnotVector< T > &  k2 
) const

Returns the B-spline representation of a THB-spline subpatch.

Parameters
b1bottom left corner of the box (vector of indices with respect to the gsCompactKnotVector of the highest possible level)
b2top right corner of the box (vector of indices with respect to the gsCompactKnotVector of the highest possible level)
levellevel of the box
geom_coefcontrol points of the THB-spline geometry
[out]cpcontrol points of the B-spline patch
[out]k1knot vector of the B-spline patch (first dimension)
[out]k2knot vector of the B-spline patch (second dimension)
index_t getLevelAtIndex ( const point Pt) const
inlineinherited

Returns the level(s) at indexes in the parameter domain.

Parameters
[in]PtgsMatrix of size d x n, where
d is the dimension of the parameter domain and
n is the number of evaluation points.
Each column of Pts represents one evaluation point.
Returns
levels gsMatrix of size 1 x n.
levels(0,i) is the level of the point defined by the i-th column in Pts.
index_t getLevelAtPoint ( const gsMatrix< T > &  Pt) const
inlineinherited

Returns the level(s) at point(s) in the parameter domain.

Parameters
[in]PtgsMatrix of size d x n, where
d is the dimension of the parameter domain and
n is the number of evaluation points.
Each column of Pts represents one evaluation point.
Returns
levels gsMatrix of size 1 x n.
levels(0,i) is the level of the point defined by the i-th column in Pts.
void getLevelUniqueSpanAtPoints ( const gsMatrix< T > &  Pt,
gsVector< index_t > &  lvl,
gsMatrix< index_t > &  loIdx 
) const
inlineinherited

Returns the level(s) and knot span(s) at point(s) in the parameter domain.

Parameters
[in]PtgsMatrix of size d x n, where
d is the dimension of the parameter domain and
n is the number of evaluation points.
Each column of Pts represents one evaluation point.
[out]lvlgsVector of length n with the levels of the respective points.
[out]loIdxgsMatrix of size d x n.
Each column contains the lower corner of the knot span containing i-th point. The corner is given in unique knot span indices of level lvl[i].
void globalRefinement ( const gsMatrix< T > &  thbCoefs,
int  level,
gsMatrix< T > &  lvlCoefs 
) const
private

Returns a representation of thbCoefs as tensor-product B-spline coefficientes lvlCoefs at level level.

The representation is valid only at areas of the parameter domain with level less or equal to level

Parameters
[in]thbCoefsThe input coefficients corresponding to basis function in this THB
[in]levelthe level of tensor-product basis to be computed
[out]lvlCoefscoefficients in tensor-product basis of level level
index_t identifyCycle ( const std::vector< std::vector< T > > &  polyline,
std::pair< T, T > &  pt 
) const
private

Identify if the polyline can be split into two cycles.

Parameters
[in]polylinedescription of polyline
[out]ptthe point where two cycles meet (if there are two cycles)
Returns
the index of the segment with the point
void increaseMultiplicity ( index_t  lvl,
int  dir,
knotValue,
int  mult = 1 
)
virtualinherited

Increases the multiplicity of a knot with the value knotValue in level lvl in direction dir by mult. If knotValue is not currently in the given knot vector its not added.

Parameters
[in]lvl: level
[in]dir: direction
[in]knotValue: value of the knot
[in]mult: multiplicity
void increaseMultiplicity ( index_t  lvl,
int  dir,
const std::vector< T > &  knotValue,
int  mult = 1 
)
virtualinherited

Increases the multiplicity of several knots with the value knotValue in level lvl in direction dir by mult. If knotValue is not currently in the given knot vector its not added.

Parameters
[in]lvl: level
[in]dir: direction
[in]knotValue: value of the knot
[in]mult: multiplicity
bool isFirstBoxCompletelyInsideSecond ( const std::vector< index_t > &  firstBox,
const std::vector< index_t > &  secondBox 
) const
inlineprivate

Checks if the first box is completely inside second box.

Utility function for the decomposeDomain member function.

void linearCombination_into ( const gsMatrix< T > &  coefs,
const gsMatrix< index_t > &  actives,
const gsMatrix< T > &  values,
gsMatrix< T > &  result,
bool  sameElement = false 
)
staticinherited

Computes the linear combination coefs * values( actives )

Todo:
documentation
Parameters
[in]coefsgsMatrix of size K x m, where K should equal size() of the basis (i.e., the number of basis functions).
[in]activesgsMatrix of size numAct x numPts
[in]valuesgsMatrix of size stride*numAct x numPts
[out]resultgsMatrix of size stride x numPts
virtual memory::unique_ptr<gsBasis<T> > makeNonRational ( ) const
inlinevirtualinherited

Clone the source of this basis in case of rational basis, same as clone() otherwise

Reimplemented in gsRationalBasis< SrcT >, gsRationalBasis< gsBSplineTraits< d, T >::Basis >, and gsRationalBasis< gsBSplineBasis< T > >.

void matchWith ( const boundaryInterface bi,
const gsBasis< T > &  other,
gsMatrix< index_t > &  bndThis,
gsMatrix< index_t > &  bndOther,
index_t  offset 
) const
virtualinherited

Computes the indices of DoFs that match on the interface bi. The interface is assumed to be a common face between this patch and other, with an offset offset. The output is two lists of indices bndThis and bndOther, with indices that match one-to-one on the boundary bi.

NOTE: bndThis will have offset but bndOther will NOT have an offset (hence offset 0)

Reimplemented from gsBasis< T >.

gsVector<index_t> numActive ( const gsMatrix< T > &  u) const
inlineinherited

Number of active basis functions at an arbitrary parameter value.

Usually, this is used for getting the active functions on one element, assuming that this number doesn't change for different parameters inside the element.

int numBreaks ( int  lvl,
int  k 
) const
inlineinherited

Returns the number of breaks (distinct knot values) in direction k of level lvl

void refine ( gsMatrix< T > const &  boxes,
int  refExt 
)
virtualinherited

Refine the basis to levels and in the areas defined by boxes with an extension.

Parameters
[in]boxesgsMatrix of size d x n, where
n is the number of refinement boxes.
Every two consecutive columns specify the lower and upper corner of one refinement box (See also documentation of refine() for the format of box)
[in]refExtis an integer specifying how many cells should also be refined around the respective boxes.

Reimplemented from gsBasis< T >.

void refine ( gsMatrix< T > const &  boxes)
virtualinherited

Refine the basis to levels and in the areas defined by boxes.

Parameters
[in]boxesgsMatrix of size d x n, where
n is the number of refinement boxes.
Every two consecutive columns specify the lower and upper corner of one refinement box (See also documentation of refine() for the format of box)
void refineElements ( std::vector< index_t > const &  boxes)
virtualinherited

Insert the given boxes into the quadtree.

Each box is defined by 2d+1 indices, where d is the dimension of the parameter domain. The first index defines the level in which the box should be inserted, the next d indices the "coordinates" of the lower corner in the index space, and the last d indices the "coordinates" of the upper corner.

Example: Let d=3 and

\[ \mathsf{boxes} = [ L^1, \ell_x^1, \ell_y^1, \ell_z^1, u_x^1, u_y^1, u_z^1, L^2, \ell_x^2, \ell_y^2, \ell_z^2, u_x^2, u_y^2, u_z^2, L^3, \ell_x^3, \ell_y^3, \ldots ], \]

then, the first box will be inserted in level \(L^1\) and its lower and upper corner will have the indices \( (\ell_x^1, \ell_y^1, \ell_z^1)\) and \( (u_x^1, u_y^1, u_z^1) \) in the index space of level \(L^1\), respectively.

Parameters
boxesvector of size N (2d+1), where
N is the number of boxes,
d is the dimension of the parameter domain.
See description above for details on the format.

Reimplemented from gsBasis< T >.

void refineElements_withCoefs ( gsMatrix< T > &  coefs,
std::vector< index_t > const &  boxes 
)
virtualinherited

Refine the basis and adjust the given matrix of coefficients accordingly.

Parameters
coefsis a matrix of coefficients as given, e.g., by gsTHBSpline<>::coefs();
boxesspecify where to refine; each 5-tuple gives the level of the box, then two indices (in the current level indexing) of the lower left corner and finally two indices of the upper right corner, see gsHTensorBasis::refineElements() for details.

Reimplemented from gsBasis< T >.

virtual const gsBasis& source ( ) const
inlinevirtualinherited

Applicable for rational bases: returns the underlying "source" (non-rational) basis

Reimplemented in gsRationalBasis< SrcT >, gsRationalBasis< gsBSplineTraits< d, T >::Basis >, and gsRationalBasis< gsBSplineBasis< T > >.

virtual gsBasis& source ( )
inlinevirtualinherited

Applicable for rational bases: returns the underlying "source" (non-rational) basis

Reimplemented in gsRationalBasis< SrcT >, gsRationalBasis< gsBSplineTraits< d, T >::Basis >, and gsRationalBasis< gsBSplineBasis< T > >.

gsMatrix< T > support ( ) const
virtualinherited

Returns the boundary basis for side s.

Returns a bounding box for the basis' domain

Reimplemented from gsBasis< T >.

gsMatrix< T > support ( const index_t i) const
virtualinherited

Returns (a bounding box for) the support of the i-th basis function.

Returns a dx2 matrix, containing the two diagonally extreme corners of a hypercube.

Reimplemented from gsBasis< T >.

gsMatrix< T > supportInterval ( index_t  dir) const
inherited

Returns an interval that contains the parameter values in direction dir.

Returns a 1x2 matrix, containing the two endpoints of the interval.

bool testPartitionOfUnity ( const index_t  npts = 100,
const T  tol = 1e-12 
) const
inherited

Test the partition of unity.

Parameters
[in]nptsThe number of points in each direction
Returns
True if the basis has the parition of unity property.
void uniformCoarsen ( int  numKnots = 1)
virtualinherited

Coarsen the basis uniformly by removing groups of numKnots consecutive knots, each knot removed mul times.

This function is the oposite of gsBasis::uniformRefine

The execution of

basis->uniformRefine (nKnots, mul)
basis->uniformCoarsen(nKnots);

results in no overall change in "basis". However,

basis->uniformCoarsen(nKnots);
basis->uniformRefine (nKnots, mul)

is not guaranteed to keep "basis" unchanged.

See Also
gsBasis::uniformRefine

Reimplemented from gsBasis< T >.

void uniformCoarsen_withCoefs ( gsMatrix< T > &  coefs,
int  numKnots = 1 
)
virtualinherited

Coarsen the basis uniformly.

The function simultainously updates the vector coefs, representing a function in the bases, such that its new version represents the same function.

This function is equivalent to

gsSparseMatrix<T,RowMajor> transfer;
basis->uniformCoarsen_withTransfer(transfer, numKnots);
coefs = transfer * coefs;
See Also
gsBasis::uniformRefine

Reimplemented from gsBasis< T >.

void uniformCoarsen_withTransfer ( gsSparseMatrix< T, RowMajor > &  transfer,
int  numKnots = 1 
)
virtualinherited

Coarsen the basis uniformly and produce a sparse matrix which maps coarse coefficient vectors to refined ones.

The function writes a sparse matrix into the variable transfer that indicates how the functions on the coarse grid are represented as linear combinations as fine grid functions

See Also
gsBasis::uniformCoarsen

Reimplemented in gsTensorBSplineBasis< 1, T >, gsTensorBasis< d, T >, and gsTensorBasis< 1, T >.

void uniformRefine_withCoefs ( gsMatrix< T > &  coefs,
int  numKnots = 1,
int  mul = 1,
int  dir = -1 
)
virtualinherited

Refine the basis uniformly.

The function simultainously updates the vector coefs, representing a function in the bases, such that its new version represents the same function.

This function is equivalent to

gsSparseMatrix<T,RowMajor> transfer;
basis->uniformRefine_withTransfer(transfer, numKnots, mul);
coefs = transfer * coefs;
See Also
gsBasis::uniformRefine

Reimplemented from gsBasis< T >.

void uniformRefine_withTransfer ( gsSparseMatrix< T, RowMajor > &  transfer,
int  numKnots = 1,
int  mul = 1 
)
virtualinherited

Refine the basis uniformly.

The function writes a sparse matrix into the variable transfer that indicates how the functions on the coarse grid are represented as linear combinations as fine grid functions

See Also
gsBasis::uniformRefine

Reimplemented in gsTensorBSplineBasis< 1, T >, gsTensorBasis< d, T >, gsTensorBasis< 1, T >, and gsRationalBasis< SrcT >.

void unrefineElements ( std::vector< index_t > const &  boxes)
virtualinherited

Clear the given boxes into the quadtree.

Parameters
boxesSee refineElements
[in]refExtSee refineElements

Reimplemented from gsBasis< T >.

Member Data Documentation

std::vector<tensorBasis*> m_bases
mutableprotectedinherited

The list of nested spaces.

See documentation for the class for details on the underlying structure.

Recall that the hierarchical basis is built from a sequence of underlying bases \( B^0, B^1,\ldots, B^L\). These underlying bases are stored in gsHTensorBasis.m_bases, which is of type std::vector.
m_bases[k] stores the pointer to the (global) tensor-product basis \( B^k\).

std::vector< CMatrix > m_xmatrix
protectedinherited

The characteristic matrices for each level.

See documentation for the class for details on the underlying structure.

Characteristic matrices provide information on the relation between
the basis functions of this gsHTensorBasis \( H \) and
the tensor-product basis functions of the underlying tensor-product bases \( B^\ell \).

Let vk = m_xmatrix[k]. vk is a gsSortedVector. It contains a list of indices of the basis function of level k, i.e., of the basis functions which "are taken" from \(B^k\). These indices are stored as the global indices in \(B^k\).

std::vector<index_t> m_xmatrix_offset
protectedinherited

Stores the offsets of active functions for all levels.

See documentation for the class for details on the underlying structure. As mentioned there, the basis functions of the hierarchical basis \( H\) have a global numbering, where the functions from \(B^0\) come first, then those from \(B^1\), then \(B^2\), and so forth.

The entry m_xmatrix_offset[k] indicates the index from which the basis functions from level k (i.e., those taken from \( B^k \)) start.