v0.14.0
Loading...
Searching...
No Matches
Classes | Functions
Distributed mesh manager

Implementation of PETSc DM, managing interactions between mesh data structures and vectors and matrices. More...

Collaboration diagram for Distributed mesh manager:

Classes

struct  MoFEM::DMCtx
 PETSc Discrete Manager data structure. More...
 
struct  DMMGViaApproxOrdersCtx
 Structure for DM for multi-grid via approximation orders. More...
 

Functions

PetscErrorCode MoFEM::DMRegister_MoFEM (const char sname[])
 Register MoFEM problem. More...
 
PetscErrorCode MoFEM::DMMoFEMCreateMoFEM (DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
 Must be called by user to set MoFEM data structures. More...
 
PetscErrorCode MoFEM::DMMoFEMCreateSubDM (DM subdm, DM dm, const char problem_name[])
 Must be called by user to set Sub DM MoFEM data structures. More...
 
PetscErrorCode MoFEM::DMoFEMGetInterfacePtr (DM dm, MoFEM::Interface **m_field_ptr)
 Get pointer to MoFEM::Interface. More...
 
PetscErrorCode MoFEM::DMMoFEMGetProblemPtr (DM dm, const MoFEM::Problem **problem_ptr)
 Get pointer to problem data structure. More...
 
PetscErrorCode MoFEM::DMMoFEMSetSquareProblem (DM dm, PetscBool square_problem)
 set squared problem More...
 
PetscErrorCode MoFEM::DMMoFEMGetSquareProblem (DM dm, PetscBool *square_problem)
 get squared problem More...
 
PetscErrorCode MoFEM::DMMoFEMResolveSharedFiniteElements (DM dm, std::string fe_name)
 Resolve shared entities. More...
 
PetscErrorCode MoFEM::DMMoFEMGetProblemFiniteElementLayout (DM dm, std::string fe_name, PetscLayout *layout)
 Get finite elements layout in the problem. More...
 
PetscErrorCode MoFEM::DMMoFEMAddElement (DM dm, std::string fe_name)
 add element to dm More...
 
PetscErrorCode MoFEM::DMMoFEMAddElement (DM dm, std::vector< std::string > fe_name)
 add element to dm More...
 
PetscErrorCode MoFEM::DMMoFEMUnSetElement (DM dm, std::string fe_name)
 unset element from dm More...
 
PetscErrorCode MoFEM::DMoFEMMeshToLocalVector (DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
 set local (or ghosted) vector values on mesh for partition only More...
 
PetscErrorCode MoFEM::DMoFEMMeshToGlobalVector (DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
 set ghosted vector values on all existing mesh entities More...
 
PetscErrorCode MoFEM::DMoFEMPreProcessFiniteElements (DM dm, MoFEM::FEMethod *method)
 execute finite element method for each element in dm (problem) More...
 
PetscErrorCode MoFEM::DMoFEMPostProcessFiniteElements (DM dm, MoFEM::FEMethod *method)
 execute finite element method for each element in dm (problem) More...
 
PetscErrorCode MoFEM::DMoFEMLoopFiniteElementsUpAndLowRank (DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank, int up_rank, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
 Executes FEMethod for finite elements in DM. More...
 
PetscErrorCode MoFEM::DMoFEMLoopFiniteElementsUpAndLowRank (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, int low_rank, int up_rank, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
 Executes FEMethod for finite elements in DM. More...
 
PetscErrorCode MoFEM::DMoFEMLoopFiniteElements (DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
 Executes FEMethod for finite elements in DM. More...
 
PetscErrorCode MoFEM::DMoFEMLoopFiniteElements (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
 Executes FEMethod for finite elements in DM. More...
 
PetscErrorCode MoFEM::DMoFEMLoopDofs (DM dm, const char field_name[], MoFEM::DofMethod *method)
 execute method for dofs on field in problem More...
 
PetscErrorCode MoFEM::DMMoFEMKSPSetComputeRHS (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 set KSP right hand side evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMKSPSetComputeRHS (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 set KSP right hand side evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMKSPSetComputeOperators (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 Set KSP operators and push mofem finite element methods. More...
 
PetscErrorCode MoFEM::DMMoFEMKSPSetComputeOperators (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 Set KSP operators and push mofem finite element methods. More...
 
PetscErrorCode MoFEM::DMMoFEMSNESSetFunction (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 set SNES residual evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMSNESSetFunction (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 set SNES residual evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMSNESSetJacobian (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 set SNES Jacobian evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMSNESSetJacobian (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 set SNES Jacobian evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetIFunction (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 set TS implicit function evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetIFunction (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 set TS implicit function evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetIJacobian (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 set TS Jacobian evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetIJacobian (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 set TS Jacobian evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetI2Function (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 set TS implicit function evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetI2Function (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 set TS implicit function evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetI2Jacobian (DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
 set TS Jacobian evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMTSSetI2Jacobian (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 set TS Jacobian evaluation function More...
 
PetscErrorCode MoFEM::DMMoFEMGetKspCtx (DM dm, MoFEM::KspCtx **ksp_ctx)
 get MoFEM::KspCtx data structure More...
 
PetscErrorCode MoFEM::DMMoFEMGetKspCtx (DM dm, const boost::shared_ptr< MoFEM::KspCtx > &ksp_ctx)
 get MoFEM::KspCtx data structure More...
 
PetscErrorCode MoFEM::DMMoFEMSetKspCtx (DM dm, boost::shared_ptr< MoFEM::KspCtx > ksp_ctx)
 set MoFEM::KspCtx data structure More...
 
PetscErrorCode MoFEM::DMMoFEMGetSnesCtx (DM dm, MoFEM::SnesCtx **snes_ctx)
 get MoFEM::SnesCtx data structure More...
 
PetscErrorCode MoFEM::DMMoFEMGetSnesCtx (DM dm, const boost::shared_ptr< MoFEM::SnesCtx > &snes_ctx)
 get MoFEM::SnesCtx data structure More...
 
PetscErrorCode MoFEM::DMMoFEMSetSnesCtx (DM dm, boost::shared_ptr< MoFEM::SnesCtx > snes_ctx)
 Set MoFEM::SnesCtx data structure. More...
 
PetscErrorCode MoFEM::DMMoFEMGetTsCtx (DM dm, MoFEM::TsCtx **ts_ctx)
 get MoFEM::TsCtx data structure More...
 
PetscErrorCode MoFEM::DMMoFEMGetTsCtx (DM dm, const boost::shared_ptr< MoFEM::TsCtx > &ts_ctx)
 get MoFEM::TsCtx data structure More...
 
PetscErrorCode MoFEM::DMMoFEMSetTsCtx (DM dm, boost::shared_ptr< MoFEM::TsCtx > ts_ctx)
 Set MoFEM::TsCtx data structure. More...
 
PetscErrorCode MoFEM::DMMoFEMSetIsPartitioned (DM dm, PetscBool is_partitioned)
 
PetscErrorCode MoFEM::DMMoFEMGetIsPartitioned (DM dm, PetscBool *is_partitioned)
 
PetscErrorCode MoFEM::DMSetOperators_MoFEM (DM dm)
 Set operators for MoFEM dm. More...
 
PetscErrorCode MoFEM::DMCreate_MoFEM (DM dm)
 Create dm data structure with MoFEM data structure. More...
 
PetscErrorCode MoFEM::DMDestroy_MoFEM (DM dm)
 Destroys dm with MoFEM data structure. More...
 
PetscErrorCode MoFEM::DMCreateGlobalVector_MoFEM (DM dm, Vec *g)
 DMShellSetCreateGlobalVector. More...
 
PetscErrorCode MoFEM::DMCreateGlobalVector_MoFEM (DM dm, SmartPetscObj< Vec > &g_ptr)
 DMShellSetCreateGlobalVector. More...
 
PetscErrorCode MoFEM::DMCreateLocalVector_MoFEM (DM dm, Vec *l)
 DMShellSetCreateLocalVector. More...
 
PetscErrorCode MoFEM::DMCreateMatrix_MoFEM (DM dm, Mat *M)
 
PetscErrorCode MoFEM::DMCreateMatrix_MoFEM (DM dm, SmartPetscObj< Mat > &M)
 
PetscErrorCode MoFEM::DMSetFromOptions_MoFEM (DM dm)
 
PetscErrorCode MoFEM::DMSetUp_MoFEM (DM dm)
 
PetscErrorCode MoFEM::DMSubDMSetUp_MoFEM (DM subdm)
 
PetscErrorCode MoFEM::DMMoFEMAddSubFieldRow (DM dm, const char field_name[])
 
PetscErrorCode MoFEM::DMMoFEMAddSubFieldRow (DM dm, const char field_name[], boost::shared_ptr< Range > r_ptr)
 Add field to sub dm problem on rows. More...
 
PetscErrorCode MoFEM::DMMoFEMAddSubFieldCol (DM dm, const char field_name[])
 
PetscErrorCode MoFEM::DMMoFEMGetIsSubDM (DM dm, PetscBool *is_sub_dm)
 
PetscErrorCode MoFEM::DMMoFEMAddRowCompositeProblem (DM dm, const char prb_name[])
 Add problem to composite DM on row. More...
 
PetscErrorCode MoFEM::DMMoFEMAddColCompositeProblem (DM dm, const char prb_name[])
 Add problem to composite DM on col. More...
 
PetscErrorCode MoFEM::DMMoFEMGetIsCompDM (DM dm, PetscBool *is_comp_dm)
 Get if this DM is composite DM. More...
 
PetscErrorCode MoFEM::DMGlobalToLocalBegin_MoFEM (DM dm, Vec, InsertMode, Vec)
 
PetscErrorCode MoFEM::DMGlobalToLocalEnd_MoFEM (DM dm, Vec, InsertMode, Vec)
 
PetscErrorCode MoFEM::DMLocalToGlobalBegin_MoFEM (DM, Vec, InsertMode, Vec)
 
PetscErrorCode MoFEM::DMLocalToGlobalEnd_MoFEM (DM, Vec, InsertMode, Vec)
 
PetscErrorCode MoFEM::DMCreateFieldIS_MoFEM (DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
 
PetscErrorCode MoFEM::DMMoFEMGetFieldIS (DM dm, RowColData rc, const char field_name[], IS *is)
 get field is in the problem More...
 
auto MoFEM::createDMMatrix (DM dm)
 Get smart matrix from DM. More...
 
auto MoFEM::createDMVector (DM dm)
 Get smart vector from DM. More...
 
MoFEMErrorCode DMMGViaApproxOrdersPushBackCoarseningIS (DM, IS is, Mat A, Mat *subA, bool create_sub_matrix, bool shell_sub_a)
 Push back coarsening level to MG via approximation orders. More...
 
MoFEMErrorCode DMMGViaApproxOrdersPopBackCoarseningIS (DM)
 Pop is form MG via approximation orders. More...
 
MoFEMErrorCode DMMGViaApproxOrdersClearCoarseningIS (DM)
 Clear approximation orders. More...
 
MoFEMErrorCode DMRegister_MGViaApproxOrders (const char sname[])
 Register DM for Multi-Grid via approximation orders. More...
 
MoFEMErrorCode DMCreateMatrix_MGViaApproxOrders (DM dm, Mat *M)
 Create matrix for Multi-Grid via approximation orders. More...
 
MoFEMErrorCode DMCoarsen_MGViaApproxOrders (DM dm, MPI_Comm comm, DM *dmc)
 Coarsen DM. More...
 

Detailed Description

Implementation of PETSc DM, managing interactions between mesh data structures and vectors and matrices.

DM objects are used to manage communication between the algebraic structures in PETSc (Vec and Mat) and mesh data structures in PDE-based (or other) simulations.

DM is abstract interface, here is it particular implementation for MoFEM code.

Function Documentation

◆ createDMMatrix()

auto MoFEM::createDMMatrix ( DM  dm)
inline

Get smart matrix from DM.

Definition at line 988 of file DMMoFEM.hpp.

988 {
989 SmartPetscObj<Mat> a;
990 ierr = DMCreateMatrix_MoFEM(dm, a);
991 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
992 return a;
993};
constexpr double a
static PetscErrorCode ierr
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition: DMMoFEM.cpp:1183
MPI_Comm getCommFromPetscObject(PetscObject obj)
Get the Comm From Petsc Object object.

◆ createDMVector()

auto MoFEM::createDMVector ( DM  dm)
inline

Get smart vector from DM.

Definition at line 1003 of file DMMoFEM.hpp.

1003 {
1004 SmartPetscObj<Vec> v;
1006 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1007 return v;
1008};
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition: DMMoFEM.cpp:1153
const double v
phase velocity of light in medium (cm/ns)

◆ DMCoarsen_MGViaApproxOrders()

MoFEMErrorCode DMCoarsen_MGViaApproxOrders ( DM  dm,
MPI_Comm  comm,
DM *  dmc 
)

Coarsen DM.

Not used directly by user

Parameters
dmDistributed mesh data structure
commCommunicator
dmcCoarse distributed mesh data structure
Returns
Error code

Definition at line 462 of file PCMGSetUpViaApproxOrders.cpp.

462 {
463 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
465 GET_DM_FIELD(dm);
466 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
467 CHKERR DMCreate(comm, dmc);
468 (*dmc)->data = dm->data;
469 DMType type;
470 CHKERR DMGetType(dm, &type);
471 CHKERR DMSetType(*dmc, type);
472 CHKERR PetscObjectReference((PetscObject)(*dmc));
473 PetscInfo1(dm, "Coarsen DMMGViaApproxOrders leveldown = %d\n", dm->leveldown);
475}
#define GET_DM_FIELD(DM)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535

◆ DMCreate_MoFEM()

PetscErrorCode MoFEM::DMCreate_MoFEM ( DM  dm)

Create dm data structure with MoFEM data structure.

Definition at line 75 of file DMMoFEM.cpp.

75 {
76 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
78 dm->data = new DMCtx();
81}
PetscErrorCode DMSetOperators_MoFEM(DM dm)
Set operators for MoFEM dm.
Definition: DMMoFEM.cpp:53

◆ DMCreateFieldIS_MoFEM()

PetscErrorCode MoFEM::DMCreateFieldIS_MoFEM ( DM  dm,
PetscInt *  numFields,
char ***  fieldNames,
IS **  fields 
)

Creates a set of IS objects with the global indices of dofs for each field

Parameters
dmThe number of fields (or NULL if not requested)

Output:

Parameters
numFieldsThe number of fields (or NULL if not requested)
fieldNamesThe name for each field (or NULL if not requested)
fieldsThe global indices for each field (or NULL if not requested)
Returns
error code
Note
The user is responsible for freeing all requested arrays. In particular, every entry of names should be freed with PetscFree(), every entry of fields should be destroyed with ISDestroy(), and both arrays should be freed with PetscFree().

Definition at line 1433 of file DMMoFEM.cpp.

1434 {
1435 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1437
1438 if (numFields) {
1439 *numFields = 0;
1440 }
1441 if (fieldNames) {
1442 *fieldNames = NULL;
1443 }
1444 if (fields) {
1445 *fields = NULL;
1446 }
1447
1448 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1449 auto fields_ptr = dm_field->mField_ptr->get_fields();
1450 Field_multiIndex::iterator fit, hi_fit;
1451 fit = fields_ptr->begin();
1452 hi_fit = fields_ptr->end();
1453 *numFields = std::distance(fit, hi_fit);
1454
1455 if (fieldNames) {
1456 CHKERR PetscMalloc1(*numFields, fieldNames);
1457 }
1458 if (fields) {
1459 CHKERR PetscMalloc1(*numFields, fields);
1460 }
1461
1462 for (int f = 0; fit != hi_fit; fit++, f++) {
1463 if (fieldNames) {
1464 CHKERR PetscStrallocpy(fit->get()->getName().c_str(),
1465 (char **)&(*fieldNames)[f]);
1466 }
1467 if (fields) {
1468 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1469 ->isCreateProblemFieldAndRank(
1470 dm_field->problemPtr->getName(), ROW, fit->get()->getName(), 0,
1471 fit->get()->getNbOfCoeffs(), &(*fields)[f]);
1472 }
1473 }
1474
1476}
@ ROW
Definition: definitions.h:123

◆ DMCreateGlobalVector_MoFEM() [1/2]

PetscErrorCode MoFEM::DMCreateGlobalVector_MoFEM ( DM  dm,
SmartPetscObj< Vec > &  g_ptr 
)

DMShellSetCreateGlobalVector.

sets the routine to create a global vector associated with the shell DM

Definition at line 1163 of file DMMoFEM.cpp.

1163 {
1164 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1166 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1167 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1168 dm_field->problemName, COL, g_ptr);
1169 CHKERR VecSetDM(g_ptr, dm);
1171}
@ COL
Definition: definitions.h:123

◆ DMCreateGlobalVector_MoFEM() [2/2]

PetscErrorCode MoFEM::DMCreateGlobalVector_MoFEM ( DM  dm,
Vec *  g 
)

DMShellSetCreateGlobalVector.

sets the routine to create a global vector associated with the shell DM

Definition at line 1153 of file DMMoFEM.cpp.

1153 {
1154 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1156 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1157 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1158 dm_field->problemName, COL, g);
1159 CHKERR VecSetDM(*g, dm);
1161}
constexpr double g

◆ DMCreateLocalVector_MoFEM()

PetscErrorCode MoFEM::DMCreateLocalVector_MoFEM ( DM  dm,
Vec *  l 
)

DMShellSetCreateLocalVector.

sets the routine to create a local vector associated with the shell DM

Definition at line 1173 of file DMMoFEM.cpp.

1173 {
1174 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1176 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1177 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateSeq(
1178 dm_field->problemName, COL, l);
1179 CHKERR VecSetDM(*l, dm);
1181}
FTensor::Index< 'l', 3 > l

◆ DMCreateMatrix_MGViaApproxOrders()

MoFEMErrorCode DMCreateMatrix_MGViaApproxOrders ( DM  dm,
Mat *  M 
)

Create matrix for Multi-Grid via approximation orders.

Not used directly by user

Parameters
dmDistributed mesh data structure
MMatrix
Returns
Error code

Definition at line 430 of file PCMGSetUpViaApproxOrders.cpp.

430 {
431
432 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
434 GET_DM_FIELD(dm);
435
436 int leveldown = dm->leveldown;
437
438 if (dm_field->kspOperators.empty()) {
440 } else {
441 MPI_Comm comm;
442 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
443 if (dm_field->kspOperators.empty()) {
444 SETERRQ(comm, MOFEM_DATA_INCONSISTENCY,
445 "data inconsistency, operator can not be set");
446 }
447 if (static_cast<int>(dm_field->kspOperators.size()) < leveldown) {
448 SETERRQ(comm, MOFEM_DATA_INCONSISTENCY,
449 "data inconsistency, no IS for that level");
450 }
451 *M = dm_field->kspOperators[dm_field->kspOperators.size() - 1 - leveldown];
452 CHKERR PetscObjectReference((PetscObject)*M);
453 CHKERR MatSetDM(*M, dm);
454 }
455
456 PetscInfo1(dm, "Create Matrix DMMGViaApproxOrders leveldown = %d\n",
457 leveldown);
458
460}
static Index< 'M', 3 > M
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31

◆ DMCreateMatrix_MoFEM() [1/2]

PetscErrorCode MoFEM::DMCreateMatrix_MoFEM ( DM  dm,
Mat *  M 
)

DMShellSetCreateMatrix

sets the routine to create a matrix associated with the shell DM

Definition at line 1183 of file DMMoFEM.cpp.

1183 {
1184 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1186 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1187 if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1188 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1189 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1190 M);
1191 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1192 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1193 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1194 M);
1195 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1196 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1197 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1198 dm_field->problemName, M);
1199 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1200 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1201 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1202 dm_field->problemName, M);
1203 } else {
1204 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1205 "Matrix type not implemented");
1206 }
1207 CHKERR MatSetDM(*M, dm);
1209}
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32

◆ DMCreateMatrix_MoFEM() [2/2]

PetscErrorCode MoFEM::DMCreateMatrix_MoFEM ( DM  dm,
SmartPetscObj< Mat > &  M 
)

DMShellSetCreateMatrix

sets the routine to create a matrix associated with the shell DM

Definition at line 1211 of file DMMoFEM.cpp.

1211 {
1212 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1214 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1215 if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1216 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1217 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1218 M);
1219 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1220 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1221 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1222 M);
1223 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1224 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1225 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1226 dm_field->problemName, M);
1227 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1228 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1229 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1230 dm_field->problemName, M);
1231 } else {
1232 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1233 "Matrix type not implemented");
1234 }
1235 CHKERR MatSetDM(M, dm);
1237}

◆ DMDestroy_MoFEM()

PetscErrorCode MoFEM::DMDestroy_MoFEM ( DM  dm)

Destroys dm with MoFEM data structure.

destroy the MoFEM structure

Definition at line 83 of file DMMoFEM.cpp.

83 {
84 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
85 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
87
88 MPI_Comm comm;
89 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
90
91 int result;
92 MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
93 if (result == MPI_IDENT)
94 MOFEM_LOG("DMSELF", Sev::noisy)
95 << "MoFEM DM destroy for problem " << dm_field->problemName
96 << " referenceNumber " << dm_field->referenceNumber;
97 else
98 MOFEM_LOG("DMWORLD", Sev::noisy)
99 << "MoFEM DM destroy for problem " << dm_field->problemName
100 << " referenceNumber " << dm_field->referenceNumber;
101
102 if (dm_field->referenceNumber == 0) {
103 if (dm_field->destroyProblem) {
104
105 if (dm_field->mField_ptr->check_problem(dm_field->problemName)) {
106 dm_field->mField_ptr->delete_problem(dm_field->problemName);
107 } // else problem has to be deleted by the user
108 }
109
110 delete static_cast<DMCtx *>(dm->data);
111
112 } else
113 --dm_field->referenceNumber;
114
116}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:440
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308

◆ DMGlobalToLocalBegin_MoFEM()

PetscErrorCode MoFEM::DMGlobalToLocalBegin_MoFEM ( DM  dm,
Vec  g,
InsertMode  mode,
Vec  l 
)

DMShellSetGlobalToLocal

the routine that begins the global to local scatter

Definition at line 1361 of file DMMoFEM.cpp.

1362 {
1363 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1365 CHKERR VecGhostUpdateBegin(g, INSERT_VALUES, SCATTER_FORWARD);
1367}

◆ DMGlobalToLocalEnd_MoFEM()

PetscErrorCode MoFEM::DMGlobalToLocalEnd_MoFEM ( DM  dm,
Vec  g,
InsertMode  mode,
Vec  l 
)

DMShellSetGlobalToLocal

the routine that begins the global to local scatter

Definition at line 1369 of file DMMoFEM.cpp.

1369 {
1371 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1373
1374 CHKERR VecGhostUpdateEnd(g, INSERT_VALUES, SCATTER_FORWARD);
1375
1376 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1377 int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1378 int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1379
1380 double *array_loc, *array_glob;
1381 CHKERR VecGetArray(l, &array_loc);
1382 CHKERR VecGetArray(g, &array_glob);
1383 switch (mode) {
1384 case INSERT_VALUES:
1385 cblas_dcopy(nb_dofs + nb_ghost, array_glob, 1, array_loc, 1);
1386 break;
1387 case ADD_VALUES:
1388 cblas_daxpy(nb_dofs + nb_ghost, 1, array_glob, 1, array_loc, 1);
1389 break;
1390 default:
1391 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1392 }
1393 CHKERR VecRestoreArray(l, &array_loc);
1394 CHKERR VecRestoreArray(g, &array_glob);
1396}

◆ DMLocalToGlobalBegin_MoFEM()

PetscErrorCode MoFEM::DMLocalToGlobalBegin_MoFEM ( DM  dm,
Vec  l,
InsertMode  mode,
Vec  g 
)

DMShellSetLocalToGlobal

the routine that begins the local to global scatter

DMShellSetLocalToGlobal

the routine that ends the local to global scatter

Definition at line 1398 of file DMMoFEM.cpp.

1399 {
1400
1401 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1403
1404 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1405 int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1406 int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1407
1408 double *array_loc, *array_glob;
1409 CHKERR VecGetArray(l, &array_loc);
1410 CHKERR VecGetArray(g, &array_glob);
1411 switch (mode) {
1412 case INSERT_VALUES:
1413 cblas_dcopy(nb_dofs + nb_ghost, array_loc, 1, array_glob, 1);
1414 break;
1415 case ADD_VALUES:
1416 cblas_daxpy(nb_dofs + nb_ghost, 1, array_loc, 1, array_glob, 1);
1417 break;
1418 default:
1419 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1420 }
1421 CHKERR VecRestoreArray(l, &array_loc);
1422 CHKERR VecRestoreArray(g, &array_glob);
1423
1425}

◆ DMLocalToGlobalEnd_MoFEM()

PetscErrorCode MoFEM::DMLocalToGlobalEnd_MoFEM ( DM  ,
Vec  l,
InsertMode  mode,
Vec  g 
)

DMShellSetLocalToGlobal

the routine that ends the local to global scatter

Definition at line 1427 of file DMMoFEM.cpp.

1427 {
1428 //
1431}

◆ DMMGViaApproxOrdersClearCoarseningIS()

MoFEMErrorCode DMMGViaApproxOrdersClearCoarseningIS ( DM  dm)

Clear approximation orders.

Parameters
DMdm
Returns
Error code

Definition at line 276 of file PCMGSetUpViaApproxOrders.cpp.

276 {
277 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
279 GET_DM_FIELD(dm);
280 CHKERR dm_field->destroyCoarseningIS();
281 PetscInfo(dm, "Clear DMs data structures\n");
283}

◆ DMMGViaApproxOrdersPopBackCoarseningIS()

MoFEMErrorCode DMMGViaApproxOrdersPopBackCoarseningIS ( DM  dm)

Pop is form MG via approximation orders.

Parameters
DMdm
ispop back IS
Returns
error code

Definition at line 260 of file PCMGSetUpViaApproxOrders.cpp.

260 {
261 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
263 GET_DM_FIELD(dm);
264 if (dm_field->coarseningIS.back()) {
265 CHKERR ISDestroy(&dm_field->coarseningIS.back());
266 dm_field->coarseningIS.pop_back();
267 }
268 if (dm_field->kspOperators.back()) {
269 CHKERR MatDestroy(&dm_field->kspOperators.back());
270 }
271 dm_field->kspOperators.pop_back();
272 PetscInfo(dm, "Pop back IS to DMMGViaApproxOrders\n");
274}

◆ DMMGViaApproxOrdersPushBackCoarseningIS()

MoFEMErrorCode DMMGViaApproxOrdersPushBackCoarseningIS ( DM  dm,
IS  is,
Mat  A,
Mat *  subA,
bool  create_sub_matrix,
bool  shell_sub_a 
)

Push back coarsening level to MG via approximation orders.

Parameters
DMdiscrete manager
isPush back IS used for coarsening
AGet sub-matrix of A using is (that sets operators for coarsening levels)
subAReturning pointer to created sub matrix
subAIf true create sub matrix, otherwise in subA has to be valid pointer to subA
Returns
Error code

Definition at line 206 of file PCMGSetUpViaApproxOrders.cpp.

209 {
210 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
212 GET_DM_FIELD(dm);
213 dm_field->coarseningIS.push_back(is);
214 dm_field->shellMatrixCtxPtr.push_back(new PCMGSubMatrixCtx_private(A, is));
215 if (is) {
216 CHKERR PetscObjectReference((PetscObject)is);
217 }
218 if (is) {
219 IS is2 = is;
220 if (dm_field->aO) {
221 CHKERR ISDuplicate(is, &is2);
222 CHKERR ISCopy(is, is2);
223 CHKERR AOApplicationToPetscIS(dm_field->aO, is2);
224 }
225 if (create_sub_matrix) {
226 if (shell_sub_a) {
227 int n, N;
228 CHKERR ISGetSize(is, &N);
229 CHKERR ISGetLocalSize(is, &n);
230 MPI_Comm comm;
231 CHKERR PetscObjectGetComm((PetscObject)A, &comm);
232 CHKERR MatCreateShell(comm, n, n, N, N,
233 &(dm_field->shellMatrixCtxPtr.back()), subA);
234 CHKERR MatShellSetOperation(*subA, MATOP_MULT,
235 (void (*)(void))sub_mat_mult);
236 CHKERR MatShellSetOperation(*subA, MATOP_MULT_ADD,
237 (void (*)(void))sub_mat_mult_add);
238 CHKERR MatShellSetOperation(*subA, MATOP_SOR,
239 (void (*)(void))sub_mat_sor);
240 } else {
241#if PETSC_VERSION_GE(3, 8, 0)
242 CHKERR MatCreateSubMatrix(A, is2, is2, MAT_INITIAL_MATRIX, subA);
243#else
244 CHKERR MatGetSubMatrix(A, is2, is2, MAT_INITIAL_MATRIX, subA);
245#endif
246 }
247 }
248 if (dm_field->aO) {
249 CHKERR ISDestroy(&is2);
250 }
251 dm_field->kspOperators.push_back(*subA);
252 CHKERR PetscObjectReference((PetscObject)(*subA));
253 } else {
254 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
255 }
256 PetscInfo(dm, "Push back IS to DMMGViaApproxOrders\n");
258}
MoFEMErrorCode sub_mat_mult(Mat a, Vec x, Vec f)
MoFEMErrorCode sub_mat_sor(Mat mat, Vec b, PetscReal omega, MatSORType flag, PetscReal shift, PetscInt its, PetscInt lits, Vec x)
MoFEMErrorCode sub_mat_mult_add(Mat a, Vec x, Vec f)
FTensor::Index< 'n', SPACE_DIM > n
const int N
Definition: speed_test.cpp:3

◆ DMMoFEMAddColCompositeProblem()

PetscErrorCode MoFEM::DMMoFEMAddColCompositeProblem ( DM  dm,
const char  prb_name[] 
)

Add problem to composite DM on col.

This create block on col with DOFs from problem of given name

Parameters
dmthe DM object
prb_nameadd problem name
Returns
error code

Definition at line 371 of file DMMoFEM.cpp.

371 {
372 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
374 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
375 if (!dm->data) {
376 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
377 "data structure for MoFEM not yet created");
378 }
379 if (!dm_field->isCompDM) {
380 dm_field->isCompDM = PETSC_TRUE;
381 }
382 if (dm_field->isSquareMatrix) {
383 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
384 "No need to add problem on column when problem block structurally "
385 "symmetric");
386 }
387 dm_field->colCompPrb.push_back(prb_name);
389}
@ MOFEM_INVALID_DATA
Definition: definitions.h:36

◆ DMMoFEMAddElement() [1/2]

PetscErrorCode MoFEM::DMMoFEMAddElement ( DM  dm,
std::string  fe_name 
)

add element to dm

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.

Definition at line 483 of file DMMoFEM.cpp.

483 {
484 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
486 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
487 CHKERR dm_field->mField_ptr->modify_problem_add_finite_element(
488 dm_field->problemName, fe_name);
490}

◆ DMMoFEMAddElement() [2/2]

PetscErrorCode MoFEM::DMMoFEMAddElement ( DM  dm,
std::vector< std::string >  fe_name 
)

add element to dm

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.

Definition at line 492 of file DMMoFEM.cpp.

492 {
494 for (auto fe : fe_name) {
496 }
498}
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition: DMMoFEM.cpp:483

◆ DMMoFEMAddRowCompositeProblem()

PetscErrorCode MoFEM::DMMoFEMAddRowCompositeProblem ( DM  dm,
const char  prb_name[] 
)

Add problem to composite DM on row.

This create block on row with DOFs from problem of given name

Parameters
dmthe DM object
prb_nameadd problem name
Returns
error code

Definition at line 353 of file DMMoFEM.cpp.

353 {
354 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
356 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
357 if (!dm->data) {
358 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
359 "data structure for MoFEM not yet created");
360 }
361 if (!dm_field->isCompDM) {
362 dm_field->isCompDM = PETSC_TRUE;
363 }
364 dm_field->rowCompPrb.push_back(prb_name);
365 if (dm_field->isSquareMatrix) {
366 dm_field->colCompPrb.push_back(prb_name);
367 }
369}

◆ DMMoFEMAddSubFieldCol()

PetscErrorCode MoFEM::DMMoFEMAddSubFieldCol ( DM  dm,
const char  field_name[] 
)

Add field to sub dm problem on columns

Definition at line 275 of file DMMoFEM.cpp.

275 {
276 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
278 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
279 if (!dm->data) {
280 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
281 "data structure for MoFEM not yet created");
282 }
283 if (!dm_field->isSubDM) {
284 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
285 }
286 dm_field->colFields.push_back(field_name);
287 dm_field->mapTypeCol.erase(field_name);
289}
constexpr auto field_name

◆ DMMoFEMAddSubFieldRow() [1/2]

PetscErrorCode MoFEM::DMMoFEMAddSubFieldRow ( DM  dm,
const char  field_name[] 
)

Add field to sub dm problem on rows

Definition at line 242 of file DMMoFEM.cpp.

242 {
243 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
245 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
246 if (!dm->data) {
247 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
248 "data structure for MoFEM not yet created");
249 }
250 if (!dm_field->isSubDM) {
251 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
252 }
253 dm_field->rowFields.push_back(field_name);
254 dm_field->mapTypeRow.erase(field_name);
256}

◆ DMMoFEMAddSubFieldRow() [2/2]

PetscErrorCode MoFEM::DMMoFEMAddSubFieldRow ( DM  dm,
const char  field_name[],
boost::shared_ptr< Range r_ptr 
)

Add field to sub dm problem on rows.

Parameters
dm
field_name
m
Returns
PetscErrorCode

Definition at line 258 of file DMMoFEM.cpp.

259 {
260 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
262 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
263 if (!dm->data) {
264 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
265 "data structure for MoFEM not yet created");
266 }
267 if (!dm_field->isSubDM) {
268 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
269 }
270 dm_field->rowFields.push_back(field_name);
271 dm_field->mapTypeRow[field_name] = r_ptr;
273}

◆ DMMoFEMCreateMoFEM()

PetscErrorCode MoFEM::DMMoFEMCreateMoFEM ( DM  dm,
MoFEM::Interface m_field_ptr,
const char  problem_name[],
const MoFEM::BitRefLevel  bit_level,
const MoFEM::BitRefLevel  bit_mask = MoFEM::BitRefLevel().set() 
)

Must be called by user to set MoFEM data structures.

Note
If problem exist function create DM for it. If you set bit levels, those bits are to existing bits. Thus if you do not like to change bit ref level for existing problem, set bits to zero.

Definition at line 118 of file DMMoFEM.cpp.

121 {
123
124 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
125 if (!dm->data) {
126 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
127 "data structure for MoFEM not yet created");
128 }
129 if (!m_field_ptr) {
130 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
131 "DM function not implemented into MoFEM");
132 }
133 dm_field->mField_ptr = m_field_ptr;
134 dm_field->problemName = problem_name;
135 if (!m_field_ptr->check_problem(dm_field->problemName)) {
136 // problem is not defined, declare problem internally set bool to
137 // destroyProblem problem with DM
138 dm_field->destroyProblem = PETSC_TRUE;
139 CHKERR dm_field->mField_ptr->add_problem(dm_field->problemName, MF_EXCL,
140 dm_field->verbosity);
141 } else {
142 dm_field->destroyProblem = PETSC_FALSE;
143 }
144 CHKERR dm_field->mField_ptr->modify_problem_ref_level_add_bit(
145 dm_field->problemName, bit_level);
146 CHKERR dm_field->mField_ptr->modify_problem_mask_ref_level_add_bit(
147 dm_field->problemName, bit_mask);
148 dm_field->kspCtx =
149 boost::shared_ptr<KspCtx>(new KspCtx(*m_field_ptr, problem_name));
150 dm_field->snesCtx =
151 boost::shared_ptr<SnesCtx>(new SnesCtx(*m_field_ptr, problem_name));
152 dm_field->tsCtx =
153 boost::shared_ptr<TsCtx>(new TsCtx(*m_field_ptr, problem_name));
154
155 MPI_Comm comm;
156 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
157 int result = 0;
158 MPI_Comm_compare(comm, m_field_ptr->get_comm(), &result);
159 if (result > MPI_CONGRUENT) {
160 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
161 "MoFEM and DM using different communicators");
162 }
163 MPI_Comm_size(comm, &dm_field->sIze);
164 MPI_Comm_rank(comm, &dm_field->rAnk);
165
166 // problem structure
167 CHKERR dm_field->mField_ptr->get_problem(dm_field->problemName,
168 &dm_field->problemPtr);
169
170 MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
171 if (result == MPI_IDENT) {
172 MOFEM_LOG("DMSELF", Sev::noisy)
173 << "MoFEM DM created for problem " << dm_field->problemName;
174 MOFEM_LOG("DMSELF", Sev::noisy) << *dm_field->problemPtr;
175 } else {
176 MOFEM_LOG("DMWORLD", Sev::noisy)
177 << "MoFEM DM created for problem " << dm_field->problemName;
178 MOFEM_LOG("DMWORLD", Sev::noisy) << *dm_field->problemPtr;
179 }
180
182}
@ MF_EXCL
Definition: definitions.h:99
virtual bool check_problem(const std::string name)=0
check if problem exist
virtual MPI_Comm & get_comm() const =0

◆ DMMoFEMCreateSubDM()

PetscErrorCode MoFEM::DMMoFEMCreateSubDM ( DM  subdm,
DM  dm,
const char  problem_name[] 
)

Must be called by user to set Sub DM MoFEM data structures.

Definition at line 219 of file DMMoFEM.cpp.

219 {
221
222 if (!dm->data) {
223 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
224 "data structure for MoFEM not yet created");
225 }
226 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
227
228 CHKERR DMMoFEMCreateMoFEM(subdm, dm_field->mField_ptr, problem_name,
229 dm_field->problemPtr->getBitRefLevel(),
230 dm_field->problemPtr->getBitRefLevelMask());
231
232 DMCtx *subdm_field = (DMCtx *)subdm->data;
233 subdm_field->isSubDM = PETSC_TRUE;
234 subdm_field->problemMainOfSubPtr = dm_field->problemPtr;
235 subdm_field->isPartitioned = dm_field->isPartitioned;
236 subdm_field->isSquareMatrix = PETSC_FALSE;
237 subdm->ops->setup = DMSubDMSetUp_MoFEM;
238
240}
PetscErrorCode DMMoFEMCreateMoFEM(DM dm, MoFEM::Interface *m_field_ptr, const char problem_name[], const MoFEM::BitRefLevel bit_level, const MoFEM::BitRefLevel bit_mask=MoFEM::BitRefLevel().set())
Must be called by user to set MoFEM data structures.
Definition: DMMoFEM.cpp:118

