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::DMMoFEMRebuildProblem (DM dm, const MoFEM::BitRefLevel target_bit, const MoFEM::BitRefLevel target_mask, IS *old_row_indices=PETSC_NULLPTR, IS *new_row_indices=PETSC_NULLPTR)
 Rebuild the DM's parent problem in place on a new bit ref level.
 
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 1236 of file DMMoFEM.hpp.

1236 {
1237 SmartPetscObj<Mat> a;
1239 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1240 return a;
1241};
constexpr double a
static PetscErrorCode ierr
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition DMMoFEM.cpp:1274
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 1279 of file DMMoFEM.hpp.

1279 {
1280 SmartPetscObj<Vec> v;
1282 CHKERRABORT(getCommFromPetscObject(reinterpret_cast<PetscObject>(dm)), ierr);
1283 return v;
1284};
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition DMMoFEM.cpp:1243
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 1548 of file DMMoFEM.cpp.

1549 {
1550 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1552
1553 if (numFields) {
1554 *numFields = 0;
1555 }
1556 if (fieldNames) {
1557 *fieldNames = NULL;
1558 }
1559 if (fields) {
1560 *fields = NULL;
1561 }
1562
1563 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1564 auto fields_ptr = dm_field->mField_ptr->get_fields();
1565 Field_multiIndex::iterator fit, hi_fit;
1566 fit = fields_ptr->begin();
1567 hi_fit = fields_ptr->end();
1568 *numFields = std::distance(fit, hi_fit);
1569
1570 if (fieldNames) {
1571 CHKERR PetscMalloc1(*numFields, fieldNames);
1572 }
1573 if (fields) {
1574 CHKERR PetscMalloc1(*numFields, fields);
1575 }
1576
1577 for (int f = 0; fit != hi_fit; fit++, f++) {
1578 if (fieldNames) {
1579 CHKERR PetscStrallocpy(fit->get()->getName().c_str(),
1580 (char **)&(*fieldNames)[f]);
1581 }
1582 if (fields) {
1583 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1584 ->isCreateProblemFieldAndRank(
1585 dm_field->problemPtr->getName(), ROW, fit->get()->getName(), 0,
1586 fit->get()->getNbOfCoeffs(), &(*fields)[f]);
1587 }
1588 }
1589
1591}
@ 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 1253 of file DMMoFEM.cpp.

1254 {
1255 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1257 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1258 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1259 dm_field->problemName, rc, g_ptr);
1260 CHKERR VecSetDM(g_ptr, dm);
1262}

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

1243 {
1244 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1246 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1247 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateGhost(
1248 dm_field->problemName, COL, g);
1249 CHKERR VecSetDM(*g, dm);
1251}
@ COL

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

1264 {
1265 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1267 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1268 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->vecCreateSeq(
1269 dm_field->problemName, COL, l);
1270 CHKERR VecSetDM(*l, dm);
1272}
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 1274 of file DMMoFEM.cpp.

1274 {
1275 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1277 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1278
1279 if (strcmp(dm->mattype, MATSHELL) == 0) {
1280
1281 if (dm_field->blocMatDataPtr) {
1283 CHKERR MatSetDM(*M, dm);
1285 } else {
1286 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1287 "Matrix shell data not set, or matrix type not implemented");
1288 }
1289
1290 } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1291 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1292 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1293 M);
1294 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1295 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1296 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1297 M);
1298 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1299 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1300 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1301 dm_field->problemName, M);
1302 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1303 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1304 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1305 dm_field->problemName, M);
1306 } else {
1307 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1308 "Matrix type not implemented");
1309 }
1310 CHKERR MatSetDM(*M, dm);
1312}
#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:1630

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

