23template<
short_t d,
class T>
class gsMappedBasis;
33template<
short_t d,
class T>
37 typedef memory::unique_ptr< gsDomainIterator<T> > domainIter;
42 typedef memory::shared_ptr< gsMappedSingleBasis >
Ptr;
45 typedef memory::unique_ptr< gsMappedSingleBasis >
uPtr;
54 static const int Dim = d;
58 : m_basis(
basis),m_index(i)
60 GISMO_ASSERT( i<
unsigned(m_basis->nPatches()),
"Invalid basis function index" );
65 m_basis = other.m_basis;
66 m_index = other.m_index;
72 ~gsMappedSingleBasis() { }
90 size_t numElements(
boxSide const & s = 0)
const {
return m_basis->getBase(m_index).numElements(s); }
103 m_basis->active_into(m_index,u,result);
110 m_basis->numActive_into(m_index,u,result);
116 return m_basis->getBase(m_index).support();
122 typename gsMappedBasis<d,T>::IndexContainer sourceIndices;
123 m_basis->getMapper().targetToSource(kk,sourceIndices);
127 for (
typename gsMappedBasis<d,T>::IndexContainer::iterator i = sourceIndices.begin(); i!=sourceIndices.end(); i++)
130 if (m_basis->getPatch(*i)!=m_index)
continue;
132 localSupp = m_basis->getBase(m_index).support(m_basis->getPatchIndex(*i));
134 if (supp.rows()==0 && supp.cols()==0)
140 for (
index_t dim=0; dim!=d; dim++)
142 if (localSupp(dim,0) < supp(dim,0))
143 supp(dim,0) = localSupp(dim,0);
144 if (localSupp(dim,1) > supp(dim,1))
145 supp(dim,1) = localSupp(dim,1);
154 return m_basis->getBase(m_index).boundaryBasis(s).release();
161 m_basis->eval_into(m_index,u,result);
167 m_basis->evalSingle_into(m_index,i,u,result);
173 m_basis->deriv_into(m_index,u,result);
181 m_basis->derivSingle_into(m_index,i,u,result);
187 m_basis->deriv2_into(m_index,u,result);
201 bool sameElement =
false)
const
203 m_basis->evalAllDers_into(m_index,u,n,result,sameElement);
231 std::ostream &
print(std::ostream &os)
const
234 os <<
"Mapped basis function "<< m_index <<
" / "<< m_basis->size()-1 <<
"\n";
242 std::ostringstream os;
253 return m_basis->size(m_index);
274 return m_basis->maxDegree();
280 return m_basis->degree(m_index,i);
293 GISMO_ASSERT( i<
unsigned(m_basis->nPatches()),
"Invalid basis index" );
308 return ( ++m_index < (
index_t)m_basis->nPatches() );
315 return m_basis->getBase(m_index).component(i);
322 return m_basis->getBase(m_index).component(i);
328 return m_basis->getBase(m_index).makeDomainIterator();
334 return m_basis->getBase(m_index).makeDomainIterator(s);
340 std::vector<index_t> temp, rtemp;
341 m_basis->addLocalIndicesOfPatchSide(
patchSide(m_index,s),offset,temp);
342 m_basis->getMapper().sourceToTarget(temp,rtemp);
347 GISMO_ASSERT(offset==1,
"The indices of boundaryOffset(s,1) "
348 "will be substract from boundaryOffset(s,0)");
350 std::vector<index_t> diff, temp2, rtemp2;
352 m_basis->addLocalIndicesOfPatchSide(
patchSide(m_index,s),0,temp2);
353 m_basis->getMapper().sourceToTarget(temp2,rtemp2);
355 std::set_difference(rtemp.begin(), rtemp.end(), rtemp2.begin(), rtemp2.end(),
356 std::inserter(diff, diff.begin()));
360 return makeMatrix<index_t>(rtemp.begin(),rtemp.size(),1 );
365 index_t cindex = m_basis->getBase(m_index).functionAtCorner(c);
366 cindex = m_basis->_getLocalIndex(m_index,cindex);
367 GISMO_ENSURE(m_basis->getMapper().sourceIsId(cindex),
"Corner function has no identity map, i.e. there are more than 1 functions associated to the corner?");
368 std::vector<index_t> indices;
369 m_basis->getMapper().sourceToTarget(cindex,indices);
370 GISMO_ASSERT(indices.size()==1,
"Size of the indices returned for the corner basis function should be 1 but is "<<indices.size()<<
". Otherwise, there are more than 1 functions associated to the corner");
371 return indices.front();
377 gsMappedBasis<d,T> * m_basis;
382#ifdef GISMO_WITH_PYBIND11
388 void pybind11_init_gsMappedSingleBasis2(pybind11::module &m);
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
virtual void evalAllDersSingle_into(index_t i, const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result) const
Evaluate the basis function i and its derivatives up to order n at points u into result.
Definition gsBasis.hpp:494
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition gsFunctionSet.hpp:33
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
Class gsMappedSingleBasis represents an indivisual .....of a.
Definition gsMappedSingleBasis.h:35
virtual void evalAllDersSingle_into(index_t i, const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result) const override
Evaluate the basis function i and its derivatives up to order n at points u into result.
Definition gsMappedSingleBasis.h:209
void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the (partial) derivatives of the nonzero basis functions at points u into result.
Definition gsMappedSingleBasis.h:185
short_t maxDegree() const
Returns the polynomial degree.
Definition gsMappedSingleBasis.h:257
void setBasis(unsigned const &i) const
Definition gsMappedSingleBasis.h:291
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 gsMappedSingleBasis.h:107
void evalSingle_into(index_t i, const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates i-th basis functions at value u.
Definition gsMappedSingleBasis.h:165
void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition gsMappedSingleBasis.h:81
memory::unique_ptr< gsGeometry< T > > makeGeometry(gsMatrix< T > coefs) const
Create a gsGeometry of proper type for this basis with the given coefficient matrix.
Definition gsMappedSingleBasis.h:225
gsBasis< T >::domainIter makeDomainIterator() const
Create a domain iterator for the computational mesh of this basis, that points to the first element o...
Definition gsMappedSingleBasis.h:325
void first() const
Point to the first basis function of the basis.
Definition gsMappedSingleBasis.h:299
gsBasis< T > & component(short_t i)
For a tensor product basis, return the 1-d basis for the i-th parameter component.
Definition gsMappedSingleBasis.h:318
short_t degree(short_t i) const
Returns the polynomial degree.
Definition gsMappedSingleBasis.h:278
void evalAllDers_into(const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const
Evaluate the nonzero basis functions and their derivatives up to order n at points u into result.
Definition gsMappedSingleBasis.h:200
bool check() const
Check the LagrangeBasis for consistency.
Definition gsMappedSingleBasis.h:284
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the non-zero basis functions at value u.
Definition gsMappedSingleBasis.h:158
index_t size() const
size
Definition gsMappedSingleBasis.h:251
void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Returns the indices of active (non zero) basis functions at points (columns of) u,...
Definition gsMappedSingleBasis.h:101
std::string detail() const
Prints the object as a string with extended details.
Definition gsMappedSingleBasis.h:239
gsMappedSingleBasis()
Default empty constructor.
Definition gsMappedSingleBasis.h:49
gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition gsMappedSingleBasis.h:338
short_t domainDim() const
Dimension of the (source) domain.
Definition gsMappedSingleBasis.h:76
gsMappedSingleBasis(gsMappedBasis< d, T > *basis, unsigned const &i=0)
Construct a basis function by a pointer to a basis and an index i.
Definition gsMappedSingleBasis.h:57
gsBasis< T > * boundaryBasis_impl(boxSide const &s) const
Returns the boundary basis on side s.
Definition gsMappedSingleBasis.h:152
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the (partial) derivatives of non-zero basis functions at (the columns of) u.
Definition gsMappedSingleBasis.h:171
memory::shared_ptr< gsMappedSingleBasis > Ptr
Shared pointer for gsMappedSingleBasis.
Definition gsMappedSingleBasis.h:42
gsMatrix< T > support() const
Returns a bounding box for the basis' domain.
Definition gsMappedSingleBasis.h:114
bool next() const
Definition gsMappedSingleBasis.h:306
memory::unique_ptr< gsMappedSingleBasis > uPtr
Unique pointer for gsMappedSingleBasis.
Definition gsMappedSingleBasis.h:45
size_t numElements(boxSide const &s=0) const
The number of elements on side s.
Definition gsMappedSingleBasis.h:90
gsMatrix< T > support(const index_t &kk) const
Returns a bounding box for basis function kk domain on the domain of *this.
Definition gsMappedSingleBasis.h:120
const gsBasis< T > & component(short_t i) const
Return the 1-d basis of the underlying tensor product basis for the i-th parameter component.
Definition gsMappedSingleBasis.h:312
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsMappedSingleBasis.h:231
short_t minDegree() const
Returns the polynomial degree.
Definition gsMappedSingleBasis.h:264
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 gsMappedSingleBasis.h:192
static const int Dim
Dimension of the parameter domain.
Definition gsMappedSingleBasis.h:54
gsBasis< T >::domainIter makeDomainIterator(const boxSide &s) const
Create a boundary domain iterator for the computational mesh this basis, that points to the first ele...
Definition gsMappedSingleBasis.h:331
short_t degree() const
Returns the polynomial degree.
Definition gsMappedSingleBasis.h:271
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 gsMappedSingleBasis.h:217
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 (the columns of) u.
Definition gsMappedSingleBasis.h:177
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Class Representing a triangle mesh with 3D vertices.
Definition gsMesh.h:32
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
Provides declaration of Basis abstract interface.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
#define GISMO_ENSURE(cond, message)
Definition gsDebug.h:102
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of Basis abstract interface.
Provides declaration of the Mesh class.
The G+Smo namespace, containing all definitions for the library.
Struct which represents a certain corner of a hyper-cube.
Definition gsBoundary.h:292
Struct which represents a certain side of a patch.
Definition gsBoundary.h:232