◆ DMMoFEMGetFieldIS()

PetscErrorCode MoFEM::DMMoFEMGetFieldIS ( DM  dm,
RowColData  rc,
const char  field_name[],
IS *  is 
)

get field is in the problem

Parameters
dmthe DM objects
rcROW or COL (no difference is problem is squared)
field_namename of the field
isreturned the IS object
Returns
error code
IS is;
ierr = DMMoFEMGetFieldIS(dm,ROW,"DISP",&is_disp); CHKERRG(ierr);
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:483
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
Definition: DMMoFEM.cpp:1478
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76

Definition at line 1478 of file DMMoFEM.cpp.

1479 {
1480 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1482 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1483 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1484 ->isCreateProblemFieldAndRank(dm_field->problemPtr->getName(), ROW,
1485 field_name, 0, 1000, is);
1487}

◆ DMMoFEMGetIsCompDM()

PetscErrorCode MoFEM::DMMoFEMGetIsCompDM ( DM  dm,
PetscBool *  is_comp_dm 
)

Get if this DM is composite DM.

Parameters
dmthe DM object
is_comp_dmreturn true if composite problem here
Returns
error code

Definition at line 391 of file DMMoFEM.cpp.

391 {
393 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
395 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
396 *is_comp_dm = dm_field->isCompDM;
398}

