v0.15.0
Loading...
Searching...
No Matches
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  MoFEM::DMMGViaApproxOrdersCtx
 Structure for DM for multi-grid via approximation orders. More...
 

Functions

PetscErrorCode MoFEM::DMRegister_MoFEM (const char sname[])
 Register MoFEM problem.
 
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.
 
PetscErrorCode MoFEM::DMMoFEMCreateSubDM (DM subdm, DM dm, const char problem_name[])
 Must be called by user to set Sub DM MoFEM data structures.
 
PetscErrorCode MoFEM::DMoFEMGetInterfacePtr (DM dm, MoFEM::Interface **m_field_ptr)
 Get pointer to MoFEM::Interface.
 
PetscErrorCode MoFEM::DMMoFEMGetProblemPtr (DM dm, const MoFEM::Problem **problem_ptr)
 Get pointer to problem data structure.
 
PetscErrorCode MoFEM::DMMoFEMSetSquareProblem (DM dm, PetscBool square_problem)
 set squared problem
 
PetscErrorCode MoFEM::DMMoFEMGetSquareProblem (DM dm, PetscBool *square_problem)
 get squared problem
 
PetscErrorCode MoFEM::DMMoFEMResolveSharedFiniteElements (DM dm, std::string fe_name)
 Resolve shared entities.
 
PetscErrorCode MoFEM::DMMoFEMGetProblemFiniteElementLayout (DM dm, std::string fe_name, PetscLayout *layout)
 Get finite elements layout in the problem.
 
PetscErrorCode MoFEM::DMMoFEMAddElement (DM dm, std::string fe_name)
 add element to dm
 
PetscErrorCode MoFEM::DMMoFEMAddElement (DM dm, std::vector< std::string > fe_name)
 add element to dm
 
PetscErrorCode MoFEM::DMMoFEMUnSetElement (DM dm, std::string fe_name)
 unset element from dm
 