1314 {
1315 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1317 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1318
1319 if (strcmp(dm->mattype, MATSHELL) == 0) {
1320 if (dm_field->blocMatDataPtr) {
1321 Mat mat_raw;
1322 CHKERR DMMoFEMCreateBlockMat(dm, &mat_raw);
1323 M = SmartPetscObj<Mat>(mat_raw);
1325 } else {
1326 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1327 "Matrix shell data not set, or matrix type not implemented");
1328 }
1329 } else if (strcmp(dm->mattype, MATMPIAIJ) == 0) {
1330 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1331 ->createMPIAIJWithArrays<PetscGlobalIdx_mi_tag>(dm_field->problemName,
1332 M);
1333 } else if (strcmp(dm->mattype, MATAIJ) == 0) {
1334 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1335 ->createSeqAIJWithArrays<PetscLocalIdx_mi_tag>(dm_field->problemName,
1336 M);
1337 } else if (strcmp(dm->mattype, MATAIJCUSPARSE) == 0) {
1338 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1339 ->createMPIAIJCUSPARSEWithArrays<PetscGlobalIdx_mi_tag>(
1340 dm_field->problemName, M);
1341 } else if (strcmp(dm->mattype, MATSEQAIJCUSPARSE) == 0) {
1342 CHKERR dm_field->mField_ptr->getInterface<MatrixManager>()
1343 ->createSeqAIJCUSPARSEWithArrays<PetscLocalIdx_mi_tag>(
1344 dm_field->problemName, M);
1345 } else {
1346 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
1347 "Matrix type not implemented");
1348 }
1349 CHKERR MatSetDM(M, dm);
1351}

◆ 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}
TetMeshData result
#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 1478 of file DMMoFEM.cpp.

1479 {
1480 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1482 CHKERR VecGhostUpdateBegin(g, INSERT_VALUES, SCATTER_FORWARD);
1484}

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

1486 {
1487 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1489
1490 CHKERR VecGhostUpdateEnd(g, INSERT_VALUES, SCATTER_FORWARD);
1491
1492 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1493 int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1494 int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1495
1496 double *array_loc, *array_glob;
1497 CHKERR VecGetArray(l, &array_loc);
1498 CHKERR VecGetArray(g, &array_glob);
1499 switch (mode) {
1500 case INSERT_VALUES:
1501 cblas_dcopy(nb_dofs + nb_ghost, array_glob, 1, array_loc, 1);
1502 break;
1503 case ADD_VALUES:
1504 cblas_daxpy(nb_dofs + nb_ghost, 1, array_glob, 1, array_loc, 1);
1505 break;
1506 default:
1507 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1508 }
1509 CHKERR VecRestoreArray(l, &array_loc);
1510 CHKERR VecRestoreArray(g, &array_glob);
1512}

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

1515 {
1516
1517 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1519
1520 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1521 int nb_dofs = dm_field->problemPtr->getNbLocalDofsRow();
1522 int nb_ghost = dm_field->problemPtr->getNbGhostDofsRow();
1523
1524 double *array_loc, *array_glob;
1525 CHKERR VecGetArray(l, &array_loc);
1526 CHKERR VecGetArray(g, &array_glob);
1527 switch (mode) {
1528 case INSERT_VALUES:
1529 cblas_dcopy(nb_dofs + nb_ghost, array_loc, 1, array_glob, 1);
1530 break;
1531 case ADD_VALUES:
1532 cblas_daxpy(nb_dofs + nb_ghost, 1, array_loc, 1, array_glob, 1);
1533 break;
1534 default:
1535 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
1536 }
1537 CHKERR VecRestoreArray(l, &array_loc);
1538 CHKERR VecRestoreArray(g, &array_glob);
1539
1541}

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

1543 {
1546}

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

574 {
575 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
577 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
578 CHKERR dm_field->mField_ptr->modify_problem_add_finite_element(
579 dm_field->problemName, fe_name);
581}

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

583 {
585 for (auto fe : fe_name) {
587 }
589}
PetscErrorCode DMMoFEMAddElement(DM dm, std::string fe_name)
add element to dm
Definition DMMoFEM.cpp:574

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