◆ DMMoFEMGetIsPartitioned()

PetscErrorCode MoFEM::DMMoFEMGetIsPartitioned ( DM  dm,
PetscBool *  is_partitioned 
)

get if read mesh is partitioned

Definition at line 1120 of file DMMoFEM.cpp.

1120 {
1121 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1123 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1124 *is_partitioned = dm_field->isPartitioned;
1126}

◆ DMMoFEMGetIsSubDM()

PetscErrorCode MoFEM::DMMoFEMGetIsSubDM ( DM  dm,
PetscBool *  is_sub_dm 
)

Return true if this DM is sub problem

Parameters
dmthe DM object
is_subproblemtrue if subproblem
Returns
error code

Definition at line 308 of file DMMoFEM.cpp.

308 {
310 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
312 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
313 *is_sub_dm = dm_field->isSubDM;
315}

◆ DMMoFEMGetKspCtx() [1/2]

PetscErrorCode MoFEM::DMMoFEMGetKspCtx ( DM  dm,
const boost::shared_ptr< MoFEM::KspCtx > &  ksp_ctx 
)

get MoFEM::KspCtx data structure

Definition at line 1063 of file DMMoFEM.cpp.

1063 {
1064 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1066 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1067 const_cast<boost::shared_ptr<MoFEM::KspCtx> &>(ksp_ctx) = dm_field->kspCtx;
1069}