PetscErrorCode MoFEM::DMoFEMMeshToLocalVector (DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
 set local (or ghosted) vector values on mesh for partition only
 
PetscErrorCode MoFEM::DMoFEMMeshToGlobalVector (DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
 set ghosted vector values on all existing mesh entities
 
PetscErrorCode MoFEM::DMoFEMPreProcessFiniteElements (DM dm, MoFEM::FEMethod *method)
 execute finite element method for each element in dm (problem)
 
PetscErrorCode MoFEM::DMoFEMPostProcessFiniteElements (DM dm, MoFEM::FEMethod *method)
 execute finite element method for each element in dm (problem)
 
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.
 
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.
 
PetscErrorCode MoFEM::DMoFEMLoopFiniteElements (DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
 Executes FEMethod for finite elements in DM.
 
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.
 
PetscErrorCode MoFEM::DMoFEMLoopDofs (DM dm, const char field_name[], MoFEM::DofMethod *method)
 execute method for dofs on field in problem
 
PetscErrorCode MoFEM::DMMoFEMKSPSetComputeRHS (DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
 Set compute operator for KSP solver via sub-matrix and IS.
 
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
 
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.
 
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.
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
PetscErrorCode MoFEM::DMMoFEMGetKspCtx (DM dm, MoFEM::KspCtx **ksp_ctx)
 get MoFEM::KspCtx data structure
 
PetscErrorCode MoFEM::DMMoFEMGetKspCtx (DM dm, const boost::shared_ptr< MoFEM::KspCtx > &ksp_ctx)
 get MoFEM::KspCtx data structure
 
PetscErrorCode MoFEM::DMMoFEMSetKspCtx (DM dm, boost::shared_ptr< MoFEM::KspCtx > ksp_ctx)
 set MoFEM::KspCtx data structure
 
PetscErrorCode MoFEM::DMMoFEMGetSnesCtx (DM dm, MoFEM::SnesCtx **snes_ctx)
 get MoFEM::SnesCtx data structure
 
PetscErrorCode MoFEM::DMMoFEMGetSnesCtx (DM dm, const boost::shared_ptr< MoFEM::SnesCtx > &snes_ctx)
 get MoFEM::SnesCtx data structure
 
PetscErrorCode MoFEM::DMMoFEMSetSnesCtx (DM dm, boost::shared_ptr< MoFEM::SnesCtx > snes_ctx)
 Set MoFEM::SnesCtx data structure.
 
PetscErrorCode MoFEM::DMMoFEMGetTsCtx (DM dm, MoFEM::TsCtx **ts_ctx)
 get MoFEM::TsCtx data structure
 
PetscErrorCode MoFEM::DMMoFEMGetTsCtx (DM dm, const boost::shared_ptr< MoFEM::TsCtx > &ts_ctx)
 get MoFEM::TsCtx data structure
 
PetscErrorCode MoFEM::DMMoFEMSetTsCtx (DM dm, boost::shared_ptr< MoFEM::TsCtx > ts_ctx)
 Set MoFEM::TsCtx data structure.
 
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.
 
PetscErrorCode MoFEM::DMCreate_MoFEM (DM dm)
 Create dm data structure with MoFEM data structure.
 
PetscErrorCode MoFEM::DMDestroy_MoFEM (DM dm)
 Destroys dm with MoFEM data structure.
 
PetscErrorCode MoFEM::DMCreateGlobalVector_MoFEM (DM dm, Vec *g)
 DMShellSetCreateGlobalVector.
 
PetscErrorCode MoFEM::DMCreateGlobalVector_MoFEM (DM dm, SmartPetscObj< Vec > &g_ptr)
 DMShellSetCreateGlobalVector.
 
PetscErrorCode MoFEM::DMCreateLocalVector_MoFEM (DM dm, Vec *l)
 DMShellSetCreateLocalVector.
 
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.
 
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.
 
PetscErrorCode MoFEM::DMMoFEMAddColCompositeProblem (DM dm, const char prb_name[])
 Add problem to composite DM on col.
 
PetscErrorCode MoFEM::DMMoFEMGetIsCompDM (DM dm, PetscBool *is_comp_dm)
 Get if this DM is composite DM.
 
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
 
MoFEMErrorCode MoFEM::DMMoFEMCreateBlockMat (DM dm, Mat *mat)
 Create block matrix.
 
MoFEMErrorCode MoFEM::DMMoFEMCreateBlockMat (DM dm, SmartPetscObj< Mat > &mat)
 Create block matrix.
 
auto MoFEM::createDMMatrix (DM dm)
 Get smart matrix from DM.
 
auto MoFEM::createDMVector (DM dm)
 Get smart vector from DM.
 
MoFEMErrorCode MoFEM::DMMGViaApproxOrdersPushBackCoarseningIS (DM, IS is, Mat A, bool create_sub_matrix, bool shell_sub_a)
 Push back coarsening level to MG via approximation orders.
 
MoFEMErrorCode MoFEM::DMMGViaApproxOrdersPopBackCoarseningIS (DM)
 Pop IS form MG via approximation orders.
 
MoFEMErrorCode MoFEM::DMMGViaApproxOrdersClearCoarseningIS (DM)
 Clear approximation orders.
 
MoFEMErrorCode MoFEM::DMRegister_MGViaApproxOrders (const char sname[])
 Register DM for Multi-Grid via approximation orders.
 
MoFEMErrorCode MoFEM::DMCreateMatrix_MGViaApproxOrders (DM dm, Mat *M)
 Create matrix for Multi-Grid via approximation orders.
 
MoFEMErrorCode MoFEM::DMCoarsen_MGViaApproxOrders (DM dm, MPI_Comm comm, DM *dmc)
 Coarsen DM.
 

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

#include <src/petsc/DMMoFEM.hpp>

Get smart matrix from DM.

Examples
free_surface.cpp, level_set.cpp, mofem/tutorials/vec-7/adjoint.cpp, and navier_stokes.cpp.

Definition at line 1059 of file DMMoFEM.hpp.

1059 {
1060 SmartPetscObj<Mat> a;
1062 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1063 return a;
1064};
constexpr double a
static PetscErrorCode ierr
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition DMMoFEM.cpp:1187
MPI_Comm getCommFromPetscObject(PetscObject obj)
Get the Comm From Petsc Object object.

◆ createDMVector()

auto MoFEM::createDMVector ( DM dm)
inline

#include <src/petsc/DMMoFEM.hpp>

Get smart vector from DM.

Examples
adolc_plasticity.cpp, approx_sphere.cpp, child_and_parent.cpp, dg_projection.cpp, dynamic_first_order_con_law.cpp, eigen_elastic.cpp, free_surface.cpp, hanging_node_approx.cpp, heat_method.cpp, helmholtz.cpp, higher_derivatives.cpp, level_set.cpp, mixed_poisson.cpp, mofem/tutorials/vec-7/adjoint.cpp, navier_stokes.cpp, phase.cpp, plate.cpp, poisson_2d_dis_galerkin.cpp, poisson_2d_homogeneous.cpp, and shallow_wave.cpp.

Definition at line 1102 of file DMMoFEM.hpp.

1102 {
1103 SmartPetscObj<Vec> v;
1105 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1106 return v;
1107};
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition DMMoFEM.cpp:1157
const double v
phase velocity of light in medium (cm/ns)

◆ DMCoarsen_MGViaApproxOrders()

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

#include <src/petsc/impl/PCMGSetUpViaApproxOrders.cpp>

Coarsen DM.

Not used directly by user

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

Definition at line 386 of file PCMGSetUpViaApproxOrders.cpp.

386 {
387 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
389 GET_DM_FIELD(dm);
390 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
391 CHKERR DMCreate(comm, dmc);
392 (*dmc)->data = dm->data;
393 DMType type;
394 CHKERR DMGetType(dm, &type);
395 CHKERR DMSetType(*dmc, type);
396 dm_field->coarsenDM = SmartPetscObj<DM>(*dmc, false);
397#if PETSC_VERSION_GE(3, 17, 0)
398 PetscInfo(dm, "Coarsen DMMGViaApproxOrders leveldown = %d\n", dm->leveldown);
399#else
400 PetscInfo1(dm, "Coarsen DMMGViaApproxOrders leveldown = %d\n", dm->leveldown);
401#endif
403}
#define GET_DM_FIELD(DM)
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.

◆ DMCreate_MoFEM()

PetscErrorCode MoFEM::DMCreate_MoFEM ( DM dm)

#include <src/petsc/DMMoFEM.hpp>

Create dm data structure with MoFEM data structure.

Definition at line 71 of file DMMoFEM.cpp.

71 {
72 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
74 dm->data = new DMCtxImpl();
77}
PetscErrorCode DMSetOperators_MoFEM(DM dm)
Set operators for MoFEM dm.
Definition DMMoFEM.cpp:49

◆ DMCreateFieldIS_MoFEM()

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

#include <src/petsc/DMMoFEM.hpp>

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 1461 of file DMMoFEM.cpp.

1462 {
1463 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1465
1466 if (numFields) {
1467 *numFields = 0;
1468 }
1469 if (fieldNames) {
1470 *fieldNames = NULL;
1471 }
1472 if (fields) {
1473 *fields = NULL;
1474 }
1475
1476 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1477 auto fields_ptr = dm_field->mField_ptr->get_fields();
1478 Field_multiIndex::iterator fit, hi_fit;
1479 fit = fields_ptr->begin();
1480 hi_fit = fields_ptr->end();
1481 *numFields = std::distance(fit, hi_fit);
1482
1483 if (fieldNames) {
1484 CHKERR PetscMalloc1(*numFields, fieldNames);
1485 }
1486 if (fields) {
1487 CHKERR PetscMalloc1(*numFields, fields);
1488 }
1489
1490 for (int f = 0; fit != hi_fit; fit++, f++) {
1491 if (fieldNames) {
1492 CHKERR PetscStrallocpy(fit->get()->getName().c_str(),
1493 (char **)&(*fieldNames)[f]);
1494 }
1495 if (fields) {
1496 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1497 ->isCreateProblemFieldAndRank(
1498 dm_field->problemPtr->getName(), ROW, fit->get()->getName(), 0,
1499 fit->get()->getNbOfCoeffs(), &(*fields)[f]);
1500 }
1501 }
1502
1504}
@ ROW

◆ DMCreateGlobalVector_MoFEM() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetCreateGlobalVector.

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

Definition at line 1167 of file DMMoFEM.cpp.

1167 {
1168 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1170 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1171 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1172 dm_field->problemName, COL, g_ptr);
1173 CHKERR VecSetDM(g_ptr, dm);
1175}
@ COL

◆ DMCreateGlobalVector_MoFEM() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetCreateGlobalVector.

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

Definition at line 1157 of file DMMoFEM.cpp.

1157 {
1158 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1160 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1161 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1162 dm_field->problemName, COL, g);
1163 CHKERR VecSetDM(*g, dm);
1165}
constexpr double g

◆ DMCreateLocalVector_MoFEM()

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetCreateLocalVector.

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

Definition at line 1177 of file DMMoFEM.cpp.

1177 {
1178 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1180 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1181 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateSeq(
1182 dm_field->problemName, COL, l);
1183 CHKERR VecSetDM(*l, dm);
1185}
FTensor::Index< 'l', 3 > l

◆ DMCreateMatrix_MGViaApproxOrders()

MoFEMErrorCode MoFEM::DMCreateMatrix_MGViaApproxOrders ( DM dm,
Mat * M )

#include <src/petsc/impl/PCMGSetUpViaApproxOrders.cpp>

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 349 of file PCMGSetUpViaApproxOrders.cpp.

349 {
350
351 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
353 GET_DM_FIELD(dm);
354
355 int leveldown = dm->leveldown;
356
357 if (dm_field->kspOperators.empty()) {
359 } else {
360 MPI_Comm comm;
361 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
362 if (dm_field->kspOperators.empty()) {
363 SETERRQ(comm, MOFEM_DATA_INCONSISTENCY,
364 "data inconsistency, operator can not be set");
365 }
366 if (static_cast<int>(dm_field->kspOperators.size()) < leveldown) {
367 SETERRQ(comm, MOFEM_DATA_INCONSISTENCY,
368 "data inconsistency, no IS for that level");
369 }
370 *M = dm_field->kspOperators[dm_field->kspOperators.size() - 1 - leveldown];
371 CHKERR PetscObjectReference((PetscObject)*M);
372 CHKERR MatSetDM(*M, dm);
373 }
374
375#if PETSC_VERSION_GE(3, 17, 0)
376 PetscInfo(dm, "Create Matrix DMMGViaApproxOrders leveldown = %d\n",
377 leveldown);
378#else
379 PetscInfo1(dm, "Create Matrix DMMGViaApproxOrders leveldown = %d\n",
380 leveldown);
381#endif
382
384}
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
FTensor::Index< 'M', 3 > M

◆ DMCreateMatrix_MoFEM() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetCreateMatrix

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

Examples
eigen_elastic.cpp.

Definition at line 1187 of file DMMoFEM.cpp.

1187 {
1188 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1190 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1191
1192 if (strcmp(dm->mattype, MATSHELL) == 0) {
1193
1194 if (dm_field->blocMatDataPtr) {
1196 CHKERR MatSetDM(*M, dm);
1198 } else {
1199 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1200 "Matrix shell data not set, or matrix type not implemented");
1201 }
1202
1203 } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1204 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1205 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1206 M);
1207 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1208 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1209 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1210 M);
1211 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1212 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1213 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1214 dm_field->problemName, M);
1215 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1216 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1217 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1218 dm_field->problemName, M);
1219 } else {
1220 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1221 "Matrix type not implemented");
1222 }
1223 CHKERR MatSetDM(*M, dm);
1225}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ MOFEM_NOT_IMPLEMENTED
Definition definitions.h:32
MoFEMErrorCode DMMoFEMCreateBlockMat(DM dm, Mat *mat)
Create block matrix.
Definition DMMoFEM.cpp:1543

