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

Create compressed matrix. More...

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

Public Types

typedef FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index< Unique_mi_tag >::type AdjByEnt
 
typedef Problem_multiIndex::index< Problem_mi_tag >::type ProblemsByName
 
typedef NumeredDofEntity_multiIndex::index< PetscGlobalIdx_mi_tag >::type DofByGlobalPetscIndex
 
- 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

 CreateRowComressedADJMatrix (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...
 
template<typename TAG >
MoFEMErrorCode getEntityAdjacenies (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...
 
- 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
 
- 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 refernce 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
 

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 subinterfac in core interface. 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_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 filed. 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 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 filed 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 filed 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 filed 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 filed 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 filed 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 filed 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 filed 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 filed 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_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 improvemnt are possible

Definition at line 33 of file MatrixManager.cpp.

Member Typedef Documentation

◆ AdjByEnt

typedef FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index< Unique_mi_tag>::type MoFEM::CreateRowComressedADJMatrix::AdjByEnt

Definition at line 40 of file MatrixManager.cpp.

◆ DofByGlobalPetscIndex

typedef NumeredDofEntity_multiIndex::index<PetscGlobalIdx_mi_tag>::type MoFEM::CreateRowComressedADJMatrix::DofByGlobalPetscIndex

Definition at line 43 of file MatrixManager.cpp.

◆ ProblemsByName

typedef Problem_multiIndex::index<Problem_mi_tag>::type MoFEM::CreateRowComressedADJMatrix::ProblemsByName

Definition at line 41 of file MatrixManager.cpp.

Constructor & Destructor Documentation

◆ CreateRowComressedADJMatrix()

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

Definition at line 35 of file MatrixManager.cpp.

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

Member Function Documentation

◆ createMatArrays()

template<typename TAG >
MoFEMErrorCode MoFEM::CreateRowComressedADJMatrix::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 151 of file MatrixManager.cpp.

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

◆ getEntityAdjacenies()

template<typename TAG >
MoFEMErrorCode MoFEM::CreateRowComressedADJMatrix::getEntityAdjacenies ( 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.

Definition at line 72 of file MatrixManager.cpp.

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

The documentation for this struct was generated from the following file:
MoFEM::CoreTmp< 0 >::rAnk
int rAnk
MOFEM communicator rank.
Definition: Core.hpp:970
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:209
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::CoreTmp< 0 >::MOFEM_EVENT_createMat
PetscLogEvent MOFEM_EVENT_createMat
Definition: Core.hpp:958
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:969
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:975
MoFEM::CoreTmp< 0 >::mofemComm
MPI_Comm mofemComm
MoFEM communicator.
Definition: Core.hpp:966
MAX_DOFS_ON_ENTITY
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
Definition: definitions.h:236
MoFEM::CoreTmp< 0 >::verbose
int verbose
Verbosity level.
Definition: Core.hpp:993
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1094
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:131
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:563
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
MoFEM::Types::DofIdx
int DofIdx
Index of DOF.
Definition: Types.hpp:18