1630 {
1631 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1633 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1634 auto mat_data = createBlockMat(dm, dm_field->blocMatDataPtr);
1635 *mat = mat_data.first;
1636 CHKERR PetscObjectReference((PetscObject)(*mat));
1638}
SchurShellMatData createBlockMat(DM dm, boost::shared_ptr< BlockStructure > data)
Create a Schur Mat object.
Definition Schur.cpp:3615

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

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

Definition at line 1593 of file DMMoFEM.cpp.

1594 {
1595 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1597 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1598 CHKERR dm_field->mField_ptr->getInterface<ISManager>()
1599 ->isCreateProblemFieldAndRank(dm_field->problemPtr->getName(), rc,
1600 field_name, 0, 1000, is);
1602}

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

1210 {
1211 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1213 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1214 *is_partitioned = dm_field->isPartitioned;
1216}

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

1153 {
1154 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1156 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1157 const_cast<boost::shared_ptr<MoFEM::KspCtx> &>(ksp_ctx) = dm_field->kspCtx;
1159}

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

1144 {
1145 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1147 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1148 *ksp_ctx = dm_field->kspCtx.get();
1150}

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

554 {
555 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
557 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
558
559 MPI_Comm comm;
560 CHKERR PetscObjectGetComm((PetscObject)dm, &comm);
561 CHKERR dm_field->problemPtr->getNumberOfElementsByNameAndPart(comm, fe_name,
562 layout);
564}

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

1179 {
1180 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1182 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1183 const_cast<boost::shared_ptr<MoFEM::SnesCtx> &>(snes_ctx) = dm_field->snesCtx;
1185}

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

1170 {
1171 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1173 DMCtxImpl *dm_field = (DMCtxImpl *)dm->data;
1174 *snes_ctx = dm_field->snesCtx.get();
1176}

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

566 {
567 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
569 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
570 *square_problem = dm_field->isSquareMatrix;
572}

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

1227 {
1228 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1230 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1231 const_cast<boost::shared_ptr<MoFEM::TsCtx> &>(ts_ctx) = dm_field->tsCtx;
1233}
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 1218 of file DMMoFEM.cpp.

1218 {
1219 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1221 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1222 *ts_ctx = dm_field->tsCtx.get();
1224}

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

757 {
758 return DMMoFEMKSPSetComputeOperators<const char *, MoFEM::FEMethod *,
761 dm, fe_name, method, pre_only, post_only);
762}
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:754
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 765 of file DMMoFEM.cpp.

768 {
769 return DMMoFEMKSPSetComputeOperators<const std::string,
770 boost::shared_ptr<MoFEM::FEMethod>>(
771 dm, fe_name, method, pre_only, post_only);
772}

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

716 {
717 return DMMoFEMKSPSetComputeRHS<const char *, MoFEM::FEMethod *,
719 dm, fe_name, method, pre_only, post_only);
720}
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:713

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

726 {
727 return DMMoFEMKSPSetComputeRHS<const std::string,
728 boost::shared_ptr<MoFEM::FEMethod>,
729 boost::shared_ptr<MoFEM::BasicMethod>,
730 boost::shared_ptr<MoFEM::BasicMethod>>(
731 dm, fe_name, method, pre_only, post_only);
732}

◆ DMMoFEMRebuildProblem()

PetscErrorCode MoFEM::DMMoFEMRebuildProblem ( DM  dm,
const MoFEM::BitRefLevel  target_bit,
const MoFEM::BitRefLevel  target_mask,
IS *  old_row_indices = PETSC_NULLPTR,
IS *  new_row_indices = PETSC_NULLPTR 
)

#include <src/petsc/DMMoFEM.hpp>

Rebuild the DM's parent problem in place on a new bit ref level.

Collective. For a set-up, partitioned, non-composite parent DM: the problem keeps its name and the DM, its selector is set to target_bit and target_mask, the numbered DOFs are rebuilt by the distributed builder (every index changes; nothing is preserved), the finite elements and the ghost DOFs are partitioned again, and the vectors the DM caches, its block matrix structure and its nested Schur data are dropped. Sub-DMs, matrices, vectors, index sets and solvers made from the old numbering must be recreated by the caller.

