v0.16.3
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  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, RowColData rc=RowColData::COL)
 set local (or ghosted) vector values on mesh for partition only
 
PetscErrorCode MoFEM::DMoFEMMeshToGlobalVector (DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
 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 KSP right hand side evaluation function
 
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, RowColData rc=RowColData::COL)
 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, RowColData rc=RowColData::COL)
 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
mofem/tutorials/adv-0_plasticity/plastic.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 1207 of file DMMoFEM.hpp.

1207 {
1208 SmartPetscObj<Mat> a;
1210 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1211 return a;
1212};
constexpr double a
static PetscErrorCode ierr
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition DMMoFEM.cpp:1217
MPI_Comm getCommFromPetscObject(PetscObject obj)
Get the Comm From Petsc Object object.

◆ createDMVector()

auto MoFEM::createDMVector ( DM  dm,
RowColData  rc = RowColData::COL 
)
inline

#include <src/petsc/DMMoFEM.hpp>

Get smart vector from DM.

Examples
mofem/atom_tests/child_and_parent.cpp, mofem/atom_tests/dg_projection.cpp, mofem/atom_tests/hanging_node_approx.cpp, mofem/atom_tests/higher_derivatives.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-4_dynamic_first_order_con_law/dynamic_first_order_con_law.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/clx-0_acoustics/helmholtz.cpp, mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/mix-0_mixed_poisson/mixed_poisson.cpp, mofem/tutorials/mix-1_light_intensity_equation/phase.cpp, mofem/tutorials/scl-0_least_squares/approximation.cpp, mofem/tutorials/scl-12_electrostatics/electrostatics.cpp, mofem/tutorials/scl-1_poisson_2d_homogeneous/poisson_2d_homogeneous.cpp, mofem/tutorials/scl-8_heat_radiation/radiation.cpp, mofem/tutorials/scl-9_heat_method/heat_method.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-1_eigen_elasticity/eigen_elastic.cpp, mofem/tutorials/vec-3_nonlinear_dynamics/nonlinear_dynamic_elastic.cpp, mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp, mofem/tutorials/vec-4_shallow_wave/shallow_wave.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, mofem/tutorials/vec-6_dg_kirchhoff_plate/plate.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, and mofem/users_modules/adolc-plasticity/adolc_plasticity.cpp.

Definition at line 1250 of file DMMoFEM.hpp.

1250 {
1251 SmartPetscObj<Vec> v;
1253 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1254 return v;
1255};
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition DMMoFEM.cpp:1186
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}
MPI_Comm comm
std::string type
#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.

Parameters
dmDistributed mesh manager to create
Returns
Error code

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

1492 {
1493 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1495
1496 if (numFields) {
1497 *numFields = 0;
1498 }
1499 if (fieldNames) {
1500 *fieldNames = NULL;
1501 }
1502 if (fields) {
1503 *fields = NULL;
1504 }
1505
1506 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1507 auto fields_ptr = dm_field->mField_ptr->get_fields();
1508 Field_multiIndex::iterator fit, hi_fit;
1509 fit = fields_ptr->begin();
1510 hi_fit = fields_ptr->end();
1511 *numFields = std::distance(fit, hi_fit);
1512
1513 if (fieldNames) {
1514 CHKERR PetscMalloc1(*numFields, fieldNames);
1515 }
1516 if (fields) {
1517 CHKERR PetscMalloc1(*numFields, fields);
1518 }
1519
1520 for (int f = 0; fit != hi_fit; fit++, f++) {
1521 if (fieldNames) {
1522 CHKERR PetscStrallocpy(fit->get()->getName().c_str(),
1523 (char **)&(*fieldNames)[f]);
1524 }
1525 if (fields) {
1526 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1527 ->isCreateProblemFieldAndRank(
1528 dm_field->problemPtr->getName(), ROW, fit->get()->getName(), 0,
1529 fit->get()->getNbOfCoeffs(), &(*fields)[f]);
1530 }
1531 }
1532
1534}
@ ROW

◆ DMCreateGlobalVector_MoFEM() [1/2]

PetscErrorCode MoFEM::DMCreateGlobalVector_MoFEM ( DM  dm,
SmartPetscObj< Vec > &  g_ptr,
RowColData  rc = RowColData::COL 
)

#include <src/petsc/DMMoFEM.hpp>

DMShellSetCreateGlobalVector.

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

Definition at line 1196 of file DMMoFEM.cpp.

1197 {
1198 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1200 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1201 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1202 dm_field->problemName, rc, g_ptr);
1203 CHKERR VecSetDM(g_ptr, dm);
1205}

◆ 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

Parameters
dmDistributed mesh manager
gPointer to global vector to create
Returns
Error code

Definition at line 1186 of file DMMoFEM.cpp.

1186 {
1187 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1189 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1190 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1191 dm_field->problemName, COL, g);
1192 CHKERR VecSetDM(*g, dm);
1194}
@ COL
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 1207 of file DMMoFEM.cpp.

