v0.16.3
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Member Functions | List of all members
MoFEM::CreateRowCompressedADJMatrix Struct Reference
Inheritance diagram for MoFEM::CreateRowCompressedADJMatrix:
[legend]
Collaboration diagram for MoFEM::CreateRowCompressedADJMatrix:
[legend]

Public Types

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

Public Member Functions

 CreateRowCompressedADJMatrix (moab::Interface &moab, MPI_Comm comm=PETSC_COMM_WORLD, int verbose=1)
 
template<typename TAG >
MoFEMErrorCode createMatArrays (ProblemsByName::iterator p_miit, const MatType type, std::vector< PetscInt > &i, std::vector< PetscInt > &j, const bool no_diagonals=true, int verb=QUIET) const
 Create matrix adjacencies.
 
- Public Member Functions inherited from MoFEM::CoreTmp< 0 >
int getValue () const
 Get the core.
 
RefEntityTmp< 0 > getRefEntity (const EntityHandle ent)
 
virtual boost::shared_ptr< RefEntityTmp< 0 > > make_shared_ref_entity (const EntityHandle ent)
 Get RefEntity.
 
 CoreTmp (moab::Interface &moab, MPI_Comm comm=PETSC_COMM_WORLD, const int verbose=VERBOSE)
 
virtual ~CoreTmp ()
 
int & getBuildMoFEM () const
 Get flags/semaphores for different stages.
 
MoFEMErrorCode addPrismToDatabase (const EntityHandle prism, int verb=DEFAULT_VERBOSITY)
 add prim element
 
MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 Getting interface of core database.
 
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
 
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
 
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
 
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.
 
DEPRECATED MoFEMErrorCode synchronise_entities (Range &ent, int verb=DEFAULT_VERBOSITY)
 
DEPRECATED MoFEMErrorCode synchronise_field_entities (const std::string &name, int verb=DEFAULT_VERBOSITY)
 
- Public Member Functions inherited from MoFEM::CoreInterface
virtual ~CoreInterface ()=default
 
virtual MoFEMErrorCode add_broken_field (const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const std::vector< std::pair< EntityType, std::function< MoFEMErrorCode(BaseFunction::DofsSideMap &)> > > list_dof_side_map, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
 Add field.
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface reference to pointer of interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface.
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface.
 
virtual ~UnknownInterface ()=default
 

Private Types

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

Private Member Functions

template<typename TAG >
MoFEMErrorCode getEntityAdjacencies (ProblemsByName::iterator p_miit, typename boost::multi_index::index< NumeredDofEntity_multiIndex, TAG >::type::iterator mit_row, boost::shared_ptr< FieldEntity > mofem_ent_ptr, std::vector< int > &dofs_col_view, int verb) const
 Get element adjacencies.
 
template<typename TAG >
MoFEMErrorCode addElementColumns (const EntFiniteElement &fe, ElementColumns &columns, int &slot) const
 Add the column indices of one element and return its slot.
 

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.
 
static const std::string & getPetscOptionsFile ()
 
static MoFEMErrorCode Finalize ()
 Checks for options to be called at the conclusion of the program.
 
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.
 
static MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version)
 Get database major version.
 
static MoFEMErrorCode setFileVersion (moab::Interface &moab, Version version=Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD))
 Get database major version.
 
static MoFEMErrorCode getInterfaceVersion (Version &version)
 Get database major version.
 
- 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
 
MoFEMErrorCode getTags (int verb=DEFAULT_VERBOSITY)
 Get tag handles.
 
MoFEMErrorCode clearMap ()
 Cleaning database.
 
MoFEMErrorCode registerSubInterfaces ()
 Register insterfaces.
 
BitProblemId getProblemShift ()
 Return unique problem Id.
 
MoFEMErrorCode initialiseDatabaseFromMesh (int verb=DEFAULT_VERBOSITY)
 Initialize database getting information on mesh.
 
MoFEMErrorCode getOptions (int verb=DEFAULT_VERBOSITY)
 Get core options from command line.
 
template<class IFACE >
MoFEMErrorCode regSubInterface ()
 Register sub-interfaces in core interface.
 
template<class IFACE >
MoFEMErrorCode regEvents ()
 Register petsc events.
 
boost::shared_ptr< BasicEntityData > & get_basic_entity_data_ptr ()
 Get pointer to basic entity data.
 
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.
 
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
 
MoFEMErrorCode check_number_of_ents_in_ents_field () const
 check data consistency in entitiesPtr
 
MoFEMErrorCode check_number_of_ents_in_ents_finite_element (const std::string &name) const
 check data consistency in entsFiniteElements
 
MoFEMErrorCode check_number_of_ents_in_ents_finite_element () const
 check data consistency in entsFiniteElements
 
MoFEMErrorCode clear_database (int verb=DEFAULT_VERBOSITY)
 Clear database.
 
MoFEMErrorCode rebuild_database (int verb=DEFAULT_VERBOSITY)
 Clear database and initialize it once again.
 
MeshsetsManager * get_meshsets_manager_ptr ()
 get MeshsetsManager pointer
 
const MeshsetsManager * get_meshsets_manager_ptr () const
 get MeshsetsManager pointer
 
MeshsetsManager & get_meshsets_manager ()
 get MeshsetsManager reference
 
const MeshsetsManager & get_meshsets_manager () const
 get MeshsetsManager reference
 
MoFEMErrorCode remove_parents_by_ents (const Range &ents, int verb=DEFAULT_VERBOSITY)
 Remove parents from entities.
 
MoFEMErrorCode remove_parents_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 Remove parent from entities on bit level.
 
MoFEMErrorCode remove_parents_by_parents (const Range &ents, int verb=DEFAULT_VERBOSITY)
 Remove parents from entities having parents in passed range.
 
MoFEMErrorCode remove_ents (const Range ents, int verb=DEFAULT_VERBOSITY)
 Remove entities from MoFEM database.
 
