31 template<
short_t d,
class T>
37 typedef std::vector<std::pair<int,int> >::iterator step_iter;
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;
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)
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;
178 (*m_mapper)*=permMatrix;
179 m_mapper->optimize(gsWeightMapper<T>::optSourceToTarget);
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,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);
406 {
return _getFirstLocalIndex(patch)+patchIndex; }
421 {
return _getFirstLocalIndex(patch)+m_bases[patch]->size()-1; }
426 gsBoxTopology m_topol;
429 std::vector<BasisType *> m_bases;
432 gsWeightMapper<T> * m_mapper;
436 mutable std::vector<gsMappedSingleBasis<d,T> > m_sb;
441 #ifdef GISMO_WITH_PYBIND11
447 void pybind11_init_gsMappedBasis2(pybind11::module &m);
450 #endif // GISMO_WITH_PYBIND11
454 #ifndef GISMO_BUILD_LIB
455 #include GISMO_HPP_HEADER(gsMappedBasis.hpp)
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
Provides declaration of the BoxTopology class.
Class gsMappedSingleBasis represents an indivisual .....of a.
Definition: gsMappedBasis.h:29
#define short_t
Definition: gsConfig.h:35
gsEigen::PermutationMatrix< Dynamic, Dynamic, index_t > gsPermutationMatrix
reorderMapperTarget permutes the target indices of mapper according to permutation. If permutation does not contain all indices then the order of the remaining indices is preserved and the specified indices are appended to the end.
Definition: gsWeightMapperUtils.h:36
Provides definition of the BasisFun class.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
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
Sparse matrix class, based on gsEigen::SparseMatrix.
Definition: gsSparseMatrix.h:140
Provides declaration of gsWeightMapper class.
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
Provides declaration of the MultiPatch class.
memory::shared_ptr< gsBasis > Ptr
Shared pointer for gsBasis.
Definition: gsBasis.h:86
Provides declaration of DomainIterator abstract interface.
Implementation of a piece of the gsMappedBasis.
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition: gsMemory.h:312
Provides declaration of a gsPiecewiseFunction class.
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition: gsBasis.h:89
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78