1207 {
1208 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1210 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1211 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateSeq(
1212 dm_field->problemName, COL, l);
1213 CHKERR VecSetDM(*l, dm);
1215}
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()) {
364 "data inconsistency, operator can not be set");
365 }
366 if (static_cast<int>(dm_field->kspOperators.size()) < leveldown) {
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

◆ 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
mofem/tutorials/vec-1_eigen_elasticity/eigen_elastic.cpp.

Definition at line 1217 of file DMMoFEM.cpp.

1217 {
1218 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1220 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1221
1222 if (strcmp(dm->mattype, MATSHELL) == 0) {
1223
1224 if (dm_field->blocMatDataPtr) {
1226 CHKERR MatSetDM(*M, dm);
1228 } else {
1229 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1230 "Matrix shell data not set, or matrix type not implemented");
1231 }
1232
1233 } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1234 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1235 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1236 M);
1237 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1238 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1239 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1240 M);
1241 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1242 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1243 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1244 dm_field->problemName, M);
1245 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1246 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1247 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1248 dm_field->problemName, M);
1249 } else {
1250 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1251 "Matrix type not implemented");
1252 }
1253 CHKERR MatSetDM(*M, dm);
1255}
#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:1573

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

1257 {
1258 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1260 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1261
1262 if (strcmp(dm->mattype, MATSHELL) == 0) {
1263 if (dm_field->blocMatDataPtr) {
1264 Mat mat_raw;
1265 CHKERR DMMoFEMCreateBlockMat(dm, &mat_raw);
1266 M = SmartPetscObj<Mat>(mat_raw);
1268 } else {
1269 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1270 "Matrix shell data not set, or matrix type not implemented");
1271 }
1272 } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1273 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1274 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1275 M);
1276 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1277 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1278 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1279 M);
1280 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1281 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1282 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1283 dm_field->problemName, M);
1284 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1285 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1286 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1287 dm_field->problemName, M);
1288 } else {
1289 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1290 "Matrix type not implemented");
1291 }
1292 CHKERR MatSetDM(M, dm);
1294}

◆ DMDestroy_MoFEM()

PetscErrorCode MoFEM::DMDestroy_MoFEM ( DM  dm)

#include <src/petsc/DMMoFEM.hpp>

Destroys dm with MoFEM data structure.

Parameters
dmDistributed mesh manager to destroy
Returns
Error code

destroy the MoFEM structure

Definition at line 105 of file DMMoFEM.cpp.

105 {
106 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
107 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
109
110 MPI_Comm comm;
111 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
112
113 int result;
114 MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
115 if (result == MPI_IDENT)
116 MOFEM_LOG("DMSELF", Sev::noisy)
117 << "MoFEM DM destroy for problem " << dm_field->problemName
118 << " referenceNumber " << dm_field->referenceNumber;
119 else
120 MOFEM_LOG("DMWORLD", Sev::noisy)
121 << "MoFEM DM destroy for problem " << dm_field->problemName
122 << " referenceNumber " << dm_field->referenceNumber;
123
124 if (dm_field->referenceNumber == 0) {
126
127 if (dm_field->destroyProblem) {
128
129 if (dm_field->mField_ptr->check_problem(dm_field->problemName)) {
130 dm_field->mField_ptr->delete_problem(dm_field->problemName);
131 } // else problem has to be deleted by the user
132 }
133
134 delete static_cast<DMCtxImpl *>(dm->data);
135 dm->data = nullptr;
136
137 } else
138 --dm_field->referenceNumber;
139
141}
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MOFEM_LOG(channel, severity)
Log.
PetscErrorCode DMMoFEMClearDMCtx(DM dm)
Clear solver and Schur data owned by a MoFEM DM context.
Definition DMMoFEM.cpp:79

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

1422 {
1423 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1425 CHKERR VecGhostUpdateBegin(g, INSERT_VALUES, SCATTER_FORWARD);
1427}

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

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

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

1458 {
1459
1460 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1462
1463 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1464 int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1465 int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1466
1467 double *array_loc, *array_glob;
1468 CHKERR VecGetArray(l, &array_loc);
1469 CHKERR VecGetArray(g, &array_glob);
1470 switch (mode) {
1471 case INSERT_VALUES:
1472 cblas_dcopy(nb_dofs + nb_ghost, array_loc, 1, array_glob, 1);
1473 break;
1474 case ADD_VALUES:
1475 cblas_daxpy(nb_dofs + nb_ghost, 1, array_loc, 1, array_glob, 1);
1476 break;
1477 default:
1478 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1479 }
1480 CHKERR VecRestoreArray(l, &array_loc);
1481 CHKERR VecRestoreArray(g, &array_glob);
1482
1484}

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

1486 {
1489}

◆ 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)
constexpr AssemblyType A
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 411 of file DMMoFEM.cpp.

411 {
412 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
414 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
415 if (!dm->data) {
416 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
417 "data structure for MoFEM not yet created");
418 }
419 if (!dm_field->isCompDM) {
420 dm_field->isCompDM = PETSC_TRUE;
421 }
422 if (dm_field->isSquareMatrix) {
423 SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
424 "No need to add problem on column when problem block structurally "
425 "symmetric");
426 }
427 dm_field->colCompPrb.push_back(prb_name);
429}
@ 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.
Parameters
dmDistributed mesh manager
fe_nameFinite element name
Returns
Error code
Examples
mofem/atom_tests/test_broken_space.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/scl-12_electrostatics/electrostatics.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 517 of file DMMoFEM.cpp.