◆ DMMoFEMGetKspCtx() [2/2]

PetscErrorCode MoFEM::DMMoFEMGetKspCtx ( DM  dm,
MoFEM::KspCtx **  ksp_ctx 
)

get MoFEM::KspCtx data structure

Definition at line 1054 of file DMMoFEM.cpp.

1054 {
1055 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1057 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1058 *ksp_ctx = dm_field->kspCtx.get();
1060}

◆ DMMoFEMGetProblemFiniteElementLayout()

PetscErrorCode MoFEM::DMMoFEMGetProblemFiniteElementLayout ( DM  dm,
std::string  fe_name,
PetscLayout *  layout 
)

Get finite elements layout in the problem.

In layout is stored information how many elements is on each processor, for more information look int petsc documentation http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/IS/PetscLayoutCreate.html#PetscLayoutCreate

Parameters
dmdiscrete manager for this problem
fe_namefinite element name
layoutpointer to layout, for created layout user takes responsibility for destroying it.
Returns
error code

Definition at line 459 of file DMMoFEM.cpp.

460 {
462 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
464 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
465
466 MPI_Comm comm;
467 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
468 CHKERR dm_field->problemPtr->getNumberOfElementsByNameAndPart(comm, fe_name,
469 layout);
471}

◆ DMMoFEMGetProblemPtr()

