25 gsBasis<T>::~gsBasis()
47 this->active_into(u,actives);
51 linearCombination_into( coefs, actives, B, result );
61 const index_t numPts = u.cols();
62 const index_t pardim = this->dim();
64 result.setZero( n, pardim * numPts );
68 this->deriv_into(u,B);
69 this->active_into(u,ind);
70 const index_t numAct=ind.rows();
72 for (
index_t p = 0; p < numPts; ++p)
74 for (
index_t a=0; a< numAct ; ++a )
76 result.block(c,p*pardim, 1, pardim).noalias() +=
77 coefs(ind(a,p), c) * B.block(a*pardim, p, pardim, 1).transpose();
90 this->deriv_into(u,B);
92 this->active_into(u,actives);
96 linearCombination_into( coefs, actives, B, result );
109 this->deriv2_into(u,B);
111 this->active_into(u,actives);
115 linearCombination_into( coefs, actives, B, result );
123 bool sameElement)
const
128 if ( 0 == u.cols() )
return;
131 std::vector< gsMatrix<T> >B;
136 this->evalAllDers_into(u,n,B,sameElement);
138 this->active_into(u.col(0), actives);
140 this->active_into(u, actives);
144 for(
unsigned i = 0; i <= n; i++)
145 linearCombination_into( coefs, actives, B[i], result[i], sameElement);
155 const index_t numPts = values.cols() ;
156 const index_t tarDim = coefs.cols() ;
157 const index_t stride = values.rows() / actives.rows();
160 "Number of values "<<values.rows()<<
" and actives "<<actives.rows()<<
" does not fit together");
162 result.resize( tarDim * stride, numPts );
167 for (
index_t i = 0; i < actives.rows(); ++i )
168 for (
index_t c = 0; c < tarDim; ++c )
169 result.middleRows( stride * c, stride).noalias() +=
170 coefs( actives.
at(i), c) * values.middleRows(stride * i, stride);
174 for (
index_t pt = 0; pt < numPts; ++pt )
175 for (
index_t i = 0; i < actives.rows(); ++i )
176 for (
index_t c = 0; c < tarDim; ++c )
177 result.block( stride * c, pt, stride, 1).noalias() +=
178 coefs( actives(i,pt), c) * values.block( stride * i, pt, stride, 1);
187 this->deriv2_into(u,tmp);
188 return tmp.colwise().sum();
191 template<
class T>
inline
198 eval_into (u.col(0), ev);
199 active_into(u.col(0), act);
200 result.reservePerColumn( act.rows() );
201 for (
index_t i=0; i!=act.rows(); ++i)
202 result.insert(0, act.
at(i) ) = ev.at(i);
204 for (
index_t k=1; k!=u.cols(); ++k)
206 eval_into (u.col(k), ev );
207 active_into(u.col(k), act);
208 for (
index_t i=0; i!=act.rows(); ++i)
209 result.insert(k, act.
at(i) ) = ev.at(i);
212 result.makeCompressed();
216 template<
class T>
inline
220 GISMO_ASSERT (dim() == pts.rows() ,
"Wrong dimension of the points("<<
221 pts.rows()<<
", expected "<<dim() <<
").");
222 GISMO_ASSERT (this->size() == pts.cols() ,
"Expecting as many points as the basis functions." );
223 GISMO_ASSERT (this->size() == vals.cols(),
"Expecting as many values as the number of points." );
231 typename gsSparseSolver<T>::BiCGSTABILUT solver( Cmat );
234 x = solver.solve( vals.transpose() );
240 return makeGeometry(
give(x) );
243 template<
class T>
inline
247 "Expecting as many values as the number of basis functions." );
250 return interpolateData(vals, pts);
271 template<
class T>
inline
275 template<
class T>
inline
280 template<
class T>
inline
284 nodes.transposeInPlace();
285 connectivity(nodes, mesh);
326 gsBasis<T>* gsBasis<T>::boundaryBasis_impl(boxSide
const &)
const
335 const short_t dim = this->dim();
345 result = result->boundaryBasis(
boxSide(loc+2*d) );
347 result = this->boundaryBasis(
boxSide(loc+2*d) );
363 const short_t dim = this->dim();
375 for (
index_t j=0; j<tmp.size(); ++j)
376 tmp(j,0) = indices(tmp(j,0),0);
378 result = result->boundaryBasis(
boxSide(loc+2*d) );
383 result = this->boundaryBasis(
boxSide(loc+2*d) );
393 const index_t sz = this->size();
394 indices.resize(sz,1);
399 if (noBoundary && d > 0)
404 const index_t indices_sz = indices.rows();
405 const index_t bdy_indices_sz = bdy_indices.rows();
412 for (
index_t i = 0; i < indices_sz; ++i)
414 if (
util::greater(i, bdy_indices(j, 0)) && j < bdy_indices_sz)
416 if (
util::less(i, bdy_indices(j, 0)) || j == bdy_indices_sz)
418 indices_cleaned(t, 0) = indices(i, 0);
422 GISMO_ASSERT(t == indices_cleaned.rows(),
"Internal error.");
423 indices.swap(indices_cleaned);
440 {
return support().row(dir); }
492 typename gsBasis<T>::domainIter
497 typename gsBasis<T>::domainIter
526 std::vector<index_t> gsBasis<T>::asElementsUnrefine(gsMatrix<T>
const &,
int)
const
598 const short_t dm = this->dim();
599 for (
short_t k = 0; k!=dm; ++k)
601 const short_t p = this->degree(k);
604 this->degreeElevate(i-p, k);
608 this->degreeReduce(p-i, k);
616 for (
short_t d = 0; d < dim(); ++ d )
619 degreeIncrease(i-degree(d),d);
620 else if ( i < degree(d) )
621 degreeDecrease(-i+degree(d),d);
665 const domainIter it = this->makeDomainIterator();
667 for (; it->good(); it->next() )
669 const T sz = it->getMinCellLength();
670 if ( sz < h || h == 0 ) h = sz;
678 const domainIter it = this->makeDomainIterator();
680 for (; it->good(); it->next() )
682 const T sz = it->getMaxCellLength();
683 if ( sz > h ) h = sz;
689 template<
class T>
inline
690 std::vector<gsSparseMatrix<T> >
695 std::vector<gsMatrix<T>> ev;
700 result[0].reservePerColumn( act.rows() );
701 result[1].reservePerColumn( act.rows() );
703 result[2].reservePerColumn( act.rows() );
704 for (
index_t i=0; i!=act.rows(); ++i)
706 result[0].insert(0, act.
at(i) ) = ev[0].at(i);
707 result[1].insert(0, act.
at(i) ) = ev[1].at(dim*i);
709 result[2].insert(0, act.
at(i) ) = ev[1].at(dim*i+1);
711 for (
index_t k=1; k!=u.cols(); ++k)
715 for (
index_t i=0; i!=act.rows(); ++i)
717 result[0].insert(k, act.
at(i) ) = ev[0].at(i);
718 result[1].insert(k, act.
at(i) ) = ev[1].at(dim*i);
720 result[2].insert(k, act.
at(i) ) = ev[1].at(dim*i +1);
724 result[0].makeCompressed();
725 result[1].makeCompressed();
727 result[2].makeCompressed();
Class representing a domain. i.e. a collection of elements (triangles, rectangles, cubes, simplices.
Definition: gsDomain.h:31
short_t totalDim() const
Dimension of the computational domain (the box itself)
Definition: gsBoundary.h:506
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...
Definition: gsBasis.hpp:119
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.
Definition: gsBasis.hpp:471
virtual T getMaxCellLength() const
Get the maximum mesh size, as expected for approximation error estimates.
Definition: gsBasis.hpp:676
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
virtual gsBasis::uPtr create() const
Create an empty basis of the derived type and return a pointer to it.
Definition: gsBasis.hpp:483
bool less(T1 t1, T2 t2)
Definition: gsTemplateTools.h:247
virtual 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.
Definition: gsBasis.hpp:455
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. ...
Definition: gsBasis.hpp:588
gsMatrix< T > supportInterval(index_t dir) const
Returns an interval that contains the parameter values in direction dir.
Definition: gsBasis.hpp:439
#define short_t
Definition: gsConfig.h:35
virtual void refineElements(std::vector< index_t > const &boxes)
Refinement function, with different sytax for different basis.
Definition: gsBasis.hpp:538
Provides structs and classes related to interfaces and boundaries.
virtual 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...
Definition: gsFunctionSet.hpp:81
virtual void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition: gsBasis.hpp:289
virtual short_t degree(short_t i) const
Degree with respect to the i-th variable. If the basis is a tensor product of (piecewise) polynomial ...
Definition: gsBasis.hpp:650
virtual short_t minDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the minimum po...
Definition: gsBasis.hpp:642
Struct that defines the boundary sides and corners and types of a geometric object.
Definition: gsBoundary.h:55
virtual gsMatrix< T > elementInSupportOf(index_t j) const
Returns (the coordinates of) an element in the support of basis function j.
Definition: gsBasis.hpp:510
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...
Definition: gsBasis.hpp:476
Provides definition of the BasisFun class.
bool greater(T1 t1, T2 t2)
Definition: gsTemplateTools.h:313
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.
Definition: gsBasis.hpp:84
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 i...
Definition: gsBasis.hpp:58
virtual index_t size() const
size
Definition: gsFunctionSet.h:578
S give(S &x)
Definition: gsMemory.h:266
Provides declaration of Geometry abstract interface.
virtual size_t elementIndex(const gsVector< T > &u) const
Returns an index for the element which contains point u.
Definition: gsBasis.hpp:506
#define index_t
Definition: gsConfig.h:32
virtual size_t numElements(boxSide const &s=0) const
The number of elements on side s.
Definition: gsBasis.hpp:502
virtual uPtr componentBasis_withIndices(boxComponent b, gsMatrix< index_t > &indices, bool noBoundary=true) const
Returns the basis that corresponds to the component.
Definition: gsBasis.hpp:360
virtual const gsBasis< T > & component(short_t i) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsBasis.hpp:514
virtual gsDomain< T > * domain() const
Definition: gsBasis.hpp:634
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the second derivatives of all active basis function at points u.
Definition: gsBasis.hpp:461
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...
Definition: gsBasis.hpp:554
virtual T getMinCellLength() const
Get the minimum mesh size, as expected for inverse inequalities.
Definition: gsBasis.hpp:663
location locationForDirection(index_t direction) const
Definition: gsBoundary.cpp:154
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
virtual void uniformCoarsen_withCoefs(gsMatrix< T > &coefs, int numKnots=1)
Coarsen the basis uniformly.
Definition: gsBasis.hpp:571
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.
Definition: gsBasis.hpp:217
T at(index_t i) const
Returns the i-th element of the vectorization of the matrix.
Definition: gsMatrix.h:211
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. ...
Definition: gsBasis.hpp:592
virtual void uniformCoarsen(int numKnots=1)
Coarsen the basis uniformly by removing groups of numKnots consecutive knots, each knot removed mul t...
Definition: gsBasis.hpp:567
virtual uPtr componentBasis(boxComponent b) const
Returns the basis that corresponds to the component.
Definition: gsBasis.hpp:331
virtual void anchors_into(gsMatrix< T > &result) const
Returns the anchor points that represent the members of the basis in result. There is exactly one anc...
Definition: gsBasis.hpp:272
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.
Definition: gsBasis.hpp:305
virtual short_t totalDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the total poly...
Definition: gsBasis.hpp:646
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 refi...
Definition: gsBasis.hpp:575
virtual void uniformRefine_withCoefs(gsMatrix< T > &coefs, int numKnots=1, int mul=1, int dir=-1)
Refine the basis uniformly.
Definition: gsBasis.hpp:558
virtual void refineElements_withCoefs(gsMatrix< T > &coefs, std::vector< index_t > const &boxes)
Refine basis and geometry coefficients to levels.
Definition: gsBasis.hpp:546
void setDegreePreservingMultiplicity(short_t const &i)
Set the degree of the basis (either increase or decrecee) in order to have degree equal to i...
Definition: gsBasis.hpp:614
Provides declaration of DomainIterator abstract interface.
virtual void connectivityAtAnchors(gsMesh< T > &mesh) const
Definition: gsBasis.hpp:281
virtual void refine(gsMatrix< T > const &boxes, int refExt=0)
Refine the basis on the area defined by the matrix boxes.
Definition: gsBasis.hpp:530
gsBasisFun< T > function(index_t i) const
Returns the i-th basis function as a gsFunction.
Definition: gsBasis.hpp:29
virtual short_t domainDim() const =0
Dimension of the (source) domain.
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 )
Definition: gsBasis.hpp:150
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
virtual 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.
Definition: gsBasis.hpp:447
Represents an individual function in a function set, or a certain component of a vector-valued functi...
Definition: gsBasisFun.h:36
virtual void numActive_into(const gsMatrix< T > &u, gsVector< index_t > &result) const
Returns the number of active (nonzero) basis functions at points u in result.
Definition: gsBasis.hpp:301
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition: gsBasis.hpp:443
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 de...
Definition: gsBasis.hpp:244
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition: gsBasis.h:89
virtual gsBasis::uPtr tensorize(const gsBasis &other) const
Return a tensor basis of this and other.
Definition: gsBasis.hpp:488
location
Represents a location.
Definition: gsBoundary.h:530
virtual gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition: gsBasis.hpp:316
virtual void reduceContinuity(int const &i=1)
Reduces the continuity of the basis along element boundaries.
Definition: gsBasis.hpp:630
virtual gsMatrix< index_t > allBoundary() const
Returns the indices of the basis functions that are nonzero at the domain boundary.
Definition: gsBasis.hpp:311
virtual void matchWith(const boundaryInterface &bi, const gsBasis< T > &other, gsMatrix< index_t > &bndThis, gsMatrix< index_t > &bndOther, index_t offset=0) const
Computes the indices of DoFs that match on the interface bi. The interface is assumed to be a common ...
Definition: gsBasis.hpp:658
virtual void reverse()
Reverse the basis.
Definition: gsBasis.hpp:654
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.
Definition: gsBasis.hpp:580
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 func...
Definition: gsBasis.hpp:297
virtual short_t maxDegree() const
If the basis is of polynomial or piecewise polynomial type, then this function returns the maximum po...
Definition: gsBasis.hpp:638
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
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...
Definition: gsBasis.hpp:37
virtual domainIter makeDomainIterator() const
Create a domain iterator for the computational mesh of this basis, that points to the first element o...
Definition: gsBasis.hpp:493
virtual void uniformRefine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, int numKnots=1, int mul=1)
Refine the basis uniformly.
Definition: gsBasis.hpp:562
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the first partial derivatives of the nonzero basis function.
Definition: gsBasis.hpp:451
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
gsSparseMatrix< T > collocationMatrix(gsMatrix< T > const &u) const
Computes the collocation matrix w.r.t. points u.
Definition: gsBasis.hpp:192
virtual void anchor_into(index_t i, gsMatrix< T > &result) const
Returns the anchor point for member i of the basis.
Definition: gsBasis.hpp:276
virtual gsMatrix< T > support() const
Returns (a bounding box for) the domain of the whole basis.
Definition: gsBasis.hpp:431
virtual gsMatrix< T > laplacian(const gsMatrix< T > &u) const
Compute the Laplacian of all nonzero basis functions at points u.
Definition: gsBasis.hpp:184
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
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...
Definition: gsBasis.hpp:596
virtual 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.
Definition: gsBasis.hpp:465
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.
Definition: gsBasis.hpp:101
virtual void elevateContinuity(int const &i=1)
Elevates the continuity of the basis along element boundaries.
Definition: gsBasis.hpp:626
virtual 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: gsBasis.hpp:293
Struct which represents a certain component (interior, face, egde, corner).
Definition: gsBoundary.h:445
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.
Definition: gsBasis.hpp:584