◆ DMCreateMatrix_MoFEM() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetCreateMatrix

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

Definition at line 1227 of file DMMoFEM.cpp.

1227 {
1228 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1230 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1231
1232 if (strcmp(dm->mattype, MATSHELL) == 0) {
1233 if (dm_field->blocMatDataPtr) {
1234 Mat mat_raw;
1235 CHKERR DMMoFEMCreateBlockMat(dm, &mat_raw);
1236 M = SmartPetscObj<Mat>(mat_raw);
1238 } else {
1239 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1240 "Matrix shell data not set, or matrix type not implemented");
1241 }
1242 } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1243 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1244 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1245 M);
1246 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1247 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1248 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1249 M);
1250 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1251 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1252 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1253 dm_field->problemName, M);
1254 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1255 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1256 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1257 dm_field->problemName, M);
1258 } else {
1259 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1260 "Matrix type not implemented");
1261 }
1262 CHKERR MatSetDM(M, dm);
1264}

◆ DMDestroy_MoFEM()

PetscErrorCode MoFEM::DMDestroy_MoFEM ( DM dm)

#include <src/petsc/DMMoFEM.hpp>

Destroys dm with MoFEM data structure.

destroy the MoFEM structure

Definition at line 79 of file DMMoFEM.cpp.

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

◆ DMGlobalToLocalBegin_MoFEM()

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetGlobalToLocal

the routine that begins the global to local scatter

Definition at line 1391 of file DMMoFEM.cpp.

1392 {
1393 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1395 CHKERR VecGhostUpdateBegin(g, INSERT_VALUES, SCATTER_FORWARD);
1397}

◆ DMGlobalToLocalEnd_MoFEM()

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetGlobalToLocal

the routine that begins the global to local scatter

Definition at line 1399 of file DMMoFEM.cpp.

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

◆ DMLocalToGlobalBegin_MoFEM()

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetLocalToGlobal

the routine that begins the local to global scatter

DMShellSetLocalToGlobal

the routine that ends the local to global scatter

Definition at line 1427 of file DMMoFEM.cpp.

1428 {
1429
1430 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1432
1433 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1434 int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1435 int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1436
1437 double *array_loc, *array_glob;
1438 CHKERR VecGetArray(l, &array_loc);
1439 CHKERR VecGetArray(g, &array_glob);
1440 switch (mode) {
1441 case INSERT_VALUES:
1442 cblas_dcopy(nb_dofs + nb_ghost, array_loc, 1, array_glob, 1);
1443 break;
1444 case ADD_VALUES:
1445 cblas_daxpy(nb_dofs + nb_ghost, 1, array_loc, 1, array_glob, 1);
1446 break;
1447 default:
1448 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1449 }
1450 CHKERR VecRestoreArray(l, &array_loc);
1451 CHKERR VecRestoreArray(g, &array_glob);
1452
1454}

◆ DMLocalToGlobalEnd_MoFEM()

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

#include <src/petsc/DMMoFEM.hpp>

DMShellSetLocalToGlobal

the routine that ends the local to global scatter

Definition at line 1456 of file DMMoFEM.cpp.

1456 {
1459}

◆ DMMGViaApproxOrdersClearCoarseningIS()

MoFEMErrorCode MoFEM::DMMGViaApproxOrdersClearCoarseningIS ( DM )

#include <src/petsc/impl/PCMGSetUpViaApproxOrders.cpp>

Clear approximation orders.

Parameters
DMdm
Returns
Error code

Definition at line 293 of file PCMGSetUpViaApproxOrders.cpp.

293 {
294 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
296 GET_DM_FIELD(dm);
297 CHKERR dm_field->destroyCoarseningIS();
298 PetscInfo(dm, "Clear DMs data structures\n");
300}

◆ DMMGViaApproxOrdersPopBackCoarseningIS()

MoFEMErrorCode MoFEM::DMMGViaApproxOrdersPopBackCoarseningIS ( DM )

#include <src/petsc/impl/PCMGSetUpViaApproxOrders.cpp>

Pop IS form MG via approximation orders.

Parameters
DMdm
Returns
error code

Definition at line 281 of file PCMGSetUpViaApproxOrders.cpp.

281 {
282 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
284 GET_DM_FIELD(dm);
285 if (dm_field->coarseningIS.back()) {
286 dm_field->coarseningIS.pop_back();
287 }
288 dm_field->kspOperators.pop_back();
289 PetscInfo(dm, "Pop back IS to DMMGViaApproxOrders\n");
291}

◆ DMMGViaApproxOrdersPushBackCoarseningIS()

MoFEMErrorCode MoFEM::DMMGViaApproxOrdersPushBackCoarseningIS ( DM ,
IS is,
Mat A,
bool create_sub_matrix,
bool shell_sub_a )

#include <src/petsc/impl/PCMGSetUpViaApproxOrders.cpp>

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 227 of file PCMGSetUpViaApproxOrders.cpp.