PetscErrorCode MoFEM::DMMoFEMGetProblemPtr ( DM  dm,
const MoFEM::Problem **  problem_ptr 
)

Get pointer to problem data structure.

Definition at line 412 of file DMMoFEM.cpp.

412 {
413 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
415 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
416 if (!dm->data) {
417 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
418 "data structure for MoFEM not yet created");
419 }
420 *problem_ptr = dm_field->problemPtr;
422}

◆ DMMoFEMGetSnesCtx() [1/2]

PetscErrorCode MoFEM::DMMoFEMGetSnesCtx ( DM  dm,
const boost::shared_ptr< MoFEM::SnesCtx > &  snes_ctx 
)

get MoFEM::SnesCtx data structure

Definition at line 1089 of file DMMoFEM.cpp.

1089 {
1090 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1092 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1093 const_cast<boost::shared_ptr<MoFEM::SnesCtx> &>(snes_ctx) = dm_field->snesCtx;
1095}

◆ DMMoFEMGetSnesCtx() [2/2]

PetscErrorCode MoFEM::DMMoFEMGetSnesCtx ( DM  dm,
MoFEM::SnesCtx **  snes_ctx 
)

get MoFEM::SnesCtx data structure

Definition at line 1080 of file DMMoFEM.cpp.

1080 {
1081 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1083 DMCtx *dm_field = (DMCtx *)dm->data;
1084 *snes_ctx = dm_field->snesCtx.get();
1086}

◆ DMMoFEMGetSquareProblem()

PetscErrorCode MoFEM::DMMoFEMGetSquareProblem ( DM  dm,
PetscBool *  square_problem 
)

get squared problem

It if true is assumed that matrix has the same indexing on rows and columns. This reduces interprocessor communication.

Definition at line 473 of file DMMoFEM.cpp.

473 {
476 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
478 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
479 *square_problem = dm_field->isSquareMatrix;
481}

◆ DMMoFEMGetTsCtx() [1/2]

PetscErrorCode MoFEM::DMMoFEMGetTsCtx ( DM  dm,
const boost::shared_ptr< MoFEM::TsCtx > &  ts_ctx 
)

get MoFEM::TsCtx data structure

Definition at line 1136 of file DMMoFEM.cpp.

1137 {
1138 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1140 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1141 const_cast<boost::shared_ptr<MoFEM::TsCtx> &>(ts_ctx) = dm_field->tsCtx;
1143}
MoFEM::TsCtx * ts_ctx
Definition: level_set.cpp:1884

◆ DMMoFEMGetTsCtx() [2/2]

PetscErrorCode MoFEM::DMMoFEMGetTsCtx ( DM  dm,
MoFEM::TsCtx **  ts_ctx 
)

get MoFEM::TsCtx data structure

Definition at line 1128 of file DMMoFEM.cpp.

1128 {
1129 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1131 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1132 *ts_ctx = dm_field->tsCtx.get();
1134}

◆ DMMoFEMKSPSetComputeOperators() [1/2]

PetscErrorCode MoFEM::DMMoFEMKSPSetComputeOperators ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

Set KSP operators and push mofem finite element methods.

Parameters
dmDM
fe_namefinite element name
methodmethod on the element (executed for each element in the problem which given name)
pre_onlymethod for pre-process before element method
post_onlymethod for post-process after element method
Returns
error code

Definition at line 664 of file DMMoFEM.cpp.