517 {
518 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
520 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
521 CHKERR dm_field->mField_ptr->modify_problem_add_finite_element(
522 dm_field->problemName, fe_name);
524}

◆ 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.
Parameters
dmDistributed mesh manager
fe_nameVector of finite element names
Returns
Error code

Definition at line 526 of file DMMoFEM.cpp.

526 {
528 for (auto fe : fe_name) {
530 }
532}
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:517

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

393 {
394 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
396 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
397 if (!dm->data) {
398 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
399 "data structure for MoFEM not yet created");
400 }
401 if (!dm_field->isCompDM) {
402 dm_field->isCompDM = PETSC_TRUE;
403 }
404 dm_field->rowCompPrb.push_back(prb_name);
405 if (dm_field->isSquareMatrix) {
406 dm_field->colCompPrb.push_back(prb_name);
407 }
409}

◆ DMMoFEMAddSubFieldCol()

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

#include <src/petsc/DMMoFEM.hpp>

Add field to sub dm problem on columns

Examples
mofem/atom_tests/test_broken_space.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 309 of file DMMoFEM.cpp.

309 {
310 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
312 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
313 if (!dm->data) {
314 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
315 "data structure for MoFEM not yet created");
316 }
317 if (!dm_field->isSubDM) {
318 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
319 }
320 dm_field->colSubFields.push_back(field_name);
321 dm_field->mapTypeCol.erase(field_name);
323}
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

Parameters
dmDistributed mesh manager
field_nameName of field to add to rows
Returns
Error code
Examples
mofem/atom_tests/test_broken_space.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 267 of file DMMoFEM.cpp.

267 {
268 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
270 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
271 if (!dm->data) {
272 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
273 "data structure for MoFEM not yet created");
274 }
275 if (!dm_field->isSubDM) {
276 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
277 }
278 dm_field->rowSubFields.push_back(field_name);
279 dm_field->mapTypeRow.erase(field_name);
281}

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

288 {
289 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
291 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
292 if (!dm->data) {
293 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
294 "data structure for MoFEM not yet created");
295 }
296 if (!dm_field->isSubDM) {
297 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "this is not sub-dm");
298 }
299 dm_field->rowSubFields.push_back(field_name);
300 dm_field->mapTypeRow[field_name] = r_ptr;
302}

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

1573 {
1574 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1576 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1577 auto mat_data = createBlockMat(dm, dm_field->blocMatDataPtr);
1578 *mat = mat_data.first;
1579 CHKERR PetscObjectReference((PetscObject)(*mat));
1581}
SchurShellMatData createBlockMat(DM dm, boost::shared_ptr< BlockStructure > data)
Create a Schur Mat object.
Definition Schur.cpp:3072

◆ 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
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 143 of file DMMoFEM.cpp.

146 {
148
149 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
150 if (!dm->data) {
151 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
152 "data structure for MoFEM not yet created");
153 }
154 if (!m_field_ptr) {
155 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
156 "DM function not implemented into MoFEM");
157 }
158 dm_field->mField_ptr = m_field_ptr;
159 dm_field->problemName = problem_name;
160 if (!m_field_ptr->check_problem(dm_field->problemName)) {
161 // problem is not defined, declare problem internally set bool to
162 // destroyProblem problem with DM
163 dm_field->destroyProblem = PETSC_TRUE;
164 CHKERR dm_field->mField_ptr->add_problem(dm_field->problemName, MF_EXCL,
165 dm_field->verbosity);
166 } else {
167 dm_field->destroyProblem = PETSC_FALSE;
168 }
169 CHKERR dm_field->mField_ptr->modify_problem_ref_level_add_bit(
170 dm_field->problemName, bit_level);
171 CHKERR dm_field->mField_ptr->modify_problem_mask_ref_level_add_bit(
172 dm_field->problemName, bit_mask);
173 dm_field->kspCtx =
174 boost::shared_ptr<KspCtx>(new KspCtx(*m_field_ptr, problem_name));
175 dm_field->snesCtx =
176 boost::shared_ptr<SnesCtx>(new SnesCtx(*m_field_ptr, problem_name));
177 dm_field->tsCtx =
178 boost::shared_ptr<TsCtx>(new TsCtx(*m_field_ptr, problem_name));
179
180 MPI_Comm comm;
181 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
182 int result = 0;
183 MPI_Comm_compare(comm, m_field_ptr->get_comm(), &result);
184 if (result > MPI_CONGRUENT) {
185 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
186 "MoFEM and DM using different communicators");
187 }
188 MPI_Comm_size(comm, &dm_field->sIze);
189 MPI_Comm_rank(comm, &dm_field->rAnk);
190
191 // problem structure
192 CHKERR dm_field->mField_ptr->get_problem(dm_field->problemName,
193 &dm_field->problemPtr);
194
195 MPI_Comm_compare(comm, PETSC_COMM_SELF, &result);
196 if (result == MPI_IDENT) {
197 MOFEM_LOG("DMSELF", Sev::noisy)
198 << "MoFEM DM created for problem " << dm_field->problemName;
199 MOFEM_LOG("DMSELF", Sev::noisy) << *dm_field->problemPtr;
200 } else {
201 MOFEM_LOG("DMWORLD", Sev::noisy)
202 << "MoFEM DM created for problem " << dm_field->problemName;
203 MOFEM_LOG("DMWORLD", Sev::noisy) << *dm_field->problemPtr;
204 }
205
207}
@ MF_EXCL
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
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.