229 {
230 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
232 GET_DM_FIELD(dm);
233 dm_field->coarseningIS.emplace_back(SmartPetscObj<IS>(is, true));
234 dm_field->shellMatrixCtxPtr.push_back(new PCMGSubMatrixCtx(A, is));
235 if (is) {
236 auto is2 = SmartPetscObj<IS>(is, true);
237 if (dm_field->aO) {
238 is2 = isDuplicate(is);
239 CHKERR ISCopy(is, is2);
240 CHKERR AOApplicationToPetscIS(dm_field->aO, is2);
241 }
242 if (create_sub_matrix) {
243 if (shell_sub_a) {
244 int n, N;
245 CHKERR ISGetSize(is, &N);
246 CHKERR ISGetLocalSize(is, &n);
247 MPI_Comm comm;
248 CHKERR PetscObjectGetComm((PetscObject)A, &comm);
249 Mat sub_a_raw;
250 CHKERR MatCreateShell(comm, n, n, N, N,
251 &(dm_field->shellMatrixCtxPtr.back()),
252 &sub_a_raw);
253 CHKERR MatShellSetOperation(sub_a_raw, MATOP_MULT,
254 (void (*)(void))sub_mat_mult);
255 CHKERR MatShellSetOperation(sub_a_raw, MATOP_MULT_ADD,
256 (void (*)(void))sub_mat_mult_add);
257 CHKERR MatShellSetOperation(sub_a_raw, MATOP_SOR,
258 (void (*)(void))sub_mat_sor);
259 dm_field->kspOperators.emplace_back(
260 SmartPetscObj<Mat>(sub_a_raw, false));
261 } else {
262 Mat sub_a_raw;
263#if PETSC_VERSION_GE(3, 8, 0)
264 CHKERR MatCreateSubMatrix(A, is2, is2, MAT_INITIAL_MATRIX, &sub_a_raw);
265#else
266 CHKERR MatGetSubMatrix(A, is2, is2, MAT_INITIAL_MATRIX, &sub_a_raw);
267#endif
268 dm_field->kspOperators.emplace_back(
269 SmartPetscObj<Mat>(sub_a_raw, false));
270 }
271 } else {
272 dm_field->kspOperators.emplace_back(SmartPetscObj<Mat>(A, true));
273 }
274 } else {
275 SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
276 }
277 PetscInfo(dm, "Push back IS to DMMGViaApproxOrders\n");
279}
const double n
refractive index of diffusive medium
auto isDuplicate(IS is)
const int N
Definition speed_test.cpp:3

◆ DMMoFEMAddColCompositeProblem()

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

#include <src/petsc/DMMoFEM.hpp>

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 382 of file DMMoFEM.cpp.

382 {
383 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
385 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
386 if (!dm->data) {
387 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
388 "data structure for MoFEM not yet created");
389 }
390 if (!dm_field->isCompDM) {
391 dm_field->isCompDM = PETSC_TRUE;
392 }
393 if (dm_field->isSquareMatrix) {
394 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
395 "No need to add problem on column when problem block structurally "
396 "symmetric");
397 }
398 dm_field->colCompPrb.push_back(prb_name);
400}
@ MOFEM_INVALID_DATA
Definition definitions.h:36

◆ DMMoFEMAddElement() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

add element to dm

Note
add_file is a collective, should be executed on all processors. Otherwise could lead to deadlock.
Examples
free_surface.cpp, level_set.cpp, mofem/tutorials/vec-7/adjoint.cpp, navier_stokes.cpp, and photon_diffusion.cpp.

Definition at line 488 of file DMMoFEM.cpp.

488 {
489 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
491 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
492 CHKERR dm_field->mField_ptr->modify_problem_add_finite_element(
493 dm_field->problemName, fe_name);
495}

◆ DMMoFEMAddElement() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

add element to dm

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

Definition at line 497 of file DMMoFEM.cpp.

497 {
499 for (auto fe : fe_name) {
501 }
503}
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:488

◆ DMMoFEMAddRowCompositeProblem()

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

#include <src/petsc/DMMoFEM.hpp>

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 364 of file DMMoFEM.cpp.

364 {
365 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
367 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
368 if (!dm->data) {
369 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
370 "data structure for MoFEM not yet created");
371 }
372 if (!dm_field->isCompDM) {
373 dm_field->isCompDM = PETSC_TRUE;
374 }
375 dm_field->rowCompPrb.push_back(prb_name);
376 if (dm_field->isSquareMatrix) {
377 dm_field->colCompPrb.push_back(prb_name);
378 }
380}

◆ DMMoFEMAddSubFieldCol()

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

#include <src/petsc/DMMoFEM.hpp>

Add field to sub dm problem on columns

Examples
free_surface.cpp, and mofem/tutorials/vec-7/adjoint.cpp.

Definition at line 280 of file DMMoFEM.cpp.

280 {
281 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
283 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
284 if (!dm->data) {
285 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
286 "data structure for MoFEM not yet created");
287 }
288 if (!dm_field->isSubDM) {
289 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
290 }
291 dm_field->colSubFields.push_back(field_name);
292 dm_field->mapTypeCol.erase(field_name);
294}
constexpr auto field_name

◆ DMMoFEMAddSubFieldRow() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

Add field to sub dm problem on rows

Examples
free_surface.cpp, level_set.cpp, and mofem/tutorials/vec-7/adjoint.cpp.

Definition at line 238 of file DMMoFEM.cpp.

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

◆ DMMoFEMAddSubFieldRow() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

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 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(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->rowSubFields.push_back(field_name);
271 dm_field->mapTypeRow[field_name] = r_ptr;
273}

◆ DMMoFEMCreateBlockMat() [1/2]

MoFEMErrorCode MoFEM::DMMoFEMCreateBlockMat ( DM dm,
Mat * mat )

#include <src/petsc/DMMoFEM.hpp>

Create block matrix.

Parameters
dm
mat
Returns
MoFEMErrorCode

Definition at line 1543 of file DMMoFEM.cpp.

1543 {
1544 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1546 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1547 auto mat_data = createBlockMat(dm, dm_field->blocMatDataPtr);
1548 *mat = mat_data.first;
1549 CHKERR PetscObjectReference((PetscObject)(*mat));
1551}
SchurShellMatData createBlockMat(DM dm, boost::shared_ptr< BlockStructure > data)
Create a Schur Mat object.
Definition Schur.cpp:1452

◆ DMMoFEMCreateBlockMat() [2/2]

MoFEMErrorCode MoFEM::DMMoFEMCreateBlockMat ( DM dm,
SmartPetscObj< Mat > & mat )

#include <src/petsc/DMMoFEM.hpp>

Create block matrix.

Parameters
dm
matsmart pointer
Returns
MoFEMErrorCode

◆ 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() )

#include <src/petsc/DMMoFEM.hpp>

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.
Examples
free_surface.cpp, mofem/tutorials/vec-7/adjoint.cpp, and navier_stokes.cpp.

Definition at line 114 of file DMMoFEM.cpp.

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

#include <src/petsc/DMMoFEM.hpp>

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

Examples
free_surface.cpp, level_set.cpp, and mofem/tutorials/vec-7/adjoint.cpp.

Definition at line 215 of file DMMoFEM.cpp.

