Flow123d
release_3.0.0-688-g6b683cf
|
Provides the numbering of the finite element degrees of freedom on the computational mesh. More...
#include <dofhandler.hh>
Public Member Functions | |
DOFHandlerMultiDim (Mesh &_mesh, bool make_elem_part=true) | |
Constructor. More... | |
void | distribute_dofs (std::shared_ptr< DiscreteSpace > ds) |
Distributes degrees of freedom on the mesh needed for the given discrete space. More... | |
std::shared_ptr< DOFHandlerMultiDim > | sequential () |
Returns sequential version of the current dof handler. More... | |
std::shared_ptr< VecScatter > | sequential_scatter () |
Returns scatter context from parallel to sequential vectors. More... | |
unsigned int | get_dof_indices (const ElementAccessor< 3 > &cell, std::vector< LongIdx > &indices) const override |
Returns the global indices of dofs associated to the cell . More... | |
unsigned int | get_loc_dof_indices (const ElementAccessor< 3 > &cell, std::vector< LongIdx > &indices) const override |
Returns the indices of dofs associated to the cell on the local process. More... | |
int | el_index (int loc_el) const |
Returns the global index of local element. More... | |
LongIdx | edge_index (int loc_edg) const |
Returns the global index of local edge. More... | |
LongIdx | nb_index (int loc_nb) const |
Returns the global index of local neighbour. More... | |
unsigned int | n_dofs (ElementAccessor< 3 > cell) const |
Return number of dofs on given cell. More... | |
unsigned int | n_loc_edges () const |
Returns number of local edges. More... | |
unsigned int | n_loc_nb () const |
Returns number of local neighbours. More... | |
bool | el_is_local (int index) const |
template<unsigned int dim> | |
FiniteElement< dim > * | fe (const ElementAccessor< 3 > &cell) const |
Returns finite element object for given space dimension. More... | |
const Dof & | cell_dof (ElementAccessor< 3 > cell, unsigned int idof) const |
Return dof on a given cell. More... | |
void | print () const |
Output structure of dof handler. More... | |
std::size_t | hash () const override |
Range< DHCellAccessor > | own_range () const |
Returns range of DOF handler cells (only range of own without ghost cells) More... | |
Range< DHCellAccessor > | local_range () const |
Returns range over own and ghost cells of DOF handler. More... | |
Range< DHCellAccessor > | ghost_range () const |
Returns range over ghosts DOF handler cells. More... | |
DHCellAccessor | cell_accessor_from_element (unsigned int elm_idx) const |
Return DHCellAccessor appropriate to ElementAccessor of given idx. More... | |
~DOFHandlerMultiDim () override | |
Destructor. More... | |
Public Member Functions inherited from DOFHandlerBase | |
DOFHandlerBase (Mesh &_mesh) | |
Constructor. More... | |
const unsigned int | n_global_dofs () const |
Getter for the number of all mesh dofs required by the given finite element. More... | |
const unsigned int | lsize () const |
Returns the number of dofs on the current process. More... | |
const unsigned int | loffset () const |
Returns the offset of the local part of dofs. More... | |
const unsigned int | max_elem_dofs () const |
Returns max. number of dofs on one element. More... | |
std::shared_ptr< Distribution > | distr () const |
Mesh * | mesh () const |
Returns the mesh. More... | |
virtual | ~DOFHandlerBase () |
Destructor. More... | |
Private Member Functions | |
void | make_elem_partitioning () |
Prepare parallel distribution of elements, edges and neighbours. More... | |
void | init_cell_starts () |
Initialize vector of starting indices for elements. More... | |
void | init_node_dof_starts (std::vector< LongIdx > &node_dof_starts) |
Initialize auxiliary vector of starting indices of nodal dofs. More... | |
void | init_node_status (std::vector< short int > &node_status) |
Initialize node_status. More... | |
void | receive_ghost_dofs (unsigned int proc, std::vector< LongIdx > &dofs) |
Obtain dof numbers on ghost elements from other processor. More... | |
void | send_ghost_dofs (unsigned int proc) |
Send dof numbers to other processor. More... | |
void | update_local_dofs (unsigned int proc, const std::vector< bool > &update_cells, const std::vector< LongIdx > &dofs, const std::vector< LongIdx > &node_dof_starts, std::vector< LongIdx > &node_dofs) |
Update dofs on local elements from ghost element dofs. More... | |
void | create_sequential () |
Communicate local dof indices to all processors and create new sequential dof handler. More... | |
Private Attributes | |
std::shared_ptr< DiscreteSpace > | ds_ |
Pointer to the discrete space for which the handler distributes dofs. More... | |
bool | is_parallel_ |
Indicator for parallel/sequential dof handler. More... | |
std::shared_ptr< DOFHandlerMultiDim > | dh_seq_ |
Sequential dof handler associated to the current (parallel) one. More... | |
std::shared_ptr< VecScatter > | scatter_to_seq_ |
Scatter context for parallel to sequential vectors. More... | |
std::vector< LongIdx > | cell_starts |
Starting indices for element dofs. More... | |
std::vector< LongIdx > | dof_indices |
Dof numbers on local and ghost elements. More... | |
std::vector< LongIdx > | local_to_global_dof_idx_ |
Maps local and ghost dof indices to global ones. More... | |
std::unordered_map< LongIdx, LongIdx > | global_to_local_el_idx_ |
Maps global element index into local/ghost index (obsolete). More... | |
LongIdx * | row_4_el |
Global element index -> index according to partitioning. More... | |
LongIdx * | el_4_loc |
Local element index -> global element index. More... | |
Distribution * | el_ds_ |
Distribution of elements. More... | |
vector< LongIdx > | edg_4_loc |
Local edge index -> global edge index. More... | |
vector< LongIdx > | nb_4_loc |
Local neighbour index -> global neighbour index. More... | |
vector< LongIdx > | node_4_loc |
Indices of local nodes in mesh tree. More... | |
vector< LongIdx > | ghost_4_loc |
Indices of ghost cells (neighbouring with local elements). More... | |
set< unsigned int > | ghost_proc |
Processors of ghost elements. More... | |
map< unsigned int, vector< LongIdx > > | ghost_proc_el |
Arrays of ghost cells for each neighbouring processor. More... | |
Static Private Attributes | |
static const int | INVALID_NODE = 1 |
static const int | VALID_NODE = 2 |
static const int | ASSIGNED_NODE = 3 |
static const int | INVALID_DOF = -1 |
Friends | |
class | DHCellAccessor |
Additional Inherited Members | |
Protected Attributes inherited from DOFHandlerBase | |
unsigned int | n_global_dofs_ |
Number of global dofs assigned by the handler. More... | |
unsigned int | lsize_ |
Number of dofs associated to local process. More... | |
unsigned int | loffset_ |
Index of the first dof on the local process. More... | |
unsigned int | max_elem_dofs_ |
Max. number of dofs per element. More... | |
Mesh * | mesh_ |
Pointer to the mesh to which the dof handler is associated. More... | |
std::shared_ptr< Distribution > | dof_ds_ |
Distribution of dofs associated to local process. More... | |
Provides the numbering of the finite element degrees of freedom on the computational mesh.
Class DOFHandlerMultiDim distributes the degrees of freedom (dof) for a particular triplet of 1d, 2d and 3d finite elements on the computational mesh and provides mappings between local and global dofs. The template parameter dim
denotes the spatial dimension of the reference finite element.
Currently the functionality is restricted to finite elements with internal and nodal dofs, i.e. the neighboring elements can share only dofs on nodes.
Definition at line 156 of file dofhandler.hh.
DOFHandlerMultiDim::DOFHandlerMultiDim | ( | Mesh & | _mesh, |
bool | make_elem_part = true |
||
) |
Constructor.
_mesh | The mesh. |
make_elem_part | Allow switch off make_element_partitioning, necessary for boundary DOF handler. |
Definition at line 42 of file dofhandler.cc.
|
override |
Destructor.
Definition at line 484 of file dofhandler.cc.
DHCellAccessor DOFHandlerMultiDim::cell_accessor_from_element | ( | unsigned int | elm_idx | ) | const |
Return DHCellAccessor appropriate to ElementAccessor of given idx.
Definition at line 612 of file dofhandler.cc.
const Dof & DOFHandlerMultiDim::cell_dof | ( | ElementAccessor< 3 > | cell, |
unsigned int | idof | ||
) | const |
Return dof on a given cell.
cell | Mesh cell. |
idof | Number of dof on the cell. |
Definition at line 72 of file dofhandler.cc.
|
private |
Communicate local dof indices to all processors and create new sequential dof handler.
Collective on all processors.
Definition at line 373 of file dofhandler.cc.
void DOFHandlerMultiDim::distribute_dofs | ( | std::shared_ptr< DiscreteSpace > | ds | ) |
Distributes degrees of freedom on the mesh needed for the given discrete space.
By default, the dof handler is parallel, meaning that each processor has access to dofs on the local elements and on one layer of ghost elements (owned by neighbouring elements). This can be changed by setting sequential
to true.
ds | The discrete space consisting of finite elements for each mesh element. |
sequential | If true then each processor will have information about all dofs. |
Definition at line 266 of file dofhandler.cc.
|
inline |
Returns the global index of local edge.
loc_edg | Local index of edge. |
Definition at line 225 of file dofhandler.hh.
|
inline |
Returns the global index of local element.
loc_el | Local index of element. |
Definition at line 218 of file dofhandler.hh.
bool DOFHandlerMultiDim::el_is_local | ( | int | index | ) | const |
Returns true if element is on local process.
index | Global element index. |
Definition at line 580 of file dofhandler.cc.
|
inline |
Returns finite element object for given space dimension.
cell | Cell accessor. |
Definition at line 263 of file dofhandler.hh.
|
overridevirtual |
Returns the global indices of dofs associated to the cell
.
cell | The cell. |
indices | Array of dof indices on the cell. |
Implements DOFHandlerBase.
Definition at line 461 of file dofhandler.cc.
|
overridevirtual |
Returns the indices of dofs associated to the cell
on the local process.
cell | The cell. |
indices | Array of dof indices on the cell. |
Implements DOFHandlerBase.
Definition at line 473 of file dofhandler.cc.
Range< DHCellAccessor > DOFHandlerMultiDim::ghost_range | ( | ) | const |
Returns range over ghosts DOF handler cells.
Definition at line 605 of file dofhandler.cc.
|
overridevirtual |
Implements DOFHandlerBase::hash
.
Implements DOFHandlerBase.
Definition at line 586 of file dofhandler.cc.
|
private |
Initialize vector of starting indices for elements.
Definition at line 102 of file dofhandler.cc.
|
private |
Initialize auxiliary vector of starting indices of nodal dofs.
node_dof_starts | Vector of starting indices (output). |
Definition at line 116 of file dofhandler.cc.
|
private |
Initialize node_status.
Set VALID_NODE for nodes owned by local elements and INVALID_NODE for nodes owned by ghost elements.
node_status | Vector of nodal status (output). |
Definition at line 133 of file dofhandler.cc.
Range< DHCellAccessor > DOFHandlerMultiDim::local_range | ( | ) | const |
Returns range over own and ghost cells of DOF handler.
Definition at line 598 of file dofhandler.cc.
|
private |
Prepare parallel distribution of elements, edges and neighbours.
Definition at line 489 of file dofhandler.cc.
unsigned int DOFHandlerMultiDim::n_dofs | ( | ElementAccessor< 3 > | cell | ) | const |
Return number of dofs on given cell.
cell | Cell accessor. |
Definition at line 56 of file dofhandler.cc.
|
inline |
Returns number of local edges.
Definition at line 244 of file dofhandler.hh.
|
inline |
Returns number of local neighbours.
Definition at line 249 of file dofhandler.hh.
|
inline |
Returns the global index of local neighbour.
loc_nb | Local index of neighbour. |
Definition at line 232 of file dofhandler.hh.
Range< DHCellAccessor > DOFHandlerMultiDim::own_range | ( | ) | const |
Returns range of DOF handler cells (only range of own without ghost cells)
Definition at line 591 of file dofhandler.cc.
void DOFHandlerMultiDim::print | ( | ) | const |
Output structure of dof handler.
Definition at line 619 of file dofhandler.cc.
|
private |
Obtain dof numbers on ghost elements from other processor.
proc | Neighbouring processor. |
dofs | Array where dofs are stored (output). |
Definition at line 160 of file dofhandler.cc.
|
private |
Send dof numbers to other processor.
proc | Neighbouring processor. |
Definition at line 181 of file dofhandler.cc.
std::shared_ptr< DOFHandlerMultiDim > DOFHandlerMultiDim::sequential | ( | ) |
Returns sequential version of the current dof handler.
Collective on all processors.
Definition at line 88 of file dofhandler.cc.
std::shared_ptr< VecScatter > DOFHandlerMultiDim::sequential_scatter | ( | ) |
Returns scatter context from parallel to sequential vectors.
For sequential dof handler it returns null pointer. Collective on all processors.
Definition at line 95 of file dofhandler.cc.
|
private |
Update dofs on local elements from ghost element dofs.
proc | Neighbouring processor. |
update_cells | Vector of global indices of elements which need to be updated from ghost elements. |
dofs | Vector of dof indices on ghost elements from processor proc . |
node_dof_starts | Vector of starting indices of nodal dofs. |
node_dofs | Vector of nodal dof indices (output). |
Definition at line 204 of file dofhandler.cc.
|
friend |
Definition at line 298 of file dofhandler.hh.
|
staticprivate |
Definition at line 373 of file dofhandler.hh.
|
private |
Starting indices for element dofs.
E.g. dof_indices[cell_starts[idx]] = dof number for first dof on the cell with index idx within the parallel structure. To use with element accessor use the following:
ElementAccessor<3> cell; ... // i-th dof number on the cell dof_indices[cell_starts[row_4_el[cell.idx()]]+i] = ...
For parallel dof handler, only local and ghost elements are stored, but the vector has size mesh_->n_elements()+1.
Definition at line 404 of file dofhandler.hh.
|
private |
Sequential dof handler associated to the current (parallel) one.
Definition at line 384 of file dofhandler.hh.
|
private |
Dof numbers on local and ghost elements.
Dofs are ordered accordingly with cell_starts and local dof order given by the finite element. See cell_starts for more description.
Definition at line 412 of file dofhandler.hh.
|
private |
Pointer to the discrete space for which the handler distributes dofs.
Definition at line 378 of file dofhandler.hh.
Local edge index -> global edge index.
Definition at line 437 of file dofhandler.hh.
|
private |
Local element index -> global element index.
Definition at line 431 of file dofhandler.hh.
|
private |
Distribution of elements.
Definition at line 434 of file dofhandler.hh.
Indices of ghost cells (neighbouring with local elements).
Definition at line 446 of file dofhandler.hh.
|
private |
Processors of ghost elements.
Definition at line 449 of file dofhandler.hh.
Arrays of ghost cells for each neighbouring processor.
Definition at line 452 of file dofhandler.hh.
Maps global element index into local/ghost index (obsolete).
Definition at line 425 of file dofhandler.hh.
|
staticprivate |
Definition at line 374 of file dofhandler.hh.
|
staticprivate |
Flags used during distribution of dofs to mark node and dof status.
Definition at line 371 of file dofhandler.hh.
|
private |
Indicator for parallel/sequential dof handler.
Definition at line 381 of file dofhandler.hh.
|
private |
Maps local and ghost dof indices to global ones.
First lsize_ entries correspond to dofs owned by local processor, the remaining entries are ghost dofs sorted by neighbouring processor id.
Definition at line 420 of file dofhandler.hh.
Local neighbour index -> global neighbour index.
Definition at line 440 of file dofhandler.hh.
Indices of local nodes in mesh tree.
Definition at line 443 of file dofhandler.hh.
|
private |
Global element index -> index according to partitioning.
Definition at line 428 of file dofhandler.hh.
|
private |
Scatter context for parallel to sequential vectors.
Definition at line 387 of file dofhandler.hh.
|
staticprivate |
Definition at line 372 of file dofhandler.hh.