v0.16.3
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | Private Attributes | List of all members
MoFEM::MatrixManager Struct Reference

Matrix manager is used to build and partition problems. More...

#include "src/interfaces/MatrixManager.hpp"

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

Public Member Functions

MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 MatrixManager (const MoFEM::Core &core)
 
virtual ~MatrixManager ()=default
 Destructor.
 
template<class Tag >
MoFEMErrorCode createMPIAIJWithArrays (const std::string name, Mat *Aij, int verb=QUIET)
 Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.
 
template<class Tag >
MoFEMErrorCode createMPIAIJWithArrays (const std::string name, SmartPetscObj< Mat > &aij_ptr, int verb=QUIET)
 Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.
 
template<class Tag >
MoFEMErrorCode createMPIAIJCUSPARSEWithArrays (const std::string name, Mat *Aij, int verb=QUIET)
 
template<class Tag >
MoFEMErrorCode createMPIAIJCUSPARSEWithArrays (const std::string name, SmartPetscObj< Mat > &aij_ptr, int verb=QUIET)
 
template<class Tag >
MoFEMErrorCode createSeqAIJCUSPARSEWithArrays (const std::string name, Mat *Aij, int verb=QUIET)
 
template<class Tag >
MoFEMErrorCode createSeqAIJCUSPARSEWithArrays (const std::string name, SmartPetscObj< Mat > &aij_ptr, int verb=QUIET)
 
template<class Tag >
MoFEMErrorCode createMPIAIJ (const std::string name, Mat *Aij, int verb=QUIET)
 Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.
 
template<class Tag >
MoFEMErrorCode createMPIAIJ (const std::string name, SmartPetscObj< Mat > &aij_ptr, int verb=QUIET)
 Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.
 
template<class Tag >
MoFEMErrorCode createMPIAdjWithArrays (const std::string name, Mat *Adj, int verb=QUIET)
 Creates a sparse matrix representing an adjacency list.
 
template<class Tag >
MoFEMErrorCode createSeqAIJWithArrays (const std::string name, Mat *Aij, int verb=QUIET)
 Create sequencial matrix.
 
template<class Tag >
MoFEMErrorCode createSeqAIJWithArrays (const std::string name, SmartPetscObj< Mat > &aij_ptr, int verb=QUIET)
 Create sequencial matrix.
 
MoFEMErrorCode checkMatrixFillIn (const std::string problem_name, int row_print, int col_print, Mat A, int verb=QUIET)
 check if matrix fill in correspond to finite element indices
 
template<class Tag >
MoFEMErrorCode checkMPIAIJWithArraysMatrixFillIn (const std::string problem_name, int row_print, int col_print, int verb=QUIET)
 check if matrix fill in correspond to finite element indices
 
template<class Tag >
MoFEMErrorCode checkMPIAIJMatrixFillIn (const std::string problem_name, int row_print, int col_print, int verb=QUIET)
 check if matrix fill in correspond to finite element indices
 
template<class Tag >
MoFEMErrorCode createHybridL2MPIAIJ (const std::string problem_name, SmartPetscObj< Mat > &aij_ptr, int verb=QUIET)
 Create a Hybrid MPIAij object.
 
