v0.14.0
Loading...
Searching...
No Matches
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 ()
 
int & getBuildMoFEM () const
 Get flags/semaphores for different stages. More...
 
MoFEMErrorCode addPrismToDatabase (const EntityHandle prism, int verb=DEFAULT_VERBOSITY)
 add prim element More...
 
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
 
- 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 const int getValue () const =0
 Get the core. More...
 
virtual boost::shared_ptr< RefEntityTmp< 0 > > make_shared_ref_entity (const EntityHandle ent)=0
 Get RefEntity. More...
 
- Public Member Functions inherited from MoFEM::UnknownInterface
virtual MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const =0
 
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)
 
MPI_Comm & get_comm () const
 
int get_comm_size () const
 
int get_comm_rank () const
 
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...
 
- 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) {}
CoreTmp< 0 > Core
Definition: Core.hpp:1094
int verbose
Verbosity level.
Definition: Core.hpp:993
std::reference_wrapper< moab::Interface > moab
moab database
Definition: Core.hpp:321

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 145 of file MatrixManager.cpp.

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

◆ 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 const bool empty_row_block =
102 (empty_field_blocks.first & (*mit_row)->getId()).none();
103
104 for (auto &it : r.first->entFePtr->getColFieldEnts()) {
105 if (auto e = it.lock()) {
106 if (empty_row_block ||
107 (empty_field_blocks.second & e->getId()).none()) {
108
109 if (auto cache = e->entityCacheColDofs.lock()) {
110 const auto lo = cache->loHi[0];
111 const auto hi = cache->loHi[1];
112 for (auto vit = lo; vit != hi; ++vit) {
113
114 const int idx = TAG::get_index(vit);
115 if (PetscLikely(idx >= 0))
116 dofs_col_view.push_back(idx);
117
118#ifndef NDEBUG
119 const DofIdx nb_dofs_col = p_miit->getNbDofsCol();
120 if (PetscUnlikely(idx >= nb_dofs_col)) {
121 MOFEM_LOG("SELF", Sev::error)
122 << "Problem with dof: " << std::endl
123 << "Rank " << rAnk << " : " << *(*vit);
124 SETERRQ(
125 mofemComm, PETSC_ERR_ARG_SIZ,
126 "Index of dof larger than number of DOFs in column");
127 }
128#endif
129 }
130
131 } else {
132 SETERRQ(mofemComm, MOFEM_DATA_INCONSISTENCY, "Cache not set");
133 }
134 }
135 }
136 }
137 }
138 }
139 }
140
142}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ BYROW
Definition: definitions.h:131
int DofIdx
Index of DOF.
Definition: Types.hpp:18
Problem::EmptyFieldBlocks EmptyFieldBlocks

The documentation for this struct was generated from the following file: