41 typedef memory::shared_ptr<gsMultiBasis>
Ptr;
42 typedef memory::unique_ptr<gsMultiBasis>
uPtr;
44 typedef std::vector<gsBasis<T> *> BasisContainer;
49 typedef typename BasisContainer::iterator
iterator;
50 typedef typename BasisContainer::const_iterator const_iterator;
70 bool numeratorOnly =
false);
74 : m_topology( topology )
84 const std::vector<patchSide>&
boundary,
85 const std::vector<boundaryInterface>& interfaces )
86 : m_topology( bases[0]->
dim(), bases.
size(), boundary, interfaces )
97 #if EIGEN_HAS_RVALUE_REFERENCES
108 m_bases =
give(other.m_bases);
109 m_topology =
give(other.m_topology);
129 return m_bases.begin();
134 const_iterator
end()
const
136 return m_bases.end();
142 return m_bases.begin();
148 return m_bases.end();
158 const gsBoxTopology & topology()
const {
return m_topology; }
164 {
return *m_bases.at(i);}
169 const_reference operator[](
size_t i)
const
170 {
return *m_bases[i];}
172 reference operator[](
size_t i)
173 {
return *m_bases[i];}
178 const_reference front()
const
179 {
return *m_bases.front();}
184 const_reference back()
const
185 {
return *m_bases.back();}
188 {m_bases.pop_back();}
199 m_topology.
swap( other.m_topology );
201 m_bases.swap( other.m_bases );
205 std::ostream&
print( std::ostream& os )
const;
215 "Invalid patch index "<<i<<
" requested from gsMultiBasis" );
216 return m_bases[i]->degree(comp);
235 "Invalid patch index "<<i<<
" requested from gsMultiBasis" );
236 return m_bases[i]->size();
249 for (
size_t k = 0; k < m_bases.size(); ++k)
250 sum += m_bases[k]->
size();
258 for (
size_t k = 0; k < m_bases.size(); ++k)
259 sum += m_bases[k]->numElements();
264 size_t nBases()
const {
return m_bases.size(); }
270 "Invalid patch index"<<i<<
" requested from gsMultiBasis" );
277 "Invalid patch index"<<i<<
" requested from gsMultiBasis" );
288 "Invalid patch index"<<i<<
" requested from gsMultiBasis" );
320 for (
size_t k = 0; k < m_bases.size(); ++k)
322 m_bases[k]->uniformRefine(numKnots,mul,dir);
366 for (
size_t k = 0; k < m_bases.size(); ++k)
368 m_bases[k]->component(comp).uniformRefine(numKnots,mul);
375 m_bases[k]->refine(boxes);
379 void unrefine(
int k, gsMatrix<T>
const & boxes)
381 m_bases[k]->unrefine(boxes);
390 m_bases[k]->refineElements(boxes);
393 void unrefineElements(
int k, std::vector<index_t>
const & boxes)
395 m_bases[k]->unrefineElements(boxes);
405 "Invalid patch index "<<k<<
" requested from gsMultiBasis" );
406 m_bases[k]->refine( boxes, refExt);
408 void unrefine(
size_t k,
gsMatrix<T> const & boxes,
int refExt)
411 "Invalid patch index "<<k<<
" requested from gsMultiBasis" );
412 m_bases[k]->unrefine( boxes, refExt);
420 for (
size_t k = 0; k < m_bases.size(); ++k)
422 m_bases[k]->uniformCoarsen(numKnots);
447 {
return m_bases[p.
patch()]->componentBasis(p); }
471 const std::vector<patchComponent>& pc,
487 size_t kmax = 2*bivec.size();
489 bool sthChanged =
false;
494 for(
size_t i = 0; i < bivec.size(); i++ )
497 sthChanged = sthChanged || change;
501 while( sthChanged && k <= kmax );
547 std::vector<index_t> & refEltsFirst,
548 std::vector<index_t> & refEltsSecond );
553 for (
size_t k = 0; k < m_bases.size(); ++k)
561 for (
size_t k = 0; k < m_bases.size(); ++k)
569 for (
size_t k = 0; k < m_bases.size(); ++k)
576 for (
size_t k = 0; k < m_bases.size(); ++k)
583 for (
size_t k = 0; k < m_bases.size(); ++k)
590 for (
size_t k = 0; k < m_bases.size(); ++k)
594 BasisContainer & patchBases()
599 const BasisContainer & patchBases()
const
604 void setTopology(
const gsBoxTopology & tpl)
610 void getMapper(
bool conforming,
611 const gsBoundaryConditions<T> & bc,
613 gsDofMapper & mapper,
614 bool finalize =
true)
const;
616 void getMapper(
bool conforming,
617 const gsBoundaryConditions<T> & bc,
618 gsDofMapper & mapper,
619 bool finalize =
true)
const
620 { getMapper(conforming, bc, 0, mapper, finalize); }
622 void getMapper(iFace::strategy is,
623 const gsBoundaryConditions<T> & bc,
624 gsDofMapper & mapper,
626 bool finalize =
true)
const
627 { getMapper(is==iFace::glue, bc, unk, mapper, finalize); }
629 void getMapper(dirichlet::strategy ds,
631 const gsBoundaryConditions<T> & bc,
632 gsDofMapper & mapper,
634 bool finalize =
true)
const
636 if ( ds == dirichlet::elimination )
637 getMapper(is==iFace::glue, bc, unk, mapper, finalize);
639 getMapper(is==iFace::glue, mapper, finalize);
642 gsDofMapper getMapper(dirichlet::strategy ds,
644 const gsBoundaryConditions<T> & bc,
646 bool finalize =
true)
const
649 if ( ds == dirichlet::elimination )
650 getMapper(is==iFace::glue, bc, unk, mapper, finalize);
652 getMapper(is==iFace::glue, mapper, finalize);
658 void getMapper(
bool conforming, gsDofMapper & mapper,
bool finalize =
true)
const;
660 void getMapper(iFace::strategy is, gsDofMapper & mapper,
bool finalize =
true)
const
661 { getMapper(is==iFace::glue, mapper, finalize); }
688 gsDofMapper & mapper)
const;
696 BasisContainer m_bases;
698 gsBoxTopology m_topology;
705 std::ostream& operator<<( std::ostream& os, const gsMultiBasis<T>& b )
707 return b.print( os );
710 #ifdef GISMO_WITH_PYBIND11
715 void pybind11_init_gsMultiBasis(pybind11::module &m);
717 #endif // GISMO_WITH_PYBIND11
722 #ifndef GISMO_BUILD_LIB
723 #include GISMO_HPP_HEADER(gsMultiBasis.hpp)
gsBasis< T >::uPtr componentBasis_withIndices(patchComponent pc, const gsDofMapper &dm, gsMatrix< index_t > &indices, bool no_lower=true) const
Returns the basis that corresponds to the component.
Definition: gsMultiBasis.hpp:262
void addBoundary(index_t p, boxSide s, std::string l="")
Set side s of box p to a boundary.
Definition: gsBoxTopology.h:208
int findBasisIndex(gsBasis< T > *g) const
Search for the given basis and return its index.
Definition: gsMultiBasis.hpp:112
void addInterface(gsBasis< T > *g1, boxSide s1, gsBasis< T > *g2, boxSide s2)
Add an interface joint between side s1 of geometry g1 side s2 of geometry g2.
Definition: gsMultiBasis.hpp:121
size_t totalSize() const
The total number of basis functions in all bases.
Definition: gsMultiBasis.h:246
index_t patch() const
Returns the patch number.
Definition: gsBoundary.h:626
gsMultiBasis()
Default empty constructor.
Definition: gsMultiBasis.h:58
Struct which represents a certain side of a patch.
Definition: gsBoundary.h:231
Provides declaration of the BoxTopology class.
gsMultiBasis & operator=(gsMultiBasis other)
Assignment operator (uses copy-and-swap idiom)
Definition: gsMultiBasis.h:114
gsMultiBasis(BasisContainer &bases, const gsBoxTopology &topology)
Create from a vector of bases and topology.
Definition: gsMultiBasis.h:73
#define short_t
Definition: gsConfig.h:35
void degreeElevate(short_t const i=1, short_t const dir=-1)
Elevate the degree of every basis by the given amount. (keeping the smoothness)
Definition: gsMultiBasis.h:551
iterator end()
Definition: gsMultiBasis.h:147
int size(size_t i) const
The number of basis functions in basis i.
Definition: gsMultiBasis.h:232
Struct that defines the boundary sides and corners and types of a geometric object.
Definition: gsBoundary.h:55
short_t maxDegree(short_t k) const
Maximum degree with respect to variable k.
Definition: gsMultiBasis.hpp:331
bool repairInterface2d(const boundaryInterface &bi)
Checks if the 2D-interface is fully matching, and if not, repairs it.
Definition: gsMultiBasis.hpp:692
short_t minCwiseDegree() const
Minimum degree with respect to all variables.
Definition: gsMultiBasis.hpp:352
Provides declaration of Basis abstract interface.
S give(S &x)
Definition: gsMemory.h:266
Provides declaration of Geometry abstract interface.
short_t degree(size_t i=0, short_t comp=0) const
Returns the polynomial degree of basis i in component j, if the basis is of polynomial or piecewise p...
Definition: gsMultiBasis.h:212
void degreeIncrease(short_t const i=1, short_t const dir=-1)
Increase the degree of every basis by the given amount. (keeping the multiplicity) ...
Definition: gsMultiBasis.h:559
#define index_t
Definition: gsConfig.h:32
void swap(gsMultiBasis &other)
Swap with another gsMultiBasis.
Definition: gsMultiBasis.h:197
Provides assembler and solver options.
void degreeDecrease(short_t const i=1, short_t const dir=-1)
Increase the degree of every basis by the given amount. (keeping the multiplicity) ...
Definition: gsMultiBasis.h:567
gsBasis< T >::uPtr componentBasis(patchComponent p) const
Returns the basis that corresponds to the component.
Definition: gsMultiBasis.h:446
void matchInterface(const boundaryInterface &bi, gsDofMapper &mapper) const
Matches the degrees of freedom along an interface.
Definition: gsMultiBasis.hpp:415
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsMultiBasis.hpp:71
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
size_t totalElements() const
The total number of elements in all patches.
Definition: gsMultiBasis.h:255
void uniformRefineComponent(int comp, int numKnots=1, int mul=1)
Refine the component comp of every basis uniformly by inserting numKnots new knots on each knot span...
Definition: gsMultiBasis.h:364
Maintains a mapping from patch-local dofs to global dof indices and allows the elimination of individ...
Definition: gsDofMapper.h:68
void uniformCoarsen(int numKnots=1)
Coarsen every basis uniformly.
Definition: gsMultiBasis.h:418
void addPatchBoundary(gsBasis< T > *g, boxSide s)
Add side s of patch g to the outer boundary of the domain.
Definition: gsMultiBasis.h:309
memory::shared_ptr< gsFunctionSet > Ptr
Shared pointer for gsFunctionSet.
Definition: gsFunctionSet.h:223
bool repairInterface(const boundaryInterface &bi)
Checks if the interface is fully matching, and if not, repairs it.
Definition: gsMultiBasis.hpp:428
const_reference at(size_t i) const
Assess i-th parametric basis.
Definition: gsMultiBasis.h:163
const_iterator begin() const
Definition: gsMultiBasis.h:127
Provides the gsDofMapper class for re-indexing DoFs.
index_t nPieces() const
Number of patch-wise bases.
Definition: gsMultiBasis.h:282
void degreeReduce(short_t const i=1)
Reduce the degree of the basis by the given amount.
Definition: gsMultiBasis.h:574
gsMultiBasis(BasisContainer &bases, const std::vector< patchSide > &boundary, const std::vector< boundaryInterface > &interfaces)
Create from bases and boundary/interface information.
Definition: gsMultiBasis.h:83
memory::unique_ptr< gsFunctionSet > uPtr
Unique pointer for gsFunctionSet.
Definition: gsFunctionSet.h:226
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
short_t maxCwiseDegree() const
Maximum degree with respect to all variables.
Definition: gsMultiBasis.hpp:342
iterator begin()
Definition: gsMultiBasis.h:141
short_t dim() const
Dimension of the parameter domain (must match for all bases).
Definition: gsMultiBasis.h:208
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
gsBasis< T > & basis(const size_t i)
Return the i-th basis block.
Definition: gsMultiBasis.h:285
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition: gsMemory.h:312
void refineElements(int k, std::vector< index_t > const &boxes)
Refine the are defined by boxes on patch k.
Definition: gsMultiBasis.h:388
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
const gsBasis< T > & piece(const index_t i) const
Returns the piece(s) of the function(s) at subdomain k.
Definition: gsMultiBasis.h:274
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsMultiBasis.h:192
Struct which represents a certain component (interior, face, egde, corner) of a particular patch...
Definition: gsBoundary.h:565
void swap(gsBoxTopology &other)
Swap with another gsBoxTopology.
Definition: gsBoxTopology.h:174
memory::unique_ptr< gsBasis > uPtr
Unique pointer for gsBasis.
Definition: gsBasis.h:89
const gsBasis< T > & basis(const size_t i) const
Return the i-th basis block.
Definition: gsMultiBasis.h:267
BasisContainer::iterator iterator
Type definitions.
Definition: gsMultiBasis.h:49
short_t minDegree(short_t k) const
Minimum degree with respect to variable k.
Definition: gsMultiBasis.hpp:362
void clearAll()
Clear all boxes, boundary and interface data.
Definition: gsBoxTopology.h:165
void uniformRefine(int numKnots=1, int mul=1, int dir=-1)
Refine every basis uniformly.
Definition: gsMultiBasis.h:318
const_iterator end() const
Definition: gsMultiBasis.h:134
Class containing a set of boundary conditions.
Definition: gsBoundaryConditions.h:341
void uniformRefine_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, const gsBoundaryConditions< T > &boundaryConditions, const gsOptionList &assemblerOptions, int numKnots=1, int mul=1, index_t unk=0)
Refine every basis uniformly.
Definition: gsMultiBasis.hpp:181
bool repairInterfaceFindElements(const boundaryInterface &bi, std::vector< index_t > &refEltsFirst, std::vector< index_t > &refEltsSecond)
Finds the elements that need to be refined in order to repair an interface.
Definition: gsMultiBasis.hpp:462
void repairInterfaces(const std::vector< boundaryInterface > &bivec)
Checks if the interfaces bivec are fully matching, and if not, repairs them, i.e., makes them fully matching.
Definition: gsMultiBasis.h:485
size_t nBases() const
Number of patch-wise bases.
Definition: gsMultiBasis.h:264
void refine(size_t k, gsMatrix< T > const &boxes, int refExt)
Refine the are defined by boxes on patch k with extension refExt.
Definition: gsMultiBasis.h:402
Provides gsBoundaryConditions class.
~gsMultiBasis()
Destructor.
Definition: gsMultiBasis.hpp:65
void reduceContinuity(int const i=1)
Reduce the continuity by i.
Definition: gsMultiBasis.h:588
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
index_t size() const
size
Definition: gsMultiBasis.h:239
void setDegree(short_t const &i)
Set the degree of the basis.
Definition: gsMultiBasis.h:581
Defines a topological arrangement of a collection of "boxes" (e.g., parameter domains that map to phy...
Definition: gsBoxTopology.h:38
void clear()
Clear (delete) all patches.
Definition: gsMultiBasis.h:152
short_t targetDim() const
Dimension of the target space.
Definition: gsMultiBasis.h:194
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
void uniformCoarsen_withTransfer(gsSparseMatrix< T, RowMajor > &transfer, const gsBoundaryConditions< T > &boundaryConditions, const gsOptionList &assemblerOptions, int numKnots=1, index_t unk=0)
Coarsen every basis uniformly.
Definition: gsMultiBasis.hpp:222
static void combineTransferMatrices(const std::vector< gsSparseMatrix< T, RowMajor > > &localTransferMatrices, const gsDofMapper &coarseMapper, const gsDofMapper &fineMapper, gsSparseMatrix< T, RowMajor > &transferMatrix)
This function takes local transfer matrices (per patch) and combines them using given DofMappers to a...
Definition: gsMultiBasis.hpp:137
void addBasis(gsBasis< T > *g)
Add a basis (ownership of the pointer is also acquired)
Definition: gsMultiBasis.hpp:79