v0.14.0
Public Types | Public Member Functions | Private Types | Private Member Functions | List of all members
MoFEM::CreateRowCompressedADJMatrix Struct Reference

Create compressed matrix. More...

Inheritance diagram for MoFEM::CreateRowCompressedADJMatrix:
[legend]
Collaboration diagram for MoFEM::CreateRowCompressedADJMatrix:
[legend]

Public Types

using ProblemsByName = Problem_multiIndex::index< Problem_mi_tag >::type
 
- Public Types inherited from MoFEM::CoreTmp< 0 >
enum  SemaphoresBuildMofem {
  BUILD_FIELD = 1 << 0, BUILD_FE = 1 << 1, BUILD_ADJ = 1 << 2, BUILD_PROBLEM = 1 << 3,
  PARTITION_PROBLEM = 1 << 4, PARTITION_FE = 1 << 5, PARTITION_GHOST_DOFS = 1 << 6, PARTITION_MESH = 1 << 7
}
 

Public Member Functions

 CreateRowCompressedADJMatrix (moab::Interface &moab, MPI_Comm comm=PETSC_COMM_WORLD, int verbose=1)
 
template<typename TAG >
MoFEMErrorCode createMatArrays (ProblemsByName::iterator p_miit, const MatType type, std::vector< PetscInt > &i, std::vector< PetscInt > &j, const bool no_diagonals=true, int verb=QUIET) const
 Create matrix adjacencies. More...
 
- Public Member Functions inherited from MoFEM::CoreTmp< 0 >
const int getValue () const
 Get the core. More...
 
RefEntityTmp< 0 > getRefEntity (const EntityHandle ent)
 
virtual boost::shared_ptr< RefEntityTmp< 0 > > make_shared_ref_entity (const EntityHandle ent)
 Get RefEntity. More...
 
 CoreTmp (moab::Interface &moab, MPI_Comm comm=PETSC_COMM_WORLD, const int verbose=VERBOSE)
 
 ~CoreTmp ()
 
MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 Getting interface of core database. More...
 
Tag get_th_RefParentHandle () const
 
Tag get_th_RefBitLevel () const
 
Tag get_th_RefBitEdge () const
 
int & getBuildMoFEM () const
 Get flags/semaphores for different stages. More...
 
MoFEMErrorCode addPrismToDatabase (const EntityHandle prism, int verb=DEFAULT_VERBOSITY)
 add prim element More...
 
- Public Member Functions inherited from MoFEM::DeprecatedCoreInterface
virtual DEPRECATED MoFEMErrorCode seed_ref_level_2D (const EntityHandle meshset, const BitRefLevel &bit, int verb=-1)
 seed 2D entities (Triangles entities only) in the meshset and their adjacencies (only TRIs adjacencies) in a particular BitRefLevel More...
 
DEPRECATED MoFEMErrorCode seed_ref_level_3D (const EntityHandle meshset, const BitRefLevel &bit, int verb=-1)
 seed 2D entities in the meshset and their adjacencies (only TETs adjacencies) in a particular BitRefLevel More...
 
DEPRECATED MoFEMErrorCode seed_ref_level (const Range &ents, const BitRefLevel &bit, const bool only_tets=true, int verb=-1)
 seed entities in the range and their adjacencies in a particular BitRefLevel More...
 
DEPRECATED MoFEMErrorCode partition_mesh (const Range &ents, const int dim, const int adj_dim, const int n_parts, int verb=-1)
 Set partition tag to each finite element in the problem. More...
 
DEPRECATED MoFEMErrorCode synchronise_entities (Range &ent, int verb=DEFAULT_VERBOSITY)
 
DEPRECATED MoFEMErrorCode synchronise_field_entities (const std::string &name, int verb=DEFAULT_VERBOSITY)
 
- Public Member Functions inherited from MoFEM::CoreInterface
virtual ~CoreInterface ()=default
 
virtual MoFEMErrorCode add_broken_field (const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const std::vector< std::pair< EntityType, std::function< MoFEMErrorCode(BaseFunction::DofsSideMap &)>> > list_dof_side_map, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
 Add field. More...
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface reference to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface. More...
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface. More...
 
virtual ~UnknownInterface ()=default
 

Private Types

using AdjByEnt = FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index< Unique_mi_tag >::type
 
using DofByGlobalPetscIndex = NumeredDofEntity_multiIndex::index< PetscGlobalIdx_mi_tag >::type
 

Private Member Functions

template<typename TAG >
MoFEMErrorCode getEntityAdjacencies (ProblemsByName::iterator p_miit, typename boost::multi_index::index< NumeredDofEntity_multiIndex, TAG >::type::iterator mit_row, boost::shared_ptr< FieldEntity > mofem_ent_ptr, std::vector< int > &dofs_col_view, int verb) const
 Get element adjacencies. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from MoFEM::CoreTmp< 0 >
static MoFEMErrorCode Initialize (int *argc, char ***args, const char file[], const char help[])
 Initializes the MoFEM database PETSc, MOAB and MPI. More...
 
static MoFEMErrorCode Finalize ()
 Checks for options to be called at the conclusion of the program. More...
 
static void setRefEntBasicDataPtr (MoFEM::Interface &m_field, boost::shared_ptr< BasicEntityData > &ptr)
 
static boost::shared_ptr< RefEntityTmp< 0 > > makeSharedRefEntity (MoFEM::Interface &m_field, const EntityHandle ent)
 
- Static Public Member Functions inherited from MoFEM::UnknownInterface
static MoFEMErrorCode getLibVersion (Version &version)
 Get library version. More...
 
static MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version)
 Get database major version. More...
 
static MoFEMErrorCode setFileVersion (moab::Interface &moab, Version version=Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD))
 Get database major version. More...
 
static MoFEMErrorCode getInterfaceVersion (Version &version)
 Get database major version. More...
 
- Static Public Attributes inherited from MoFEM::CoreTmp< 0 >
static constexpr int value = 0
 
- Protected Member Functions inherited from MoFEM::CoreTmp< 0 >
template<int V>
 CoreTmp (moab::Interface &moab, MPI_Comm comm, const int verbose, CoreValue< V >)
 
MoFEMErrorCode coreGenericConstructor (moab::Interface &moab, MPI_Comm comm, const int verbose)
 
MoFEMErrorCode addProblem (const BitProblemId id, const std::string &name, int verb=DEFAULT_VERBOSITY)
 add problem More...
 
MoFEMErrorCode getTags (int verb=DEFAULT_VERBOSITY)
 Get tag handles. More...
 
MoFEMErrorCode clearMap ()
 Cleaning database. More...
 
MoFEMErrorCode registerSubInterfaces ()
 Register insterfaces. More...
 
BitProblemId getProblemShift ()
 Return unique problem Id. More...
 
MoFEMErrorCode initialiseDatabaseFromMesh (int verb=DEFAULT_VERBOSITY)
 Initialize database getting information on mesh. More...
 
MoFEMErrorCode getOptions (int verb=DEFAULT_VERBOSITY)
 Get core options from command line. More...
 
template<class IFACE >
MoFEMErrorCode regSubInterface ()
 Register sub-interfaces in core interface. More...
 
template<class IFACE >
MoFEMErrorCode regEvents ()
 Register petsc events. More...
 
boost::shared_ptr< BasicEntityData > & get_basic_entity_data_ptr ()
 Get pointer to basic entity data. More...
 
moab::Interface & get_moab ()
 
const moab::Interface & get_moab () const
 
MoFEMErrorCode set_moab_interface (moab::Interface &new_moab, int verb=VERBOSE)
 Set the moab interface object. More...
 