Parameters
subdmSub distributed mesh manager to create
dmParent distributed mesh manager
problem_nameName of the problem to create sub DM for
Returns
Error code
Examples
mofem/atom_tests/test_broken_space.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 244 of file DMMoFEM.cpp.

244 {
246
247 if (!dm->data) {
248 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
249 "data structure for MoFEM not yet created");
250 }
251 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
252
253 CHKERR DMMoFEMCreateMoFEM(subdm, dm_field->mField_ptr, problem_name,
254 dm_field->problemPtr->getBitRefLevel(),
255 dm_field->problemPtr->getBitRefLevelMask());
256
257 DMCtxImpl *subdm_field = (DMCtxImpl *)subdm->data;
258 subdm_field->isSubDM = PETSC_TRUE;
259 subdm_field->problemMainOfSubPtr = dm_field->problemPtr;
260 subdm_field->isPartitioned = dm_field->isPartitioned;
261 subdm_field->isSquareMatrix = PETSC_FALSE;
262 subdm->ops->setup = DMSubDMSetUp_MoFEM;
263
265}
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:143
PetscErrorCode DMSubDMSetUp_MoFEM(DM subdm)
Definition DMMoFEM.cpp:1374

◆ 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:1536
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr

Definition at line 1536 of file DMMoFEM.cpp.

1537 {
1538 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1540 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1541 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1542 ->isCreateProblemFieldAndRank(dm_field->problemPtr->getName(), rc,
1543 field_name, 0, 1000, is);
1545}

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

431 {
432 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
434 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
435 *is_comp_dm = dm_field->isCompDM;
437}

◆ DMMoFEMGetIsPartitioned()

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

#include <src/petsc/DMMoFEM.hpp>

get if read mesh is partitioned

Parameters
dmDistributed mesh manager
is_partitionedPointer to boolean flag for partition status
Returns
Error code

get if read mesh is partitioned

Definition at line 1153 of file DMMoFEM.cpp.

1153 {
1154 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1156 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1157 *is_partitioned = dm_field->isPartitioned;
1159}

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

351 {
352 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
354 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
355 *is_sub_dm = dm_field->isSubDM;
357}

◆ 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

Parameters
dmDistributed mesh manager
ksp_ctxShared pointer to KSP context structure
Returns
Error code

Definition at line 1096 of file DMMoFEM.cpp.

1096 {
1097 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1099 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1100 const_cast<boost::shared_ptr<MoFEM::KspCtx> &>(ksp_ctx) = dm_field->kspCtx;
1102}

◆ DMMoFEMGetKspCtx() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::KspCtx data structure

Parameters
dmDistributed mesh manager
ksp_ctxPointer to KSP context structure
Returns
Error code

Definition at line 1087 of file DMMoFEM.cpp.

1087 {
1088 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1090 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1091 *ksp_ctx = dm_field->kspCtx.get();
1093}

◆ 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 are on each processor, for more information look at 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 496 of file DMMoFEM.cpp.

497 {
498 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
500 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
501
502 MPI_Comm comm;
503 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
504 CHKERR dm_field->problemPtr->getNumberOfElementsByNameAndPart(comm, fe_name,
505 layout);
507}

◆ DMMoFEMGetProblemPtr()

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

#include <src/petsc/DMMoFEM.hpp>

Get pointer to problem data structure.

Parameters
dmDistributed mesh manager
problem_ptrPointer to pointer of problem data structure
Returns
Error code

Definition at line 451 of file DMMoFEM.cpp.

451 {
452 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
454 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
455 if (!dm->data) {
456 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
457 "data structure for MoFEM not yet created");
458 }
459 *problem_ptr = dm_field->problemPtr;
461}

◆ 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

Parameters
dmDistributed mesh manager
snes_ctxShared pointer to SNES context structure
Returns
Error code

Definition at line 1122 of file DMMoFEM.cpp.

1122 {
1123 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1125 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1126 const_cast<boost::shared_ptr<MoFEM::SnesCtx> &>(snes_ctx) = dm_field->snesCtx;
1128}

◆ DMMoFEMGetSnesCtx() [2/2]

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

#include <src/petsc/DMMoFEM.hpp>

get MoFEM::SnesCtx data structure

Parameters
dmDistributed mesh manager
snes_ctxPointer to SNES context structure
Returns
Error code
Examples
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp.

Definition at line 1113 of file DMMoFEM.cpp.

1113 {
1114 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1116 DMCtxImpl *dm_field = (DMCtxImpl *)dm->data;
1117 *snes_ctx = dm_field->snesCtx.get();
1119}

◆ DMMoFEMGetSquareProblem()

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

#include <src/petsc/DMMoFEM.hpp>

get squared problem

If true, it is assumed that matrix has the same indexing on rows and columns. This reduces interprocessor communication.