215 {
217
218 if (!dm->data) {
219 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
220 "data structure for MoFEM not yet created");
221 }
222 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
223
224 CHKERR DMMoFEMCreateMoFEM(subdm, dm_field->mField_ptr, problem_name,
225 dm_field->problemPtr->getBitRefLevel(),
226 dm_field->problemPtr->getBitRefLevelMask());
227
228 DMCtxImpl *subdm_field = (DMCtxImpl *)subdm->data;
229 subdm_field->isSubDM = PETSC_TRUE;
230 subdm_field->problemMainOfSubPtr = dm_field->problemPtr;
231 subdm_field->isPartitioned = dm_field->isPartitioned;
232 subdm_field->isSquareMatrix = PETSC_FALSE;
233 subdm->ops->setup = DMSubDMSetUp_MoFEM;
234
236}
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:114
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition DMMoFEM.cpp:1344

◆ DMMoFEMGetFieldIS()

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

#include <src/petsc/DMMoFEM.hpp>

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.
PetscErrorCode DMMoFEMGetFieldIS(DM dm, RowColData rc, const char field_name[], IS *is)
get field is in the problem
Definition DMMoFEM.cpp:1506
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr

Definition at line 1506 of file DMMoFEM.cpp.

1507 {
1508 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1510 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1511 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1512 ->isCreateProblemFieldAndRank(dm_field->problemPtr->getName(), ROW,
1513 field_name, 0, 1000, is);
1515}

◆ DMMoFEMGetIsCompDM()

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

#include <src/petsc/DMMoFEM.hpp>

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 402 of file DMMoFEM.cpp.

402 {
403 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
405 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
406 *is_comp_dm = dm_field->isCompDM;
408}

◆ DMMoFEMGetIsPartitioned()

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

#include <src/petsc/DMMoFEM.hpp>

get if read mesh is partitioned

Definition at line 1124 of file DMMoFEM.cpp.

1124 {
1125 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1127 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1128 *is_partitioned = dm_field->isPartitioned;
1130}

◆ DMMoFEMGetIsSubDM()

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

#include <src/petsc/DMMoFEM.hpp>

Return true if this DM is sub problem

Parameters
dmthe DM object
is_subproblemtrue if subproblem
Returns
error code

Definition at line 322 of file DMMoFEM.cpp.

322 {
323 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
325 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
326 *is_sub_dm = dm_field->isSubDM;
328}

◆ DMMoFEMGetKspCtx() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::KspCtx data structure

Definition at line 1067 of file DMMoFEM.cpp.

1067 {
1068 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1070 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1071 const_cast<boost::shared_ptr<MoFEM::KspCtx> &>(ksp_ctx) = dm_field->kspCtx;
1073}

◆ DMMoFEMGetKspCtx() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::KspCtx data structure

Definition at line 1058 of file DMMoFEM.cpp.

1058 {
1059 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1061 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1062 *ksp_ctx = dm_field->kspCtx.get();
1064}

◆ DMMoFEMGetProblemFiniteElementLayout()

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

#include <src/petsc/DMMoFEM.hpp>

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 467 of file DMMoFEM.cpp.

468 {
469 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
471 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
472
473 MPI_Comm comm;
474 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
475 CHKERR dm_field->problemPtr->getNumberOfElementsByNameAndPart(comm, fe_name,
476 layout);
478}

◆ DMMoFEMGetProblemPtr()

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

#include <src/petsc/DMMoFEM.hpp>

Get pointer to problem data structure.

Examples
poisson_2d_dis_galerkin.cpp.

Definition at line 422 of file DMMoFEM.cpp.

422 {
423 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
425 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
426 if (!dm->data) {
427 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
428 "data structure for MoFEM not yet created");
429 }
430 *problem_ptr = dm_field->problemPtr;
432}

◆ DMMoFEMGetSnesCtx() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::SnesCtx data structure

Definition at line 1093 of file DMMoFEM.cpp.

1093 {
1094 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1096 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1097 const_cast<boost::shared_ptr<MoFEM::SnesCtx> &>(snes_ctx) = dm_field->snesCtx;
1099}

◆ DMMoFEMGetSnesCtx() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::SnesCtx data structure

Examples
navier_stokes.cpp.

Definition at line 1084 of file DMMoFEM.cpp.

1084 {
1085 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1087 DMCtxImpl *dm_field = (DMCtxImpl *)dm->data;
1088 *snes_ctx = dm_field->snesCtx.get();
1090}

◆ DMMoFEMGetSquareProblem()

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

#include <src/petsc/DMMoFEM.hpp>

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 480 of file DMMoFEM.cpp.

480 {
481 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
483 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
484 *square_problem = dm_field->isSquareMatrix;
486}

◆ DMMoFEMGetTsCtx() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::TsCtx data structure

Definition at line 1140 of file DMMoFEM.cpp.

1141 {
1142 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1144 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1145 const_cast<boost::shared_ptr<MoFEM::TsCtx> &>(ts_ctx) = dm_field->tsCtx;
1147}
MoFEM::TsCtx * ts_ctx

◆ DMMoFEMGetTsCtx() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::TsCtx data structure

Definition at line 1132 of file DMMoFEM.cpp.

1132 {
1133 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1135 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1136 *ts_ctx = dm_field->tsCtx.get();
1138}

◆ DMMoFEMKSPSetComputeOperators() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

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
Examples
level_set.cpp.

Definition at line 668 of file DMMoFEM.cpp.

671 {
672 return DMMoFEMKSPSetComputeOperators<const char *, MoFEM::FEMethod *,
675 dm, fe_name, method, pre_only, post_only);
676}
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:668
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 )

#include <src/petsc/DMMoFEM.hpp>

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 679 of file DMMoFEM.cpp.

682 {
683 return DMMoFEMKSPSetComputeOperators<const std::string,
684 boost::shared_ptr<MoFEM::FEMethod>>(
685 dm, fe_name, method, pre_only, post_only);
686}

◆ DMMoFEMKSPSetComputeRHS() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

Set compute operator for KSP solver via sub-matrix and IS.

Parameters
dmDM
Returns
error code

set KSP right hand side evaluation function

Examples
level_set.cpp.

Definition at line 627 of file DMMoFEM.cpp.

630 {
631 return DMMoFEMKSPSetComputeRHS<const char *, MoFEM::FEMethod *,
633 dm, fe_name, method, pre_only, post_only);
634}
PetscErrorCode DMMoFEMKSPSetComputeRHS(DM dm, const char fe_name[], MoFEM::FEMethod *method, MoFEM::BasicMethod *pre_only, MoFEM::BasicMethod *post_only)
Set compute operator for KSP solver via sub-matrix and IS.
Definition DMMoFEM.cpp:627

◆ 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 )

#include <src/petsc/DMMoFEM.hpp>

set KSP right hand side evaluation function

Definition at line 637 of file DMMoFEM.cpp.

640 {
641 return DMMoFEMKSPSetComputeRHS<const std::string,
642 boost::shared_ptr<MoFEM::FEMethod>,
643 boost::shared_ptr<MoFEM::BasicMethod>,
644 boost::shared_ptr<MoFEM::BasicMethod>>(
645 dm, fe_name, method, pre_only, post_only);
646}