667 {
668 return DMMoFEMKSPSetComputeOperators<const char *, MoFEM::FEMethod *,
671 dm, fe_name, method, pre_only, post_only);
672}
PetscErrorCode DMMoFEMKSPSetComputeOperators(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set KSP operators and push mofem finite element methods.
Definition: DMMoFEM.cpp:664
Data structure to exchange data between mofem and User Loop Methods.
structure for User Loop Methods on finite elements

◆ DMMoFEMKSPSetComputeOperators() [2/2]

PetscErrorCode MoFEM::DMMoFEMKSPSetComputeOperators ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

Set KSP operators and push mofem finite element methods.

Parameters
dmDM
fe_namefinite element name
methodmethod on the element (executed for each element in the problem which given name)
pre_onlymethod for pre-process before element method
post_onlymethod for post-process after element method
Returns
error code

Definition at line 675 of file DMMoFEM.cpp.

678 {
679 return DMMoFEMKSPSetComputeOperators<const std::string,
680 boost::shared_ptr<MoFEM::FEMethod>>(
681 dm, fe_name, method, pre_only, post_only);
682}

◆ DMMoFEMKSPSetComputeRHS() [1/2]

PetscErrorCode MoFEM::DMMoFEMKSPSetComputeRHS ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

set KSP right hand side evaluation function

Definition at line 623 of file DMMoFEM.cpp.

626 {
627 return DMMoFEMKSPSetComputeRHS<const char *, MoFEM::FEMethod *,
629 dm, fe_name, method, pre_only, post_only);
630}
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set KSP right hand side evaluation function
Definition: DMMoFEM.cpp:623

◆ DMMoFEMKSPSetComputeRHS() [2/2]

PetscErrorCode MoFEM::DMMoFEMKSPSetComputeRHS ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

set KSP right hand side evaluation function

Definition at line 633 of file DMMoFEM.cpp.

636 {
637 return DMMoFEMKSPSetComputeRHS<const std::string,
638 boost::shared_ptr<MoFEM::FEMethod>,
639 boost::shared_ptr<MoFEM::BasicMethod>,
640 boost::shared_ptr<MoFEM::BasicMethod>>(
641 dm, fe_name, method, pre_only, post_only);
642}

◆ DMMoFEMResolveSharedFiniteElements()

PetscErrorCode MoFEM::DMMoFEMResolveSharedFiniteElements ( DM  dm,
std::string  fe_name 
)

Resolve shared entities.

Parameters
dmdm
fe_namefinite element for which shared entities are resolved
Returns
error code
Note
This function is valid for parallel algebra and serial mesh. It should be run collectively, i.e. on all processors.

This allows for tag reduction or tag exchange, f.e.

Tag th;
CHKERR mField.get_moab().tag_get_handle("ADAPT_ORDER",th);
ParallelComm* pcomm =
ParallelComm::get_pcomm(&mField.get_moab(),MYPCOMM_INDEX);
// CHKERR pcomm->reduce_tags(th,MPI_SUM,prisms);
CHKERR pcomm->exchange_tags(th,prisms);
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:215
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name)
Resolve shared entities.
Definition: DMMoFEM.cpp:450

Definition at line 450 of file DMMoFEM.cpp.

450 {
451 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
453 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
454 CHKERR dm_field->mField_ptr->getInterface<CommInterface>()
455 ->resolveSharedFiniteElements(dm_field->problemPtr, fe_name);
457}

◆ DMMoFEMSetIsPartitioned()

PetscErrorCode MoFEM::DMMoFEMSetIsPartitioned ( DM  dm,
PetscBool  is_partitioned 
)

sets if read mesh is partitioned

get if read mesh is partitioned

Definition at line 1109 of file DMMoFEM.cpp.

1109 {
1110 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1112 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1113 dm_field->isPartitioned = is_partitioned;
1115}

◆ DMMoFEMSetKspCtx()

PetscErrorCode MoFEM::DMMoFEMSetKspCtx ( DM  dm,
boost::shared_ptr< MoFEM::KspCtx ksp_ctx 
)

set MoFEM::KspCtx data structure

Definition at line 1071 of file DMMoFEM.cpp.

1072 {
1073 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1075 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1076 dm_field->kspCtx = ksp_ctx;
1078}

◆ DMMoFEMSetSnesCtx()

PetscErrorCode MoFEM::DMMoFEMSetSnesCtx ( DM  dm,
boost::shared_ptr< MoFEM::SnesCtx snes_ctx 
)

Set MoFEM::SnesCtx data structure.

Definition at line 1097 of file DMMoFEM.cpp.

1098 {
1099 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1101 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1102 dm_field->snesCtx = snes_ctx;
1104}

◆ DMMoFEMSetSquareProblem()

PetscErrorCode MoFEM::DMMoFEMSetSquareProblem ( DM  dm,
PetscBool  square_problem 
)

set squared problem

It if true is assumed that matrix has the same indexing on rows and columns. This reduces interprocessor communication.

Definition at line 442 of file DMMoFEM.cpp.

442 {
443 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
445 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
446 dm_field->isSquareMatrix = square_problem;
448}

◆ DMMoFEMSetTsCtx()

PetscErrorCode MoFEM::DMMoFEMSetTsCtx ( DM  dm,
boost::shared_ptr< MoFEM::TsCtx ts_ctx 
)

Set MoFEM::TsCtx data structure.

It take over pointer, do not delete it, DM will destroy pointer when is destroyed.

Definition at line 1145 of file DMMoFEM.cpp.

1145 {
1146 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1148 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1149 dm_field->tsCtx = ts_ctx;
1151}

◆ DMMoFEMSNESSetFunction() [1/2]

PetscErrorCode MoFEM::DMMoFEMSNESSetFunction ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

set SNES residual evaluation function

Definition at line 704 of file DMMoFEM.cpp.

707 {
708 return DMMoFEMSNESSetFunction<const char *, MoFEM::FEMethod *,
710 dm, fe_name, method, pre_only, post_only);
711}
PetscErrorCode DMMoFEMSNESSetFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES residual evaluation function
Definition: DMMoFEM.cpp:704

◆ DMMoFEMSNESSetFunction() [2/2]

PetscErrorCode MoFEM::DMMoFEMSNESSetFunction ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

set SNES residual evaluation function

Definition at line 714 of file DMMoFEM.cpp.

717 {
718 return DMMoFEMSNESSetFunction<const std::string,
719 boost::shared_ptr<MoFEM::FEMethod>,
720 boost::shared_ptr<MoFEM::BasicMethod>,
721 boost::shared_ptr<MoFEM::BasicMethod>>(
722 dm, fe_name, method, pre_only, post_only);
723}

◆ DMMoFEMSNESSetJacobian() [1/2]

PetscErrorCode MoFEM::DMMoFEMSNESSetJacobian ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

set SNES Jacobian evaluation function

Definition at line 745 of file DMMoFEM.cpp.