template<>
MoFEMErrorCode createMPIAIJWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createMPIAIJCUSPARSEWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createSeqAIJCUSPARSEWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createMPIAIJ (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createMPIAdjWithArrays (const std::string name, Mat *Adj, int verb)
 
template<>
MoFEMErrorCode createSeqAIJWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode checkMPIAIJWithArraysMatrixFillIn (const std::string problem_name, int row_print, int col_print, int verb)
 
template<>
MoFEMErrorCode checkMPIAIJMatrixFillIn (const std::string problem_name, int row_print, int col_print, int verb)
 
template<>
MoFEMErrorCode createHybridL2MPIAIJ (const std::string problem_name, SmartPetscObj< Mat > &aij_ptr, int verb)
 
template<>
MoFEMErrorCode createMPIAIJWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createMPIAIJCUSPARSEWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createMPIAIJ (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createMPIAdjWithArrays (const std::string name, Mat *Adj, int verb)
 
template<>
MoFEMErrorCode createSeqAIJWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode createSeqAIJCUSPARSEWithArrays (const std::string name, Mat *Aij, int verb)
 
template<>
MoFEMErrorCode checkMPIAIJWithArraysMatrixFillIn (const std::string problem_name, int row_print, int col_print, int verb)
 
template<>
MoFEMErrorCode checkMPIAIJMatrixFillIn (const std::string problem_name, int row_print, int col_print, int verb)
 
template<>
MoFEMErrorCode createHybridL2MPIAIJ (const std::string problem_name, SmartPetscObj< Mat > &aij_ptr, int verb)
 
- 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
 

Public Attributes

MoFEM::Core & cOre
 

Private Attributes

PetscLogEvent MOFEM_EVENT_createMPIAIJ
 
PetscLogEvent MOFEM_EVENT_createMPIAIJWithArrays
 
PetscLogEvent MOFEM_EVENT_createMPIAdjWithArrays
 
PetscLogEvent MOFEM_EVENT_createSeqAIJWithArrays
 
PetscLogEvent MOFEM_EVENT_createMPIAIJCUSPARSEWithArrays
 
PetscLogEvent MOFEM_EVENT_createSeqAIJCUSPARSEWithArrays
 
PetscLogEvent MOFEM_EVENT_checkMatrixFillIn
 

Additional Inherited Members

- 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.
 

Detailed Description

Matrix manager is used to build and partition problems.

Examples
mofem/atom_tests/build_composite_problem.cpp, mofem/atom_tests/build_large_problem.cpp, mofem/atom_tests/build_problems.cpp, mofem/atom_tests/dm_build_partitioned_mesh.cpp, mofem/atom_tests/dm_create_subdm.cpp, mofem/atom_tests/dm_partitioned_no_field.cpp, mofem/atom_tests/prism_polynomial_approximation.cpp, mofem/atom_tests/quad_polynomial_approximation.cpp, mofem/atom_tests/rebuild_problem.cpp, mofem/atom_tests/remove_entities_from_problem.cpp, mofem/atom_tests/remove_entities_from_problem_not_partitioned.cpp, mofem/tutorials/cor-12_cohesive_interface/arc_length_interface.cpp, and mofem/users_modules/basic_finite_elements/nonlinear_elasticity/nonlinear_dynamics.cpp.

Definition at line 21 of file MatrixManager.hpp.

Constructor & Destructor Documentation

◆ MatrixManager()

MoFEM::MatrixManager::MatrixManager ( const MoFEM::Core &  core)

Definition at line 743 of file MatrixManager.cpp.

744 : cOre(const_cast<MoFEM::Core &>(core)) {
745 PetscLogEventRegister("MatMngCrtMPIAIJ", 0, &MOFEM_EVENT_createMPIAIJ);
746 PetscLogEventRegister("MatMngCrtMPIAIJWthArr", 0,
748 PetscLogEventRegister("MatMngCrtMPIAdjWithArr", 0,
750 PetscLogEventRegister("MatMngCrtMPIAIJCUSPARSEWthArr", 0,
752 PetscLogEventRegister("MatMngCrtSeqAIJCUSPARSEWthArrs", 0,
754 PetscLogEventRegister("MatMngCrtSeqAIJWthArrs", 0,
756 PetscLogEventRegister("MatMngCrtCheckMPIAIJWthArrFillIn", 0,
758}
Core (interface) class.
Definition Core.hpp:83
PetscLogEvent MOFEM_EVENT_createSeqAIJCUSPARSEWithArrays
PetscLogEvent MOFEM_EVENT_createMPIAdjWithArrays
PetscLogEvent MOFEM_EVENT_checkMatrixFillIn
PetscLogEvent MOFEM_EVENT_createMPIAIJ
MoFEMErrorCode createMPIAIJWithArrays(const std::string name, Mat *Aij, int verb=QUIET)
Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.
PetscLogEvent MOFEM_EVENT_createMPIAIJWithArrays
PetscLogEvent MOFEM_EVENT_createSeqAIJWithArrays
PetscLogEvent MOFEM_EVENT_createMPIAIJCUSPARSEWithArrays

◆ ~MatrixManager()

virtual MoFEM::MatrixManager::~MatrixManager ( )
virtualdefault

Destructor.

Member Function Documentation

◆ checkMatrixFillIn()

MoFEMErrorCode MoFEM::MatrixManager::checkMatrixFillIn ( const std::string  problem_name,
int  row_print,
int  col_print,
Mat  A,
int  verb = QUIET 
)

check if matrix fill in correspond to finite element indices

This is used to check consistency of code. If problem is notices with additional non-zero elements in matrix, this function can help detect problem. Should be used as a part of atom tests

Parameters
problem_name
rowprint info at particular row
colprint info at particular col
Returns
MoFEMErrorCode

Definition at line 1036 of file MatrixManager.cpp.

1038 {
1041
1043
1044 struct TestMatrixFillIn : public FEMethod {
1045 CoreInterface *mFieldPtr;
1046
1047 Mat A;
1048
1049 int rowPrint, colPrint;
1050
1051 TestMatrixFillIn(CoreInterface *m_field_ptr, Mat a, int row_print,
1052 int col_print)
1053 : mFieldPtr(m_field_ptr), A(a), rowPrint(row_print),
1055
1056 MoFEMErrorCode preProcess() {
1059 }
1060
1061 MoFEMErrorCode operator()() {
1063
1064 if (refinedFiniteElementsPtr->find(
1065 numeredEntFiniteElementPtr->getEnt()) ==
1066 refinedFiniteElementsPtr->end()) {
1067 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1068 "data inconsistency");
1069 }
1070
1071 auto row_dofs = getRowDofsPtr();
1072 auto col_dofs = getColDofsPtr();
1073
1074 for (auto cit = col_dofs->begin(); cit != col_dofs->end(); cit++) {
1075
1076 if (refinedEntitiesPtr->find((*cit)->getEnt()) ==
1077 refinedEntitiesPtr->end()) {
1078 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1079 "data inconsistency");
1080 }
1081 if (!(*cit)->getActive()) {
1082 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1083 "data inconsistency");
1084 }
1085
1086 FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index<
1087 Composite_Unique_mi_tag>::type::iterator ait;
1088 ait = adjacenciesPtr->get<Composite_Unique_mi_tag>().find(
1089 boost::make_tuple((*cit)->getFieldEntityPtr()->getLocalUniqueId(),
1090 numeredEntFiniteElementPtr->getLocalUniqueId()));
1091 if (ait == adjacenciesPtr->end()) {
1092 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1093 "adjacencies data inconsistency");
1094 } else {
1095 UId uid = ait->getEntUniqueId();
1096 if (entitiesPtr->find(uid) == entitiesPtr->end()) {
1097 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1098 "data inconsistency");
1099 }
1100 if (dofsPtr->find((*cit)->getLocalUniqueId()) == dofsPtr->end()) {
1101 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1102 "data inconsistency");
1103 }
1104 }
1105
1106 if ((*cit)->getEntType() != MBVERTEX) {
1107
1108 auto range =
1109 col_dofs->get<Ent_mi_tag>().equal_range((*cit)->getEnt());
1110 int nb_dofs_on_ent = std::distance(range.first, range.second);
1111
1112 int max_order = (*cit)->getMaxOrder();
1113 if ((*cit)->getNbOfCoeffs() * (*cit)->getOrderNbDofs(max_order) !=
1115
1116 /* It could be that you have
1117 removed DOFs from problem, and for example if this was vector field
1118 with components {Ux,Uy,Uz}, you removed on Uz element.*/
1119
1120 MOFEM_LOG("SELF", Sev::warning)
1121 << "Warning: Number of Dofs in Col different than number "
1122 "of dofs for given entity order: "
1123 << "Field name: " << (*cit)->getName() << " "
1124 << (*cit)->getNbOfCoeffs() * (*cit)->getOrderNbDofs(max_order)
1125 << " != " << nb_dofs_on_ent;
1126 }
1127 }
1128 }
1129
1130 for (auto rit = row_dofs->begin(); rit != row_dofs->end(); rit++) {
1131
1132 if (refinedEntitiesPtr->find((*rit)->getEnt()) ==
1133 refinedEntitiesPtr->end()) {
1134 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1135 "data inconsistency");
1136 }
1137 if (!(*rit)->getActive()) {
1138 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1139 "data inconsistency");
1140 }
1141
1142 FieldEntityEntFiniteElementAdjacencyMap_multiIndex::index<
1143 Composite_Unique_mi_tag>::type::iterator ait;
1144 ait = adjacenciesPtr->get<Composite_Unique_mi_tag>().find(
1145 boost::make_tuple((*rit)->getFieldEntityPtr()->getLocalUniqueId(),
1146 numeredEntFiniteElementPtr->getLocalUniqueId()));
1147 if (ait == adjacenciesPtr->end()) {
1149 MOFEM_LOG("SELF", Sev::error) << *(*rit);
1150 MOFEM_LOG("SELF", Sev::error) << *(*rit);
1151 MOFEM_LOG("SELF", Sev::error) << *numeredEntFiniteElementPtr;
1152 MOFEM_LOG("SELF", Sev::error) << "dof: " << (*rit)->getBitRefLevel();
1153 MOFEM_LOG("SELF", Sev::error)
1154 << "fe: " << numeredEntFiniteElementPtr->getBitRefLevel();
1155 MOFEM_LOG("SELF", Sev::error)
1156 << "problem: " << problemPtr->getBitRefLevel();
1157 MOFEM_LOG("SELF", Sev::error)
1158 << "problem mask: " << problemPtr->getBitRefLevelMask();
1159 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1160 "adjacencies data inconsistency");
1161 } else {
1162 UId uid = ait->getEntUniqueId();
1163 if (entitiesPtr->find(uid) == entitiesPtr->end()) {
1164 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1165 "data inconsistency");
1166 }
1167 if (dofsPtr->find((*rit)->getLocalUniqueId()) == dofsPtr->end()) {
1168 SETERRQ(mFieldPtr->get_comm(), MOFEM_DATA_INCONSISTENCY,
1169 "data inconsistency");
1170 }
1171 }
1172 int row = (*rit)->getPetscGlobalDofIdx();
1173
1174 auto col_dofs = getColDofsPtr();
1175 for (auto cit = col_dofs->begin(); cit != col_dofs->end(); cit++) {
1176
1177 int col = (*cit)->getPetscGlobalDofIdx();
1178
1179 if (row == rowPrint && col == colPrint) {
1180 MOFEM_LOG("SELF", Sev::noisy) << "fe:\n"
1181 << *numeredEntFiniteElementPtr;
1182 MOFEM_LOG("SELF", Sev::noisy) << "row:\n" << *(*rit);
1183 MOFEM_LOG("SELF", Sev::noisy) << "col:\n" << *(*cit);
1184 MOFEM_LOG("SELF", Sev::noisy)
1185 << "fe:\n"
1186 << numeredEntFiniteElementPtr->getBitRefLevel();
1187 MOFEM_LOG("SELF", Sev::noisy) << "row:\n"
1188 << (*rit)->getBitRefLevel();
1189 MOFEM_LOG("SELF", Sev::noisy) << "col:\n"
1190 << (*cit)->getBitRefLevel();
1191 }
1192
1194 }
1195
1196 if ((*rit)->getEntType() != MBVERTEX) {
1197
1198 auto range =
1199 row_dofs->get<Ent_mi_tag>().equal_range((*rit)->getEnt());
1200 int nb_dofs_on_ent = std::distance(range.first, range.second);
1201
1202 int max_order = (*rit)->getMaxOrder();
1203 if ((*rit)->getNbOfCoeffs() * (*rit)->getOrderNbDofs(max_order) !=
1205
1206 /* It could be that you have removed DOFs from problem, and for
1207 * example if this was vector field with components {Ux,Uy,Uz}, you
1208 * removed on Uz element. */
1209
1210 MOFEM_LOG("SELF", Sev::warning)
1211 << "Warning: Number of Dofs in Row different than number "
1212 "of dofs for given entity order "
1213 << "Field name: " << (*rit)->getName() << " "
1214 << (*rit)->getNbOfCoeffs() * (*rit)->getOrderNbDofs(max_order)
1215 << " != " << nb_dofs_on_ent;
1216 }
1217 }
1218 }
1219
1221 }
1222
1223 MoFEMErrorCode postProcess() {
1225
1226 // cerr << mFieldPtr->get_comm_rank() << endl;
1229
1231 }
1232 };
1233
1234 // create matrix
1236
1237 if (verb >= VERY_VERBOSE) {
1239 }
1240
1241 if (verb >= NOISY) {
1243 std::string wait;
1244 std::cin >> wait;
1245 }
1246
1248
1249 // get problem
1250 auto problems_ptr = m_field.get_problems();
1251 auto &prb_set = problems_ptr->get<Problem_mi_tag>();
1252 auto p_miit = prb_set.find(problem_name);
1253 if (p_miit == prb_set.end())
1255 "problem < %s > not found (top tip: check spelling)",
1256 problem_name.c_str());
1257 MOFEM_LOG_C("WORLD", Sev::inform, "check problem < %s >",
1258 problem_name.c_str());
1259
1260 // loop all elements in problem and check if assemble is without error
1261 auto fe_ptr = m_field.get_finite_elements();
1262 for (auto &fe : *fe_ptr) {
1263 MOFEM_LOG_C("WORLD", Sev::verbose, "\tcheck element %s",
1264 fe->getName().c_str());
1265 CHKERR m_field.loop_finite_elements(problem_name, fe->getName(), method,
1266 nullptr, MF_EXIST,
1267 CacheTupleSharedPtr(), verb);
1268 }
1269
1272
1274
1276}
#define MOFEM_LOG_C(channel, severity, format,...)
#define MatrixManagerFunctionBegin
Create adjacent matrices using different indices.
std::vector< FieldBitNumber > row
Definition Schur.cpp:2488
std::vector< FieldBitNumber > col
Definition Schur.cpp:2488
constexpr double a
@ VERY_VERBOSE
@ NOISY
@ MF_EXIST
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_ATTRIBUTES(channel, bit)
Add attributes to channel.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
uint128_t UId
Unique Id.
Definition Types.hpp:31
boost::shared_ptr< CacheTuple > CacheTupleSharedPtr
constexpr AssemblyType A