MoFEMErrorCode setMoabInterface (moab::Interface &new_moab, int verb=VERBOSE)
 
MoFEMErrorCode check_number_of_ents_in_ents_field (const std::string &name) const
 check data consistency in entitiesPtr More...
 
MoFEMErrorCode check_number_of_ents_in_ents_field () const
 check data consistency in entitiesPtr More...
 
MoFEMErrorCode check_number_of_ents_in_ents_finite_element (const std::string &name) const
 check data consistency in entsFiniteElements More...
 
MoFEMErrorCode check_number_of_ents_in_ents_finite_element () const
 check data consistency in entsFiniteElements More...
 
MoFEMErrorCode clear_database (int verb=DEFAULT_VERBOSITY)
 Clear database. More...
 
MoFEMErrorCode rebuild_database (int verb=DEFAULT_VERBOSITY)
 Clear database and initialize it once again. More...
 
MeshsetsManagerget_meshsets_manager_ptr ()
 get MeshsetsManager pointer More...
 
const MeshsetsManagerget_meshsets_manager_ptr () const
 get MeshsetsManager pointer More...
 
MeshsetsManagerget_meshsets_manager ()
 get MeshsetsManager pointer More...
 
const MeshsetsManagerget_meshsets_manager () const
 get MeshsetsManager pointer More...
 
MoFEMErrorCode remove_parents_by_ents (const Range &ents, int verb=DEFAULT_VERBOSITY)
 Remove parents from entities. More...
 
MoFEMErrorCode remove_parents_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 Remove parent from entities on bit level. More...
 
MoFEMErrorCode remove_parents_by_parents (const Range &ents, int verb=DEFAULT_VERBOSITY)
 Remove paremts from entities having parents in passed range. More...
 
MoFEMErrorCode remove_ents (const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities form mofem database More...
 
MoFEMErrorCode remove_ents_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 remove entities form mofem database More...
 
MoFEMErrorCode delete_ents_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, const bool remove_parent=false, int verb=DEFAULT_VERBOSITY, MoFEMTypes mf=MF_ZERO)
 delete entities form mofem and moab database More...
 