MoFEMErrorCode remove_ents_by_bit_ref (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 Remove entities from MoFEM database.
 
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 from MoFEM and MOAB database.
 
virtual MoFEMErrorCode add_broken_field (const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_coefficients, std::vector< std::pair< EntityType, std::function< MoFEMErrorCode(BaseFunction::DofsSideMap &)> > > list_dof_side_map, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 Add field.
 
virtual MoFEMErrorCode add_field (const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 Add field.
 
MoFEMErrorCode delete_field (const std::string name, int verb=DEFAULT_VERBOSITY)
 Delete field.
 
MoFEMErrorCode addField (const std::string &name, const FieldSpace space, const FieldContinuity continuity, const FieldApproximationBase base, const FieldCoefficientsNumber nb_coefficients, const TagType tag_type, const enum MoFEMTypes bh, int verb)
 Template for add_field.
 
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.
 
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.
 
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.
 
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.
 
MoFEMErrorCode create_vertices_and_add_to_field (const std::string name, const double coords[], int size, int verb=DEFAULT_VERBOSITY)
 Create vertices and add to the field object.
 
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.
 
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.
 
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.
 
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, const Range *ents_ptr, int verb=DEFAULT_VERBOSITY)
 
MoFEMErrorCode buildField (const boost::shared_ptr< Field > &field, const Range *ents_ptr, 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
 
MoFEMErrorCode build_fields (const Range &ents, int verb=DEFAULT_VERBOSITY)
 Build DOFs of every field on the given entities only.
 
MoFEMErrorCode build_field (const std::string field_name, const Range &ents, int verb=DEFAULT_VERBOSITY)
 Build DOFs of one field on the given entities only.
 
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
 
MoFEMErrorCode remove_ents_from_field (const std::string name, const EntityHandle meshset, const EntityType type, int verb=DEFAULT_VERBOSITY)
 remove entities from field
 
MoFEMErrorCode remove_ents_from_field (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from field
 
MoFEMErrorCode remove_ents_from_field (const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from all fields
 
MoFEMErrorCode list_dofs_by_field_name (const std::string &name) const
 
MoFEMErrorCode list_fields () const
 list entities in the field
 
BitFieldId get_field_id (const std::string &name) const
 Get field Id.
 
FieldBitNumber get_field_bit_number (const std::string name) const
 get field bit number
 
std::string get_field_name (const BitFieldId id) const
 get field name from id
 
EntityHandle get_field_meshset (const BitFieldId id) const
 
EntityHandle get_field_meshset (const std::string name) const
 get field meshset
 
MoFEMErrorCode get_field_entities_by_dimension (const std::string name, int dim, Range &ents) const
 get entities in the field by dimension
 
MoFEMErrorCode get_field_entities_by_type (const std::string name, EntityType type, Range &ents) const
 get entities in the field by type
 
MoFEMErrorCode get_field_entities_by_handle (const std::string name, Range &ents) const
 get entities in the field by handle
 
bool check_field (const std::string &name) const
 check if field is in database
 
const Field * get_field_structure (const std::string &name, enum MoFEMTypes bh=MF_EXIST) const
 get field structure
 
const FiniteElement * get_finite_element_structure (const std::string &name, enum MoFEMTypes bh=MF_EXCL) const
 get finite element structure
 
bool check_finite_element (const std::string &name) const
 Check if finite element is in database.
 
MoFEMErrorCode add_finite_element (const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 add finite element
 
MoFEMErrorCode modify_finite_element_adjacency_table (const std::string &fe_name, const EntityType type, ElementAdjacencyFunct function)
 modify finite element table, only for advanced user
 
MoFEMErrorCode modify_finite_element_add_field_data (const std::string &fe_name, const std::string name_filed)
 set finite element field data
 
MoFEMErrorCode modify_finite_element_add_field_row (const std::string &fe_name, const std::string name_row)
 set field row which finite element use
 
MoFEMErrorCode modify_finite_element_add_field_col (const std::string &fe_name, const std::string name_col)
 set field col which finite element use
 
MoFEMErrorCode modify_finite_element_off_field_data (const std::string &fe_name, const std::string name_filed)
 unset finite element field data
 
MoFEMErrorCode modify_finite_element_off_field_row (const std::string &fe_name, const std::string name_row)
 unset field row which finite element use
 
MoFEMErrorCode modify_finite_element_off_field_col (const std::string &fe_name, const std::string name_col)
 unset field col which finite element use
 
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
 
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
 
MoFEMErrorCode add_ents_to_finite_element_by_type (const Range ents, const EntityType type, const std::string name)
 add entities to finite elements
 
MoFEMErrorCode add_ents_to_finite_element_by_dim (const Range ents, const int dim, const std::string name)
 add entities to finite elements
 
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
 
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
 
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
 
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
 
MoFEMErrorCode remove_ents_from_finite_element (const std::string name, const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from finite element database
 
MoFEMErrorCode remove_ents_from_finite_element (const Range ents, int verb=DEFAULT_VERBOSITY)
 remove entities from finite elements in database
 
MoFEMErrorCode delete_finite_element (const std::string name, int verb=DEFAULT_VERBOSITY)
 Delete finite element from MoFEM database.
 
BitFEId getBitFEId (const std::string &fe_name) const
 Get field Id.
 
std::string getBitFEIdName (const BitFEId id) const
 Get field name.
 
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
 
MoFEMErrorCode get_finite_element_entities_by_type (const std::string name, EntityType type, Range &ents) const
 get entities in the finite element by type
 
MoFEMErrorCode get_finite_element_entities_by_handle (const std::string name, Range &ents) const
 get entities in the finite element by handle
 
MoFEMErrorCode list_finite_elements () const
 list finite elements in database
 
MoFEMErrorCode add_problem (const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)
 Add problem.
 
bool check_problem (const std::string name)
 check if problem exist
 
MoFEMErrorCode delete_problem (const std::string name)
 Delete problem.
 
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
 
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
 
MoFEMErrorCode modify_problem_ref_level_add_bit (const std::string &name_problem, const BitRefLevel &bit)
 add ref level to problem
 
MoFEMErrorCode modify_problem_ref_level_set_bit (const std::string &name_problem, const BitRefLevel &bit)
 set ref level for problem
 
MoFEMErrorCode modify_problem_mask_ref_level_add_bit (const std::string &name_problem, const BitRefLevel &bit)
 set dof mask ref level for problem
 
MoFEMErrorCode modify_problem_mask_ref_level_set_bit (const std::string &name_problem, const BitRefLevel &bit)
 set dof mask ref level for problem
 
BitProblemId getBitProblemId (const std::string &name) const
 
MoFEMErrorCode list_problem () const
 list problems
 
MoFEMErrorCode clear_problem (const std::string name, int verb=DEFAULT_VERBOSITY)
 clear problem
 
MoFEMErrorCode clear_problems (int verb=DEFAULT_VERBOSITY)
 clear problems
 
MoFEMErrorCode build_finite_elements (int verb=DEFAULT_VERBOSITY)
 Build finite elements.
 
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.
 
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
 
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
 
MoFEMErrorCode build_adjacencies (const BitRefLevel &bit, int verb=DEFAULT_VERBOSITY)
 build adjacencies
 
MoFEMErrorCode build_adjacencies (const BitRefLevel &bit, const BitRefLevel &mask, int verb=DEFAULT_VERBOSITY)
 build adjacencies
 
MoFEMErrorCode clear_adjacencies_entities (const BitRefLevel bit, const BitRefLevel mask, int verb=DEFAULT_VERBOSITY)
 clear adjacency map for entities on given bit level
 
MoFEMErrorCode clear_adjacencies_entities (const Range ents, int verb=DEFAULT_VERBOSITY)
 clear adjacencies for field entities by entities
 
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
 
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
 
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.
 
MoFEMErrorCode problem_basic_method_preProcess (const std::string &problem_name, BasicMethod &method, int verb=DEFAULT_VERBOSITY)
 Set data for BasicMethod.
 
MoFEMErrorCode problem_basic_method_postProcess (const Problem *problem_ptr, BasicMethod &method, int verb=DEFAULT_VERBOSITY)
 Set data for BasicMethod.
 
MoFEMErrorCode problem_basic_method_postProcess (const std::string &problem_name, BasicMethod &method, int verb=DEFAULT_VERBOSITY)
 Set data for BasicMethod.
 
MoFEMErrorCode cache_problem_entities (const std::string prb_name, CacheTupleWeakPtr cache_ptr)
 Cache variables.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
MoFEMErrorCode loop_dofs (const std::string &field_name, DofMethod &method, int verb=DEFAULT_VERBOSITY)
 Make a loop over dofs.
 
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.
 
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.
 
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.
 
MoFEMErrorCode loop_entities (const std::string field_name, EntityMethod &method, Range const *const ents=nullptr, int verb=DEFAULT_VERBOSITY)
 Loop over field entities.
 
MoFEMErrorCode get_fields (const Field_multiIndex **fields_ptr) const
 Get fields multi-index from database.
 
MoFEMErrorCode get_ref_ents (const RefEntity_multiIndex **refined_entities_ptr) const
 Get ref entities multi-index from database.
 
MoFEMErrorCode get_ref_finite_elements (const RefElement_multiIndex **refined_finite_elements_ptr) const
 Get ref finite elements multi-index form database.
 
MoFEMErrorCode get_finite_elements (const FiniteElement_multiIndex **fe_ptr) const
 Get finite elements multi-index.
 
MoFEMErrorCode get_ents_finite_elements (const EntFiniteElement_multiIndex **fe_ent_ptr) const
 Get entities finite elements multi-index.
 
MoFEMErrorCode get_field_ents (const FieldEntity_multiIndex **field_ents) const
 Get field multi index.
 
MoFEMErrorCode get_dofs (const DofEntity_multiIndex **dofs_ptr) const
 Get dofs multi index.
 
MoFEMErrorCode get_problem (const std::string &problem_name, const Problem **problem_ptr) const
 Get problem database (data structure)
 
MoFEMErrorCode get_problems (const Problem_multiIndex **problems_ptr) const
 Get pointer to problems multi-index.
 
MoFEMErrorCode get_ents_elements_adjacency (const FieldEntityEntFiniteElementAdjacencyMap_multiIndex **dofs_elements_adjacency) const
 Get the dofs elements adjacency object.
 
const Field_multiIndex * get_fields () const
 Get the fields object.
 
const RefEntity_multiIndex * get_ref_ents () const
 Get the ref ents object.
 
const RefElement_multiIndex * get_ref_finite_elements () const
 Get the ref finite elements object.
 
const FiniteElement_multiIndex * get_finite_elements () const
 Get the finite elements object.
 
const EntFiniteElement_multiIndex * get_ents_finite_elements () const
 Get the ents finite elements object.
 
const FieldEntity_multiIndex * get_field_ents () const
 Get the field ents object.
 
const DofEntity_multiIndex * get_dofs () const
 Get the dofs object.
 
const Problem * get_problem (const std::string problem_name) const
 Get the problem object.
 
const Problem_multiIndex * get_problems () const
 Get the problems object.
 
const FieldEntityEntFiniteElementAdjacencyMap_multiIndex * get_ents_elements_adjacency () const
 Get the dofs elements adjacency object.
 
FieldEntityByUId::iterator get_ent_field_by_name_begin (const std::string &field_name) const
 get begin iterator of field ents of given name (instead you can use IT_GET_ENT_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT)
 
FieldEntityByUId::iterator get_ent_field_by_name_end (const std::string &field_name) const
 get end iterator of field ents of given name (instead you can use IT_GET_ENT_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT)
 
DofEntityByUId::iterator get_dofs_by_name_begin (const std::string &field_name) const
 get begin iterator of field dofs of given name (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT)
 
DofEntityByUId::iterator get_dofs_by_name_end (const std::string &field_name) const
 get begin iterator of field dofs of given name (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,IT)
 
DofEntityByUId::iterator get_dofs_by_name_and_ent_begin (const std::string &field_name, const EntityHandle ent) const
 get begin iterator of field dofs of given name and ent(instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,ENT,IT)
 
DofEntityByUId::iterator get_dofs_by_name_and_ent_end (const std::string &field_name, const EntityHandle ent) const
 get end iterator of field dofs of given name and ent (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,ENT,IT)
 
DofEntityByUId::iterator get_dofs_by_name_and_type_begin (const std::string &field_name, const EntityType type) const
 get begin iterator of field dofs of given name and ent type (instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,TYPE,IT)
 
DofEntityByUId::iterator get_dofs_by_name_and_type_end (const std::string &field_name, const EntityType ent) const
 get end iterator of field dofs of given name and ent type(instead you can use IT_GET_DOFS_FIELD_BY_NAME_FOR_LOOP(MFIELD,NAME,TYPE,IT)
 
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)
 
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)
 
- Protected Attributes inherited from MoFEM::CoreTmp< 0 >
boost::shared_ptr< WrapMPIComm > wrapMPIMOABComm
 manage creation and destruction of MOAB communicator
 
int verbose
 Verbosity level.
 
boost::ptr_map< boost::typeindex::type_index, UnknownInterface > iFaces
 Hash map of pointers to interfaces.
 
int * buildMoFEM
 keeps flags/semaphores for different stages
 
std::string optionsPrefix
 Prefix for options on command line.
 
PetscBool initaliseAndBuildField
 
PetscBool initaliseAndBuildFiniteElements
 
Tag th_Part
 Tag for partition number.
 
Tag th_RefParentHandle
 
Tag th_RefBitLevel
 
Tag th_RefBitLevel_Mask
 
Tag th_RefBitEdge
 
Tag th_RefFEMeshset
 
Tag th_FieldId
 
Tag th_FieldName
 
Tag th_FieldName_DataNamePrefix
 
Tag th_FieldSpace
 
Tag th_FieldContinuity
 
Tag th_FieldBase
 
Tag th_FEId
 
Tag th_FEName
 
Tag th_FEIdCol
 
Tag th_FEIdRow
 
Tag th_FEIdData
 
Tag th_ProblemId
 
Tag th_ProblemName
 
Tag th_ProblemFEId
 
Tag th_ProblemNbDofsRow
 
Tag th_ProblemNbDofsCol
 
Tag th_ProblemLocalNbDofRow
 
Tag th_ProblemGhostNbDofRow
 
Tag th_ProblemLocalNbDofCol
 
Tag th_ProblemGhostNbDofCol
 
Tag th_ProblemShift
 
Tag th_ElemType
 Needed for VTK files.
 
Tag th_MoFEMBuild
 
boost::shared_ptr< BasicEntityData > basicEntityDataPtr
 
RefEntity_multiIndex refinedEntities
 refined entities
 
RefElement_multiIndex refinedFiniteElements
 refined elements
 
Field_multiIndex fIelds
 fields
 
FieldEntity_multiIndex entsFields
 entities on fields
 
DofEntity_multiIndex dofsField
 dofs on fields
 
FiniteElement_multiIndex finiteElements
 finite elements
 
EntFiniteElement_multiIndex entsFiniteElements
 finite element entities
 
FieldEntityEntFiniteElementAdjacencyMap_multiIndex entFEAdjacencies
 adjacencies of elements to dofs
 
Problem_multiIndex pRoblems
 problems multi-index
 
std::reference_wrapper< moab::Interface > moab
 moab database
 
PetscLogEvent MOFEM_EVENT_preProcess
 Event for preProcess finite element.
 
PetscLogEvent MOFEM_EVENT_operator
 Event for evaluating operator of finite element.
 
PetscLogEvent MOFEM_EVENT_postProcess
 Event for postProcess finite element.
 
PetscLogEvent MOFEM_EVENT_createMat
 
MPI_Comm mofemComm
 MoFEM communicator.
 
ParallelComm * pComm
 MOAB communicator structure.
 
int sIze
 MoFEM communicator size.
 
int rAnk
 MOFEM communicator rank.
 
- Static Protected Attributes inherited from MoFEM::CoreTmp< 0 >
static bool isGloballyInitialised = false
 Core base globally initialized.
 
static int mpiInitialised = 0
 mpi was initialised by other agent
 
static PetscBool isInitialized = PETSC_FALSE
 petsc was initialised by other agent
 
static std::string petscOptionsFile = ""
 

Detailed Description

Definition at line 53 of file MatrixManager.cpp.

Member Typedef Documentation

◆ AdjByEnt

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

Definition at line 78 of file MatrixManager.cpp.

◆ DofByGlobalPetscIndex

Definition at line 81 of file MatrixManager.cpp.

◆ ProblemsByName

Definition at line 60 of file MatrixManager.cpp.

Constructor & Destructor Documentation

◆ CreateRowCompressedADJMatrix()

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

Definition at line 55 of file MatrixManager.cpp.

58 : Core(moab, comm, verbose) {}
MPI_Comm comm
CoreTmp< 0 > Core
Definition Core.hpp:1161
int verbose
Verbosity level.
Definition Core.hpp:1051
std::reference_wrapper< moab::Interface > moab
moab database
Definition Core.hpp:326

Member Function Documentation

◆ addElementColumns()

template<typename TAG >
MoFEMErrorCode MoFEM::CreateRowCompressedADJMatrix::addElementColumns ( const EntFiniteElement &  fe,
ElementColumns &  columns,
int &  slot 
) const
private

Add the column indices of one element and return its slot.

Requires the entity column DOF cache set by createMatArrays. Elements are added the first time a row entity is adjacent to them, so only the elements that contribute to local rows are listed.

Definition at line 106 of file MatrixManager.cpp.

107 {
109 slot = columns.elementSegments.size();
110 columns.slot[&fe] = slot;
111 const int first_segment = columns.segments.size();
112 bool open = false;
113 for (auto &it : fe.getColFieldEnts()) {
114 if (auto e = it.lock()) {
115 auto cache = e->entityCacheColDofs.lock();
116 if (!cache)
117 SETERRQ(mofemComm, MOFEM_DATA_INCONSISTENCY, "Cache not set");
118 if (!open || columns.segments.back().field != e->getId()) {
119 if (open)
120 columns.segments.back().end = columns.indices.size();
121 columns.segments.push_back(
122 {e->getId(), static_cast<int>(columns.indices.size()), 0});
123 open = true;
124 }
125 for (auto vit = cache->loHi[0]; vit != cache->loHi[1]; ++vit) {
126 const int idx = TAG::get_index(vit);
127 if (PetscLikely(idx >= 0))
128 columns.indices.push_back(idx);
129 }
130 }
131 }
132 if (open)
133 columns.segments.back().end = columns.indices.size();
134 columns.elementSegments.push_back(
135 {first_segment, static_cast<int>(columns.segments.size())});
137}
It it
Definition Schur.cpp:2568
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MPI_Comm mofemComm
MoFEM communicator.
Definition Core.hpp:1024

◆ createMatArrays()

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

Create matrix adjacencies.

TAG is the container index of the numbered DOFs that is iterated and whose index fills the arrays. The rows of this rank are the ones with its part, except for the adjacency matrix of a problem that is not partitioned yet (MATMPIADJ): then they are a PetscLayout range of the global index, which buildProblem assigns in UID order on every rank.

Definition at line 224 of file MatrixManager.cpp.

227 {
229
230 PetscLogEventBegin(MOFEM_EVENT_createMat, 0, 0, 0, 0);
231
232 auto cache = boost::make_shared<std::vector<EntityCacheNumeredDofs>>(
233 entsFields.size());
234
235 size_t idx = 0;
236 for (auto it = entsFields.begin(); it != entsFields.end(); ++it, ++idx) {
237
238 const auto uid = (*it)->getLocalUniqueId();
239 auto r = entFEAdjacencies.get<Unique_mi_tag>().equal_range(uid);
240 for (auto lo = r.first; lo != r.second; ++lo) {
241
242 if ((lo->getBitFEId() & p_miit->getBitFEId()).any()) {
243
244 const BitRefLevel &prb_bit = p_miit->getBitRefLevel();
245 const BitRefLevel &prb_mask = p_miit->getBitRefLevelMask();
246 const BitRefLevel &fe_bit = lo->entFePtr->getBitRefLevel();
247
248 // if entity is not problem refinement level
249 if ((fe_bit & prb_mask) != fe_bit)
250 continue;
251 if ((fe_bit & prb_bit).none())
252 continue;
253
254 auto dit = p_miit->numeredColDofsPtr->lower_bound(uid);
255
256 decltype(dit) hi_dit;
257 if (dit != p_miit->numeredColDofsPtr->end())
258 hi_dit = p_miit->numeredColDofsPtr->upper_bound(
259 uid | static_cast<UId>(MAX_DOFS_ON_ENTITY - 1));
260 else
261 hi_dit = dit;
262
263 (*it)->entityCacheColDofs =
264 boost::shared_ptr<EntityCacheNumeredDofs>(cache, &((*cache)[idx]));
265 (*cache)[idx].loHi = {dit, hi_dit};
266
267 break;
268 }
269 }
270 }
271
272 using NumeredDofEntitysByIdx =
273 typename boost::multi_index::index<NumeredDofEntity_multiIndex,
274 TAG>::type;
275
276 // Get multi-indices for rows and columns
277 const NumeredDofEntitysByIdx &dofs_row_by_idx =
278 p_miit->numeredRowDofsPtr->get<TAG>();
279 int nb_dofs_row = p_miit->getNbDofsRow();
280 if (nb_dofs_row == 0) {
281 SETERRQ(mofemComm, MOFEM_DATA_INCONSISTENCY, "problem <%s> has zero rows",
282 p_miit->getName().c_str());
283 }
284
285 // Get adjacencies form other processors
286 std::map<int, std::vector<int>> adjacent_dofs_on_other_parts;
287
288 // The adjacency matrix for partitioning is made before any part is set:
289 // its rows are a PetscLayout range of the global index. Otherwise the rows
290 // of this rank are the ones with its part, and the adjacencies of shared
291 // rows owned elsewhere are collected from the other parts. If only the
292 // algebra is partitioned there is nothing to collect: the mesh is assumed
293 // to be the same on every processor.
294 const bool rows_by_layout = strcmp(type, MATMPIADJ) == 0;
295 typename NumeredDofEntitysByIdx::iterator miit_row, hi_miit_row;
296
297 if (rows_by_layout) {
298
299 // Get range of local indices
300 PetscLayout layout;
301 CHKERR PetscLayoutCreate(mofemComm, &layout);
302 CHKERR PetscLayoutSetBlockSize(layout, 1);
303 CHKERR PetscLayoutSetSize(layout, nb_dofs_row);
304 CHKERR PetscLayoutSetUp(layout);
305 PetscInt rstart, rend;
306 CHKERR PetscLayoutGetRange(layout, &rstart, &rend);
307 CHKERR PetscLayoutDestroy(&layout);
308
309 if (verb >= VERBOSE) {
310 MOFEM_LOG("SYNC", Sev::noisy)
311 << "row lower " << rstart << " row upper " << rend;
313 }
314
315 miit_row = dofs_row_by_idx.lower_bound(rstart);
316 hi_miit_row = dofs_row_by_idx.lower_bound(rend);
317 if (std::distance(miit_row, hi_miit_row) != rend - rstart) {
318 SETERRQ(
319 mofemComm, PETSC_ERR_ARG_SIZ,
320 "data inconsistency, std::distance(miit_row,hi_miit_row) != rend - "
321 "rstart (%ld != %d - %d = %d) ",
322 std::distance(miit_row, hi_miit_row), rend, rstart, rend - rstart);
323 }
324
325 } else {
326
327 MPI_Comm comm;
328 // // Make sure it is a PETSc mofemComm
329 CHKERR PetscCommDuplicate(get_comm(), &comm, NULL);
330
331 // get adjacent nodes on other partitions
332 std::vector<std::vector<int>> dofs_vec(sIze);
333
334 boost::shared_ptr<FieldEntity> mofem_ent_ptr;
335 std::vector<int> dofs_col_view;
336
337 typename NumeredDofEntitysByIdx::iterator mit_row, hi_mit_row;
338
339 mit_row = dofs_row_by_idx.begin();
340 hi_mit_row = dofs_row_by_idx.end();
341 for (; mit_row != hi_mit_row; mit_row++) {
342
343 // Shared or multi-shared row and not owned. Those data should be send to
344 // other side.
345
346 // Get entity adjacencies, no need to repeat that operation for dofs when
347 // are on the same entity. For simplicity is assumed that those sheered
348 // the same adjacencies.
349 unsigned char pstatus = (*mit_row)->getPStatus();
350 if ((pstatus & PSTATUS_NOT_OWNED) &&
351 (pstatus & (PSTATUS_SHARED | PSTATUS_MULTISHARED))) {
352
353 bool get_adj_col = true;
354 if (mofem_ent_ptr) {
355 if (mofem_ent_ptr->getLocalUniqueId() ==
356 (*mit_row)->getFieldEntityPtr()->getLocalUniqueId()) {
357 get_adj_col = false;
358 }
359 }
360
361 if (get_adj_col) {
362 // Get entity adjacencies
363 mofem_ent_ptr = (*mit_row)->getFieldEntityPtr();
364 CHKERR getEntityAdjacencies<TAG>(p_miit, mit_row, mofem_ent_ptr,
365 dofs_col_view, verb);
366 // Sort, unique and resize dofs_col_view
367 {
368 std::sort(dofs_col_view.begin(), dofs_col_view.end());
369 std::vector<int>::iterator new_end =
370 std::unique(dofs_col_view.begin(), dofs_col_view.end());
371 int new_size = std::distance(dofs_col_view.begin(), new_end);
372 dofs_col_view.resize(new_size);
373 }
374 // Add that row. Patterns is that first index is row index, second is
375 // size of adjacencies after that follows column adjacencies.
376 int owner = (*mit_row)->getOwnerProc();
377 dofs_vec[owner].emplace_back(TAG::get_index(mit_row)); // row index
378 dofs_vec[owner].emplace_back(
379 dofs_col_view.size()); // nb. of column adjacencies
380 // add adjacent cools
381 dofs_vec[owner].insert(dofs_vec[owner].end(), dofs_col_view.begin(),
382 dofs_col_view.end());
383 }
384 }
385 }
386
387 int nsends = 0; // number of messages to send
388 std::vector<int> dofs_vec_length(sIze); // length of the message to proc
389 for (int proc = 0; proc < sIze; proc++) {
390
391 if (!dofs_vec[proc].empty()) {
392
393 dofs_vec_length[proc] = dofs_vec[proc].size();
394 nsends++;
395
396 } else {
397
398 dofs_vec_length[proc] = 0;
399 }
400 }
401
402 std::vector<MPI_Status> status(sIze);
403
404 // Computes the number of messages a node expects to receive
405 int nrecvs; // number of messages received
406 CHKERR PetscGatherNumberOfMessages(comm, NULL, &dofs_vec_length[0],
407 &nrecvs);
408
409 // Computes info about messages that a MPI-node will receive, including
410 // (from-id,length) pairs for each message.
411 int *onodes; // list of node-ids from which messages are expected
412 int *olengths; // corresponding message lengths
413 CHKERR PetscGatherMessageLengths(comm, nsends, nrecvs, &dofs_vec_length[0],
414 &onodes, &olengths);
415
416 // Gets a unique new tag from a PETSc communicator.
417 int tag;
418 CHKERR PetscCommGetNewTag(comm, &tag);
419
420 // Allocate a buffer sufficient to hold messages of size specified in
421 // olengths. And post Irecvs on these buffers using node info from onodes
422 int **rbuf; // must bee freed by user
423 MPI_Request *r_waits; // must bee freed by user
424
425 // rbuf has a pointers to messages. It has size of of nrecvs (number of
426 // messages) +1. In the first index a block is allocated,
427 // such that rbuf[i] = rbuf[i-1]+olengths[i-1].
428 CHKERR PetscPostIrecvInt(comm, tag, nrecvs, onodes, olengths, &rbuf,
429 &r_waits);
430
431 MPI_Request *s_waits; // status of sens messages
432 CHKERR PetscMalloc1(nsends, &s_waits);
433
434 // Send messages
435 for (int proc = 0, kk = 0; proc < sIze; proc++) {
436 if (!dofs_vec_length[proc])
437 continue; // no message to send to this proc
438 CHKERR MPI_Isend(&(dofs_vec[proc])[0], // buffer to send
439 dofs_vec_length[proc], // message length
440 MPIU_INT, proc, // to proc
441 tag, comm, s_waits + kk);
442 kk++;
443 }
444
445 // Wait for received
446 if (nrecvs) {
447 CHKERR MPI_Waitall(nrecvs, r_waits, &status[0]);
448 }
449 // Wait for send messages
450 if (nsends) {
451 CHKERR MPI_Waitall(nsends, s_waits, &status[0]);
452 }
453
454 for (int kk = 0; kk < nrecvs; kk++) {
455
456 int len = olengths[kk];
457 int *data_from_proc = rbuf[kk];
458
459 for (int ii = 0; ii < len;) {
460
461 int row_idx = data_from_proc[ii++]; // get row number
462 int nb_adj_dofs = data_from_proc[ii++]; // get nb. of adjacent dofs
463
464 if (debug) {
465
466 DofByGlobalPetscIndex::iterator dit;
467 dit = p_miit->numeredRowDofsPtr->get<PetscGlobalIdx_mi_tag>().find(
468 row_idx);
469 if (dit ==
470 p_miit->numeredRowDofsPtr->get<PetscGlobalIdx_mi_tag>().end()) {
472 "dof %d can not be found in problem", row_idx);
473 }
474 }
475
476 for (int jj = 0; jj < nb_adj_dofs; jj++) {
477 adjacent_dofs_on_other_parts[row_idx].push_back(data_from_proc[ii++]);
478 }
479 }
480 }
481
482 // Cleaning
483 CHKERR PetscFree(s_waits);
484 CHKERR PetscFree(rbuf[0]);
485 CHKERR PetscFree(rbuf);
486 CHKERR PetscFree(r_waits);
487 CHKERR PetscFree(onodes);
488 CHKERR PetscFree(olengths);
489
490 miit_row = dofs_row_by_idx.begin();
491 hi_miit_row = dofs_row_by_idx.end();
492
493 CHKERR PetscCommDestroy(&comm);
494 }
495
496 boost::shared_ptr<FieldEntity> mofem_ent_ptr;
497 int row_last_evaluated_idx = -1;
498
499 std::vector<int> dofs_vec;
500
501 // Column lists per element, built on first use and merged per row entity
502 // through a stamp array: an index enters the row once, without sorting
503 // the concatenation of all adjacent elements' DOFs.
504 ElementColumns columns;
505 columns.slot.reserve(p_miit->numeredFiniteElementsPtr->size());
506 std::vector<int> stamp(p_miit->getNbDofsCol(), -1);
507 int stamp_id = -1;
508 const auto &empty_field_blocks = p_miit->getEmptyFieldBlocks();
509 auto check_block = [&empty_field_blocks](const BitFieldId &row_field,
510 const BitFieldId &col_field) {
511 for (auto &b : empty_field_blocks)
512 if ((b.first & row_field).any() && (b.second & col_field).any())
513 return false;
514 return true;
515 };
516 const BitRefLevel prb_bit = p_miit->getBitRefLevel();
517 const BitRefLevel prb_mask = p_miit->getBitRefLevelMask();
518 auto push_once = [&](const int idx) {
520 if (PetscUnlikely(idx >= static_cast<int>(stamp.size())))
521 SETERRQ(mofemComm, PETSC_ERR_ARG_SIZ,
522 "Index of dof larger than number of DOFs in column");
523 if (stamp[idx] != stamp_id) {
524 stamp[idx] = stamp_id;
525 dofs_vec.push_back(idx);
526 }
528 };
529
530 // loop local rows
531 int nb_loc_row_from_iterators = 0;
532 unsigned int rows_to_fill = p_miit->getNbLocalDofsRow();
533 // Stage one sorted list per run of rows on a field entity. This is much
534 // smaller than the final CSR at high order, where many rows share a list.
535 struct RowPattern {
536 std::size_t begin, end;
537 int firstRow, lastRow;
538 };
539 std::vector<RowPattern> row_patterns;
540 row_patterns.reserve(std::min<std::size_t>(rows_to_fill, entsFields.size()));
541 std::vector<PetscInt> pattern_columns;
542 std::vector<PetscInt> row_diagonals;
543 if (no_diagonals)
544 row_diagonals.reserve(rows_to_fill);
545 std::size_t nb_nonzeros = j.size();
546 i.reserve(rows_to_fill + 1);
547 for (; miit_row != hi_miit_row; miit_row++) {
548
549 if (!rows_by_layout) {
550 if (static_cast<int>((*miit_row)->getPart()) != rAnk)
551 continue;
552 }
553 // This is only for cross-check if everything is ok
554 nb_loc_row_from_iterators++;
555
556 // add next row to compressed matrix
557 i.push_back(static_cast<PetscInt>(nb_nonzeros));
558
559 // Get entity adjacencies, no need to repeat that operation for dofs when
560 // are on the same entity. For simplicity is assumed that those share the
561 // same adjacencies.
562 if ((!mofem_ent_ptr)
563 ? 1
564 : (mofem_ent_ptr->getLocalUniqueId() !=
565 (*miit_row)->getFieldEntityPtr()->getLocalUniqueId())) {
566
567 // get entity adjacencies
568 mofem_ent_ptr = (*miit_row)->getFieldEntityPtr();
569 row_last_evaluated_idx = TAG::get_index(miit_row);
570 const BitFieldId row_field = (*miit_row)->getId();
571
572 dofs_vec.resize(0);
573 ++stamp_id;
574 for (auto r = entFEAdjacencies.get<Unique_mi_tag>().equal_range(
575 mofem_ent_ptr->getLocalUniqueId());
576 r.first != r.second; ++r.first) {
577 if (!(r.first->byWhat & BYROW))
578 continue;
579 const auto &fe_ptr = r.first->entFePtr;
580 if ((fe_ptr->getId() & p_miit->getBitFEId()).none())
581 continue;
582 const BitRefLevel &fe_bit = fe_ptr->getBitRefLevel();
583 if (!((fe_bit & prb_bit).any() && (fe_bit & prb_mask) == fe_bit))
584 continue;
585 int slot;
586 auto slot_it = columns.slot.find(fe_ptr.get());
587 if (slot_it != columns.slot.end())
588 slot = slot_it->second;
589 else
590 CHKERR addElementColumns<TAG>(*fe_ptr, columns, slot);
591 const auto segment_range = columns.elementSegments[slot];
592 for (int s = segment_range[0]; s != segment_range[1]; ++s) {
593 const auto &segment = columns.segments[s];
594 if (!check_block(row_field, segment.field))
595 continue;
596 for (int k = segment.begin; k != segment.end; ++k)
597 CHKERR push_once(columns.indices[k]);
598 }
599 }
600
601 unsigned char pstatus = (*miit_row)->getPStatus();
602 if (pstatus > 0) {
603 std::map<int, std::vector<int>>::iterator mit;
604 mit = adjacent_dofs_on_other_parts.find(row_last_evaluated_idx);
605 if (mit == adjacent_dofs_on_other_parts.end()) {
606 // NOTE: Dof can adjacent to other part but no elements are there
607 // which use that dof std::cerr << *miit_row << std::endl; SETERRQ(
608 // get_comm(),MOFEM_DATA_INCONSISTENCY,
609 // "data inconsistency row_last_evaluated_idx = %d",
610 // row_last_evaluated_idx
611 // );
612 } else {
613 for (auto idx : mit->second)
614 CHKERR push_once(idx);
615 }
616 }
617
618 // The unique list is sorted so that PETSc inserts rows in order.
619 std::sort(dofs_vec.begin(), dofs_vec.end());
620 const auto begin = pattern_columns.size();
621 pattern_columns.insert(pattern_columns.end(), dofs_vec.begin(),
622 dofs_vec.end());
623 row_patterns.push_back({begin, pattern_columns.size(),
624 nb_loc_row_from_iterators - 1,
625 nb_loc_row_from_iterators});
626 }
627
628 row_patterns.back().lastRow = nb_loc_row_from_iterators;
629 auto row_size = dofs_vec.size();
630 if (no_diagonals) {
631 const auto diagonal = TAG::get_index(miit_row);
632 row_diagonals.push_back(diagonal);
633 if (std::binary_search(dofs_vec.begin(), dofs_vec.end(), diagonal))
634 --row_size;
635 }
636 if (row_size > std::numeric_limits<PetscInt>::max() - nb_nonzeros)
637 SETERRQ(mofemComm, PETSC_ERR_ARG_SIZ,
638 "CSR column offsets exceed the PetscInt range");
639 nb_nonzeros += row_size;
640 }
641
642 i.push_back(static_cast<PetscInt>(nb_nonzeros));
643 // The exact row counts are known: reserve once and bulk-copy each list,
644 // splitting it only when the graph-partitioning path excludes a diagonal.
645 j.reserve(nb_nonzeros);
646 for (const auto &pattern : row_patterns) {
647 const auto begin = pattern_columns.begin() + pattern.begin;
648 const auto end = pattern_columns.begin() + pattern.end;
649 for (int row = pattern.firstRow; row != pattern.lastRow; ++row) {
650 if (!no_diagonals || i[row + 1] - i[row] == pattern.end - pattern.begin)
651 j.insert(j.end(), begin, end);
652 else {
653 const auto diagonal = std::lower_bound(begin, end, row_diagonals[row]);
654 j.insert(j.end(), begin, diagonal);
655 j.insert(j.end(), std::next(diagonal), end);
656 }
657 }
658 }
659
660 if (strcmp(type, MATMPIADJ) == 0) {
661
662 // Adjacency matrix used to partition problems, f.e. METIS
663 if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
664 SETERRQ(
665 get_comm(), PETSC_ERR_ARG_SIZ,
666 "Number of rows from iterator is different than size of rows in "
667 "compressed row "
668 "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %u != "
669 "%zu",
670 (unsigned int)nb_loc_row_from_iterators, i.size() - 1);
671 }
672
673 } else if (strcmp(type, MATMPIAIJ) == 0) {
674
675 // Compressed MPIADJ matrix
676 if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
677 SETERRQ(
678 get_comm(), PETSC_ERR_ARG_SIZ,
679 "Number of rows from iterator is different than size of rows in "
680 "compressed row "
681 "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %u != "
682 "%zu",
683 (unsigned int)nb_loc_row_from_iterators, i.size() - 1);
684 }
685 PetscInt nb_local_dofs_row = p_miit->getNbLocalDofsRow();
686 if ((unsigned int)nb_local_dofs_row != i.size() - 1) {
687 SETERRQ(
688 get_comm(), PETSC_ERR_ARG_SIZ,
689 "Number of rows is different than size of rows in compressed row "
690 "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %u != "
691 "%zu",
692 (unsigned int)nb_local_dofs_row, i.size() - 1);
693 }
694
695 } else if (strcmp(type, MATAIJ) == 0) {
696
697 // Sequential compressed ADJ matrix
698 if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
699 SETERRQ(
700 get_comm(), PETSC_ERR_ARG_SIZ,
701 "Number of rows form iterator is different than size of rows in "
702 "compressed row "
703 "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %u != "
704 "%zu",
705 (unsigned int)nb_loc_row_from_iterators, i.size() - 1);
706 }
707 PetscInt nb_local_dofs_row = p_miit->getNbLocalDofsRow();
708 if ((unsigned int)nb_local_dofs_row != i.size() - 1) {
709 SETERRQ(
710 get_comm(), PETSC_ERR_ARG_SIZ,
711 "Number of rows is different than size of rows in compressed row "
712 "matrix (unsigned int)nb_local_dofs_row != i.size() - 1, i.e. %u != "
713 "%zu",
714 (unsigned int)nb_local_dofs_row, i.size() - 1);
715 }
716
717 } else if (strcmp(type, MATAIJCUSPARSE) == 0) {
718
719 if (i.size() - 1 != (unsigned int)nb_loc_row_from_iterators) {
720 SETERRQ(get_comm(), PETSC_ERR_ARG_SIZ, "data inconsistency");
721 }
722 PetscInt nb_local_dofs_row = p_miit->getNbLocalDofsRow();
723 if ((unsigned int)nb_local_dofs_row != i.size() - 1) {
724 SETERRQ(get_comm(), PETSC_ERR_ARG_SIZ, "data inconsistency");
725 }
726
727 } else {
728
729 SETERRQ(get_comm(), PETSC_ERR_ARG_NULL, "not implemented");
730 }
731
732 PetscLogEventEnd(MOFEM_EVENT_createMat, 0, 0, 0, 0);
734}
CGALInterfaceImpl & owner
unsigned char status
Tag tag
std::vector< double > empty
One value per component.
std::string type
#define MOFEM_LOG_SYNCHRONISE(comm)
Synchronise "SYNC" channel.
#define MatrixManagerFunctionBegin
Create adjacent matrices using different indices.
std::vector< FieldBitNumber > row
Definition Schur.cpp:2488
It end
Definition Schur.cpp:2568
SmartPetscObj< Vec > diagonal
@ VERBOSE
#define MAX_DOFS_ON_ENTITY
Maximal number of DOFs on entity.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ BYROW
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
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< 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.
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
std::bitset< BITFIELDID_SIZE > BitFieldId
Field Id.
Definition Types.hpp:42
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:205
MPI_Comm & get_comm() const
Definition Core.hpp:1033
PetscLogEvent MOFEM_EVENT_createMat
Definition Core.hpp:1016
FieldEntity_multiIndex entsFields
entities on fields
Definition Core.hpp:309
int sIze
MoFEM communicator size.
Definition Core.hpp:1027
int rAnk
MOFEM communicator rank.
Definition Core.hpp:1028
FieldEntityEntFiniteElementAdjacencyMap_multiIndex entFEAdjacencies
adjacencies of elements to dofs
Definition Core.hpp:316

◆ getEntityAdjacencies()

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

Get element adjacencies.

Definition at line 145 of file MatrixManager.cpp.

150 {
152
153 BitRefLevel prb_bit = p_miit->getBitRefLevel();
154 BitRefLevel prb_mask = p_miit->getBitRefLevelMask();
155
156 const EmptyFieldBlocks &empty_field_blocks = p_miit->getEmptyFieldBlocks();
157
158 dofs_col_view.clear();
159 for (auto r = entFEAdjacencies.get<Unique_mi_tag>().equal_range(
160 mofem_ent_ptr->getLocalUniqueId());
161 r.first != r.second; ++r.first) {
162
163 if (r.first->byWhat & BYROW) {
164
165 if ((r.first->entFePtr->getId() & p_miit->getBitFEId()).none()) {
166 // if element is not part of problem
167 continue;
168 }
169
170 const BitRefLevel &fe_bit = r.first->entFePtr->getBitRefLevel();
171 // if entity is not problem refinement level
172 if ((fe_bit & prb_bit).any() && (fe_bit & prb_mask) == fe_bit) {
173
174 auto check_block = [&empty_field_blocks](auto &r_if, auto &col_id) {
175 for (auto &b : empty_field_blocks) {
176 if ((b.first & r_if).any() && (b.second & col_id).any()) {
177 return false;
178 }
179 }
180 return true;
181 };
182
183 for (auto &it : r.first->entFePtr->getColFieldEnts()) {
184 if (auto e = it.lock()) {
185
186 if (check_block((*mit_row)->getId(), e->getId())) {
187
188 if (auto cache = e->entityCacheColDofs.lock()) {
189 const auto lo = cache->loHi[0];
190 const auto hi = cache->loHi[1];
191 for (auto vit = lo; vit != hi; ++vit) {
192
193 const int idx = TAG::get_index(vit);
194 if (PetscLikely(idx >= 0))
195 dofs_col_view.push_back(idx);
196
197#ifndef NDEBUG
198 const DofIdx nb_dofs_col = p_miit->getNbDofsCol();
199 if (PetscUnlikely(idx >= nb_dofs_col)) {
200 MOFEM_LOG("SELF", Sev::error)
201 << "Problem with dof: " << std::endl
202 << "Rank " << rAnk << " : " << *(*vit);
203 SETERRQ(
204 mofemComm, PETSC_ERR_ARG_SIZ,
205 "Index of dof larger than number of DOFs in column");
206 }
207#endif
208 }
209
210 } else {
211 SETERRQ(mofemComm, MOFEM_DATA_INCONSISTENCY, "Cache not set");
212 }
213 }
214 }
215 }
216 }
217 }
218 }
219
221}
int DofIdx
Index of DOF.
Definition Types.hpp:18
Problem::EmptyFieldBlocks EmptyFieldBlocks

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