29template<
short_t d,
class T>
class gsMappedSingleBasis;
31template<
short_t d,
class T>
32class gsMappedBasis :
public gsFunctionSet<T>
34 friend class gsMappedSingleBasis<d,T>;
37 typedef std::vector<std::pair<int,int> >::iterator step_iter;
38 typedef gsBasis<T> BasisType;
39 typedef typename std::vector<BasisType *>::const_iterator ConstBasisIter;
40 typedef typename std::vector<BasisType *>::iterator BasisIter;
41 typedef typename std::vector<gsMatrix<T> *>::const_iterator ConstMatrixPtrIter;
42 typedef typename gsSparseMatrix<T,0,index_t>::InnerIterator InIterMat;
43 typedef typename std::vector<index_t> IndexContainer;
44 typedef typename std::vector<index_t>::const_iterator ConstIndexIter;
45 typedef typename std::vector<T> WeightContainer;
46 typedef typename std::vector<T>::const_iterator ConstWeightIter;
49 typedef memory::unique_ptr< gsDomainIterator<T> > domainIter;
53 typedef memory::shared_ptr< gsMappedBasis > Ptr;
56 typedef memory::unique_ptr< gsMappedBasis > uPtr;
58 gsMappedBasis() : m_mapper(nullptr)
61 gsMappedBasis(gsMultiBasis<T>
const & mb,
const gsSparseMatrix<T> & m)
67 gsMappedBasis(
const gsMappedBasis& other );
69 virtual ~gsMappedBasis();
71 void init(gsMultiBasis<T>
const & mb,
const gsSparseMatrix<T> & m)
74 m_topol = mb.topology();
77 m_mapper =
new gsWeightMapper<T>(m);
80 m_bases.reserve(mb.nBases());
83 m_sb.reserve(m_bases.size());
84 for (
size_t q=0; q!=m_bases.size(); ++q )
85 m_sb.push_back( gsMappedSingleBasis<d,T>(
this,q) );
87 m_mapper->optimize(gsWeightMapper<T>::optSourceToTarget);
90 index_t nPieces()
const {
return m_topol.nBoxes();}
98 BasisType
const & getBase(
index_t i)
const
99 {
return *m_bases[i]; }
103 {
return *m_bases[i]; }
106 const std::vector<BasisType*> getBases()
const;
109 std::vector<BasisType*> getBasesCopy()
const
111 std::vector<BasisType*> bases;
117 gsWeightMapper<T>
const & getMapper()
const
118 {
return *m_mapper; }
121 gsWeightMapper<T> * getMapPointer()
const
125 gsBoxTopology
const & getTopol()
const
134 GISMO_CLONE_FUNCTION(gsMappedBasis)
141 GISMO_ASSERT(m_bases.size()>0,
"there should be at least one basis provided.");
142 return m_bases[0]->domainDim();
149 index_t size()
const {
return m_mapper->getNrOfTargets(); }
151 index_t globalSize()
const {
return m_mapper->getNrOfTargets(); }
154 index_t localSize()
const {
return m_mapper->getNrOfSources(); }
158 {
return m_bases[index]->size(); }
165 {
return m_bases[patch]->degree(i); }
168 size_t nPatches()
const
169 {
return m_bases.size(); }
173 void addLocalIndicesOfPatchSide(
const patchSide& ps,
index_t offset,std::vector<index_t>& locals)
const;
176 void reorderDofs(
const gsPermutationMatrix& permMatrix)
178 (*m_mapper)*=permMatrix;
179 m_mapper->optimize(gsWeightMapper<T>::optSourceToTarget);
182 void reorderDofs_withCoef(
const gsPermutationMatrix& permMatrix,gsMatrix<T>& coefs)
184 reorderDofs(permMatrix);
190 void boundary(std::vector<index_t> & indices,
index_t offset = 0)
const;
194 void innerBoundaries(std::vector<index_t> & indices,
index_t offset = 0)
const;
198 gsMappedSingleBasis<d,T> & getMappedSingleBasis(
const index_t i)
const
209 const gsMappedSingleBasis<d,T> & piece(
const index_t k)
const {
return getMappedSingleBasis(k); }
213 domainIter makeDomainIterator(
const index_t patch,
const boxSide & s)
const
214 {
return m_bases[patch]->makeDomainIterator(s); }
222 gsGeometry<T>* exportPatch(
const index_t i,gsMatrix<T>
const & localCoef)
const;
228 gsMultiPatch<T> exportToPatches(gsMatrix<T>
const & localCoef)
const;
232 void active_into(
const gsMatrix<T> &,gsMatrix<index_t>&)
const
234 void eval_into(
const gsMatrix<T> &,gsMatrix<T>&)
const
236 void deriv_into(
const gsMatrix<T> &,gsMatrix<T>&)
const
238 void deriv2_into(
const gsMatrix<T> &,gsMatrix<T>&)
const
240 void evalAllDers_into(
const gsMatrix<T> &,
int,
241 std::vector<gsMatrix<T> >&,
bool)
const
256 void active_into(
const index_t patch,
const gsMatrix<T> & u,
257 gsMatrix<index_t>& result)
const;
260 virtual void numActive_into(
const index_t patch,
const gsMatrix<T> & u, gsVector<index_t>& result)
const
292 void eval_into(
const index_t patch,
const gsMatrix<T> & u, gsMatrix<T>& result )
const;
293 void deriv_into(
const index_t patch,
const gsMatrix<T> & u, gsMatrix<T>& result )
const;
294 void deriv2_into(
const index_t patch,
const gsMatrix<T> & u, gsMatrix<T>& result )
const;
296 gsPiecewiseFunction<T> basisFunction(
index_t global_BF)
298 const size_t np = nPatches();
299 gsPiecewiseFunction<T> bf(np);
300 for(
size_t i = 0; i!=np; ++i)
301 bf.addPiece( getMappedSingleBasis(i).
function(global_BF) );
306 void evalSingle_into(
const index_t patch,
const index_t global_BF,
const gsMatrix<T> & u, gsMatrix<T>& result )
const;
307 void derivSingle_into(
const index_t patch,
const index_t global_BF,
const gsMatrix<T> & u, gsMatrix<T>& result )
const;
308 void deriv2Single_into(
const index_t patch,
const index_t global_BF,
const gsMatrix<T> & u, gsMatrix<T>& result )
const;
311 gsMatrix<T> evalSingle(
const index_t patch,
const index_t global_BF,
const gsMatrix<T> & u)
const
314 this->evalSingle_into(patch, global_BF, u, result);
319 gsMatrix<T> derivSingle(
const index_t patch,
const index_t global_BF,
const gsMatrix<T> & u)
const
322 this->derivSingle_into(patch, global_BF, u, result);
327 gsMatrix<T> deriv2Single(
const index_t patch,
const index_t global_BF,
const gsMatrix<T> & u)
const
330 this->deriv2Single_into(patch, global_BF, u, result);
336 void evalAllDers_into(
const index_t patch,
const gsMatrix<T> & u,
337 const index_t n, std::vector<gsMatrix<T> >& result,
338 bool sameElement =
false)
const;
342 void evalAllDersSingle_into(
const index_t patch,
const index_t global_BF,
const gsMatrix<T> & u,
const index_t n,std::vector<gsMatrix<T> >& result)
const;
347 std::ostream &print(std::ostream &os)
const;
359 void global_coef_to_local_coef(gsMatrix<T>
const & globalCoefs,gsMatrix<T> & localCoefs)
const
360 { m_mapper->mapToSourceCoefs(globalCoefs,localCoefs); }
367 void local_coef_to_global_coef(gsMatrix<T>
const & localCoefs,gsMatrix<T> & globalCoefs)
const
368 { m_mapper->mapToTargetCoefs(localCoefs,globalCoefs); }
373 return _getPatch(localIndex);
377 return _getPatchIndex(localIndex);
390 gsMatrix<index_t> getGlobalIndex(
index_t patch, gsMatrix<index_t> localIndices);
418 {
return _getFirstLocalIndex(patch)+patchIndex; }
433 {
return _getFirstLocalIndex(patch)+m_bases[patch]->size()-1; }
438 gsBoxTopology m_topol;
441 std::vector<BasisType *> m_bases;
444 gsWeightMapper<T> * m_mapper;
448 mutable std::vector<gsMappedSingleBasis<d,T> > m_sb;
453#ifdef GISMO_WITH_PYBIND11
459 void pybind11_init_gsMappedBasis2(pybind11::module &m);
466#ifndef GISMO_BUILD_LIB
467#include GISMO_HPP_HEADER(gsMappedBasis.hpp)
const gsFunction< T > & function(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsFunction.
Definition gsFunctionSet.hpp:25
Provides definition of the BasisFun class.
Provides declaration of the BoxTopology class.
#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_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of DomainIterator abstract interface.
Implementation of a piece of the gsMappedBasis.
Provides declaration of the MultiPatch class.
Provides declaration of a gsPiecewiseFunction class.
Provides declaration of gsWeightMapper class.
The G+Smo namespace, containing all definitions for the library.
void cloneAll(It start, It end, ItOut out)
Clones all pointers in the range [start end) and stores new raw pointers in iterator out.
Definition gsMemory.h:295
gsEigen::PermutationMatrix< Dynamic, Dynamic, index_t > gsPermutationMatrix
reorderMapperTarget permutes the target indices of mapper according to permutation....
Definition gsWeightMapperUtils.h:36
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition gsMemory.h:312