virtual MoFEMErrorCode add_broken_field (const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_coefficients, std::vector< std::pair< EntityType, std::function< MoFEMErrorCode(BaseFunction::DofsSideMap &)> >> list_dof_side_map, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 Add field. More...
 
virtual MoFEMErrorCode add_field (const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 Add field. More...
 
MoFEMErrorCode delete_field (const std::string name, int verb=DEFAULT_VERBOSITY)
 Delete field. More...
 
MoFEMErrorCode addField (const std::string &name, const FieldSpace space, const FieldContinuity continuity, const FieldApproximationBase base, const FieldCoefficientsNumber nb_coefficients, const TagType tag_type, const enum MoFEMTypes bh, int verb)
 Template for add_field. More...
 
MoFEMErrorCode addEntsToFieldByDim (const Range &ents, const int dim, const std::string &name, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode add_ents_to_field_by_dim (const Range &ents, const int dim, const std::string &name, int verb=DEFAULT_VERBOSITY)
 Add entities to field meshset. More...
 
MoFEMErrorCode add_ents_to_field_by_type (const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)
 Add entities to field meshset. More...
 
MoFEMErrorCode add_ents_to_field_by_dim (const EntityHandle meshset, const int dim, const std::string &name, const bool recursive=true, int verb=DEFAULT_VERBOSITY)
 Add entities to field meshset. More...
 
MoFEMErrorCode add_ents_to_field_by_type (const EntityHandle meshset, const EntityType type, const std::string &name, const bool recursive=true, int verb=DEFAULT_VERBOSITY)
 Add entities to field meshset. More...
 
MoFEMErrorCode create_vertices_and_add_to_field (const std::string name, const double coords[], int size, int verb=DEFAULT_VERBOSITY)
 Create a vertices and add to field object. More...
 
MoFEMErrorCode setFieldOrder (const Range &ents, const BitFieldId id, const ApproximationOrder order, int ver)
 
MoFEMErrorCode setFieldOrderImpl (boost::shared_ptr< Field > field_ptr, const Range &ents, const ApproximationOrder order, int verb)
 
MoFEMErrorCode set_field_order (const Range &ents, const BitFieldId id, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode set_field_order (const EntityHandle meshset, const EntityType type, const BitFieldId id, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode set_field_order (const Range &ents, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)
 Set order approximation of the entities in the field. More...
 
MoFEMErrorCode set_field_order (const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)
 Set order approximation of the entities in the field. More...
 
MoFEMErrorCode set_field_order_by_entity_type_and_bit_ref (const BitRefLevel &bit, const BitRefLevel &mask, const EntityType type, const BitFieldId id, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode set_field_order_by_entity_type_and_bit_ref (const BitRefLevel &bit, const BitRefLevel &mask, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)
 Set order approximation of the entities in the field. More...
 
MoFEMErrorCode buildFieldForNoFieldImpl (boost::shared_ptr< Field > field_ptr, std::map< EntityType, int > &dof_counter, int verb)
 
MoFEMErrorCode buildFieldForNoField (const BitFieldId id, std::map< EntityType, int > &dof_counter, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode buildFieldForL2H1HcurlHdiv (const BitFieldId id, std::map< EntityType, int > &dof_counter, std::map< EntityType, int > &inactive_dof_counter, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode buildField (const boost::shared_ptr< Field > &field, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode build_fields (int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode build_field (const std::string field_name, int verb=DEFAULT_VERBOSITY)
 build field by name More...
 
MoFEMErrorCode clear_inactive_dofs (int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_dofs_fields_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_dofs_fields (const Range ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_dofs_fields (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_ents_fields_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_ents_fields (const Range ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_ents_fields (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode remove_ents_from_field_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 remove entities from field More...
 
MoFEMErrorCode remove_ents_from_field (const std::string name, const EntityHandle meshset, const EntityType type, int verb=DEFAULT_VERBOSITY)
 remove entities from field More...
 
MoFEMErrorCode remove_ents_from_field (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from field More...
 
MoFEMErrorCode remove_ents_from_field (const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from all fields More...
 
MoFEMErrorCode list_dofs_by_field_name (const std::string &name) const
 
MoFEMErrorCode list_fields () const
 list entities in the field More...
 
BitFieldId get_field_id (const std::string &name) const
 Get field Id. More...
 
FieldBitNumber get_field_bit_number (const std::string name) const
 get field bit number More...
 
std::string get_field_name (const BitFieldId id) const
 get field name from id More...
 
EntityHandle get_field_meshset (const BitFieldId id) const
 
EntityHandle get_field_meshset (const std::string name) const
 get field meshset More...
 
MoFEMErrorCode get_field_entities_by_dimension (const std::string name, int dim, Range &ents) const
 get entities in the field by dimension More...
 
MoFEMErrorCode get_field_entities_by_type (const std::string name, EntityType type, Range &ents) const
 get entities in the field by type More...
 
MoFEMErrorCode get_field_entities_by_handle (const std::string name, Range &ents) const
 get entities in the field by handle More...
 
bool check_field (const std::string &name) const
 check if field is in database More...
 
const Fieldget_field_structure (const std::string &name, enum MoFEMTypes bh=MF_EXIST) const
 get field structure More...
 
const FiniteElementget_finite_element_structure (const std::string &name, enum MoFEMTypes bh=MF_EXCL) const
 get finite element struture More...
 
bool check_finite_element (const std::string &name) const
 Check if finite element is in database. More...
 
MoFEMErrorCode add_finite_element (const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 add finite element More...
 
MoFEMErrorCode modify_finite_element_adjacency_table (const std::string &fe_name, const EntityType type, ElementAdjacencyFunct function)
 modify finite element table, only for advanced user More...
 
MoFEMErrorCode modify_finite_element_add_field_data (const std::string &fe_name, const std::string name_filed)
 set finite element field data More...
 
MoFEMErrorCode modify_finite_element_add_field_row (const std::string &fe_name, const std::string name_row)
 set field row which finite element use More...
 
MoFEMErrorCode modify_finite_element_add_field_col (const std::string &fe_name, const std::string name_col)
 set field col which finite element use More...
 
MoFEMErrorCode modify_finite_element_off_field_data (const std::string &fe_name, const std::string name_filed)
 unset finite element field data More...
 
MoFEMErrorCode modify_finite_element_off_field_row (const std::string &fe_name, const std::string name_row)
 unset field row which finite element use More...
 
MoFEMErrorCode modify_finite_element_off_field_col (const std::string &fe_name, const std::string name_col)
 unset field col which finite element use More...
 
MoFEMErrorCode add_ents_to_finite_element_by_type (const EntityHandle meshset, const EntityType type, const std::string &name, const bool recursive=true)
 add entities to finite element More...
 
MoFEMErrorCode add_ents_to_finite_element_by_dim (const EntityHandle meshset, const int dim, const std::string &name, const bool recursive=true)
 add entities to finite element More...
 
MoFEMErrorCode add_ents_to_finite_element_by_type (const Range &ents, const EntityType type, const std::string &name)
 add entities to finite elements More...
 
MoFEMErrorCode add_ents_to_finite_element_by_dim (const Range &ents, const int dim, const std::string &name)
 add entities to finite elements More...
 
MoFEMErrorCode add_ents_to_finite_element_by_bit_ref (const BitRefLevel &bit, const BitRefLevel &mask, const std::string &name, EntityType type, int verb=DEFAULT_VERBOSITY)
 add TET entities from given refinement level to finite element database given by name More...
 
MoFEMErrorCode add_ents_to_finite_element_by_MESHSET (const EntityHandle meshset, const std::string &name, const bool recursive=false)
 add MESHSET element to finite element database given by name More...
 
DEPRECATED MoFEMErrorCode add_ents_to_finite_element_EntType_by_bit_ref (const BitRefLevel &bit, const std::string &name, EntityType type, int verb=DEFAULT_VERBOSITY)
 
DEPRECATED MoFEMErrorCode add_ents_to_finite_element_EntType_by_bit_ref (const BitRefLevel &bit, const BitRefLevel &mask, const std::string &name, EntityType type, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode remove_ents_from_finite_element_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 remove elements from given refinement level to finite element database More...
 
MoFEMErrorCode remove_ents_from_finite_element (const std::string name, const EntityHandle meshset, const EntityType type, int verb=DEFAULT_VERBOSITY)
 remove entities from given refinement level to finite element database More...
 
MoFEMErrorCode remove_ents_from_finite_element (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from finite element database More...
 
MoFEMErrorCode remove_ents_from_finite_element (const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from finite elements in database More...
 
MoFEMErrorCode delete_finite_element (const std::string name, int verb=DEFAULT_VERBOSITY)
 delete finite element from mofem database More...
 
BitFEId getBitFEId (const std::string &fe_name) const
 Get field Id. More...
 
std::string getBitFEIdName (const BitFEId id) const
 Get field name. More...
 
EntityHandle get_finite_element_meshset (const BitFEId id) const
 
EntityHandle get_finite_element_meshset (const std::string name) const
 
MoFEMErrorCode get_finite_element_entities_by_dimension (const std::string name, int dim, Range &ents) const
 get entities in the finite element by dimension More...
 
MoFEMErrorCode get_finite_element_entities_by_type (const std::string name, EntityType type, Range &ents) const
 get entities in the finite element by type More...
 
MoFEMErrorCode get_finite_element_entities_by_handle (const std::string name, Range &ents) const
 get entities in the finite element by handle More...
 
MoFEMErrorCode list_finite_elements () const
 list finite elements in database More...
 
MoFEMErrorCode add_problem (const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 Add problem. More...
 
bool check_problem (const std::string name)
 check if problem exist More...
 
MoFEMErrorCode delete_problem (const std::string name)
 Delete problem. More...
 
MoFEMErrorCode modify_problem_add_finite_element (const std::string name_problem, const std::string &fe_name)
 add finite element to problem, this add entities assigned to finite element to a particular problem More...
 
MoFEMErrorCode modify_problem_unset_finite_element (const std::string name_problem, const std::string &fe_name)
 unset finite element from problem, this remove entities assigned to finite element to a particular problem More...
 
MoFEMErrorCode modify_problem_ref_level_add_bit (const std::string &name_problem, const BitRefLevel &bit)
 add ref level to problem More...
 
MoFEMErrorCode modify_problem_ref_level_set_bit (const std::string &name_problem, const BitRefLevel &bit)
 set ref level for problem More...
 
MoFEMErrorCode modify_problem_mask_ref_level_add_bit (const std::string &name_problem, const BitRefLevel &bit)
 set dof mask ref level for problem More...
 
MoFEMErrorCode modify_problem_mask_ref_level_set_bit (const std::string &name_problem, const BitRefLevel &bit)
 set dof mask ref level for problem More...
 
BitProblemId getBitProblemId (const std::string &name) const
 
MoFEMErrorCode list_problem () const
 list problems More...
 
MoFEMErrorCode clear_problem (const std::string name, int verb=DEFAULT_VERBOSITY)
 clear problem More...
 
MoFEMErrorCode clear_problems (int verb=DEFAULT_VERBOSITY)
 clear problems More...
 
MoFEMErrorCode build_finite_elements (int verb=DEFAULT_VERBOSITY)
 Build finite elements. More...
 
MoFEMErrorCode build_finite_elements (const BitRefLevel &bit, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode build_finite_elements (const string fe_name, const Range *const ents_ptr=nullptr, int verb=DEFAULT_VERBOSITY)
 Build finite elements. More...
 
MoFEMErrorCode buildFiniteElements (const boost::shared_ptr< FiniteElement > &fe, const Range *ents_ptr=NULL, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_finite_elements_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_finite_elements (const Range &ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_finite_elements (const std::string &fe_name, const Range &ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode get_problem_finite_elements_entities (const std::string name, const std::string &fe_name, const EntityHandle meshset)
 add finite elements to the meshset More...
 
DEPRECATED MoFEMErrorCode build_problem_on_distributed_mesh (int verb=DEFAULT_VERBOSITY)
 
DEPRECATED MoFEMErrorCode build_problems (int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode build_adjacencies (const Range &ents, int verb=DEFAULT_VERBOSITY)
 build adjacencies More...
 
MoFEMErrorCode build_adjacencies (const BitRefLevel &bit, int verb=DEFAULT_VERBOSITY)
 build adjacencies More...
 
MoFEMErrorCode build_adjacencies (const BitRefLevel &bit, const BitRefLevel &mask, int verb=DEFAULT_VERBOSITY)
 build adjacencies More...
 
MoFEMErrorCode clear_adjacencies_entities (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 clear adjacency map for entities on given bit level More...
 
MoFEMErrorCode clear_adjacencies_entities (const Range ents, int verb=DEFAULT_VERBOSITY)
 clear adjacencies for field entities by entities More...
 
MoFEMErrorCode clear_adjacencies_entities (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 clear adjacencies for field entities by entities and field namd More...
 
MoFEMErrorCode clear_adjacencies_finite_elements (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 clear adjacency map for finite elements on given bit level More...
 
MoFEMErrorCode clear_adjacencies_finite_elements (const Range ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode clear_adjacencies_finite_elements (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode problem_basic_method_preProcess (const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)
 Set data for BasicMethod. More...
 
MoFEMErrorCode problem_basic_method_preProcess (const std::string &problem_name, BasicMethod &method, int verb=DEFAULT_VERBOSITY)
 Set data for BasicMethod. More...
 
MoFEMErrorCode problem_basic_method_postProcess (const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)
 Set data for BasicMethod. More...
 
MoFEMErrorCode problem_basic_method_postProcess (const std::string &problem_name, BasicMethod &method, int verb=DEFAULT_VERBOSITY)
 Set data for BasicMethod. More...
 
MoFEMErrorCode cache_problem_entities (const std::string prb_name, CacheTupleWeakPtr cache_ptr)
 Cache variables. More...
 
MoFEMErrorCode loop_finite_elements (const Problem *problem_ptr, const std::string &fe_name, FEMethod &method, int lower_rank, int upper_rank, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)
 Make a loop over finite elements on partitions from upper to lower rank. More...
 
MoFEMErrorCode loop_finite_elements (const std::string problem_name, const std::string &fe_name, FEMethod &method, int lower_rank, int upper_rank, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)
 Make a loop over finite elements on partitions from upper to lower rank. More...
 
MoFEMErrorCode loop_finite_elements (const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)
 Make a loop over finite elements. More...
 
MoFEMErrorCode loop_dofs (const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)
 Make a loop over dofs. More...
 
MoFEMErrorCode loop_dofs (const std::string &problem_name, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)
 Make a loop over dofs. More...
 
MoFEMErrorCode loop_dofs (const std::string &problem_name, const std::string &field_name, RowColData rc, DofMethod &method, int verb=DEFAULT_VERBOSITY)
 Make a loop over dofs. More...
 
MoFEMErrorCode loop_dofs (const std::string &field_name, DofMethod &method, int verb=DEFAULT_VERBOSITY)
 Make a loop over dofs. More...
 
MoFEMErrorCode loop_entities (const Problem *problem_ptr, const std::string field_name, RowColData rc, EntityMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)
 Loop over field entities in the problem. More...
 
MoFEMErrorCode loop_entities (const std::string problem_name, const std::string field_name, RowColData rc, EntityMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)
 Loop over field entities in the problem. More...
 
MoFEMErrorCode loop_entities (const std::string problem_name, const std::string field_name, RowColData rc, EntityMethod &method, int verb=DEFAULT_VERBOSITY)
 Loop over field entities in the problem. More...
 
MoFEMErrorCode loop_entities (const std::string field_name, EntityMethod &method, Range const *const ents=nullptr, int verb=DEFAULT_VERBOSITY)
 Loop over field entities. More...
 
MoFEMErrorCode get_fields (const Field_multiIndex **fields_ptr) const
 Get fields multi-index from database. More...
 
MoFEMErrorCode get_ref_ents (const RefEntity_multiIndex **refined_entities_ptr) const
 Get ref entities multi-index from database. More...
 
MoFEMErrorCode get_ref_finite_elements (const RefElement_multiIndex **refined_finite_elements_ptr) const
 Get ref finite elements multi-index form database. More...
 
MoFEMErrorCode get_finite_elements (const FiniteElement_multiIndex **fe_ptr) const
 Get finite elements multi-index. More...
 
MoFEMErrorCode get_ents_finite_elements (const EntFiniteElement_multiIndex **fe_ent_ptr) const
 Get entities finite elements multi-index. More...
 
MoFEMErrorCode get_field_ents (const FieldEntity_multiIndex **field_ents) const
 Get field multi index. More...
 
MoFEMErrorCode get_dofs (const DofEntity_multiIndex **dofs_ptr) const
 Get dofs multi index. More...
 
MoFEMErrorCode get_problem (const std::string &problem_name, const Problem **problem_ptr) const
 Get problem database (data structure) More...
 
MoFEMErrorCode get_problems (const Problem_multiIndex **problems_ptr) const
 Get pointer to problems multi-index. More...
 
MoFEMErrorCode get_ents_elements_adjacency (const FieldEntityEntFiniteElementAdjacencyMap_multiIndex **dofs_elements_adjacency) const
 Get the dofs elements adjacency object. More...
 
const Field_multiIndexget_fields () const
 Get the fields object. More...
 
const RefEntity_multiIndexget_ref_ents () const
 Get the ref ents object. More...
 
const RefElement_multiIndexget_ref_finite_elements () const
 Get the ref finite elements object. More...
 
const FiniteElement_multiIndexget_finite_elements () const
 Get the finite elements object. More...
 
const EntFiniteElement_multiIndexget_ents_finite_elements () const
 Get the ents finite elements object. More...
 
const FieldEntity_multiIndexget_field_ents () const
 Get the field ents object. More...
 
const DofEntity_multiIndexget_dofs () const
 Get the dofs object. More...
 
const Problemget_problem (const std::string problem_name) const
 Get the problem object. More...
 
const Problem_multiIndexget_problems () const
 Get the problems object. More...
 
const FieldEntityEntFiniteElementAdjacencyMap_multiIndexget_ents_elements_adjacency () const
 Get the dofs elements adjacency object. More...
 
FieldEntityByUId::iterator get_ent_field_by_name_begin (const std::string &field_name) const
 get begin iterator of field ents of given name (instead you can use IT_GET_ENT_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT) More...
 
FieldEntityByUId::iterator get_ent_field_by_name_end (const std::string &field_name) const
 get begin iterator of field dofs of given name (instead you can use IT_GET_ENT_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT) More...
 
DofEntityByUId::iterator get_dofs_by_name_begin (const std::string &field_name) const
 get begin iterator of field dofs of given name (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT) More...
 
DofEntityByUId::iterator get_dofs_by_name_end (const std::string &field_name) const
 get begin iterator of field dofs of given name (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT) More...
 
DofEntityByUId::iterator get_dofs_by_name_and_ent_begin (const std::string &field_name, const EntityHandle ent) const
 get begin iterator of field dofs of given name and ent(instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,ENT,IT) More...
 
DofEntityByUId::iterator get_dofs_by_name_and_ent_end (const std::string &field_name, const EntityHandle ent) const
 get begin iterator of field dofs of given name and ent (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,ENT,IT) More...
 
DofEntityByUId::iterator get_dofs_by_name_and_type_begin (const std::string &field_name, const EntityType type) const
 get begin iterator of field dofs of given name and ent type (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,TYPE,IT) More...
 
DofEntityByUId::iterator get_dofs_by_name_and_type_end (const std::string &field_name, const EntityType ent) const
 get begin iterator of field dofs of given name end ent type(instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,TYPE,IT) More...
 
EntFiniteElement_multiIndex::index< Unique_mi_tag >::type::iterator get_fe_by_name_begin (const std::string &fe_name) const
 get begin iterator of finite elements of given name (instead you can use IT_GET_FES_BY_NAME_FOR_LOOP(MFIELD,NAME,IT) More...
 
EntFiniteElement_multiIndex::index< Unique_mi_tag >::type::iterator get_fe_by_name_end (const std::string &fe_name) const
 get end iterator of finite elements of given name (instead you can use IT_GET_FES_BY_NAME_FOR_LOOP(MFIELD,NAME,IT) More...
 
MPI_Comm & get_comm () const
 
int get_comm_size () const
 
int get_comm_rank () const
 
- Protected Attributes inherited from MoFEM::CoreTmp< 0 >
boost::shared_ptr< WrapMPICommwrapMPIMOABComm
 manage creation and destruction of MOAB communicator More...
 
int verbose
 Verbosity level. More...
 
boost::ptr_map< boost::typeindex::type_index, UnknownInterfaceiFaces
 Hash map of pointers to interfaces. More...
 
int * buildMoFEM
 keeps flags/semaphores for different stages More...
 
std::string optionsPrefix
 Prefix for options on command line. More...
 
PetscBool initaliseAndBuildField
 
PetscBool initaliseAndBuildFiniteElements
 
Tag th_Part
 Tag for partition number. More...
 
Tag th_RefParentHandle
 
Tag th_RefBitLevel
 
Tag th_RefBitLevel_Mask
 
Tag th_RefBitEdge
 
Tag th_RefFEMeshset
 
Tag th_FieldId
 
Tag th_FieldName
 
Tag th_FieldName_DataNamePrefix
 
Tag th_FieldSpace
 
Tag th_FieldContinuity
 
Tag th_FieldBase
 
Tag th_FEId
 
Tag th_FEName
 
Tag th_FEIdCol
 
Tag th_FEIdRow
 
Tag th_FEIdData
 
Tag th_ProblemId
 
Tag th_ProblemName
 
Tag th_ProblemFEId
 
Tag th_ProblemNbDofsRow
 
Tag th_ProblemNbDofsCol
 
Tag th_ProblemLocalNbDofRow
 
Tag th_ProblemGhostNbDofRow
 
Tag th_ProblemLocalNbDofCol
 
Tag th_ProblemGhostNbDofCol
 
Tag th_ProblemShift
 
Tag th_ElemType
 Needed for VTK files. More...
 
Tag th_MoFEMBuild
 
boost::shared_ptr< BasicEntityDatabasicEntityDataPtr
 
RefEntity_multiIndex refinedEntities
 refined entities More...
 
RefElement_multiIndex refinedFiniteElements
 refined elements More...
 
Field_multiIndex fIelds
 fields More...
 
FieldEntity_multiIndex entsFields
 entities on fields More...
 
DofEntity_multiIndex dofsField
 dofs on fields More...
 
FiniteElement_multiIndex finiteElements
 finite elements More...
 
EntFiniteElement_multiIndex entsFiniteElements
 finite element entities More...
 
FieldEntityEntFiniteElementAdjacencyMap_multiIndex entFEAdjacencies
 adjacencies of elements to dofs More...
 
Problem_multiIndex pRoblems
 problems multi-index More...
 
std::reference_wrapper< moab::Interface > moab
 moab database More...
 
PetscLogEvent MOFEM_EVENT_preProcess
 Event for preProcess finite element. More...
 
PetscLogEvent MOFEM_EVENT_operator
 Event for evaluating operator of finite element. More...
 
PetscLogEvent MOFEM_EVENT_postProcess
 Event for postProcess finite element. More...
 
PetscLogEvent MOFEM_EVENT_createMat
 
MPI_Comm mofemComm
 MoFEM communicator. More...
 
ParallelComm * pComm
 MOAB communicator structure. More...
 
int sIze
 MoFEM communicator size. More...
 
int rAnk
 MOFEM communicator rank. More...
 
- Static Protected Attributes inherited from MoFEM::CoreTmp< 0 >
static bool isGloballyInitialised = false
 Core base globally initialized. More...
 
static int mpiInitialised
 mpi was initialised by other agent More...
 
static PetscBool isInitialized
 petsc was initialised by other agent More...
 

Detailed Description

Create compressed matrix.

Note
Only function class members are allowed in this class. NO VARIABLES.
Todo:
It is obsolete implementation, code should be moved to interface MatrixManager.
Todo:
While matrix is created is assumed that all entities on element are adjacent to each other, in some cases, this is created denser matrices than it should be. Some kind of filtering can be added.
Todo:
Creation of the block matrices
Todo:
Some efficiency improvement are possible

Definition at line 33 of file MatrixManager.cpp.

Member Typedef Documentation

◆ AdjByEnt

using MoFEM::CreateRowCompressedADJMatrix::AdjByEnt = FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index< Unique_mi_tag>::type
private

Definition at line 59 of file MatrixManager.cpp.

◆ DofByGlobalPetscIndex

using MoFEM::CreateRowCompressedADJMatrix::DofByGlobalPetscIndex = NumeredDofEntity_multiIndex::index<PetscGlobalIdx_mi_tag>::type
private

Definition at line 62 of file MatrixManager.cpp.

◆ ProblemsByName

using MoFEM::CreateRowCompressedADJMatrix::ProblemsByName = Problem_multiIndex::index<Problem_mi_tag>::type

Definition at line 40 of file MatrixManager.cpp.

Constructor & Destructor Documentation

◆ CreateRowCompressedADJMatrix()

MoFEM::CreateRowCompressedADJMatrix::CreateRowCompressedADJMatrix ( moab::Interface &  moab,
MPI_Comm  comm = PETSC_COMM_WORLD,
int  verbose = 1 
)
inline

Definition at line 35 of file MatrixManager.cpp.

38  : Core(moab, comm, verbose) {}

Member Function Documentation

◆ createMatArrays()

template<typename TAG >
MoFEMErrorCode MoFEM::CreateRowCompressedADJMatrix::createMatArrays ( ProblemsByName::iterator  p_miit,
const MatType  type,
std::vector< PetscInt > &  i,
std::vector< PetscInt > &  j,
const bool  no_diagonals = true,
int  verb = QUIET 
) const

Create matrix adjacencies.

Depending on TAG type, which some structure used to number dofs, matrix is partitioned using part number stored in multi-index, or is partitioned on parts based only on index number.

See: Idx_mi_tag PetscGlobalIdx_mi_tag and PetscLocalIdx_mi_tag

Definition at line 160 of file MatrixManager.cpp.

163  {
165 
166  PetscLogEventBegin(MOFEM_EVENT_createMat, 0, 0, 0, 0);
167 
168  auto cache = boost::make_shared<std::vector<EntityCacheNumeredDofs>>(
169  entsFields.size());
170 
171  size_t idx = 0;
172  for (auto it = entsFields.begin(); it != entsFields.end(); ++it, ++idx) {
173 
174  const auto uid = (*it)->getLocalUniqueId();
175  auto r = entFEAdjacencies.get<Unique_mi_tag>().equal_range(uid);
176  for (auto lo = r.first; lo != r.second; ++lo) {
177 
178  if ((lo->getBitFEId() & p_miit->getBitFEId()).any()) {
179 
180  const BitRefLevel &prb_bit = p_miit->getBitRefLevel();
181  const BitRefLevel &prb_mask = p_miit->getBitRefLevelMask();
182  const BitRefLevel &fe_bit = lo->entFePtr->getBitRefLevel();
183 
184  // if entity is not problem refinement level
185  if ((fe_bit & prb_mask) != fe_bit)
186  continue;
187  if ((fe_bit & prb_bit).none())
188  continue;
189 
190  auto dit = p_miit->numeredColDofsPtr->lower_bound(uid);
191 
192  decltype(dit) hi_dit;
193  if (dit != p_miit->numeredColDofsPtr->end())
194  hi_dit = p_miit->numeredColDofsPtr->upper_bound(
195  uid | static_cast<UId>(MAX_DOFS_ON_ENTITY - 1));
196  else
197  hi_dit = dit;
198 
199  (*it)->entityCacheColDofs =
200  boost::shared_ptr<EntityCacheNumeredDofs>(cache, &((*cache)[idx]));
201  (*cache)[idx].loHi = {dit, hi_dit};
202 
203  break;
204  }
205  }
206  }
207 
208  using NumeredDofEntitysByIdx =
209  typename boost::multi_index::index<NumeredDofEntity_multiIndex,
210  TAG>::type;
211 
212  // Get multi-indices for rows and columns
213  const NumeredDofEntitysByIdx &dofs_row_by_idx =
214  p_miit->numeredRowDofsPtr->get<TAG>();
215  int nb_dofs_row = p_miit->getNbDofsRow();
216  if (nb_dofs_row == 0) {
217  SETERRQ1(mofemComm, MOFEM_DATA_INCONSISTENCY, "problem <%s> has zero rows",
218  p_miit->getName().c_str());
219  }
220 
221  // Get adjacencies form other processors
222  std::map<int, std::vector<int>> adjacent_dofs_on_other_parts;
223 
224  // If not partitioned set petsc layout for matrix. If partitioned need to get
225  // adjacencies form other parts. Note if algebra is only partitioned no need
226  // to collect adjacencies form other entities. Those are already on mesh
227  // which is assumed that is on each processor the same.
228  typename boost::multi_index::index<NumeredDofEntity_multiIndex,
229  TAG>::type::iterator miit_row,
230  hi_miit_row;
231 
232  if (TAG::IamNotPartitioned) {
233 
234  // Get range of local indices
235  PetscLayout layout;
236  CHKERR PetscLayoutCreate(mofemComm, &layout);
237  CHKERR PetscLayoutSetBlockSize(layout, 1);
238  CHKERR PetscLayoutSetSize(layout, nb_dofs_row);
239  CHKERR PetscLayoutSetUp(layout);
240  PetscInt rstart, rend;
241  CHKERR PetscLayoutGetRange(layout, &rstart, &rend);
242  CHKERR PetscLayoutDestroy(&layout);
243 
244  if (verb >= VERBOSE) {
245  MOFEM_LOG("SYNC", Sev::noisy)
246  << "row lower " << rstart << " row upper " << rend;
248  }
249 
250  miit_row = dofs_row_by_idx.lower_bound(rstart);
251  hi_miit_row = dofs_row_by_idx.lower_bound(rend);
252  if (std::distance(miit_row, hi_miit_row) != rend - rstart) {
253  SETERRQ4(
254  mofemComm, PETSC_ERR_ARG_SIZ,
255  "data inconsistency, std::distance(miit_row,hi_miit_row) != rend - "
256  "rstart (%d != %d - %d = %d) ",
257  std::distance(miit_row, hi_miit_row), rend, rstart, rend - rstart);
258  }
259 
260  } else {
261 
262  MPI_Comm comm;
263  // // Make sure it is a PETSc mofemComm
264  CHKERR PetscCommDuplicate(get_comm(), &comm, NULL);
265 
266  // get adjacent nodes on other partitions
267  std::vector<std::vector<int>> dofs_vec(sIze);
268 
269  boost::shared_ptr<FieldEntity> mofem_ent_ptr;
270  std::vector<int> dofs_col_view;
271 
272  typename boost::multi_index::index<NumeredDofEntity_multiIndex,
273  TAG>::type::iterator mit_row,
274  hi_mit_row;
275 
276  mit_row = dofs_row_by_idx.begin();
277  hi_mit_row = dofs_row_by_idx.end();
278  for (; mit_row != hi_mit_row; mit_row++) {
279 
280  // Shared or multi-shared row and not owned. Those data should be send to
281  // other side.
282 
283  // Get entity adjacencies, no need to repeat that operation for dofs when
284  // are on the same entity. For simplicity is assumed that those sheered
285  // the same adjacencies.
286  unsigned char pstatus = (*mit_row)->getPStatus();
287  if ((pstatus & PSTATUS_NOT_OWNED) &&
288  (pstatus & (PSTATUS_SHARED | PSTATUS_MULTISHARED))) {
289 
290  bool get_adj_col = true;
291  if (mofem_ent_ptr) {
292  if (mofem_ent_ptr->getLocalUniqueId() ==
293  (*mit_row)->getFieldEntityPtr()->getLocalUniqueId()) {
294  get_adj_col = false;
295  }
296  }
297 
298  if (get_adj_col) {
299  // Get entity adjacencies
300  mofem_ent_ptr = (*mit_row)->getFieldEntityPtr();
301  CHKERR getEntityAdjacencies<TAG>(p_miit, mit_row, mofem_ent_ptr,
302  dofs_col_view, verb);
303  // Sort, unique and resize dofs_col_view
304  {
305  std::sort(dofs_col_view.begin(), dofs_col_view.end());
306  std::vector<int>::iterator new_end =
307  std::unique(dofs_col_view.begin(), dofs_col_view.end());
308  int new_size = std::distance(dofs_col_view.begin(), new_end);
309  dofs_col_view.resize(new_size);
310  }
311  // Add that row. Patterns is that first index is row index, second is
312  // size of adjacencies after that follows column adjacencies.
313  int owner = (*mit_row)->getOwnerProc();
314  dofs_vec[owner].emplace_back(TAG::get_index(mit_row)); // row index
315  dofs_vec[owner].emplace_back(
316  dofs_col_view.size()); // nb. of column adjacencies
317  // add adjacent cools
318  dofs_vec[owner].insert(dofs_vec[owner].end(), dofs_col_view.begin(),
319  dofs_col_view.end());
320  }
321  }
322  }
323 
324  int nsends = 0; // number of messages to send
325  std::vector<int> dofs_vec_length(sIze); // length of the message to proc
326  for (int proc = 0; proc < sIze; proc++) {
327 
328  if (!dofs_vec[proc].empty()) {
329 
330  dofs_vec_length[proc] = dofs_vec[proc].size();
331  nsends++;
332 
333  } else {
334 
335  dofs_vec_length[proc] = 0;
336  }
337  }
338 
339  std::vector<MPI_Status> status(sIze);
340 
341  // Computes the number of messages a node expects to receive
342  int nrecvs; // number of messages received
343  CHKERR PetscGatherNumberOfMessages(comm, NULL, &dofs_vec_length[0],
344  &nrecvs);
345 
346  // Computes info about messages that a MPI-node will receive, including
347  // (from-id,length) pairs for each message.
348  int *onodes; // list of node-ids from which messages are expected
349  int *olengths; // corresponding message lengths
350  CHKERR PetscGatherMessageLengths(comm, nsends, nrecvs, &dofs_vec_length[0],
351  &onodes, &olengths);
352 
353  // Gets a unique new tag from a PETSc communicator.
354  int tag;
355  CHKERR PetscCommGetNewTag(comm, &tag);
356 
357  // Allocate a buffer sufficient to hold messages of size specified in
358  // olengths. And post Irecvs on these buffers using node info from onodes
359  int **rbuf; // must bee freed by user
360  MPI_Request *r_waits; // must bee freed by user
361 
362  // rbuf has a pointers to messages. It has size of of nrecvs (number of
363  // messages) +1. In the first index a block is allocated,
364  // such that rbuf[i] = rbuf[i-1]+olengths[i-1].
365  CHKERR PetscPostIrecvInt(comm, tag, nrecvs, onodes, olengths, &rbuf,
366  &r_waits);
367 
368  MPI_Request *s_waits; // status of sens messages
369  CHKERR PetscMalloc1(nsends, &s_waits);
370 
371  // Send messages
372  for (int proc = 0, kk = 0; proc < sIze; proc++) {
373  if (!dofs_vec_length[proc])
374  continue; // no message to send to this proc
375  CHKERR MPI_Isend(&(dofs_vec[proc])[0], // buffer to send
376  dofs_vec_length[proc], // message length
377  MPIU_INT, proc, // to proc
378  tag, comm, s_waits + kk);
379  kk++;
380  }
381 
382  // Wait for received
383  if (nrecvs) {
384  CHKERR MPI_Waitall(nrecvs, r_waits, &status[0]);
385  }
386  // Wait for send messages
387  if (nsends) {
388  CHKERR MPI_Waitall(nsends, s_waits, &status[0]);
389  }
390 
391  for (int kk = 0; kk < nrecvs; kk++) {
392 
393  int len = olengths[kk];
394  int *data_from_proc = rbuf[kk];
395 
396  for (int ii = 0; ii < len;) {
397 
398  int row_idx = data_from_proc[ii++]; // get row number
399  int nb_adj_dofs = data_from_proc[ii++]; // get nb. of adjacent dofs
400 
401  if (debug) {
402 
403  DofByGlobalPetscIndex::iterator dit;
404  dit = p_miit->numeredRowDofsPtr->get<PetscGlobalIdx_mi_tag>().find(
405  row_idx);
406  if (dit ==
407  p_miit->numeredRowDofsPtr->get<PetscGlobalIdx_mi_tag>().end()) {
409  "dof %d can not be found in problem", row_idx);
410  }
411  }
412 
413  for (int jj = 0; jj < nb_adj_dofs; jj++) {
414  adjacent_dofs_on_other_parts[row_idx].push_back(data_from_proc[ii++]);
415  }
416  }
417  }
418 
419  // Cleaning
420  CHKERR PetscFree(s_waits);
421  CHKERR PetscFree(rbuf[0]);
422  CHKERR PetscFree(rbuf);
423  CHKERR PetscFree(r_waits);
424  CHKERR PetscFree(onodes);
425  CHKERR PetscFree(olengths);
426 
427  miit_row = dofs_row_by_idx.begin();
428  hi_miit_row = dofs_row_by_idx.end();
429 
430  CHKERR PetscCommDestroy(&comm);
431  }
432 
433  boost::shared_ptr<FieldEntity> mofem_ent_ptr;
434  int row_last_evaluated_idx = -1;
435 
436  std::vector<int> dofs_vec;
437  std::vector<int> dofs_col_view;
438 
439  // loop local rows
440  int nb_loc_row_from_iterators = 0;
441  unsigned int rows_to_fill = p_miit->getNbLocalDofsRow();
442  i.reserve(rows_to_fill + 1);
443  for (; miit_row != hi_miit_row; miit_row++) {
444 
445  if (!TAG::IamNotPartitioned) {
446  if (static_cast<int>((*miit_row)->getPart()) != rAnk)
447  continue;
448  }
449  // This is only for cross-check if everything is ok
450  nb_loc_row_from_iterators++;
451 
452  // add next row to compressed matrix
453  i.push_back(j.size());
454 
455  // Get entity adjacencies, no need to repeat that operation for dofs when
456  // are on the same entity. For simplicity is assumed that those share the
457  // same adjacencies.
458  if ((!mofem_ent_ptr)
459  ? 1
460  : (mofem_ent_ptr->getLocalUniqueId() !=
461  (*miit_row)->getFieldEntityPtr()->getLocalUniqueId())) {
462 
463  // get entity adjacencies
464  mofem_ent_ptr = (*miit_row)->getFieldEntityPtr();
465  CHKERR getEntityAdjacencies<TAG>(p_miit, miit_row, mofem_ent_ptr,
466  dofs_col_view, verb);
467  row_last_evaluated_idx = TAG::get_index(miit_row);
468 
469  dofs_vec.resize(0);
470  // insert dofs_col_view
471  dofs_vec.insert(dofs_vec.end(), dofs_col_view.begin(),
472  dofs_col_view.end());
473 
474  unsigned char pstatus = (*miit_row)->getPStatus();
475  if (pstatus > 0) {
476  std::map<int, std::vector<int>>::iterator mit;
477  mit = adjacent_dofs_on_other_parts.find(row_last_evaluated_idx);
478  if (mit == adjacent_dofs_on_other_parts.end()) {
479  // NOTE: Dof can adjacent to other part but no elements are there
480  // which use that dof std::cerr << *miit_row << std::endl; SETERRQ1(
481  // get_comm(),MOFEM_DATA_INCONSISTENCY,
482  // "data inconsistency row_last_evaluated_idx = %d",
483  // row_last_evaluated_idx
484  // );
485  } else {
486  dofs_vec.insert(dofs_vec.end(), mit->second.begin(),
487  mit->second.end());
488  }
489  }
490 
491  // sort and make unique
492  sort(dofs_vec.begin(), dofs_vec.end());
493  std::vector<int>::iterator new_end =
494  unique(dofs_vec.begin(), dofs_vec.end());
495  int new_size = std::distance(dofs_vec.begin(), new_end);
496  dofs_vec.resize(new_size);
497  }
498 
499  // Try to be smart reserving memory
500  if (j.capacity() < j.size() + dofs_vec.size()) {
501 
502  // TODO: [CORE-55] Improve algorithm estimating size of compressed matrix
503  unsigned int nb_nonzero = j.size() + dofs_vec.size();
504  unsigned int average_row_fill = nb_nonzero / i.size() + 1;
505  j.reserve(rows_to_fill * average_row_fill);
506  }
507 
508  auto hi_diit = dofs_vec.end();
509  for (auto diit = dofs_vec.begin(); diit != hi_diit; diit++) {
510 
511  if (no_diagonals) {
512  if (*diit == TAG::get_index(miit_row)) {
513  continue;
514  }
515  }
516  j.push_back(*diit);
517  }
518  }
519 
520  // build adj matrix
521  i.push_back(j.size());
522 
523  if (strcmp(type, MATMPIADJ) == 0) {
524 
525  // Adjacency matrix used to partition problems, f.e. METIS
526  if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
527  SETERRQ2(
528  get_comm(), PETSC_ERR_ARG_SIZ,
529  "Number of rows from iterator is different than size of rows in "
530  "compressed row "
531  "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %d != "
532  "%d",
533  (unsigned int)nb_loc_row_from_iterators, i.size() - 1);
534  }
535 
536  } else if (strcmp(type, MATMPIAIJ) == 0) {
537 
538  // Compressed MPIADJ matrix
539  if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
540  SETERRQ2(
541  get_comm(), PETSC_ERR_ARG_SIZ,
542  "Number of rows from iterator is different than size of rows in "
543  "compressed row "
544  "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %d != "
545  "%d",
546  (unsigned int)nb_loc_row_from_iterators, i.size() - 1);
547  }
548  PetscInt nb_local_dofs_row = p_miit->getNbLocalDofsRow();
549  if ((unsigned int)nb_local_dofs_row != i.size() - 1) {
550  SETERRQ2(
551  get_comm(), PETSC_ERR_ARG_SIZ,
552  "Number of rows is different than size of rows in compressed row "
553  "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %d != "
554  "%d",
555  (unsigned int)nb_local_dofs_row, i.size() - 1);
556  }
557 
558  } else if (strcmp(type, MATAIJ) == 0) {
559 
560  // Sequential compressed ADJ matrix
561  if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
562  SETERRQ2(
563  get_comm(), PETSC_ERR_ARG_SIZ,
564  "Number of rows form iterator is different than size of rows in "
565  "compressed row "
566  "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %d != "
567  "%d",
568  (unsigned int)nb_loc_row_from_iterators, i.size() - 1);
569  }
570  PetscInt nb_local_dofs_row = p_miit->getNbLocalDofsRow();
571  if ((unsigned int)nb_local_dofs_row != i.size() - 1) {
572  SETERRQ2(
573  get_comm(), PETSC_ERR_ARG_SIZ,
574  "Number of rows is different than size of rows in compressed row "
575  "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %d != "
576  "%d",
577  (unsigned int)nb_local_dofs_row, i.size() - 1);
578  }
579 
580  } else if (strcmp(type, MATAIJCUSPARSE) == 0) {
581 
582  if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
583  SETERRQ(get_comm(), PETSC_ERR_ARG_SIZ, "data inconsistency");
584  }
585  PetscInt nb_local_dofs_row = p_miit->getNbLocalDofsRow();
586  if ((unsigned int)nb_local_dofs_row != i.size() - 1) {
587  SETERRQ(get_comm(), PETSC_ERR_ARG_SIZ, "data inconsistency");
588  }
589 
590  } else {
591 
592  SETERRQ(get_comm(), PETSC_ERR_ARG_NULL, "not implemented");
593  }
594 
595  PetscLogEventEnd(MOFEM_EVENT_createMat, 0, 0, 0, 0);
597 }

◆ getEntityAdjacencies()

template<typename TAG >
MoFEMErrorCode MoFEM::CreateRowCompressedADJMatrix::getEntityAdjacencies ( ProblemsByName::iterator  p_miit,
typename boost::multi_index::index< NumeredDofEntity_multiIndex, TAG >::type::iterator  mit_row,
boost::shared_ptr< FieldEntity mofem_ent_ptr,
std::vector< int > &  dofs_col_view,
int  verb 
) const
private

Get element adjacencies.

Definition at line 81 of file MatrixManager.cpp.

86  {
88 
89  BitRefLevel prb_bit = p_miit->getBitRefLevel();
90  BitRefLevel prb_mask = p_miit->getBitRefLevelMask();
91 
92  const EmptyFieldBlocks &empty_field_blocks = p_miit->getEmptyFieldBlocks();
93 
94  dofs_col_view.clear();
95  for (auto r = entFEAdjacencies.get<Unique_mi_tag>().equal_range(
96  mofem_ent_ptr->getLocalUniqueId());
97  r.first != r.second; ++r.first) {
98 
99  if (r.first->byWhat & BYROW) {
100 
101  if ((r.first->entFePtr->getId() & p_miit->getBitFEId()).none()) {
102  // if element is not part of problem
103  continue;
104  }
105 
106  const BitRefLevel &fe_bit = r.first->entFePtr->getBitRefLevel();
107  // if entity is not problem refinement level
108  if ((fe_bit & prb_bit).any() && (fe_bit & prb_mask) == fe_bit) {
109 
110  auto check_block = [&empty_field_blocks](auto &r_if, auto &col_id) {
111  for (auto &b : empty_field_blocks) {
112  if ((b.first & r_if).any() && (b.second & col_id).any()) {
113  return false;
114  }
115  }
116  return true;
117  };
118 
119  for (auto &it : r.first->entFePtr->getColFieldEnts()) {
120  if (auto e = it.lock()) {
121 
122  if (check_block((*mit_row)->getId(), e->getId())) {
123 
124  if (auto cache = e->entityCacheColDofs.lock()) {
125  const auto lo = cache->loHi[0];
126  const auto hi = cache->loHi[1];
127  for (auto vit = lo; vit != hi; ++vit) {
128 
129  const int idx = TAG::get_index(vit);
130  if (PetscLikely(idx >= 0))
131  dofs_col_view.push_back(idx);
132 
133 #ifndef NDEBUG
134  const DofIdx nb_dofs_col = p_miit->getNbDofsCol();
135  if (PetscUnlikely(idx >= nb_dofs_col)) {
136  MOFEM_LOG("SELF", Sev::error)
137  << "Problem with dof: " << std::endl
138  << "Rank " << rAnk << " : " << *(*vit);
139  SETERRQ(
140  mofemComm, PETSC_ERR_ARG_SIZ,
141  "Index of dof larger than number of DOFs in column");
142  }
143 #endif
144  }
145 
146  } else {
147  SETERRQ(mofemComm, MOFEM_DATA_INCONSISTENCY, "Cache not set");
148  }
149  }
150  }
151  }
152  }
153  }
154  }
155 
157 }

The documentation for this struct was generated from the following file:
MoFEM::CoreTmp< 0 >::rAnk
int rAnk
MOFEM communicator rank.
Definition: Core.hpp:1016
MatrixManagerFunctionBegin
#define MatrixManagerFunctionBegin
Create adjacent matrices using different indices.
Definition: MatrixManager.cpp:6
MoFEM::CoreTmp< 0 >::entFEAdjacencies
FieldEntityEntFiniteElementAdjacencyMap_multiIndex entFEAdjacencies
adjacencies of elements to dofs
Definition: Core.hpp:311
sdf.r
int r
Definition: sdf.py:8
NumeredDofEntity_multiIndex
multi_index_container< boost::shared_ptr< NumeredDofEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, UId, &NumeredDofEntity::getLocalUniqueId > >, ordered_non_unique< tag< Part_mi_tag >, member< NumeredDofEntity, unsigned int, &NumeredDofEntity::pArt > >, ordered_non_unique< tag< Idx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::dofIdx > >, ordered_non_unique< tag< PetscGlobalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscGloablDofIdx > >, ordered_non_unique< tag< PetscLocalIdx_mi_tag >, member< NumeredDofEntity, DofIdx, &NumeredDofEntity::petscLocalDofIdx > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< NumeredDofEntity::interface_type_DofEntity, EntityHandle, &NumeredDofEntity::getEnt > > > > NumeredDofEntity_multiIndex
MultiIndex container keeps NumeredDofEntity.
Definition: DofsMultiIndices.hpp:469
VERBOSE
@ VERBOSE
Definition: definitions.h:222
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreTmp< 0 >::MOFEM_EVENT_createMat
PetscLogEvent MOFEM_EVENT_createMat
Definition: Core.hpp:1004
MoFEM::Types::UId
uint128_t UId
Unique Id.
Definition: Types.hpp:31
convert.type
type
Definition: convert.py:64
MOFEM_LOG_SYNCHRONISE
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
Definition: LogManager.hpp:345
MoFEM::CoreTmp< 0 >::sIze
int sIze
MoFEM communicator size.
Definition: Core.hpp:1015
debug
static const bool debug
Definition: dm_create_subdm.cpp:12
i
FTensor::Index< 'i', SPACE_DIM > i
Definition: hcurl_divergence_operator_2d.cpp:27
MoFEM::CoreTmp< 0 >::moab
std::reference_wrapper< moab::Interface > moab
moab database
Definition: Core.hpp:321
MoFEM::CoreTmp< 0 >::get_comm
MPI_Comm & get_comm() const
Definition: Core.hpp:1021
MoFEM::CoreTmp< 0 >::mofemComm
MPI_Comm mofemComm
MoFEM communicator.
Definition: Core.hpp:1012
MAX_DOFS_ON_ENTITY
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:249
MoFEM::CoreTmp< 0 >::verbose
int verbose
Verbosity level.
Definition: Core.hpp:1039
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
j
FTensor::Index< 'j', 3 > j
Definition: matrix_function.cpp:19
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
BYROW
@ BYROW
Definition: definitions.h:144
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
MoFEM::CoreTmp< 0 >::entsFields
FieldEntity_multiIndex entsFields
entities on fields
Definition: Core.hpp:304
MoFEM::EmptyFieldBlocks
Problem::EmptyFieldBlocks EmptyFieldBlocks
Definition: ProblemsMultiIndices.hpp:567
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MoFEM::Types::DofIdx
int DofIdx
Index of DOF.
Definition: Types.hpp:18