Definition at line 509 of file DMMoFEM.cpp.

509 {
510 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
512 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
513 *square_problem = dm_field->isSquareMatrix;
515}

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

1170 {
1171 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1173 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1174 const_cast<boost::shared_ptr<MoFEM::TsCtx> &>(ts_ctx) = dm_field->tsCtx;
1176}
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 1161 of file DMMoFEM.cpp.

1161 {
1162 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1164 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1165 *ts_ctx = dm_field->tsCtx.get();
1167}

◆ 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
mofem/tutorials/adv-3_level_set/level_set.cpp.

Definition at line 697 of file DMMoFEM.cpp.

700 {
701 return DMMoFEMKSPSetComputeOperators<const char *, MoFEM::FEMethod *,
704 dm, fe_name, method, pre_only, post_only);
705}
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:697
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 708 of file DMMoFEM.cpp.

711 {
712 return DMMoFEMKSPSetComputeOperators<const std::string,
713 boost::shared_ptr<MoFEM::FEMethod>>(
714 dm, fe_name, method, pre_only, post_only);
715}

◆ 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 KSP right hand side evaluation function

Examples
mofem/tutorials/adv-3_level_set/level_set.cpp, and mofem/tutorials/scl-12_electrostatics/electrostatics.cpp.

Definition at line 656 of file DMMoFEM.cpp.

659 {
660 return DMMoFEMKSPSetComputeRHS<const char *, MoFEM::FEMethod *,
662 dm, fe_name, method, pre_only, post_only);
663}
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:656

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

669 {
670 return DMMoFEMKSPSetComputeRHS<const std::string,
671 boost::shared_ptr<MoFEM::FEMethod>,
672 boost::shared_ptr<MoFEM::BasicMethod>,
673 boost::shared_ptr<MoFEM::BasicMethod>>(
674 dm, fe_name, method, pre_only, post_only);
675}

◆ 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:487

Definition at line 487 of file DMMoFEM.cpp.

487 {
488 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
490 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
491 CHKERR dm_field->mField_ptr->getInterface<CommInterface>()
492 ->resolveSharedFiniteElements(dm_field->problemPtr, fe_name);
494}

◆ DMMoFEMSetIsPartitioned()

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

#include <src/petsc/DMMoFEM.hpp>

sets if read mesh is partitioned

Parameters
dmDistributed mesh manager
is_partitionedBoolean flag indicating if mesh is partitioned
Returns
Error code

get if read mesh is partitioned

Examples
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 1142 of file DMMoFEM.cpp.

1142 {
1143 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1145 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1146 dm_field->isPartitioned = is_partitioned;
1148}

◆ DMMoFEMSetKspCtx()

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

#include <src/petsc/DMMoFEM.hpp>

set MoFEM::KspCtx data structure

Parameters
dmDistributed mesh manager
ksp_ctxShared pointer to KSP context structure to set
Returns
Error code

Definition at line 1104 of file DMMoFEM.cpp.

1105 {
1106 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1108 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1109 dm_field->kspCtx = ksp_ctx;
1111}

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

1131 {
1132 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1134 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1135 dm_field->snesCtx = snes_ctx;
1137}

◆ DMMoFEMSetSquareProblem()

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

#include <src/petsc/DMMoFEM.hpp>

set squared problem

If true, it is assumed that matrix has the same indexing on rows and columns. This reduces interprocessor communication.

Examples
mofem/atom_tests/test_broken_space.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 479 of file DMMoFEM.cpp.

479 {
480 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
482 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
483 dm_field->isSquareMatrix = square_problem;
485}

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

1178 {
1179 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1181 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1182 dm_field->tsCtx = ts_ctx;
1184}

◆ 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
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp.

Definition at line 737 of file DMMoFEM.cpp.

740 {
741 return DMMoFEMSNESSetFunction<const char *, MoFEM::FEMethod *,
743 dm, fe_name, method, pre_only, post_only);
744}
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:737

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

750 {
751 return DMMoFEMSNESSetFunction<const std::string,
752 boost::shared_ptr<MoFEM::FEMethod>,
753 boost::shared_ptr<MoFEM::BasicMethod>,
754 boost::shared_ptr<MoFEM::BasicMethod>>(
755 dm, fe_name, method, pre_only, post_only);
756}

◆ 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
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp.

Definition at line 778 of file DMMoFEM.cpp.

781 {
782 return DMMoFEMSNESSetJacobian<const char *, MoFEM::FEMethod *,
784 dm, fe_name, method, pre_only, post_only);
785}
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:778

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

791 {
792 return DMMoFEMSNESSetJacobian<const std::string,
793 boost::shared_ptr<MoFEM::FEMethod>,
794 boost::shared_ptr<MoFEM::BasicMethod>,
795 boost::shared_ptr<MoFEM::BasicMethod>>(
796 dm, fe_name, method, pre_only, post_only);
797}

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

986 {
987 return DMMoFEMTSSetI2Function<const char *, MoFEM::FEMethod *,
989 dm, fe_name, method, pre_only, post_only);
991}
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:994

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