◆ DMMoFEMResolveSharedFiniteElements()

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

#include <src/petsc/DMMoFEM.hpp>

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.

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
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name)
Resolve shared entities.
Definition DMMoFEM.cpp:458

Definition at line 458 of file DMMoFEM.cpp.

458 {
459 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
461 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
462 CHKERR dm_field->mField_ptr->getInterface<CommInterface>()
463 ->resolveSharedFiniteElements(dm_field->problemPtr, fe_name);
465}

◆ DMMoFEMSetIsPartitioned()

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

#include <src/petsc/DMMoFEM.hpp>

sets if read mesh is partitioned

get if read mesh is partitioned

Examples
mofem/tutorials/vec-7/adjoint.cpp, and navier_stokes.cpp.

Definition at line 1113 of file DMMoFEM.cpp.

1113 {
1114 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1116 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1117 dm_field->isPartitioned = is_partitioned;
1119}

◆ DMMoFEMSetKspCtx()

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

#include <src/petsc/DMMoFEM.hpp>

set MoFEM::KspCtx data structure

Definition at line 1075 of file DMMoFEM.cpp.

1076 {
1077 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1079 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1080 dm_field->kspCtx = ksp_ctx;
1082}

◆ DMMoFEMSetSnesCtx()

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

#include <src/petsc/DMMoFEM.hpp>

Set MoFEM::SnesCtx data structure.

Definition at line 1101 of file DMMoFEM.cpp.

1102 {
1103 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1105 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1106 dm_field->snesCtx = snes_ctx;
1108}

◆ DMMoFEMSetSquareProblem()

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

#include <src/petsc/DMMoFEM.hpp>

set squared problem

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

Examples
free_surface.cpp, level_set.cpp, and mofem/tutorials/vec-7/adjoint.cpp.

Definition at line 450 of file DMMoFEM.cpp.

450 {
451 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
453 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
454 dm_field->isSquareMatrix = square_problem;
456}

◆ DMMoFEMSetTsCtx()

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

#include <src/petsc/DMMoFEM.hpp>

Set MoFEM::TsCtx data structure.

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

Definition at line 1149 of file DMMoFEM.cpp.

1149 {
1150 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1152 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1153 dm_field->tsCtx = ts_ctx;
1155}

◆ DMMoFEMSNESSetFunction() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

set SNES residual evaluation function

Examples
navier_stokes.cpp.

Definition at line 708 of file DMMoFEM.cpp.

711 {
712 return DMMoFEMSNESSetFunction<const char *, MoFEM::FEMethod *,
714 dm, fe_name, method, pre_only, post_only);
715}
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:708

◆ 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 )

#include <src/petsc/DMMoFEM.hpp>

set SNES residual evaluation function

Definition at line 718 of file DMMoFEM.cpp.

721 {
722 return DMMoFEMSNESSetFunction<const std::string,
723 boost::shared_ptr<MoFEM::FEMethod>,
724 boost::shared_ptr<MoFEM::BasicMethod>,
725 boost::shared_ptr<MoFEM::BasicMethod>>(
726 dm, fe_name, method, pre_only, post_only);
727}

◆ DMMoFEMSNESSetJacobian() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

set SNES Jacobian evaluation function

Examples
navier_stokes.cpp.

Definition at line 749 of file DMMoFEM.cpp.

752 {
753 return DMMoFEMSNESSetJacobian<const char *, MoFEM::FEMethod *,
755 dm, fe_name, method, pre_only, post_only);
756}
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:749

◆ 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 )

#include <src/petsc/DMMoFEM.hpp>

set SNES Jacobian evaluation function

Definition at line 759 of file DMMoFEM.cpp.

762 {
763 return DMMoFEMSNESSetJacobian<const std::string,
764 boost::shared_ptr<MoFEM::FEMethod>,
765 boost::shared_ptr<MoFEM::BasicMethod>,
766 boost::shared_ptr<MoFEM::BasicMethod>>(
767 dm, fe_name, method, pre_only, post_only);
768}

◆ DMMoFEMTSSetI2Function() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

set TS implicit function evaluation function

Definition at line 954 of file DMMoFEM.cpp.

957 {
958 return DMMoFEMTSSetI2Function<const char *, MoFEM::FEMethod *,
960 dm, fe_name, method, pre_only, post_only);
962}
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:965

◆ 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 )

#include <src/petsc/DMMoFEM.hpp>

set TS implicit function evaluation function

Definition at line 965 of file DMMoFEM.cpp.

968 {
969 return DMMoFEMTSSetI2Function<const std::string,
970 boost::shared_ptr<MoFEM::FEMethod>,
971 boost::shared_ptr<MoFEM::BasicMethod>,
972 boost::shared_ptr<MoFEM::BasicMethod>>(
973 dm, fe_name, method, pre_only, post_only);
975}

◆ DMMoFEMTSSetI2Jacobian() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

set TS Jacobian evaluation function

Definition at line 997 of file DMMoFEM.cpp.

1000 {
1001 return DMMoFEMTSSetI2Jacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
1002 MoFEM::BasicMethod *>(dm, fe_name, method,
1003 pre_only, post_only);
1004}
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:1007

◆ 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 )

#include <src/petsc/DMMoFEM.hpp>

set TS Jacobian evaluation function

Definition at line 1007 of file DMMoFEM.cpp.

1010 {
1011 return DMMoFEMTSSetI2Jacobian<const std::string,
1012 boost::shared_ptr<MoFEM::FEMethod>,
1013 boost::shared_ptr<MoFEM::BasicMethod>,
1014 boost::shared_ptr<MoFEM::BasicMethod>>(
1015 dm, fe_name, method, pre_only, post_only);
1016}

◆ DMMoFEMTSSetIFunction() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

set TS implicit function evaluation function

Definition at line 790 of file DMMoFEM.cpp.

793 {
794 return DMMoFEMTSSetIFunction<const char *, MoFEM::FEMethod *,
796 dm, fe_name, method, pre_only, post_only);
798}
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:790

◆ 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 )

#include <src/petsc/DMMoFEM.hpp>

set TS implicit function evaluation function

Definition at line 801 of file DMMoFEM.cpp.

804 {
805 return DMMoFEMTSSetIFunction<const std::string,
806 boost::shared_ptr<MoFEM::FEMethod>,
807 boost::shared_ptr<MoFEM::BasicMethod>,
808 boost::shared_ptr<MoFEM::BasicMethod>>(
809 dm, fe_name, method, pre_only, post_only);
811}

◆ DMMoFEMTSSetIJacobian() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

set TS Jacobian evaluation function

Definition at line 833 of file DMMoFEM.cpp.

836 {
837 return DMMoFEMTSSetIJacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
838 MoFEM::BasicMethod *>(dm, fe_name, method,
839 pre_only, post_only);
840}
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:843

◆ 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 )

#include <src/petsc/DMMoFEM.hpp>

set TS Jacobian evaluation function

Definition at line 843 of file DMMoFEM.cpp.