Parameters
dmparent DMMOFEM, set up with DMMoFEMSetIsPartitioned true
target_bitbit ref level of the rebuilt problem
target_maskbit ref mask of the rebuilt problem
old_row_indicesoptional, collective: old global row indices of the DOFs owned by this rank that exist in both numberings; the caller destroys it
new_row_indicesoptional, collective: their new global row indices, same order; the caller destroys it
Returns
error code

Definition at line 479 of file DMMoFEM.cpp.

483 {
484 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
485 ProblemsManager *prb_mng_ptr;
487 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
488 if (!dm_field->isProblemBuild)
489 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
490 "DM problem %s is not set up; call DMSetUp first",
491 dm_field->problemName.c_str());
492 if (dm_field->isSubDM || dm_field->isCompDM)
493 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
494 "only a parent problem is rebuilt in place (%s)",
495 dm_field->problemName.c_str());
496 if (!dm_field->isPartitioned)
497 SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
498 "rebuild in place needs the distributed builder: set "
499 "DMMoFEMSetIsPartitioned for %s",
500 dm_field->problemName.c_str());
501 CHKERR dm_field->mField_ptr->getInterface(prb_mng_ptr);
502
503 SmartPetscObj<IS> is_old, is_new;
504 CHKERR prb_mng_ptr->rebuildProblemOnDistributedMesh(
505 dm_field->problemName, target_bit, target_mask,
506 dm_field->isSquareMatrix == PETSC_TRUE, dm_field->verbosity,
507 old_row_indices ? &is_old : nullptr, new_row_indices ? &is_new : nullptr);
508
509 // From here until the partitions are complete the DM is not usable.
510 dm_field->isProblemBuild = PETSC_FALSE;
511 CHKERR prb_mng_ptr->partitionFiniteElements(
512 dm_field->problemName, true, 0, dm_field->sIze, dm_field->verbosity);
513 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
514 dm_field->problemName, dm_field->verbosity);
515 dm_field->isProblemBuild = PETSC_TRUE;
516
517 // Drop what the DM caches on the old numbering.
518 dm_field->blocMatDataPtr.reset();
519 dm_field->nestedSchurDataPtr.reset();
520 CHKERR DMClearGlobalVectors(dm);
521 CHKERR DMClearLocalVectors(dm);
522 CHKERR DMClearNamedGlobalVectors(dm);
523 CHKERR DMClearNamedLocalVectors(dm);
524
525 if (old_row_indices) {
526 *old_row_indices = is_old;
527 CHKERR PetscObjectReference((PetscObject)*old_row_indices);
528 }
529 if (new_row_indices) {
530 *new_row_indices = is_new;
531 CHKERR PetscObjectReference((PetscObject)*new_row_indices);
532 }
534}

◆ 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);
MoFEM::Interface & mField
#define MYPCOMM_INDEX
default communicator number PCOMM
PetscErrorCode DMMoFEMResolveSharedFiniteElements(DM dm, std::string fe_name)
Resolve shared entities.
Definition DMMoFEM.cpp:544
virtual moab::Interface & get_moab()=0

Definition at line 544 of file DMMoFEM.cpp.

544 {
545 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
547 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
548 CHKERR dm_field->mField_ptr->getInterface<CommInterface>()
549 ->resolveSharedFiniteElements(dm_field->problemPtr, fe_name);
551}

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

1199 {
1200 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1202 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1203 dm_field->isPartitioned = is_partitioned;
1205}

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

1162 {
1163 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1165 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1166 dm_field->kspCtx = ksp_ctx;
1168}

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

1188 {
1189 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1191 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1192 dm_field->snesCtx = snes_ctx;
1194}

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

536 {
537 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
539 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
540 dm_field->isSquareMatrix = square_problem;
542}

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

1235 {
1236 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1238 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1239 dm_field->tsCtx = ts_ctx;
1241}

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