997 {
998 return DMMoFEMTSSetI2Function<const std::string,
999 boost::shared_ptr<MoFEM::FEMethod>,
1000 boost::shared_ptr<MoFEM::BasicMethod>,
1001 boost::shared_ptr<MoFEM::BasicMethod>>(
1002 dm, fe_name, method, pre_only, post_only);
1004}

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

1029 {
1030 return DMMoFEMTSSetI2Jacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
1031 MoFEM::BasicMethod *>(dm, fe_name, method,
1032 pre_only, post_only);
1033}
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:1036

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

1039 {
1040 return DMMoFEMTSSetI2Jacobian<const std::string,
1041 boost::shared_ptr<MoFEM::FEMethod>,
1042 boost::shared_ptr<MoFEM::BasicMethod>,
1043 boost::shared_ptr<MoFEM::BasicMethod>>(
1044 dm, fe_name, method, pre_only, post_only);
1045}

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

822 {
823 return DMMoFEMTSSetIFunction<const char *, MoFEM::FEMethod *,
825 dm, fe_name, method, pre_only, post_only);
827}
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:819

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

833 {
834 return DMMoFEMTSSetIFunction<const std::string,
835 boost::shared_ptr<MoFEM::FEMethod>,
836 boost::shared_ptr<MoFEM::BasicMethod>,
837 boost::shared_ptr<MoFEM::BasicMethod>>(
838 dm, fe_name, method, pre_only, post_only);
840}

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

865 {
866 return DMMoFEMTSSetIJacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
867 MoFEM::BasicMethod *>(dm, fe_name, method,
868 pre_only, post_only);
869}
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:872

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

875 {
876 return DMMoFEMTSSetIJacobian<const std::string,
877 boost::shared_ptr<MoFEM::FEMethod>,
878 boost::shared_ptr<MoFEM::BasicMethod>,
879 boost::shared_ptr<MoFEM::BasicMethod>>(
880 dm, fe_name, method, pre_only, post_only);
881}

◆ DMMoFEMUnSetElement()

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

#include <src/petsc/DMMoFEM.hpp>

unset element from dm

Parameters
dmDistributed mesh manager
fe_nameFinite element name to remove
Returns
Error code

Definition at line 534 of file DMMoFEM.cpp.

534 {
535 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
537 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
538 CHKERR dm_field->mField_ptr->modify_problem_unset_finite_element(
539 dm_field->problemName, fe_name);
541}

◆ 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
mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/users_modules/adolc-plasticity/adolc_plasticity.cpp.

Definition at line 439 of file DMMoFEM.cpp.

439 {
440 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
442 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
443 if (!dm->data) {
444 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
445 "data structure for MoFEM not yet created");
446 }
447 *m_field_ptr = dm_field->mField_ptr;
449}

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

625 {
626 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
628 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
629 ierr =
630 dm_field->mField_ptr->loop_dofs(dm_field->problemPtr, field_name, COL,
631 *method, dm_field->rAnk, dm_field->rAnk);
632 CHKERRG(ierr);
634}

◆ 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
mofem/tutorials/adv-0_plasticity/plastic.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-4_dynamic_first_order_con_law/dynamic_first_order_con_law.cpp, mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/scl-1_poisson_2d_homogeneous/poisson_2d_homogeneous.cpp, mofem/tutorials/scl-6_heat_equation/heat_equation.cpp, mofem/tutorials/scl-7_wave_equation/wave_equation.cpp, mofem/tutorials/vec-11_elastic_tie_mesh/elastic_tie_mesh.cpp, mofem/tutorials/vec-3_nonlinear_dynamics/nonlinear_dynamic_elastic.cpp, mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp, mofem/tutorials/vec-4_shallow_wave/shallow_wave.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, and mofem/users_modules/adolc-plasticity/adolc_plasticity.cpp.

Definition at line 605 of file DMMoFEM.cpp.

607 {
608 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
610 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
612 dm, fe_name, method, dm_field->rAnk, dm_field->rAnk, cache_ptr);
613 CHKERRG(ierr);
615}
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:586

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

620 {
621 return DMoFEMLoopFiniteElements(dm, fe_name.c_str(), method.get(), cache_ptr);
622}
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:605

◆ 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
Examples
mofem/tutorials/scl-12_electrostatics/electrostatics.cpp.

Definition at line 586 of file DMMoFEM.cpp.

588 {
590 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
591 ierr = dm_field->mField_ptr->loop_finite_elements(
592 dm_field->problemPtr, fe_name, *method, low_rank, up_rank, nullptr,
593 MF_EXIST, cache_ptr);
594 CHKERRG(ierr);
596}
@ 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 598 of file DMMoFEM.cpp.

600 {
601 return DMoFEMLoopFiniteElementsUpAndLowRank(dm, fe_name.c_str(), method.get(),
602 low_rank, up_rank, cache_ptr);
603}

◆ DMoFEMMeshToGlobalVector()

PetscErrorCode MoFEM::DMoFEMMeshToGlobalVector ( DM  dm,
Vec  g,
InsertMode  mode,
ScatterMode  scatter_mode,
RowColData  rc = RowColData::COL 
)

#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
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp.

Definition at line 554 of file DMMoFEM.cpp.

556 {
557 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
559 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
560 ierr = dm_field->mField_ptr->getInterface<VecManager>()->setGlobalGhostVector(
561 dm_field->problemPtr, rc, g, mode, scatter_mode);
563}