748 {
749 return DMMoFEMSNESSetJacobian<const char *, MoFEM::FEMethod *,
751 dm, fe_name, method, pre_only, post_only);
752}
PetscErrorCode DMMoFEMSNESSetJacobian(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set SNES Jacobian evaluation function
Definition: DMMoFEM.cpp:745

◆ DMMoFEMSNESSetJacobian() [2/2]

PetscErrorCode MoFEM::DMMoFEMSNESSetJacobian ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

set SNES Jacobian evaluation function

Definition at line 755 of file DMMoFEM.cpp.

758 {
759 return DMMoFEMSNESSetJacobian<const std::string,
760 boost::shared_ptr<MoFEM::FEMethod>,
761 boost::shared_ptr<MoFEM::BasicMethod>,
762 boost::shared_ptr<MoFEM::BasicMethod>>(
763 dm, fe_name, method, pre_only, post_only);
764}

◆ DMMoFEMTSSetI2Function() [1/2]

PetscErrorCode MoFEM::DMMoFEMTSSetI2Function ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

set TS implicit function evaluation function

Definition at line 950 of file DMMoFEM.cpp.

953 {
954 return DMMoFEMTSSetI2Function<const char *, MoFEM::FEMethod *,
956 dm, fe_name, method, pre_only, post_only);
958}
PetscErrorCode DMMoFEMTSSetI2Function(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS implicit function evaluation function
Definition: DMMoFEM.cpp:961

◆ DMMoFEMTSSetI2Function() [2/2]

PetscErrorCode MoFEM::DMMoFEMTSSetI2Function ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

set TS implicit function evaluation function

Definition at line 961 of file DMMoFEM.cpp.

964 {
965 return DMMoFEMTSSetI2Function<const std::string,
966 boost::shared_ptr<MoFEM::FEMethod>,
967 boost::shared_ptr<MoFEM::BasicMethod>,
968 boost::shared_ptr<MoFEM::BasicMethod>>(
969 dm, fe_name, method, pre_only, post_only);
971}

◆ DMMoFEMTSSetI2Jacobian() [1/2]

PetscErrorCode MoFEM::DMMoFEMTSSetI2Jacobian ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

set TS Jacobian evaluation function

Definition at line 993 of file DMMoFEM.cpp.

996 {
997 return DMMoFEMTSSetI2Jacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
998 MoFEM::BasicMethod *>(dm, fe_name, method,
999 pre_only, post_only);
1000}
PetscErrorCode DMMoFEMTSSetI2Jacobian(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS Jacobian evaluation function
Definition: DMMoFEM.cpp:1003

◆ DMMoFEMTSSetI2Jacobian() [2/2]

PetscErrorCode MoFEM::DMMoFEMTSSetI2Jacobian ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

set TS Jacobian evaluation function

Definition at line 1003 of file DMMoFEM.cpp.

1006 {
1007 return DMMoFEMTSSetI2Jacobian<const std::string,
1008 boost::shared_ptr<MoFEM::FEMethod>,
1009 boost::shared_ptr<MoFEM::BasicMethod>,
1010 boost::shared_ptr<MoFEM::BasicMethod>>(
1011 dm, fe_name, method, pre_only, post_only);
1012}

◆ DMMoFEMTSSetIFunction() [1/2]

PetscErrorCode MoFEM::DMMoFEMTSSetIFunction ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

set TS implicit function evaluation function

Definition at line 786 of file DMMoFEM.cpp.

789 {
790 return DMMoFEMTSSetIFunction<const char *, MoFEM::FEMethod *,
792 dm, fe_name, method, pre_only, post_only);
794}
PetscErrorCode DMMoFEMTSSetIFunction(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
set TS implicit function evaluation function
Definition: DMMoFEM.cpp:786

◆ DMMoFEMTSSetIFunction() [2/2]

PetscErrorCode MoFEM::DMMoFEMTSSetIFunction ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

set TS implicit function evaluation function

Definition at line 797 of file DMMoFEM.cpp.

800 {
801 return DMMoFEMTSSetIFunction<const std::string,
802 boost::shared_ptr<MoFEM::FEMethod>,
803 boost::shared_ptr<MoFEM::BasicMethod>,
804 boost::shared_ptr<MoFEM::BasicMethod>>(
805 dm, fe_name, method, pre_only, post_only);
807}

◆ DMMoFEMTSSetIJacobian() [1/2]

PetscErrorCode MoFEM::DMMoFEMTSSetIJacobian ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
MoFEM::BasicMethod pre_only,
MoFEM::BasicMethod post_only 
)

set TS Jacobian evaluation function

Definition at line 829 of file DMMoFEM.cpp.

832 {
833 return DMMoFEMTSSetIJacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
834 MoFEM::BasicMethod *>(dm, fe_name, method,
835 pre_only, post_only);
836}
PetscErrorCode DMMoFEMTSSetIJacobian(DM dm, const std::string fe_name, boost::shared_ptr< MoFEM::FEMethod > method, boost::shared_ptr< MoFEM::BasicMethod > pre_only, boost::shared_ptr< MoFEM::BasicMethod > post_only)
set TS Jacobian evaluation function
Definition: DMMoFEM.cpp:839

◆ DMMoFEMTSSetIJacobian() [2/2]

PetscErrorCode MoFEM::DMMoFEMTSSetIJacobian ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
boost::shared_ptr< MoFEM::BasicMethod pre_only,
boost::shared_ptr< MoFEM::BasicMethod post_only 
)

set TS Jacobian evaluation function

Definition at line 839 of file DMMoFEM.cpp.

842 {
843 return DMMoFEMTSSetIJacobian<const std::string,
844 boost::shared_ptr<MoFEM::FEMethod>,
845 boost::shared_ptr<MoFEM::BasicMethod>,
846 boost::shared_ptr<MoFEM::BasicMethod>>(
847 dm, fe_name, method, pre_only, post_only);
848}

◆ DMMoFEMUnSetElement()

PetscErrorCode MoFEM::DMMoFEMUnSetElement ( DM  dm,
std::string  fe_name 
)

unset element from dm

Definition at line 500 of file DMMoFEM.cpp.

500 {
501 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
503 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
504 CHKERR dm_field->mField_ptr->modify_problem_unset_finite_element(
505 dm_field->problemName, fe_name);
507}

◆ DMoFEMGetInterfacePtr()

PetscErrorCode MoFEM::DMoFEMGetInterfacePtr ( DM  dm,
MoFEM::Interface **  m_field_ptr 
)

Get pointer to MoFEM::Interface.

Parameters
dmDistributed mesh manager
m_field_ptrPointer to pointer of field interface
Returns
Error code

Definition at line 400 of file DMMoFEM.cpp.

400 {
401 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
403 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
404 if (!dm->data) {
405 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
406 "data structure for MoFEM not yet created");
407 }
408 *m_field_ptr = dm_field->mField_ptr;
410}

◆ DMoFEMLoopDofs()

PetscErrorCode MoFEM::DMoFEMLoopDofs ( DM  dm,
const char  field_name[],
MoFEM::DofMethod method 
)

execute method for dofs on field in problem

Definition at line 591 of file DMMoFEM.cpp.

592 {
593 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
595 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
596 ierr =
597 dm_field->mField_ptr->loop_dofs(dm_field->problemPtr, field_name, COL,
598 *method, dm_field->rAnk, dm_field->rAnk);
599 CHKERRG(ierr);
601}

◆ DMoFEMLoopFiniteElements() [1/2]

PetscErrorCode MoFEM::DMoFEMLoopFiniteElements ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
CacheTupleWeakPtr  cache_ptr = CacheTupleSharedPtr() 
)

Executes FEMethod for finite elements in DM.

Parameters
dmMoFEM discrete manager
fe_namename of element
methodpointer to MOFEM::FEMethod
Returns
Error code

Definition at line 572 of file DMMoFEM.cpp.

574 {
575 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
577 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
579 dm, fe_name, method, dm_field->rAnk, dm_field->rAnk, cache_ptr);
580 CHKERRG(ierr);
582}
PetscErrorCode DMoFEMLoopFiniteElementsUpAndLowRank(DM dm, const char fe_name[], MoFEM::FEMethod *method, int low_rank, int up_rank, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:553

◆ DMoFEMLoopFiniteElements() [2/2]

PetscErrorCode MoFEM::DMoFEMLoopFiniteElements ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
CacheTupleWeakPtr  cache_ptr = CacheTupleSharedPtr() 
)

Executes FEMethod for finite elements in DM.

Parameters
dmMoFEM discrete manager
fe_namename of element
methodpointer to MOFEM::FEMethod
Returns
Error code

Definition at line 585 of file DMMoFEM.cpp.

587 {
588 return DMoFEMLoopFiniteElements(dm, fe_name.c_str(), method.get(), cache_ptr);
589}
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition: DMMoFEM.cpp:572

◆ DMoFEMLoopFiniteElementsUpAndLowRank() [1/2]

PetscErrorCode MoFEM::DMoFEMLoopFiniteElementsUpAndLowRank ( DM  dm,
const char  fe_name[],
MoFEM::FEMethod method,
int  low_rank,
int  up_rank,
CacheTupleWeakPtr  cache_ptr = CacheTupleSharedPtr() 
)

Executes FEMethod for finite elements in DM.

Parameters
dmMoFEM discrete manager
fe_namename of finite element
methodpointer to MoFEM::FEMethod
low_ranklowest rank of processor
up_rankupper run of processor
Returns
Error code

Definition at line 553 of file DMMoFEM.cpp.

555 {
557 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
558 ierr = dm_field->mField_ptr->loop_finite_elements(
559 dm_field->problemPtr, fe_name, *method, low_rank, up_rank, nullptr,
560 MF_EXIST, cache_ptr);
561 CHKERRG(ierr);
563}
@ MF_EXIST
Definition: definitions.h:100

◆ DMoFEMLoopFiniteElementsUpAndLowRank() [2/2]

PetscErrorCode MoFEM::DMoFEMLoopFiniteElementsUpAndLowRank ( DM  dm,
const std::string  fe_name,
boost::shared_ptr< MoFEM::FEMethod method,
int  low_rank,
int  up_rank,
CacheTupleWeakPtr  cache_ptr = CacheTupleSharedPtr() 
)

Executes FEMethod for finite elements in DM.

Parameters
dmMoFEM discrete manager
fe_namename of finite element
methodpointer to MoFEM::FEMethod
low_ranklowest rank of processor
up_rankupper run of processor
Returns
Error code

Definition at line 565 of file DMMoFEM.cpp.

567 {
568 return DMoFEMLoopFiniteElementsUpAndLowRank(dm, fe_name.c_str(), method.get(),
569 low_rank, up_rank, cache_ptr);
570}

◆ DMoFEMMeshToGlobalVector()

PetscErrorCode MoFEM::DMoFEMMeshToGlobalVector ( DM  dm,
Vec  g,
InsertMode  mode,
ScatterMode  scatter_mode 
)

set ghosted vector values on all existing mesh entities

Parameters
gvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities from V vector.

SCATTER_FORWARD set vector V from data field entities

Definition at line 521 of file DMMoFEM.cpp.

522 {
523 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
525 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
526 ierr = dm_field->mField_ptr->getInterface<VecManager>()->setGlobalGhostVector(
527 dm_field->problemPtr, COL, g, mode, scatter_mode);
528 CHKERRG(ierr);
530}

◆ DMoFEMMeshToLocalVector()

PetscErrorCode MoFEM::DMoFEMMeshToLocalVector ( DM  dm,
Vec  l,
InsertMode  mode,
ScatterMode  scatter_mode 
)

set local (or ghosted) vector values on mesh for partition only

Parameters
lvector
modesee petsc manual for VecSetValue (ADD_VALUES or INSERT_VALUES)
scatter_modesee petsc manual for ScatterMode (The available modes are: SCATTER_FORWARD or SCATTER_REVERSE)