797 {
798 return DMMoFEMSNESSetFunction<const char *, MoFEM::FEMethod *,
800 dm, fe_name, method, pre_only, post_only);
801}
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:794

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

807 {
808 return DMMoFEMSNESSetFunction<const std::string,
809 boost::shared_ptr<MoFEM::FEMethod>,
810 boost::shared_ptr<MoFEM::BasicMethod>,
811 boost::shared_ptr<MoFEM::BasicMethod>>(
812 dm, fe_name, method, pre_only, post_only);
813}

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

838 {
839 return DMMoFEMSNESSetJacobian<const char *, MoFEM::FEMethod *,
841 dm, fe_name, method, pre_only, post_only);
842}
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:835

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

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

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

1043 {
1044 return DMMoFEMTSSetI2Function<const char *, MoFEM::FEMethod *,
1046 dm, fe_name, method, pre_only, post_only);
1048}
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:1051

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

1054 {
1055 return DMMoFEMTSSetI2Function<const std::string,
1056 boost::shared_ptr<MoFEM::FEMethod>,
1057 boost::shared_ptr<MoFEM::BasicMethod>,
1058 boost::shared_ptr<MoFEM::BasicMethod>>(
1059 dm, fe_name, method, pre_only, post_only);
1061}

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

1086 {
1087 return DMMoFEMTSSetI2Jacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
1088 MoFEM::BasicMethod *>(dm, fe_name, method,
1089 pre_only, post_only);
1090}
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:1093

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

1096 {
1097 return DMMoFEMTSSetI2Jacobian<const std::string,
1098 boost::shared_ptr<MoFEM::FEMethod>,
1099 boost::shared_ptr<MoFEM::BasicMethod>,
1100 boost::shared_ptr<MoFEM::BasicMethod>>(
1101 dm, fe_name, method, pre_only, post_only);
1102}

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

879 {
880 return DMMoFEMTSSetIFunction<const char *, MoFEM::FEMethod *,
882 dm, fe_name, method, pre_only, post_only);
884}
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:876

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

890 {
891 return DMMoFEMTSSetIFunction<const std::string,
892 boost::shared_ptr<MoFEM::FEMethod>,
893 boost::shared_ptr<MoFEM::BasicMethod>,
894 boost::shared_ptr<MoFEM::BasicMethod>>(
895 dm, fe_name, method, pre_only, post_only);
897}

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

922 {
923 return DMMoFEMTSSetIJacobian<const char *, FEMethod *, MoFEM::BasicMethod *,
924 MoFEM::BasicMethod *>(dm, fe_name, method,
925 pre_only, post_only);
926}
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:929

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

932 {
933 return DMMoFEMTSSetIJacobian<const std::string,
934 boost::shared_ptr<MoFEM::FEMethod>,
935 boost::shared_ptr<MoFEM::BasicMethod>,
936 boost::shared_ptr<MoFEM::BasicMethod>>(
937 dm, fe_name, method, pre_only, post_only);
938}

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

591 {
592 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
594 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
595 CHKERR dm_field->mField_ptr->modify_problem_unset_finite_element(
596 dm_field->problemName, fe_name);
598}

◆ 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

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

682 {
683 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
685 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
686 ierr =
687 dm_field->mField_ptr->loop_dofs(dm_field->problemPtr, field_name, COL,
688 *method, dm_field->rAnk, dm_field->rAnk);
689 CHKERRG(ierr);
691}

◆ 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/cor-10_navier_stokes/navier_stokes.cpp, mofem/tutorials/scl-1_poisson_2d_homogeneous/poisson_2d_homogeneous.cpp, mofem/tutorials/vec-11_elastic_tie_mesh/elastic_tie_mesh.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 662 of file DMMoFEM.cpp.

664 {
665 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
667 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
669 dm, fe_name, method, dm_field->rAnk, dm_field->rAnk, cache_ptr);
670 CHKERRG(ierr);
672}
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:643

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