846 {
847 return DMMoFEMTSSetIJacobian<const std::string,
848 boost::shared_ptr<MoFEM::FEMethod>,
849 boost::shared_ptr<MoFEM::BasicMethod>,
850 boost::shared_ptr<MoFEM::BasicMethod>>(
851 dm, fe_name, method, pre_only, post_only);
852}

◆ DMMoFEMUnSetElement()

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

#include <src/petsc/DMMoFEM.hpp>

unset element from dm

Definition at line 505 of file DMMoFEM.cpp.

505 {
506 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
508 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
509 CHKERR dm_field->mField_ptr->modify_problem_unset_finite_element(
510 dm_field->problemName, fe_name);
512}

◆ DMoFEMGetInterfacePtr()

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

#include <src/petsc/DMMoFEM.hpp>

Get pointer to MoFEM::Interface.

Parameters
dmDistributed mesh manager
m_field_ptrPointer to pointer of field interface
Returns
Error code
Examples
adolc_plasticity.cpp, and free_surface.cpp.

Definition at line 410 of file DMMoFEM.cpp.

410 {
411 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
413 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
414 if (!dm->data) {
415 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
416 "data structure for MoFEM not yet created");
417 }
418 *m_field_ptr = dm_field->mField_ptr;
420}

◆ DMoFEMLoopDofs()

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

#include <src/petsc/DMMoFEM.hpp>

execute method for dofs on field in problem

Definition at line 595 of file DMMoFEM.cpp.

596 {
597 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
599 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
600 ierr =
601 dm_field->mField_ptr->loop_dofs(dm_field->problemPtr, field_name, COL,
602 *method, dm_field->rAnk, dm_field->rAnk);
603 CHKERRG(ierr);
605}

◆ DMoFEMLoopFiniteElements() [1/2]

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

#include <src/petsc/DMMoFEM.hpp>

Executes FEMethod for finite elements in DM.

Parameters
dmMoFEM discrete manager
fe_namename of element
methodpointer to MOFEM::FEMethod
Returns
Error code
Examples
adolc_plasticity.cpp, dynamic_first_order_con_law.cpp, free_surface.cpp, heat_equation.cpp, level_set.cpp, mofem/tutorials/vec-7/adjoint.cpp, navier_stokes.cpp, photon_diffusion.cpp, plastic.cpp, poisson_2d_homogeneous.cpp, shallow_wave.cpp, and wave_equation.cpp.

Definition at line 576 of file DMMoFEM.cpp.

578 {
579 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
581 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
583 dm, fe_name, method, dm_field->rAnk, dm_field->rAnk, cache_ptr);
584 CHKERRG(ierr);
586}
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:557

◆ DMoFEMLoopFiniteElements() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

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 589 of file DMMoFEM.cpp.

591 {
592 return DMoFEMLoopFiniteElements(dm, fe_name.c_str(), method.get(), cache_ptr);
593}
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:576

◆ 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() )

#include <src/petsc/DMMoFEM.hpp>

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 557 of file DMMoFEM.cpp.

559 {
561 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
562 ierr = dm_field->mField_ptr->loop_finite_elements(
563 dm_field->problemPtr, fe_name, *method, low_rank, up_rank, nullptr,
564 MF_EXIST, cache_ptr);
565 CHKERRG(ierr);
567}
@ MF_EXIST

◆ 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() )

#include <src/petsc/DMMoFEM.hpp>

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 569 of file DMMoFEM.cpp.

571 {
572 return DMoFEMLoopFiniteElementsUpAndLowRank(dm, fe_name.c_str(), method.get(),
573 low_rank, up_rank, cache_ptr);
574}

◆ DMoFEMMeshToGlobalVector()

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

#include <src/petsc/DMMoFEM.hpp>

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

Examples
navier_stokes.cpp.

Definition at line 525 of file DMMoFEM.cpp.

526 {
527 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
529 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
530 ierr = dm_field->mField_ptr->getInterface<VecManager>()->setGlobalGhostVector(
531 dm_field->problemPtr, COL, g, mode, scatter_mode);
532 CHKERRG(ierr);
534}

◆ DMoFEMMeshToLocalVector()

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

#include <src/petsc/DMMoFEM.hpp>

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

Examples
adolc_plasticity.cpp, approx_sphere.cpp, child_and_parent.cpp, dg_projection.cpp, dynamic_first_order_con_law.cpp, free_surface.cpp, hanging_node_approx.cpp, heat_method.cpp, helmholtz.cpp, higher_derivatives.cpp, level_set.cpp, mixed_poisson.cpp, mofem/tutorials/vec-7/adjoint.cpp, phase.cpp, plate.cpp, poisson_2d_dis_galerkin.cpp, poisson_2d_homogeneous.cpp, and shallow_wave.cpp.

Definition at line 514 of file DMMoFEM.cpp.

515 {
516 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
518 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
519 ierr = dm_field->mField_ptr->getInterface<VecManager>()->setLocalGhostVector(
520 dm_field->problemPtr, COL, l, mode, scatter_mode);
521 CHKERRG(ierr);
523}

◆ DMoFEMPostProcessFiniteElements()

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

#include <src/petsc/DMMoFEM.hpp>

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

Examples
free_surface.cpp, and mofem/tutorials/vec-7/adjoint.cpp.

Definition at line 546 of file DMMoFEM.cpp.

546 {
547 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
549 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
550 ierr = dm_field->mField_ptr->problem_basic_method_postProcess(
551 dm_field->problemPtr, *method);
552 CHKERRG(ierr);
554}

◆ DMoFEMPreProcessFiniteElements()

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

#include <src/petsc/DMMoFEM.hpp>

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

Examples
free_surface.cpp, mofem/tutorials/vec-7/adjoint.cpp, and navier_stokes.cpp.

Definition at line 536 of file DMMoFEM.cpp.

536 {
537 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
539 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
540 ierr = dm_field->mField_ptr->problem_basic_method_preProcess(
541 dm_field->problemPtr, *method);
542 CHKERRG(ierr);
544}

◆ DMRegister_MGViaApproxOrders()

MoFEMErrorCode MoFEM::DMRegister_MGViaApproxOrders ( const char sname[])

#include <src/petsc/impl/PCMGSetUpViaApproxOrders.cpp>

Register DM for Multi-Grid via approximation orders.

Parameters
snameproblem/dm registered name
Returns
error code

Definition at line 302 of file PCMGSetUpViaApproxOrders.cpp.

302 {
304 CHKERR DMRegister(sname, DMCreate_MGViaApproxOrders);
306}

◆ DMRegister_MoFEM()

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

#include <src/petsc/DMMoFEM.hpp>

Register MoFEM problem.

Examples
mixed_poisson.cpp, navier_stokes.cpp, and photon_diffusion.cpp.

Definition at line 43 of file DMMoFEM.cpp.

43 {
45 CHKERR DMRegister(sname, DMCreate_MoFEM);
47}

◆ DMSetFromOptions_MoFEM()

PetscErrorCode MoFEM::DMSetFromOptions_MoFEM ( DM dm)

#include <src/petsc/DMMoFEM.hpp>

Set options for MoFEM DM

Definition at line 1275 of file DMMoFEM.cpp.

