G+Smo
24.08.0
Geometry + Simulation Modules
|
Maintains a mapping from patch-local dofs to global dof indices and allows the elimination of individual dofs.
A dof (degree of freedom) is, roughly speaking, an unknown in a discretization of a PDE. However, some dofs may be eliminated before solving the system and won't actually translate into unknowns. An example are dofs on Dirichlet boundaries.
This class creates a mapping between an arbitrary number of per-patch local dofs to an enumeration of global dofs. Furthermore, dofs can also be marked as eliminated.
This is a a many-to-one mapping: many patch-local dofs are mapped to a single global dfo (index). Every global dof gets a unique number, forming a continuous range starting from 0. This range has length gsDofMapper::size(). The dofs are numbered in the following order:
then the free dofs which are coupled with other dofs For the coupled dofs there is a list of pre-image pairs of the form (patch,localdof).
Upto here we get all the dofs which are free (number: gsDofMapper::freeSize() ). Then a final group follows:
The boundary (eg. eliminated) dofs have their own 0-based numbering. The index of an boundary global dof in this numbering can be queried with gsDofMapper::bindex().
The object must be finalized before it is used, i.e. gsDofMapper::finalize() has to be called once before use.
Public Member Functions | |
void | addShift (index_t shift) |
Add a shift amount to the global numbering. | |
bool | allFree () const |
Returns true iff all DoFs are considered as free. | |
std::pair< index_t, index_t > | anyPreImage (index_t gl) const |
For gl being a global index, this function returns a pair (patch,dof) that maps to gl. | |
std::vector< std::pair < index_t, index_t > > | anyPreImages (index_t comp=0) const |
For all global index, this function assigns a pair (patch,dof) that maps to that global index. | |
gsVector< index_t > | asVector (index_t comp=0) const |
Returns a vector taking flat local indices to global. | |
index_t | bindex (index_t i, index_t k=0, index_t c=0) const |
Returns the boundary index of local dof i of patch k. More... | |
index_t | boundarySize () const |
Returns the number of eliminated dofs. | |
index_t | cindex (index_t i, index_t k=0, index_t c=0) const |
Returns the coupled dof index. | |
void | colapseDofs (index_t k, const gsMatrix< unsigned > &b, index_t comp=0) |
Calls matchDof() for all dofs on the given patch side i ps. Thus, the whole set of dofs collapses to a single global dof. More... | |
index_t | coupledSize () const |
Returns the number of coupled (not eliminated) dofs. | |
void | eliminateDof (index_t i, index_t k, index_t comp=0) |
Mark the local dof i of patch k as eliminated. | |
void | finalize () |
Must be called after all boundaries and interfaces have been marked to set up the dof numbering. | |
gsVector< index_t > | findBoundary (const index_t k) const |
Returns all boundary dofs on patch k (local dof indices) | |
gsVector< index_t > | findCoupled (const index_t k, const index_t j=-1) const |
Returns all coupled dofs on patch k (local dof indices) | |
gsVector< index_t > | findFree (const index_t k) const |
Returns all free dofs on patch k (local dof indices) | |
gsVector< index_t > | findFreeUncoupled (const index_t k) const |
Returns all free, not coupled dofs on patch k (local dof indices) | |
gsVector< index_t > | findTagged (const index_t k) const |
Returns all tagged dofs on patch k (local dof indices) | |
index_t | firstIndex (index_t comp=0) const |
Returns the smallest value of the indices for comp. | |
index_t | freeIndex (index_t i, index_t k=0, index_t c=0) const |
Returns the index associated to local dof i of patch k without shifts. More... | |
index_t | freeSize () const |
Returns the number of free (not eliminated) dofs. | |
const std::vector< index_t > & | getTagged () const |
Returns the vector of tagged (not eliminated) dofs. | |
index_t | global_to_bindex (index_t gl) const |
Returns the boundary index of global dof gl. More... | |
gsDofMapper () | |
Default empty constructor. | |
template<class T > | |
gsDofMapper (const gsMultiBasis< T > &bases, const gsBoundaryConditions< T > &dirichlet, int unk=0) | |
construct a dof mapper that identifies the degrees of freedom in the multibasis and eliminates the degrees of freedom on the Dirichlet boundary More... | |
template<class T > | |
gsDofMapper (const gsMultiBasis< T > &bases, index_t nComp=1) | |
construct a dof mapper that identifies the degrees of freedom in the multibasis More... | |
template<class T > | |
gsDofMapper (std::vector< const gsMultiBasis< T > * > const &bases) | |
construct a dof mapper that identifies the degrees of freedom for a vector of multibasis More... | |
template<class T > | |
gsDofMapper (const gsBasis< T > &basis, index_t nComp=1) | |
construct a dof mapper that manages the degrees of freedom in a gsBasis More... | |
gsDofMapper (const gsVector< index_t > &patchDofSizes, index_t nComp=1) | |
construct a dof mapper with a given number of dofs per patch More... | |
index_t | index (index_t i, index_t k=0, index_t c=0) const |
Returns the global dof index associated to local dof i of patch k. More... | |
bool | indexOnPatch (const index_t gl, const index_t k) const |
For gl being a global index, this function returns true whenever gl corresponds to patch k. | |
template<typename T > | |
void | init (const gsMultiBasis< T > &bases, index_t nComp=1) |
Initialize by a gsMultiBasis. | |
template<typename T > | |
void | init (std::vector< const gsMultiBasis< T > * > const &bases) |
Initialize by a vector of gsMultiBasis. | |
template<class T > | |
void | init (const gsMultiBasis< T > &basis, const gsBoundaryConditions< T > &dirichlet, int unk=0) |
gsVector< index_t > | inverseAsVector (index_t comp=0) const |
Returns a vector taking global indices to flat local. More... | |
std::map< index_t, index_t > | inverseOnPatch (const index_t k) const |
Produces the inverse of the mapping on patch k assuming that the map is invertible on that patch. | |
bool | is_boundary (index_t i, index_t k=0, index_t c=0) const |
Returns true if local dof i of patch k is eliminated. | |
bool | is_boundary_index (index_t gl) const |
Returns true if global dof gl is eliminated. | |
bool | is_coupled (index_t i, index_t k=0, index_t c=0) const |
Returns true if local dof i of patch k is coupled. | |
bool | is_coupled_index (index_t gl) const |
Returns true if gl is a coupled dof. | |
bool | is_free (index_t i, index_t k=0, index_t c=0) const |
Returns true if local dof i of patch k is not eliminated. | |
bool | is_free_index (index_t gl) const |
Returns true if global dof gl is not eliminated. | |
bool | is_tagged (index_t i, index_t k=0, index_t c=0) const |
Returns true if local dof i of patch k is tagged. | |
bool | is_tagged_index (index_t gl) const |
Returns true if gl is a tagged dof. | |
bool | isFinalized () const |
Checks whether finalize() has been called. | |
bool | isPermutation () const |
Returns true iff the mapper is a permuatation. | |
index_t | lastIndex () const |
Returns one past the biggest value of the free indices. | |
void | localToGlobal (const gsMatrix< index_t > &locals, index_t patchIndex, gsMatrix< index_t > &globals, index_t comp=0) const |
Computes the global indices of the input local indices. More... | |
void | localToGlobal2 (const gsMatrix< index_t > &locals, index_t patchIndex, gsMatrix< index_t > &globals, index_t &numFree, index_t comp=0) const |
Computes the global indices of the input local indices. More... | |
index_t | mapIndex (index_t n) const |
For n being an index which is already offsetted, it returns the global index where it is mapped to by the dof mapper. | |
size_t | mapSize () const |
Returns the total number of patch-local degrees of freedom that are being mapped. | |
void | markBoundary (index_t k, const gsMatrix< index_t > &boundaryDofs, index_t comp=0) |
Mark the local dofs boundaryDofs of patch k as eliminated. | |
void | markCoupled (index_t i, index_t k, index_t comp=0) |
Mark the local dof i of patch k as coupled. | |
void | markCoupledAsTagged () |
Mark all coupled dofs as tagged. | |
void | markTagged (index_t i, index_t k, index_t comp=0) |
Mark a local dof i of patch k as tagged. | |
void | matchDof (index_t u, index_t i, index_t v, index_t j, index_t comp=0) |
Couples dof i of patch u with dof j of patch v such that they refer to the same global dof at component comp. | |
void | matchDofs (index_t u, const gsMatrix< index_t > &b1, index_t v, const gsMatrix< index_t > &b2, index_t comp=0) |
Couples dofs b1 of patch u with dofs b2 of patch v one by one such that they refer to the same global dof. | |
index_t | numComponents () const |
Returns the number of components present in the mapper. | |
size_t | numPatches () const |
Returns the number of patches present underneath the mapper. | |
size_t | offset (int k) const |
Returns the offset corresponding to patch k. | |
size_t | patchSize (const index_t k, const index_t c=0) const |
Returns the total number of patch-local DoFs that live on patch k for component c. | |
void | permuteFreeDofs (const gsVector< index_t > &permutation, index_t comp=0) |
Permutes the mapped free indices according to permutation, i.e., dofs_perm[idx] = dofs_old[permutation[idx]]. More... | |
void | preImage (index_t gl, std::vector< std::pair< index_t, index_t > > &result) const |
For gl being a global index, this function returns a vector of pairs (patch,dof) that contains all the pairs which map to gl. | |
std::ostream & | print (std::ostream &os=gsInfo) const |
Print summary. | |
void | setBoundaryShift (index_t shift) |
Set the shift amount for the boundary numbering. | |
void | setIdentity (index_t nPatches, size_t nDofs, size_t nComp=1) |
Set this mapping to be the identity. | |
void | setMatchingInterfaces (const gsBoxTopology &mp) |
void | setShift (index_t shift) |
Set the shift amount for the global numbering. | |
index_t | size () const |
Returns the total number of dofs (free and eliminated). | |
index_t | size (index_t comp) const |
Returns the total number of dofs (free and eliminated). | |
index_t | taggedSize () const |
Returns the number of tagged dofs. | |
index_t | tindex (index_t i, index_t k=0, index_t c=0) const |
Returns the tagged dof index. | |
Private Member Functions | |
void | initPatchDofs (const gsVector< index_t > &patchDofSizes, index_t nComp=1) |
Initialize by vector of DoF indices and dimension. | |
template<typename T > | |
void | initSingle (const gsBasis< T > &basis, index_t nComp=1) |
Initialize by a single basis patch. | |
Private Attributes | |
index_t | m_bshift |
Shifting of the boundary index (zero by default) | |
std::vector< index_t > | m_numCpldDofs |
Offsets of coupled dofs, nComp+1. | |
std::vector< index_t > | m_numElimDofs |
Offsets of eliminated dofs, nComp+1. | |
std::vector< index_t > | m_numFreeDofs |
Offsets of free dofs, nComp+1. | |
std::vector< size_t > | m_offset |
Offsets. | |
index_t | m_shift |
Shifting of the global index (zero by default) | |
std::vector< index_t > | m_tagged |
Stores the tagged indices. | |
|
inline |
construct a dof mapper that identifies the degrees of freedom in the multibasis and eliminates the degrees of freedom on the Dirichlet boundary
bases | |
dirichlet | |
unk |
|
inline |
construct a dof mapper that identifies the degrees of freedom in the multibasis
bases |
|
inline |
construct a dof mapper that identifies the degrees of freedom for a vector of multibasis
bases |
|
inline |
construct a dof mapper that manages the degrees of freedom in a gsBasis
basis |
|
inline |
construct a dof mapper with a given number of dofs per patch
patchDofSizes |
Returns the boundary index of local dof i of patch k.
Produces undefined results if local dof (i,k) does not lie on the boundary.
Calls matchDof() for all dofs on the given patch side i ps. Thus, the whole set of dofs collapses to a single global dof.
Returns the index associated to local dof i of patch k without shifts.
Returns the boundary index of global dof gl.
Produces undefined results if dof gl does not lie on the boundary.
Returns the global dof index associated to local dof i of patch k.
void init | ( | const gsMultiBasis< T > & | basis, |
const gsBoundaryConditions< T > & | dirichlet, | ||
int | unk = 0 |
||
) |
Initialize by gsMultiBasis, boundary conditions and the index of the unknown to be eliminated
Returns a vector taking global indices to flat local.
Assumes that the mapper is a permutation
void localToGlobal | ( | const gsMatrix< index_t > & | locals, |
index_t | patchIndex, | ||
gsMatrix< index_t > & | globals, | ||
index_t | comp = 0 |
||
) | const |
Computes the global indices of the input local indices.
[in] | locals | a column matrix with the local indices |
[in] | patchIndex | the index of the patch where the local indices belong to |
[out] | globals | the global indices of the patch |
void localToGlobal2 | ( | const gsMatrix< index_t > & | locals, |
index_t | patchIndex, | ||
gsMatrix< index_t > & | globals, | ||
index_t & | numFree, | ||
index_t | comp = 0 |
||
) | const |
Computes the global indices of the input local indices.
[in] | locals | a column matrix with the local indices |
[in] | patchIndex | the index of the patch where the local indices belong to |
[out] | globals | the local-global correspondance |
[out] | numFree | the number of free indices in local |
Permutes the mapped free indices according to permutation, i.e., dofs_perm[idx] = dofs_old[permutation[idx]].
void setMatchingInterfaces | ( | const gsBoxTopology & | mp | ) |
Called to initialize the gsDofMapper with matching interfaces after m_bases have already been set