677 {
678 return DMoFEMLoopFiniteElements(dm, fe_name.c_str(), method.get(), cache_ptr);
679}
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:662

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

645 {
647 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
648 ierr = dm_field->mField_ptr->loop_finite_elements(
649 dm_field->problemPtr, fe_name, *method, low_rank, up_rank, nullptr,
650 MF_EXIST, cache_ptr);
651 CHKERRG(ierr);
653}
@ 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 655 of file DMMoFEM.cpp.

657 {
658 return DMoFEMLoopFiniteElementsUpAndLowRank(dm, fe_name.c_str(), method.get(),
659 low_rank, up_rank, cache_ptr);
660}

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

613 {
614 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
616 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
617 ierr = dm_field->mField_ptr->getInterface<VecManager>()->setGlobalGhostVector(
618 dm_field->problemPtr, rc, g, mode, scatter_mode);
620}

◆ 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:600
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
Definition DMMoFEM.hpp:1279
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 600 of file DMMoFEM.cpp.

602 {
603 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
605 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
606 CHKERR dm_field->mField_ptr->getInterface<VecManager>()->setLocalGhostVector(
607 dm_field->problemPtr, rc, l, mode, scatter_mode);
609}

◆ 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-7_shape_optimisation/adjoint.cpp.

Definition at line 632 of file DMMoFEM.cpp.

632 {
633 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
635 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
636 ierr = dm_field->mField_ptr->problem_basic_method_postProcess(
637 dm_field->problemPtr, *method);
638 CHKERRG(ierr);
640}

◆ 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, and mofem/tutorials/vec-7_shape_optimisation/adjoint.cpp.

Definition at line 622 of file DMMoFEM.cpp.

622 {
623 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
625 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
626 ierr = dm_field->mField_ptr->problem_basic_method_preProcess(
627 dm_field->problemPtr, *method);
628 CHKERRG(ierr);
630}

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

1362 {
1363#endif
1364
1365 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1367 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1368#if PETSC_VERSION_GE(3, 18, 0)
1369 PetscOptionsHeadBegin(PetscOptionsObject, "DMMoFEM Options");
1370#elif PETSC_VERSION_GE(3, 5, 3)
1371 PetscOptionsHead(PetscOptionsObject, "DMMoFEM Options");
1372#else
1373 PetscOptionsHead("DMMoFEM Options");
1374#endif
1375 ierr = PetscOptionsBool("-dm_is_partitioned",
1376 "set if mesh is partitioned (works which native MOAB "
1377 "file format, i.e. h5m",
1378 "DMSetUp", dm_field->isPartitioned,
1379 &dm_field->isPartitioned, NULL);
1380 CHKERRG(ierr);
1382}

