23 template<
short_t d,
class T>
class gsMappedBasis;
33 template<
short_t d,
class T>
34 class gsMappedSingleBasis :
public gsBasis<T>
37 typedef memory::unique_ptr< gsDomainIterator<T> > domainIter;
38 typedef gsBasis<T> Base;
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;
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);
230 std::ostream &
print(std::ostream &os)
const
233 os <<
"Mapped basis function "<< m_index <<
" / "<< m_basis->size()-1 <<
"\n";
241 std::ostringstream os;
252 return m_basis->size(m_index);
273 return m_basis->maxDegree();
279 return m_basis->degree(m_index,i);
292 GISMO_ASSERT( i<
unsigned(m_basis->nPatches()),
"Invalid basis index" );
307 return ( ++m_index < (
index_t)m_basis->nPatches() );
314 return m_basis->getBase(m_index).component(i);
321 return m_basis->getBase(m_index).component(i);
327 return m_basis->getBase(m_index).makeDomainIterator();
333 return m_basis->getBase(m_index).makeDomainIterator(s);
339 std::vector<index_t> temp, rtemp;
340 m_basis->addLocalIndicesOfPatchSide(
patchSide(m_index,s),offset,temp);
341 m_basis->getMapper().sourceToTarget(temp,rtemp);
346 GISMO_ASSERT(offset==1,
"The indices of boundaryOffset(s,1) "
347 "will be substract from boundaryOffset(s,0)");
349 std::vector<index_t> diff, temp2, rtemp2;
351 m_basis->addLocalIndicesOfPatchSide(
patchSide(m_index,s),0,temp2);
352 m_basis->getMapper().sourceToTarget(temp2,rtemp2);
354 std::set_difference(rtemp.begin(), rtemp.end(), rtemp2.begin(), rtemp2.end(),
355 std::inserter(diff, diff.begin()));
359 return makeMatrix<index_t>(rtemp.begin(),rtemp.size(),1 );
364 index_t cindex = m_basis->getBase(m_index).functionAtCorner(c);
365 cindex = m_basis->_getLocalIndex(m_index,cindex);
366 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?");
367 std::vector<index_t> indices;
368 m_basis->getMapper().sourceToTarget(cindex,indices);
369 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");
370 return indices.front();
376 gsMappedBasis<d,T> * m_basis;
381 #ifdef GISMO_WITH_PYBIND11
387 void pybind11_init_gsMappedSingleBasis2(pybind11::module &m);
390 #endif // GISMO_WITH_PYBIND11
static const int Dim
Dimension of the parameter domain.
Definition: gsMappedSingleBasis.h:54
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsMappedSingleBasis.h:76
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
void first() const
Point to the first basis function of the basis.
Definition: gsMappedSingleBasis.h:298
Struct which represents a certain side of a patch.
Definition: gsBoundary.h:231
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
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: gsMappedSingleBasis.h:208
Class gsMappedSingleBasis represents an indivisual .....of a.
Definition: gsMappedBasis.h:29
#define short_t
Definition: gsConfig.h:35
std::string detail() const
Prints the object as a string with extended details.
Definition: gsMappedSingleBasis.h:238
memory::unique_ptr< gsMappedSingleBasis > uPtr
Unique pointer for gsMappedSingleBasis.
Definition: gsMappedSingleBasis.h:45
Provides declaration of Basis abstract interface.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
void connectivity(const gsMatrix< T > &nodes, gsMesh< T > &mesh) const
Definition: gsMappedSingleBasis.h:81
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:330
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the non-zero basis functions at value u.
Definition: gsMappedSingleBasis.h:158
short_t minDegree() const
Returns the polynomial degree.
Definition: gsMappedSingleBasis.h:263
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Class Representing a triangle mesh with 3D vertices.
Definition: gsMesh.h:31
short_t degree(short_t i) const
Returns the polynomial degree.
Definition: gsMappedSingleBasis.h:277
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
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:224
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
Provides declaration of Basis abstract interface.
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
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
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:311
void setBasis(unsigned const &i) const
Definition: gsMappedSingleBasis.h:290
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
gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition: gsMappedSingleBasis.h:337
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
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
gsMappedSingleBasis()
Default empty constructor.
Definition: gsMappedSingleBasis.h:49
bool next() const
Definition: gsMappedSingleBasis.h:305
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsMappedSingleBasis.h:230
Provides declaration of the Mesh class.
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, as a list of indices, in result.
Definition: gsMappedSingleBasis.h:101
memory::shared_ptr< gsMappedSingleBasis > Ptr
Shared pointer for gsMappedSingleBasis.
Definition: gsMappedSingleBasis.h:42
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
size_t numElements(boxSide const &s=0) const
The number of elements on side s.
Definition: gsMappedSingleBasis.h:90
short_t degree() const
Returns the polynomial degree.
Definition: gsMappedSingleBasis.h:270
gsBasis< T > * boundaryBasis_impl(boxSide const &s) const
Returns the boundary basis on side s.
Definition: gsMappedSingleBasis.h:152
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:216
gsMatrix< T > support() const
Returns a bounding box for the basis' domain.
Definition: gsMappedSingleBasis.h:114
bool check() const
Check the LagrangeBasis for consistency.
Definition: gsMappedSingleBasis.h:283
short_t maxDegree() const
Returns the polynomial degree.
Definition: gsMappedSingleBasis.h:256
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:317
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:324
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
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
Struct which represents a certain corner of a hyper-cube.
Definition: gsBoundary.h:291
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
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
index_t size() const
size
Definition: gsMappedSingleBasis.h:250