1275 {
1276#endif
1277
1278 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1280 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1281#if PETSC_VERSION_GE(3, 18, 0)
1282 PetscOptionsHeadBegin(PetscOptionsObject, "DMMoFEM Options");
1283#elif PETSC_VERSION_GE(3, 5, 3)
1284 PetscOptionsHead(PetscOptionsObject, "DMMoFEM Options");
1285#else
1286 PetscOptionsHead("DMMoFEM Options");
1287#endif
1288 ierr = PetscOptionsBool("-dm_is_partitioned",
1289 "set if mesh is partitioned (works which native MOAB "
1290 "file format, i.e. h5m",
1291 "DMSetUp", dm_field->isPartitioned,
1292 &dm_field->isPartitioned, NULL);
1293 CHKERRG(ierr);
1295}

◆ DMSetOperators_MoFEM()

PetscErrorCode MoFEM::DMSetOperators_MoFEM ( DM dm)

#include <src/petsc/DMMoFEM.hpp>

Set operators for MoFEM dm.

Parameters
dm
Returns
error code

Definition at line 49 of file DMMoFEM.cpp.

49 {
50 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
52
53 dm->ops->createglobalvector = DMCreateGlobalVector_MoFEM;
54 dm->ops->createlocalvector = DMCreateLocalVector_MoFEM;
55 dm->ops->creatematrix = DMCreateMatrix_MoFEM;
56 dm->ops->setup = DMSetUp_MoFEM;
57 dm->ops->destroy = DMDestroy_MoFEM;
58 dm->ops->setfromoptions = DMSetFromOptions_MoFEM;
59 dm->ops->globaltolocalbegin = DMGlobalToLocalBegin_MoFEM;
60 dm->ops->globaltolocalend = DMGlobalToLocalEnd_MoFEM;
61 dm->ops->localtoglobalbegin = DMLocalToGlobalBegin_MoFEM;
62 dm->ops->localtoglobalend = DMLocalToGlobalEnd_MoFEM;
63 dm->ops->createfieldis = DMCreateFieldIS_MoFEM;
64
65 // Default matrix type
66 CHKERR DMSetMatType(dm, MATMPIAIJ);
67
69}
PetscErrorCode DMGlobalToLocalBegin_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1391
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1399
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition DMMoFEM.cpp:1177
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
Definition DMMoFEM.cpp:79
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1427
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition DMMoFEM.cpp:1275
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition DMMoFEM.cpp:1461
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition DMMoFEM.cpp:1297
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1456

◆ DMSetUp_MoFEM()

PetscErrorCode MoFEM::DMSetUp_MoFEM ( DM dm)

#include <src/petsc/DMMoFEM.hpp>

sets up the MoFEM structures inside a DM object

Examples
mixed_poisson.cpp.

Definition at line 1297 of file DMMoFEM.cpp.

1297 {
1298 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1299 ProblemsManager *prb_mng_ptr;
1301 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1302 CHKERR dm_field->mField_ptr->getInterface(prb_mng_ptr);
1303
1304 if (dm_field->isCompDM) {
1305 // It is composite probelm
1306 CHKERR prb_mng_ptr->buildComposedProblem(
1307 dm_field->problemName, dm_field->rowCompPrb, dm_field->colCompPrb,
1308 dm_field->isSquareMatrix == PETSC_TRUE, dm_field->verbosity);
1309 } else {
1310 if (dm_field->isPartitioned) {
1311 CHKERR prb_mng_ptr->buildProblemOnDistributedMesh(
1312 dm_field->problemName, dm_field->isSquareMatrix == PETSC_TRUE,
1313 dm_field->verbosity);
1314 } else {
1315 CHKERR prb_mng_ptr->buildProblem(dm_field->problemName,
1316 dm_field->isSquareMatrix == PETSC_TRUE,
1317 dm_field->verbosity);
1318 CHKERR prb_mng_ptr->partitionProblem(dm_field->problemName,
1319 dm_field->verbosity);
1320 }
1321 }
1322
1323 // Partition finite elements
1324 if (dm_field->isPartitioned) {
1325 CHKERR prb_mng_ptr->partitionFiniteElements(
1326 dm_field->problemName, true, 0, dm_field->sIze, dm_field->verbosity);
1327 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1328 dm_field->problemName, dm_field->verbosity);
1329 } else {
1330 // partition finite elemnets
1331 CHKERR prb_mng_ptr->partitionFiniteElements(dm_field->problemName, false,
1332 -1, -1, dm_field->verbosity);
1333 // Get ghost DOFs
1334 CHKERR prb_mng_ptr->partitionGhostDofs(dm_field->problemName,
1335 dm_field->verbosity);
1336 }
1337
1338 // Set flag that problem is build and partitioned
1339 dm_field->isProblemBuild = PETSC_TRUE;
1340
1342}

◆ DMSubDMSetUp_MoFEM()

PetscErrorCode MoFEM::DMSubDMSetUp_MoFEM ( DM subdm)

#include <src/petsc/DMMoFEM.hpp>

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

Examples
level_set.cpp.

Definition at line 1344 of file DMMoFEM.cpp.

1344 {
1345 PetscValidHeaderSpecific(subdm, DM_CLASSID, 1);
1346 ProblemsManager *prb_mng_ptr;
1348
1349 DMCtxImpl *subdm_field = static_cast<DMCtxImpl *>(subdm->data);
1350
1351 // build sub dm problem
1352 CHKERR subdm_field->mField_ptr->getInterface(prb_mng_ptr);
1353
1354 map<std::string, boost::shared_ptr<Range>> *entity_map_row = nullptr;
1355 map<std::string, boost::shared_ptr<Range>> *entity_map_col = nullptr;
1356
1357 if (subdm_field->mapTypeRow.size())
1358 entity_map_row = &subdm_field->mapTypeRow;
1359 if (subdm_field->mapTypeCol.size())
1360 entity_map_col = &subdm_field->mapTypeCol;
1361
1362 CHKERR prb_mng_ptr->buildSubProblem(
1363 subdm_field->problemName, subdm_field->rowSubFields,
1364 subdm_field->colSubFields, subdm_field->problemMainOfSubPtr->getName(),
1365 subdm_field->isSquareMatrix == PETSC_TRUE, entity_map_row, entity_map_col,
1366 subdm_field->verbosity);
1367
1368 // partition problem
1369 subdm_field->isPartitioned = subdm_field->isPartitioned;
1370 if (subdm_field->isPartitioned) {
1371 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, true,
1372 0, subdm_field->sIze,
1373 subdm_field->verbosity);
1374 // set ghost nodes
1375 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1376 subdm_field->problemName, subdm_field->verbosity);
1377 } else {
1378 // partition finite elements
1379 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, false,
1380 -1, -1, subdm_field->verbosity);
1381 // set ghost nodes
1382 CHKERR prb_mng_ptr->partitionGhostDofs(subdm_field->problemName,
1383 subdm_field->verbosity);
1384 }
1385
1386 subdm_field->isProblemBuild = PETSC_TRUE;
1387
1389}