◆ 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:1478
PetscErrorCode DMGlobalToLocalEnd_MoFEM(DM dm, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1486
PetscErrorCode DMCreateLocalVector_MoFEM(DM dm, Vec *l)
DMShellSetCreateLocalVector.
Definition DMMoFEM.cpp:1264
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:1514
PetscErrorCode DMSetFromOptions_MoFEM(DM dm)
Definition DMMoFEM.cpp:1362
PetscErrorCode DMCreateFieldIS_MoFEM(DM dm, PetscInt *numFields, char ***fieldNames, IS **fields)
Definition DMMoFEM.cpp:1548
PetscErrorCode DMSetUp_MoFEM(DM dm)
Definition DMMoFEM.cpp:1384
PetscErrorCode DMLocalToGlobalEnd_MoFEM(DM, Vec, InsertMode, Vec)
Definition DMMoFEM.cpp:1543

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

1384 {
1385 PetscValidHeaderSpecific(dm, DM_CLASSID, 1);
1386 ProblemsManager *prb_mng_ptr;
1388 DMCtxImpl *dm_field = static_cast<DMCtxImpl *>(dm->data);
1389 CHKERR dm_field->mField_ptr->getInterface(prb_mng_ptr);
1390
1391 if (dm_field->isCompDM) {
1392 // It is composite probelm
1393 CHKERR prb_mng_ptr->buildComposedProblem(
1394 dm_field->problemName, dm_field->rowCompPrb, dm_field->colCompPrb,
1395 dm_field->isSquareMatrix == PETSC_TRUE, dm_field->verbosity);
1396 } else {
1397 if (dm_field->isPartitioned) {
1398 CHKERR prb_mng_ptr->buildProblemOnDistributedMesh(
1399 dm_field->problemName, dm_field->isSquareMatrix == PETSC_TRUE,
1400 dm_field->verbosity);
1401 } else {
1402 CHKERR prb_mng_ptr->buildProblem(dm_field->problemName,
1403 dm_field->isSquareMatrix == PETSC_TRUE,
1404 dm_field->verbosity);
1405 CHKERR prb_mng_ptr->partitionProblem(dm_field->problemName,
1406 dm_field->verbosity);
1407 }
1408 }
1409
1410 // Partition finite elements
1411 if (dm_field->isPartitioned) {
1412 CHKERR prb_mng_ptr->partitionFiniteElements(
1413 dm_field->problemName, true, 0, dm_field->sIze, dm_field->verbosity);
1414 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1415 dm_field->problemName, dm_field->verbosity);
1416 } else {
1417 // partition finite elemnets
1418 CHKERR prb_mng_ptr->partitionFiniteElements(dm_field->problemName, false,
1419 -1, -1, dm_field->verbosity);
1420 // Get ghost DOFs
1421 CHKERR prb_mng_ptr->partitionGhostDofs(dm_field->problemName,
1422 dm_field->verbosity);
1423 }
1424
1425 // Set flag that problem is build and partitioned
1426 dm_field->isProblemBuild = PETSC_TRUE;
1427
1429}

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

1431 {
1432 PetscValidHeaderSpecific(subdm, DM_CLASSID, 1);
1433 ProblemsManager *prb_mng_ptr;
1435
1436 DMCtxImpl *subdm_field = static_cast<DMCtxImpl *>(subdm->data);
1437
1438 // build sub dm problem
1439 CHKERR subdm_field->mField_ptr->getInterface(prb_mng_ptr);
1440
1441 map<std::string, boost::shared_ptr<Range>> *entity_map_row = nullptr;
1442 map<std::string, boost::shared_ptr<Range>> *entity_map_col = nullptr;
1443
1444 if (subdm_field->mapTypeRow.size())
1445 entity_map_row = &subdm_field->mapTypeRow;
1446 if (subdm_field->mapTypeCol.size())
1447 entity_map_col = &subdm_field->mapTypeCol;
1448
1449 CHKERR prb_mng_ptr->buildSubProblem(
1450 subdm_field->problemName, subdm_field->rowSubFields,
1451 subdm_field->colSubFields, subdm_field->problemMainOfSubPtr->getName(),
1452 subdm_field->isSquareMatrix == PETSC_TRUE, entity_map_row, entity_map_col,
1453 subdm_field->verbosity);
1454
1455 // partition problem
1456 subdm_field->isPartitioned = subdm_field->isPartitioned;
1457 if (subdm_field->isPartitioned) {
1458 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, true,
1459 0, subdm_field->sIze,
1460 subdm_field->verbosity);
1461 // set ghost nodes
1462 CHKERR prb_mng_ptr->partitionGhostDofsOnDistributedMesh(
1463 subdm_field->problemName, subdm_field->verbosity);
1464 } else {
1465 // partition finite elements
1466 CHKERR prb_mng_ptr->partitionFiniteElements(subdm_field->problemName, false,
1467 -1, -1, subdm_field->verbosity);
1468 // set ghost nodes
1469 CHKERR prb_mng_ptr->partitionGhostDofs(subdm_field->problemName,
1470 subdm_field->verbosity);
1471 }
1472
1473 subdm_field->isProblemBuild = PETSC_TRUE;
1474
1476}