◆ checkMPIAIJMatrixFillIn() [1/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::checkMPIAIJMatrixFillIn ( const std::string  problem_name,
int  row_print,
int  col_print,
int  verb 
)

Definition at line 1292 of file MatrixManager.cpp.

1293 {
1295 // create matrix
1296 SmartPetscObj<Mat> A;
1301}
MoFEMErrorCode checkMatrixFillIn(const std::string problem_name, int row_print, int col_print, Mat A, int verb=QUIET)
check if matrix fill in correspond to finite element indices

◆ checkMPIAIJMatrixFillIn() [2/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::checkMPIAIJMatrixFillIn ( const std::string  problem_name,
int  row_print,
int  col_print,
int  verb 
)

◆ checkMPIAIJMatrixFillIn() [3/3]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::checkMPIAIJMatrixFillIn ( const std::string  problem_name,
int  row_print,
int  col_print,
int  verb = QUIET 
)
inline

check if matrix fill in correspond to finite element indices

This is used to check consistency of code. If problem is notices with additional non-zero elements in matrix, this function can help detect problem. Should be used as a part of atom tests

Template Parameters
Tag
Parameters
problem_name
rowprint info at particular row
colprint info at particular col
Returns
MoFEMErrorCode

Definition at line 286 of file MatrixManager.hpp.

288 {
289 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
290 return 0;
291 }

◆ checkMPIAIJWithArraysMatrixFillIn() [1/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::checkMPIAIJWithArraysMatrixFillIn ( const std::string  problem_name,
int  row_print,
int  col_print,
int  verb 
)

Definition at line 1279 of file MatrixManager.cpp.

◆ checkMPIAIJWithArraysMatrixFillIn() [2/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::checkMPIAIJWithArraysMatrixFillIn ( const std::string  problem_name,
int  row_print,
int  col_print,
int  verb 
)

◆ checkMPIAIJWithArraysMatrixFillIn() [3/3]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::checkMPIAIJWithArraysMatrixFillIn ( const std::string  problem_name,
int  row_print,
int  col_print,
int  verb = QUIET 
)
inline

check if matrix fill in correspond to finite element indices

This is used to check consistency of code. If problem is notices with additional non-zero elements in matrix, this function can help detect problem. Should be used as a part of atom tests

Template Parameters
Tag
Parameters
problem_name
rowprint info at particular row
colprint info at particular col
Returns
MoFEMErrorCode

Definition at line 265 of file MatrixManager.hpp.

267 {
268 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
269 return 0;
270 }

◆ createHybridL2MPIAIJ() [1/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createHybridL2MPIAIJ ( const std::string  problem_name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb 
)

Definition at line 1304 of file MatrixManager.cpp.

1305 {
1308
1309 auto prb_ptr = m_field.get_problems();
1310 auto p_miit = prb_ptr->get<Problem_mi_tag>().find(problem_name);
1311 if (p_miit == prb_ptr->get<Problem_mi_tag>().end()) {
1312 SETERRQ(m_field.get_comm(), MOFEM_NOT_FOUND,
1313 "problem < %s > is not found (top tip: check spelling)",
1314 problem_name.c_str());
1315 }
1316
1317 auto nb_rows = p_miit->getNbDofsRow();
1318 auto nb_cols = p_miit->getNbDofsCol();
1319 auto nb_loc_rows = p_miit->getNbLocalDofsRow();
1320 auto nb_loc_cols = p_miit->getNbLocalDofsCol();
1321
1322 auto row_ptr = p_miit->getNumeredRowDofsPtr();
1323 auto col_ptr = p_miit->getNumeredColDofsPtr();
1324
1326 for (auto &c : *col_ptr) {
1327 fields_ids |= c->getId();
1328 }
1329 auto fields = m_field.get_fields();
1330 std::vector<int> fields_bit_numbers;
1331 for (auto &f : *fields) {
1332 if ((fields_ids & f->getId()).any()) {
1333 fields_bit_numbers.push_back(f->getBitNumber());
1334 }
1335 }
1336
1337 Range adj;
1338 EntityHandle prev_ent = 0;
1339 int prev_dim = -1;
1340
1341 // Each bridge cell is reached from every one of its faces; its faces are
1342 // found in MOAB once and kept. Only cells on the problem's refinement level
1343 // are bridges: after a local refinement an unsplit face is also adjacent
1344 // to the refined parent cell, which is not in the problem.
1345 std::unordered_map<EntityHandle, Range> bridge_faces;
1346 auto ref_ents = m_field.get_ref_ents();
1347 const auto prb_bit = p_miit->getBitRefLevel();
1348 const auto prb_mask = p_miit->getBitRefLevelMask();
1349 auto on_problem_level = [&](EntityHandle cell) {
1350 auto it = ref_ents->find(cell);
1351 if (it == ref_ents->end())
1352 return false;
1353 const auto &bit = (*it)->getBitRefLevel();
1354 return (bit & prb_bit).any() && (bit & prb_mask) == bit;
1355 };
1356 auto get_adj = [&](auto ent, auto dim) -> const Range & {
1357 if (prev_ent == ent && prev_dim == dim) {
1358 return adj;
1359 } else {
1360 adj.clear();
1361 Range bridge;
1362 CHK_MOAB_THROW(m_field.get_moab().get_adjacencies(&ent, 1, dim + 1,
1363 false, bridge),
1364 "bridge adjacency");
1365 for (auto b : bridge) {
1366 auto it = bridge_faces.find(b);
1367 if (it == bridge_faces.end()) {
1368 Range faces;
1369 if (on_problem_level(b))
1370 CHK_MOAB_THROW(m_field.get_moab().get_adjacencies(&b, 1, dim,
1371 false, faces),
1372 "bridge faces");
1373 it = bridge_faces.emplace(b, std::move(faces)).first;
1374 }
1375 adj.merge(it->second);
1376 }
1377 prev_ent = ent;
1378 prev_dim = dim;
1379 return adj;
1380 }
1381 };
1382
1383 // Fetched once; every owner query below would otherwise look the
1384 // ParallelComm up through two tag operations.
1385 auto *pcomm = ParallelComm::get_pcomm(
1386 &m_field.get_moab(), m_field.get_basic_entity_data_ptr()->pcommID);
1387
1388 int prev_bit_number = -1;
1389 EntityHandle prev_first_ent = 0;
1390 EntityHandle prev_second_ent = 0;
1391 using IT = boost::multi_index::index<NumeredDofEntity_multiIndex,
1392 Unique_mi_tag>::type::iterator;
1393 std::pair<IT, IT> pair_lo_hi;
1394 auto get_col_it = [&](auto bit_number, auto first_ent, auto second_ent) {
1397 return pair_lo_hi;
1398 } else {
1399 auto lo_it = col_ptr->get<Unique_mi_tag>().lower_bound(
1401 auto hi_it = col_ptr->get<Unique_mi_tag>().upper_bound(
1403 pair_lo_hi = std::make_pair(lo_it, hi_it);
1407 return pair_lo_hi;
1408 }
1409 };
1410
1411 auto create_ghost_vec = [&]() {
1412 SmartPetscObj<Vec> v;
1413 CHKERR m_field.getInterface<VecManager>()->vecCreateGhost(problem_name, ROW,
1414 v);
1418 return v;
1419 };
1420
1421 auto v_o_nnz = create_ghost_vec();
1422 auto v_d_nnz = create_ghost_vec();
1423
1424
1425 double *o_nnz_real;
1427 double *d_nnz_real;
1429
1430 EntityHandle counted_ent = 0;
1431 int counted_owner = -1;
1432 PetscInt diagonal_nnz = 0, off_diagonal_nnz = 0;
1433 for (auto r = row_ptr->begin(); r != row_ptr->end(); ++r) {
1434
1435 auto row_loc_idx = (*r)->getPetscLocalDofIdx();
1436 if (row_loc_idx < 0)
1437 continue;
1438
1439 auto ent = (*r)->getEnt();
1440 const int row_owner = (*r)->getOwnerProc(pcomm);
1441 // All DOFs on this entity see the same columns. Count once for its
1442 // owner, then retain the existing ghost-row accumulation for each DOF.
1443 if (ent != counted_ent || row_owner != counted_owner) {
1445 const auto &adj = get_adj(ent, dimension_from_handle(ent));
1446 for (auto p = adj.pair_begin(); p != adj.pair_end(); ++p) {
1447 for (auto bit_number : fields_bit_numbers) {
1448 auto [lo_it, hi_it] = get_col_it(bit_number, p->first, p->second);
1449 for (; lo_it != hi_it; ++lo_it) {
1450 if ((*lo_it)->getPetscLocalDofIdx() < 0)
1451 continue;
1452 if ((*lo_it)->getOwnerProc(pcomm) == row_owner)
1453 ++diagonal_nnz;
1454 else
1456 }
1457 }
1458 }
1459 counted_ent = ent;
1461 }
1464 }
1465
1468
1469 auto update_vec = [&](auto v) {
1476 };
1477
1480
1481 int o_nz = 0;
1482 int d_nz = 0;
1483
1486
1487 std::vector<int> d_nnz(nb_loc_rows, 0);
1488 std::vector<int> o_nnz(nb_loc_rows, 0);
1489 for (auto r = row_ptr->begin(); r != row_ptr->end(); ++r) {
1490
1491 auto row_loc_idx = (*r)->getPetscLocalDofIdx();
1492
1493 if (
1494
1496
1497 ) {
1498 auto row_loc_idx = (*r)->getPetscLocalDofIdx();
1503 }
1504
1505 }
1506
1509
1510 if (verb >= QUIET) {
1511 MOFEM_LOG("SYNC", Sev::verbose)
1512 << "Hybrid L2 matrix d_nz: " << d_nz << " o_nz: " << o_nz;
1513 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::verbose);
1514 }
1515
1516 if (verb >= VERBOSE) {
1517 MOFEM_LOG("SYNC", Sev::noisy) << "Hybrid L2 matrix";
1518 int idx = 0;
1519 for (auto &d : d_nnz) {
1520 MOFEM_LOG("SYNC", Sev::noisy) << idx << ": " << d;
1521 ++idx;
1522 }
1523 MOFEM_LOG_SEVERITY_SYNC(m_field.get_comm(), Sev::noisy);
1524 }
1525
1526 Mat a_raw;
1527 CHKERR MatCreateAIJ(m_field.get_comm(), nb_loc_rows, nb_loc_cols, nb_rows,
1528 nb_cols, 0, d_nnz.data(), 0, o_nnz.data(), &a_raw);
1530 aij_ptr = SmartPetscObj<Mat>(a_raw);
1531
1532 MOFEM_LOG_CHANNEL("WORLD");
1533 MOFEM_LOG_CHANNEL("SYNC");
1534
1536}
std::vector< std::array< EntityHandle, 3 > > faces
Sorted keys.
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
It it
Definition Schur.cpp:2568
@ QUIET
@ VERBOSE
@ ROW
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
@ MOFEM_NOT_FOUND
Definition definitions.h:33
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(channel)
Set and reset channel.
auto bit
set bit
const double c
speed of light (cm/ns)
const double v
phase velocity of light in medium (cm/ns)
std::bitset< BITFIELDID_SIZE > BitFieldId
Field Id.
Definition Types.hpp:42
auto dimension_from_handle(const EntityHandle h)
get entity dimension form handle
int r
Definition sdf.py:205
MoFEMErrorCode get_problems(const Problem_multiIndex **problems_ptr) const
Get pointer to problems multi-index.
Definition Core.cpp:859
static UId getLoFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
static UId getHiFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
constexpr IntegrationType IT

◆ createHybridL2MPIAIJ() [2/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createHybridL2MPIAIJ ( const std::string  problem_name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb 
)

◆ createHybridL2MPIAIJ() [3/3]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createHybridL2MPIAIJ ( const std::string  problem_name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb = QUIET 
)
inline

Create a Hybrid MPIAij object.

It assumes that L2 field is on skeleton, and dim+1 is bridge adjacency.

Template Parameters
Tag
Parameters
problem_name
aij_ptr
verb
Returns
MoFEMErrorCode

Definition at line 305 of file MatrixManager.hpp.

307 {
308 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
309 return 0;
310 }

◆ createMPIAdjWithArrays() [1/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAdjWithArrays ( const std::string  name,
Mat *  Adj,
int  verb 
)

Definition at line 957 of file MatrixManager.cpp.

959 {
961 CreateRowCompressedADJMatrix *core_ptr =
962 static_cast<CreateRowCompressedADJMatrix *>(&cOre);
965
966 auto problems_ptr = m_field.get_problems();
967 auto &prb = problems_ptr->get<Problem_mi_tag>();
968 auto p_miit = prb.find(name);
969 if (p_miit == prb.end()) {
970 SETERRQ(m_field.get_comm(), MOFEM_NOT_FOUND,
971 "problem < %s > is not found (top tip: check spelling)",
972 name.c_str());
973 }
974
975 std::vector<int> i_vec, j_vec;
976 j_vec.reserve(10000);
977 CHKERR core_ptr->createMatArrays<PetscGlobalIdx_mi_tag>(
978 p_miit, MATMPIADJ, i_vec, j_vec, true, verb);
979 int *_i, *_j;
980 CHKERR PetscMalloc(i_vec.size() * sizeof(int), &_i);
981 CHKERR PetscMalloc(j_vec.size() * sizeof(int), &_j);
982 copy(i_vec.begin(), i_vec.end(), _i);
983 copy(j_vec.begin(), j_vec.end(), _j);
984
985 int nb_col_dofs = p_miit->getNbDofsCol();
986 CHKERR MatCreateMPIAdj(m_field.get_comm(), i_vec.size() - 1, nb_col_dofs, _i,
989
992}
std::string name

◆ createMPIAdjWithArrays() [2/3]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAdjWithArrays ( const std::string  name,
Mat *  Adj,
int  verb 
)

◆ createMPIAdjWithArrays() [3/3]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createMPIAdjWithArrays ( const std::string  name,
Mat *  Adj,
int  verb = QUIET 
)
inline

Creates a sparse matrix representing an adjacency list.

The matrix does not have numerical values associated with it, but is intended for ordering (to reduce bandwidth etc) and partitioning.

See PETSc for details

Note
This matrix object does not support most matrix operations, include MatSetValues(). You must NOT free the ii, values and jj arrays yourself. PETSc will free them when the matrix is destroyed; you must allocate them with PetscMalloc(). If you call from Fortran you need not create the arrays with PetscMalloc(). Should not include the matrix diagonals.
Template Parameters
Tag
Parameters
name
Adj
verb
Returns
MoFEMErrorCode

Definition at line 166 of file MatrixManager.hpp.

167 {
168 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
170 }
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32

◆ createMPIAIJ() [1/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJ ( const std::string  name,
Mat *  Aij,
int  verb 
)

Definition at line 887 of file MatrixManager.cpp.

889 {
891 CreateRowCompressedADJMatrix *core_ptr =
892 static_cast<CreateRowCompressedADJMatrix *>(&cOre);
895
896 auto problems_ptr = m_field.get_problems();
897 auto &prb = problems_ptr->get<Problem_mi_tag>();
898 auto p_miit = prb.find(name);
899 if (p_miit == prb.end()) {
900 SETERRQ(m_field.get_comm(), MOFEM_NOT_FOUND,
901 "problem < %s > is not found (top tip: check spelling)",
902 name.c_str());
903 }
904
905 std::vector<int> i_vec, j_vec;
906 j_vec.reserve(10000);
907 CHKERR core_ptr->createMatArrays<PetscGlobalIdx_mi_tag>(
908 p_miit, MATMPIAIJ, i_vec, j_vec, false, verb);
909
910 int nb_row_dofs = p_miit->getNbDofsRow();
911 int nb_col_dofs = p_miit->getNbDofsCol();
912 int nb_local_dofs_row = p_miit->getNbLocalDofsRow();
913 int nb_local_dofs_col = p_miit->getNbLocalDofsCol();
914
915 auto get_layout = [&]() {
924 return std::make_pair(start_ranges, end_ranges);
925 };
926
927 auto get_nnz = [&](auto &d_nnz, auto &o_nnz) {
929 auto layout = get_layout();
930 int j = 0;
931 for (int i = 0; i != nb_local_dofs_row; ++i) {
932 for (; j != i_vec[i + 1]; ++j) {
933 if (j_vec[j] < layout.second && j_vec[j] >= layout.first)
934 ++(d_nnz[i]);
935 else
936 ++(o_nnz[i]);
937 }
938 }
940 };
941
942 std::vector<int> d_nnz(nb_local_dofs_row, 0), o_nnz(nb_local_dofs_row, 0);
944
945 CHKERR MatCreate(m_field.get_comm(), Aij);
949 CHKERR MatMPIAIJSetPreallocation(*Aij, 0, &*d_nnz.begin(), 0,
950 &*o_nnz.begin());
951
954}
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'j', 3 > j

◆ createMPIAIJ() [2/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJ ( const std::string  name,
Mat *  Aij,
int  verb 
)

◆ createMPIAIJ() [3/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJ ( const std::string  name,
Mat *  Aij,
int  verb = QUIET 
)
inline

Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.

See PETSc for details

Template Parameters
Tag
Parameters
name
Aij
verb
Returns
MoFEMErrorCode

Definition at line 123 of file MatrixManager.hpp.

124 {
125 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
126 return 0;
127 }

◆ createMPIAIJ() [4/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJ ( const std::string  name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb = QUIET 
)
inline

Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.

See PETSc for details

Template Parameters
Tag
Parameters
name
Aij
verb
Returns
MoFEMErrorCode

Definition at line 132 of file MatrixManager.hpp.

134 {
136 Mat aij;
137 CHKERR createMPIAIJ<Tag>(name, &aij, verb);
138 aij_ptr.reset(aij, false);
140 }

◆ createMPIAIJCUSPARSEWithArrays() [1/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJCUSPARSEWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

Definition at line 798 of file MatrixManager.cpp.

800 {
802
804 CreateRowCompressedADJMatrix *core_ptr =
805 static_cast<CreateRowCompressedADJMatrix *>(&cOre);
807
808 auto problems_ptr = m_field.get_problems();
809 auto &prb = problems_ptr->get<Problem_mi_tag>();
810 auto p_miit = prb.find(name);
811 if (p_miit == prb.end()) {
812 SETERRQ(m_field.get_comm(), MOFEM_NOT_FOUND,
813 "problem < %s > is not found (top tip: check spelling)",
814 name.c_str());
815 }
816
817 std::vector<int> i_vec, j_vec;
818 j_vec.reserve(10000);
819 CHKERR core_ptr->createMatArrays<PetscGlobalIdx_mi_tag>(
820 p_miit, MATAIJCUSPARSE, i_vec, j_vec, false, verb);
821
822 int nb_local_dofs_row = p_miit->getNbLocalDofsRow();
823 int nb_local_dofs_col = p_miit->getNbLocalDofsCol();
824
825 auto get_layout = [&]() {
834 return std::make_pair(start_ranges, end_ranges);
835 };
836
837 auto get_nnz = [&](auto &d_nnz, auto &o_nnz) {
839 auto layout = get_layout();
840 int j = 0;
841 for (int i = 0; i != nb_local_dofs_row; ++i) {
842 for (; j != i_vec[i + 1]; ++j) {
843 if (j_vec[j] < layout.second && j_vec[j] >= layout.first)
844 ++(d_nnz[i]);
845 else
846 ++(o_nnz[i]);
847 }
848 }
850 };
851
852 std::vector<int> d_nnz(nb_local_dofs_row, 0), o_nnz(nb_local_dofs_row, 0);
854
855#ifdef PETSC_HAVE_CUDA
856 CHKERR ::MatCreateAIJCUSPARSE(m_field.get_comm(), nb_local_dofs_row,
857 nb_local_dofs_col, nb_row_dofs, nb_col_dofs, 0,
858 &*d_nnz.begin(), 0, &*o_nnz.begin(), Aij);
859#else
861 "Error: To use this matrix type compile PETSc with CUDA.");
862#endif
863
865
867}

◆ createMPIAIJCUSPARSEWithArrays() [2/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJCUSPARSEWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

◆ createMPIAIJCUSPARSEWithArrays() [3/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJCUSPARSEWithArrays ( const std::string  name,
Mat *  Aij,
int  verb = QUIET 
)
inline

Definition at line 69 of file MatrixManager.hpp.

70 {
71 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
72 return 0;
73 }

◆ createMPIAIJCUSPARSEWithArrays() [4/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJCUSPARSEWithArrays ( const std::string  name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb = QUIET 
)
inline

Definition at line 78 of file MatrixManager.hpp.

80 {
82 Mat aij;
84 aij_ptr.reset(aij, false);
86 }

◆ createMPIAIJWithArrays() [1/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

Definition at line 761 of file MatrixManager.cpp.

762 {
764
766 CreateRowCompressedADJMatrix *core_ptr =
767 static_cast<CreateRowCompressedADJMatrix *>(&cOre);
769
770 auto problems_ptr = m_field.get_problems();
771 auto &prb = problems_ptr->get<Problem_mi_tag>();
772 auto p_miit = prb.find(name);
773 if (p_miit == prb.end()) {
774 SETERRQ(m_field.get_comm(), MOFEM_NOT_FOUND,
775 "problem < %s > is not found (top tip: check spelling)",
776 name.c_str());
777 }
778
779 std::vector<int> i_vec, j_vec;
780 j_vec.reserve(10000);
781 CHKERR core_ptr->createMatArrays<PetscGlobalIdx_mi_tag>(
782 p_miit, MATMPIAIJ, i_vec, j_vec, false, verb);
783
784 int nb_row_dofs = p_miit->getNbDofsRow();
785 int nb_col_dofs = p_miit->getNbDofsCol();
786 int nb_local_dofs_row = p_miit->getNbLocalDofsRow();
787 int nb_local_dofs_col = p_miit->getNbLocalDofsCol();
788
789 CHKERR ::MatCreateMPIAIJWithArrays(
790 m_field.get_comm(), nb_local_dofs_row, nb_local_dofs_col, nb_row_dofs,
791 nb_col_dofs, &*i_vec.begin(), &*j_vec.begin(), PETSC_NULLPTR, Aij);
792
795}

◆ createMPIAIJWithArrays() [2/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

◆ createMPIAIJWithArrays() [3/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJWithArrays ( const std::string  name,
Mat *  Aij,
int  verb = QUIET 
)
inline

Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.

See PETSc for details

Template Parameters
Tag
Parameters
name
Aij
verb
Returns
MoFEMErrorCode

Definition at line 49 of file MatrixManager.hpp.

50 {
51 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
52 return 0;
53 }

◆ createMPIAIJWithArrays() [4/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createMPIAIJWithArrays ( const std::string  name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb = QUIET 
)
inline

Creates a MPI AIJ matrix using arrays that contain in standard CSR format the local rows.

See PETSc for details

Template Parameters
Tag
Parameters
name
Aij
verb
Returns
MoFEMErrorCode

Definition at line 58 of file MatrixManager.hpp.

60 {
62 Mat aij;
64 aij_ptr.reset(aij, false);
66 }

◆ createSeqAIJCUSPARSEWithArrays() [1/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJCUSPARSEWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

Definition at line 870 of file MatrixManager.cpp.

872 {
874
875#ifdef PETSC_HAVE_CUDA
876 // CHKERR ::MatCreateSeqAIJCUSPARSE(MPI_Comm comm, PetscInt m, PetscInt n,
877 // PetscInt nz, const PetscInt nnz[], Mat
878 // *A);
880 "Not implemented type of matrix yet, try MPI version (aijcusparse)");
881#endif
882
884}

◆ createSeqAIJCUSPARSEWithArrays() [2/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJCUSPARSEWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

◆ createSeqAIJCUSPARSEWithArrays() [3/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJCUSPARSEWithArrays ( const std::string  name,
Mat *  Aij,
int  verb = QUIET 
)
inline

Definition at line 89 of file MatrixManager.hpp.

90 {
91 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
92 return 0;
93 }

◆ createSeqAIJCUSPARSEWithArrays() [4/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJCUSPARSEWithArrays ( const std::string  name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb = QUIET 
)
inline

Definition at line 98 of file MatrixManager.hpp.

100 {
102 Mat aij;
104 aij_ptr.reset(aij, false);
106 }

◆ createSeqAIJWithArrays() [1/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

Definition at line 995 of file MatrixManager.cpp.

996 {
998 CreateRowCompressedADJMatrix *core_ptr =
999 static_cast<CreateRowCompressedADJMatrix *>(&cOre);
1002
1003 auto problems_ptr = m_field.get_problems();
1004 auto &prb = problems_ptr->get<Problem_mi_tag>();
1005 auto p_miit = prb.find(name);
1006 if (p_miit == prb.end()) {
1007 SETERRQ(m_field.get_comm(), MOFEM_NOT_FOUND,
1008 "problem < %s > is not found (top tip: check spelling)",
1009 name.c_str());
1010 }
1011
1012 std::vector<int> i_vec, j_vec;
1013 j_vec.reserve(10000);
1014 CHKERR core_ptr->createMatArrays<PetscGlobalIdx_mi_tag>(p_miit, MATAIJ, i_vec,
1015 j_vec, false, verb);
1016
1017 int nb_local_dofs_row = p_miit->getNbLocalDofsRow();
1018 int nb_local_dofs_col = p_miit->getNbLocalDofsCol();
1019
1020 double *_a;
1021 CHKERR PetscMalloc(j_vec.size() * sizeof(double), &_a);
1022
1023 Mat tmpMat;
1024 CHKERR ::MatCreateSeqAIJWithArrays(PETSC_COMM_SELF, nb_local_dofs_row,
1025 nb_local_dofs_col, &*i_vec.begin(),
1026 &*j_vec.begin(), _a, &tmpMat);
1029
1031
1034}

◆ createSeqAIJWithArrays() [2/4]

template<>
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJWithArrays ( const std::string  name,
Mat *  Aij,
int  verb 
)

◆ createSeqAIJWithArrays() [3/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJWithArrays ( const std::string  name,
Mat *  Aij,
int  verb = QUIET 
)
inline

Create sequencial matrix.

Creates a sparse matrix in AIJ (compressed row) format (the default parallel PETSc format). For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter nz (or the array nnz). By setting these parameters accurately, performance during matrix assembly can be increased by more than a factor of 50.

See PETSc for details

Template Parameters
Tag
Parameters
name
Aij
i
j
v
verb
Returns
MoFEMErrorCode

Definition at line 195 of file MatrixManager.hpp.

196 {
197 static_assert(!std::is_same<Tag, Tag>::value, "not implemented");
198 return 0;
199 }

◆ createSeqAIJWithArrays() [4/4]

template<class Tag >
MoFEMErrorCode MoFEM::MatrixManager::createSeqAIJWithArrays ( const std::string  name,
SmartPetscObj< Mat > &  aij_ptr,
int  verb = QUIET 
)
inline

Create sequencial matrix.

Creates a sparse matrix in AIJ (compressed row) format (the default parallel PETSc format). For good matrix assembly performance the user should preallocate the matrix storage by setting the parameter nz (or the array nnz). By setting these parameters accurately, performance during matrix assembly can be increased by more than a factor of 50.

See PETSc for details

Template Parameters
Tag
Parameters
name
Aij(SmartPetscObj)
i
j
v
verb
Returns
MoFEMErrorCode

Definition at line 224 of file MatrixManager.hpp.

226 {
228 Mat aij;
230 aij_ptr.reset(aij, false);
232 }

◆ query_interface()

MoFEMErrorCode MoFEM::MatrixManager::query_interface ( boost::typeindex::type_index  type_index,
UnknownInterface **  iface 
) const
virtual

Implements MoFEM::UnknownInterface.

Definition at line 737 of file MatrixManager.cpp.

738 {
739 *iface = const_cast<MatrixManager *>(this);
740 return 0;
741}
MatrixManager(const MoFEM::Core &core)

Member Data Documentation

◆ cOre

MoFEM::Core& MoFEM::MatrixManager::cOre

Definition at line 26 of file MatrixManager.hpp.

◆ MOFEM_EVENT_checkMatrixFillIn

PetscLogEvent MoFEM::MatrixManager::MOFEM_EVENT_checkMatrixFillIn
private

Definition at line 319 of file MatrixManager.hpp.

◆ MOFEM_EVENT_createMPIAdjWithArrays

PetscLogEvent MoFEM::MatrixManager::MOFEM_EVENT_createMPIAdjWithArrays
private

Definition at line 315 of file MatrixManager.hpp.

◆ MOFEM_EVENT_createMPIAIJ

PetscLogEvent MoFEM::MatrixManager::MOFEM_EVENT_createMPIAIJ
private

Definition at line 313 of file MatrixManager.hpp.

◆ MOFEM_EVENT_createMPIAIJCUSPARSEWithArrays

PetscLogEvent MoFEM::MatrixManager::MOFEM_EVENT_createMPIAIJCUSPARSEWithArrays
private

Definition at line 317 of file MatrixManager.hpp.

◆ MOFEM_EVENT_createMPIAIJWithArrays

PetscLogEvent MoFEM::MatrixManager::MOFEM_EVENT_createMPIAIJWithArrays
private

Definition at line 314 of file MatrixManager.hpp.

◆ MOFEM_EVENT_createSeqAIJCUSPARSEWithArrays

PetscLogEvent MoFEM::MatrixManager::MOFEM_EVENT_createSeqAIJCUSPARSEWithArrays
private

Definition at line 318 of file MatrixManager.hpp.

◆ MOFEM_EVENT_createSeqAIJWithArrays

PetscLogEvent MoFEM::MatrixManager::MOFEM_EVENT_createSeqAIJWithArrays
private

Definition at line 316 of file MatrixManager.hpp.


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