◆ DMoFEMMeshToLocalVector()

PetscErrorCode MoFEM::DMoFEMMeshToLocalVector ( DM  dm,
Vec  l,
InsertMode  mode,
ScatterMode  scatter_mode,
RowColData  rc = RowColData::COL 
)

#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

This code will update ghosted entities on all processors

auto d_vector = createDMVector(dm);
// fill d_vector on owned entities
CHKERR DMoFEMMeshToLocalVector(dm, d_vector, INSERT_VALUES,
SCATTER_FORWARD);
// update ghost values in d_vector
CHKERR VecGhostUpdateBegin(d_vector, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(d_vector, INSERT_VALUES, SCATTER_FORWARD);
// now d_vector has updated ghost values, and following save values of
// vector to fields entities
CHKERR DMoFEMMeshToLocalVector(dm, d_vector, INSERT_VALUES,
SCATTER_REVERSE);
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
Definition DMMoFEM.cpp:543
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1250
Note
you use DMoFEMMeshToGlobalVector as scatter reverse

For implementations see VecManager::setLocalGhostVector.

Examples
mofem/atom_tests/child_and_parent.cpp, mofem/atom_tests/dg_projection.cpp, mofem/atom_tests/hanging_node_approx.cpp, mofem/atom_tests/higher_derivatives.cpp, mofem/tutorials/adv-3_level_set/level_set.cpp, mofem/tutorials/adv-4_dynamic_first_order_con_law/dynamic_first_order_con_law.cpp, mofem/tutorials/adv-6_dg_projection/between_meshes_dg_projection.cpp, mofem/tutorials/clx-0_acoustics/helmholtz.cpp, mofem/tutorials/mix-0_mixed_poisson/mixed_poisson.cpp, mofem/tutorials/mix-1_light_intensity_equation/phase.cpp, mofem/tutorials/scl-0_least_squares/approximation.cpp, mofem/tutorials/scl-12_electrostatics/electrostatics.cpp, mofem/tutorials/scl-1_poisson_2d_homogeneous/poisson_2d_homogeneous.cpp, mofem/tutorials/scl-8_heat_radiation/radiation.cpp, mofem/tutorials/scl-9_heat_method/heat_method.cpp, mofem/tutorials/vec-10_elasticity_schur/schur_elastic.cpp, mofem/tutorials/vec-3_nonlinear_dynamics/nonlinear_dynamic_elastic.cpp, mofem/tutorials/vec-4_shallow_wave/approx_sphere.cpp, mofem/tutorials/vec-4_shallow_wave/shallow_wave.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, mofem/tutorials/vec-6_dg_kirchhoff_plate/plate.cpp, mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp, and mofem/users_modules/adolc-plasticity/adolc_plasticity.cpp.

Definition at line 543 of file DMMoFEM.cpp.

545 {
546 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
548 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
549 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->setLocalGhostVector(
550 dm_field->problemPtr, rc, l, mode, scatter_mode);
552}

◆ DMoFEMPostProcessFiniteElements()

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

#include <src/petsc/DMMoFEM.hpp>

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

Parameters
dmDistributed mesh manager
methodFinite element method to execute for postprocessing
Returns
Error code
Examples
mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 575 of file DMMoFEM.cpp.

575 {
576 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
578 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
579 ierr = dm_field->mField_ptr->problem_basic_method_postProcess(
580 dm_field->problemPtr, *method);
581 CHKERRG(ierr);
583}

◆ DMoFEMPreProcessFiniteElements()

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

#include <src/petsc/DMMoFEM.hpp>

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

Parameters
dmDistributed mesh manager
methodFinite element method to execute for preprocessing
Returns
Error code
Examples
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/vec-5_free_surface/free_surface.cpp, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 565 of file DMMoFEM.cpp.

565 {
566 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
568 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
569 ierr = dm_field->mField_ptr->problem_basic_method_preProcess(
570 dm_field->problemPtr, *method);
571 CHKERRG(ierr);
573}

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

Parameters
snameSolver name string identifier
Returns
Error code
Examples
mofem/tutorials/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/mix-0_mixed_poisson/mixed_poisson.cpp, and mofem/tutorials/scl-12_electrostatics/electrostatics.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 1305 of file DMMoFEM.cpp.

1305 {
1306#endif
1307
1308 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1310 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1311#if PETSC_VERSION_GE(3, 18, 0)
1312 PetscOptionsHeadBegin(PetscOptionsObject, "DMMoFEM Options");
1313#elif PETSC_VERSION_GE(3, 5, 3)
1314 PetscOptionsHead(PetscOptionsObject, "DMMoFEM Options");
1315#else
1316 PetscOptionsHead("DMMoFEM Options");
1317#endif
1318 ierr = PetscOptionsBool("-dm_is_partitioned",
1319 "set if mesh is partitioned (works which native MOAB "
1320 "file format, i.e. h5m",
1321 "DMSetUp", dm_field->isPartitioned,
1322 &dm_field->isPartitioned, NULL);
1323 CHKERRG(ierr);
1325}

◆ DMSetOperators_MoFEM()

PetscErrorCode MoFEM::DMSetOperators_MoFEM ( DM  dm)

#include <src/petsc/DMMoFEM.hpp>

Set operators for MoFEM dm.

Parameters
dmDistributed mesh manager
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:1421
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1429
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition DMMoFEM.cpp:1207
PetscErrorCode DMDestroy_MoFEM(DM dm)
Destroys dm with MoFEM data structure.
Definition DMMoFEM.cpp:105
PetscErrorCode DMLocalToGlobalBegin_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1457
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition DMMoFEM.cpp:1305
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition DMMoFEM.cpp:1491
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition DMMoFEM.cpp:1327
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1486

◆ DMSetUp_MoFEM()

PetscErrorCode MoFEM::DMSetUp_MoFEM ( DM  dm)

#include <src/petsc/DMMoFEM.hpp>

sets up the MoFEM structures inside a DM object

Examples
mofem/tutorials/mix-0_mixed_poisson/mixed_poisson.cpp.

Definition at line 1327 of file DMMoFEM.cpp.

1327 {
1328 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1329 ProblemsManager *prb_mng_ptr;
1331 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1332 CHKERR dm_field->mField_ptr->getInterface(prb_mng_ptr);
1333
1334 if (dm_field->isCompDM) {
1335 // It is composite probelm
1336 CHKERR prb_mng_ptr->buildComposedProblem(
1337 dm_field->problemName, dm_field->rowCompPrb, dm_field->colCompPrb,
1338 dm_field->isSquareMatrix == PETSC_TRUE, dm_field->verbosity);
1339 } else {
1340 if (dm_field->isPartitioned) {
1341 CHKERR prb_mng_ptr->buildProblemOnDistributedMesh(
1342 dm_field->problemName, dm_field->isSquareMatrix == PETSC_TRUE,
1343 dm_field->verbosity);
1344 } else {
1345 CHKERR prb_mng_ptr->buildProblem(dm_field->problemName,
1346 dm_field->isSquareMatrix == PETSC_TRUE,
1347 dm_field->verbosity);
1348 CHKERR prb_mng_ptr->partitionProblem(dm_field->problemName,
1349 dm_field->verbosity);
1350 }
1351 }
1352
1353 // Partition finite elements
1354 if (dm_field->isPartitioned) {
1355 CHKERR prb_mng_ptr->partitionFiniteElements(
1356 dm_field->problemName, true, 0, dm_field->sIze, dm_field->verbosity);
1357 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1358 dm_field->problemName, dm_field->verbosity);
1359 } else {
1360 // partition finite elemnets
1361 CHKERR prb_mng_ptr->partitionFiniteElements(dm_field->problemName, false,
1362 -1, -1, dm_field->verbosity);
1363 // Get ghost DOFs
1364 CHKERR prb_mng_ptr->partitionGhostDofs(dm_field->problemName,
1365 dm_field->verbosity);
1366 }
1367
1368 // Set flag that problem is build and partitioned
1369 dm_field->isProblemBuild = PETSC_TRUE;
1370
1372}