SCATTER_REVERSE set data to field entities from V vector.

SCATTER_FORWARD set vector V from data field entities

Definition at line 509 of file DMMoFEM.cpp.

510 {
512 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
514 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
515 ierr = dm_field->mField_ptr->getInterface<VecManager>()->setLocalGhostVector(
516 dm_field->problemPtr, COL, l, mode, scatter_mode);
517 CHKERRG(ierr);
519}

◆ DMoFEMPostProcessFiniteElements()

PetscErrorCode MoFEM::DMoFEMPostProcessFiniteElements ( DM  dm,
MoFEM::FEMethod method 
)

execute finite element method for each element in dm (problem)

Definition at line 542 of file DMMoFEM.cpp.

542 {
543 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
545 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
546 ierr = dm_field->mField_ptr->problem_basic_method_postProcess(
547 dm_field->problemPtr, *method);
548 CHKERRG(ierr);
550}

◆ DMoFEMPreProcessFiniteElements()

PetscErrorCode MoFEM::DMoFEMPreProcessFiniteElements ( DM  dm,
MoFEM::FEMethod method 
)

execute finite element method for each element in dm (problem)

Definition at line 532 of file DMMoFEM.cpp.

532 {
533 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
535 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
536 ierr = dm_field->mField_ptr->problem_basic_method_preProcess(
537 dm_field->problemPtr, *method);
538 CHKERRG(ierr);
540}

◆ DMRegister_MGViaApproxOrders()

MoFEMErrorCode DMRegister_MGViaApproxOrders ( const char  sname[])

Register DM for Multi-Grid via approximation orders.

Parameters
snameproblem/dm registered name
Returns
error code

Definition at line 376 of file PCMGSetUpViaApproxOrders.cpp.

376 {
378 CHKERR DMRegister(sname, DMCreate_MGViaApproxOrders);
380}
MoFEMErrorCode DMCreate_MGViaApproxOrders(DM dm)
Create DM data structure for Multi-Grid via approximation orders.

◆ DMRegister_MoFEM()

PetscErrorCode MoFEM::DMRegister_MoFEM ( const char  sname[])

Register MoFEM problem.

Definition at line 47 of file DMMoFEM.cpp.

47 {
49 CHKERR DMRegister(sname, DMCreate_MoFEM);
51}

◆ DMSetFromOptions_MoFEM()

PetscErrorCode MoFEM::DMSetFromOptions_MoFEM ( DM  dm)

Set options for MoFEM DM

Definition at line 1245 of file DMMoFEM.cpp.

1245 {
1246#endif
1247
1248 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1250 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1251#if PETSC_VERSION_GE(3, 5, 3)
1252 ierr = PetscOptionsHead(PetscOptionsObject, "DMMoFEM Options");
1253 CHKERRG(ierr);
1254#else
1255 ierr = PetscOptionsHead("DMMoFEM Options");
1256 CHKERRG(ierr);
1257#endif
1258 ierr = PetscOptionsBool("-dm_is_partitioned",
1259 "set if mesh is partitioned (works which native MOAB "
1260 "file format, i.e. h5m",
1261 "DMSetUp", dm_field->isPartitioned,
1262 &dm_field->isPartitioned, NULL);
1263 CHKERRG(ierr);
1265}

◆ DMSetOperators_MoFEM()

PetscErrorCode MoFEM::DMSetOperators_MoFEM ( DM  dm)

Set operators for MoFEM dm.

Parameters
dm
Returns
error code

Definition at line 53 of file DMMoFEM.cpp.

53 {
54 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
56
57 dm->ops->createglobalvector = DMCreateGlobalVector_MoFEM;
58 dm->ops->createlocalvector = DMCreateLocalVector_MoFEM;
59 dm->ops->creatematrix = DMCreateMatrix_MoFEM;
60 dm->ops->setup = DMSetUp_MoFEM;
61 dm->ops->destroy = DMDestroy_MoFEM;
62 dm->ops->setfromoptions = DMSetFromOptions_MoFEM;
63 dm->ops->globaltolocalbegin = DMGlobalToLocalBegin_MoFEM;
64 dm->ops->globaltolocalend = DMGlobalToLocalEnd_MoFEM;
65 dm->ops->localtoglobalbegin = DMLocalToGlobalBegin_MoFEM;
66 dm->ops->localtoglobalend = DMLocalToGlobalEnd_MoFEM;
67 dm->ops->createfieldis = DMCreateFieldIS_MoFEM;
68
69 // Default matrix type
70 CHKERR DMSetMatType(dm, MATMPIAIJ);
71
73}
PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1361
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1369
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition: DMMoFEM.cpp:1173
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
Definition: DMMoFEM.cpp:83
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1398
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1245
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition: DMMoFEM.cpp:1433
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition: DMMoFEM.cpp:1267
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition: DMMoFEM.cpp:1427

◆ DMSetUp_MoFEM()

PetscErrorCode MoFEM::DMSetUp_MoFEM ( DM  dm)

sets up the MoFEM structures inside a DM object

Definition at line 1267 of file DMMoFEM.cpp.

1267 {
1268 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1269 ProblemsManager *prb_mng_ptr;
1271 DMCtx *dm_field = static_cast<DMCtx *>(dm->data);
1272 CHKERR dm_field->mField_ptr->getInterface(prb_mng_ptr);
1273
1274 if (dm_field->isCompDM) {
1275 // It is composite probelm
1276 CHKERR prb_mng_ptr->buildComposedProblem(
1277 dm_field->problemName, dm_field->rowCompPrb, dm_field->colCompPrb,
1278 dm_field->isSquareMatrix == PETSC_TRUE, dm_field->verbosity);
1279 } else {
1280 if (dm_field->isPartitioned) {
1281 CHKERR prb_mng_ptr->buildProblemOnDistributedMesh(
1282 dm_field->problemName, dm_field->isSquareMatrix == PETSC_TRUE,
1283 dm_field->verbosity);
1284 } else {
1285 CHKERR prb_mng_ptr->buildProblem(dm_field->problemName,
1286 dm_field->isSquareMatrix == PETSC_TRUE,
1287 dm_field->verbosity);
1288 CHKERR prb_mng_ptr->partitionProblem(dm_field->problemName,
1289 dm_field->verbosity);
1290 }
1291 }
1292
1293 // Partition finite elements
1294 if (dm_field->isPartitioned) {
1295 CHKERR prb_mng_ptr->partitionFiniteElements(
1296 dm_field->problemName, true, 0, dm_field->sIze, dm_field->verbosity);
1297 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1298 dm_field->problemName, dm_field->verbosity);
1299 } else {
1300 // partition finite elemnets
1301 CHKERR prb_mng_ptr->partitionFiniteElements(dm_field->problemName, false,
1302 -1, -1, dm_field->verbosity);
1303 // Get ghost DOFs
1304 CHKERR prb_mng_ptr->partitionGhostDofs(dm_field->problemName,
1305 dm_field->verbosity);
1306 }
1307
1308 // Set flag that problem is build and partitioned
1309 dm_field->isProblemBuild = PETSC_TRUE;
1310
1312}

◆ DMSubDMSetUp_MoFEM()

PetscErrorCode MoFEM::DMSubDMSetUp_MoFEM ( DM  subdm)

Sets up the MoFEM structures inside a DM object for sub dm

Definition at line 1314 of file DMMoFEM.cpp.

1314 {
1315 PetscValidHeaderSpecific(subdm, DM_CLASSID, 1);
1316 ProblemsManager *prb_mng_ptr;
1318
1319 DMCtx *subdm_field = static_cast<DMCtx *>(subdm->data);
1320
1321 // build sub dm problem
1322 CHKERR subdm_field->mField_ptr->getInterface(prb_mng_ptr);
1323
1324 map<std::string, boost::shared_ptr<Range>> *entity_map_row = nullptr;
1325 map<std::string, boost::shared_ptr<Range>> *entity_map_col = nullptr;
1326
1327 if (subdm_field->mapTypeRow.size())
1328 entity_map_row = &subdm_field->mapTypeRow;
1329 if (subdm_field->mapTypeCol.size())
1330 entity_map_col = &subdm_field->mapTypeCol;
1331
1332 CHKERR prb_mng_ptr->buildSubProblem(
1333 subdm_field->problemName, subdm_field->rowFields, subdm_field->colFields,
1334 subdm_field->problemMainOfSubPtr->getName(),
1335 subdm_field->isSquareMatrix == PETSC_TRUE, entity_map_row, entity_map_col,
1336 subdm_field->verbosity);
1337
1338 // partition problem
1339 subdm_field->isPartitioned = subdm_field->isPartitioned;
1340 if (subdm_field->isPartitioned) {
1341 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, true,
1342 0, subdm_field->sIze,
1343 subdm_field->verbosity);
1344 // set ghost nodes
1345 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1346 subdm_field->problemName, subdm_field->verbosity);
1347 } else {
1348 // partition finite elements
1349 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, false,
1350 -1, -1, subdm_field->verbosity);
1351 // set ghost nodes
1352 CHKERR prb_mng_ptr->partitionGhostDofs(subdm_field->problemName,
1353 subdm_field->verbosity);
1354 }
1355
1356 subdm_field->isProblemBuild = PETSC_TRUE;
1357
1359}
if(!static_cast< bool >(ifstream(param_file)))