◆ 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

Parameters
subdmSub distributed mesh manager to set up
Returns
Error code
Examples
mofem/tutorials/adv-3_level_set/level_set.cpp.

Definition at line 1374 of file DMMoFEM.cpp.

1374 {
1375 PetscValidHeaderSpecific(subdm, DM_CLASSID, 1);
1376 ProblemsManager *prb_mng_ptr;
1378
1379 DMCtxImpl *subdm_field = static_cast<DMCtxImpl *>(subdm->data);
1380
1381 // build sub dm problem
1382 CHKERR subdm_field->mField_ptr->getInterface(prb_mng_ptr);
1383
1384 map<std::string, boost::shared_ptr<Range>> *entity_map_row = nullptr;
1385 map<std::string, boost::shared_ptr<Range>> *entity_map_col = nullptr;
1386
1387 if (subdm_field->mapTypeRow.size())
1388 entity_map_row = &subdm_field->mapTypeRow;
1389 if (subdm_field->mapTypeCol.size())
1390 entity_map_col = &subdm_field->mapTypeCol;
1391
1392 CHKERR prb_mng_ptr->buildSubProblem(
1393 subdm_field->problemName, subdm_field->rowSubFields,
1394 subdm_field->colSubFields, subdm_field->problemMainOfSubPtr->getName(),
1395 subdm_field->isSquareMatrix == PETSC_TRUE, entity_map_row, entity_map_col,
1396 subdm_field->verbosity);
1397
1398 // partition problem
1399 subdm_field->isPartitioned = subdm_field->isPartitioned;
1400 if (subdm_field->isPartitioned) {
1401 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, true,
1402 0, subdm_field->sIze,
1403 subdm_field->verbosity);
1404 // set ghost nodes
1405 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1406 subdm_field->problemName, subdm_field->verbosity);
1407 } else {
1408 // partition finite elements
1409 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, false,
1410 -1, -1, subdm_field->verbosity);
1411 // set ghost nodes
1412 CHKERR prb_mng_ptr->partitionGhostDofs(subdm_field->problemName,
1413 subdm_field->verbosity);
1414 }
1415
1416 subdm_field->isProblemBuild = PETSC_TRUE;
1417
1419}