9struct KspCtx::KspCtx::KspCtxImpl {
 
   59  friend PetscErrorCode KspRhs(KSP ksp, Vec f, 
void *ctx);
 
   60  friend PetscErrorCode KspMat(KSP ksp, Mat 
A, Mat 
B, 
void *ctx);
 
 
   97    : kspCtxImpl(boost::movelib::make_unique<
KspCtx::KspCtxImpl>(
 
   98          m_field, problem_name)) {}
 
 
  129                               std::string problem_name)
 
  130    : mField(m_field), moab(m_field.get_moab()), problemName(problem_name),
 
 
  138  loopsOperator.clear();
 
  140  preProcessOperator.clear();
 
  141  postProcessOperator.clear();
 
  142  preProcessRhs.clear();
 
 
  146PetscErrorCode 
KspRhs(KSP ksp, Vec f, 
void *ctx) {
 
  149  PetscLogEventBegin(ksp_ctx->MOFEM_EVENT_KspRhs, 0, 0, 0, 0);
 
  151  ksp_ctx->vecAssembleSwitch = boost::movelib::make_unique<bool>(
true);
 
  153  auto cache_ptr = boost::make_shared<CacheTuple>();
 
  154  CHKERR ksp_ctx->mField.cache_problem_entities(ksp_ctx->problemName,
 
  157  auto set = [&](
auto &fe) {
 
  162    fe.cacheWeakPtr = cache_ptr;
 
  165  auto unset = [&](
auto &fe) {
 
  171  for (
auto &
bit : ksp_ctx->preProcessRhs) {
 
  172    bit->vecAssembleSwitch = boost::move(ksp_ctx->vecAssembleSwitch);
 
  174    CHKERR ksp_ctx->mField.problem_basic_method_preProcess(ksp_ctx->problemName,
 
  177    ksp_ctx->vecAssembleSwitch = boost::move(
bit->vecAssembleSwitch);
 
  181  for (
auto &lit : ksp_ctx->loopsRhs) {
 
  182    lit.second->vecAssembleSwitch = boost::move(ksp_ctx->vecAssembleSwitch);
 
  184    CHKERR ksp_ctx->mField.loop_finite_elements(ksp_ctx->problemName, lit.first,
 
  185                                                *(lit.second), 
nullptr,
 
  186                                                ksp_ctx->bH, cache_ptr);
 
  188    ksp_ctx->vecAssembleSwitch = boost::move(lit.second->vecAssembleSwitch);
 
  192  for (
auto &
bit : ksp_ctx->postProcessRhs) {
 
  193    bit->vecAssembleSwitch = boost::move(ksp_ctx->vecAssembleSwitch);
 
  195    CHKERR ksp_ctx->mField.problem_basic_method_postProcess(
 
  196        ksp_ctx->problemName, *
bit);
 
  198    ksp_ctx->vecAssembleSwitch = boost::move(
bit->vecAssembleSwitch);
 
  201  if (*ksp_ctx->vecAssembleSwitch) {
 
  202    CHKERR VecGhostUpdateBegin(f, ADD_VALUES, SCATTER_REVERSE);
 
  203    CHKERR VecGhostUpdateEnd(f, ADD_VALUES, SCATTER_REVERSE);
 
  204    CHKERR VecAssemblyBegin(f);
 
  207  PetscLogEventEnd(ksp_ctx->MOFEM_EVENT_KspRhs, 0, 0, 0, 0);
 
 
  210PetscErrorCode 
KspMat(KSP ksp, Mat 
A, Mat 
B, 
void *ctx) {
 
  214  PetscLogEventBegin(ksp_ctx->MOFEM_EVENT_KspMat, 0, 0, 0, 0);
 
  216  ksp_ctx->matAssembleSwitch = boost::movelib::make_unique<bool>(
true);
 
  217  auto cache_ptr = boost::make_shared<CacheTuple>();
 
  218  CHKERR ksp_ctx->mField.cache_problem_entities(ksp_ctx->problemName,
 
  221  auto set = [&](
auto &fe) {
 
  227    fe.cacheWeakPtr = cache_ptr;
 
  230  auto unset = [&](
auto &fe) {
 
  235  auto ent_data_cache = boost::make_shared<std::vector<EntityCacheDofs>>();
 
  237      boost::make_shared<std::vector<EntityCacheNumeredDofs>>();
 
  239      boost::make_shared<std::vector<EntityCacheNumeredDofs>>();
 
  242  for (
auto &
bit : ksp_ctx->preProcessOperator) {
 
  243    bit->matAssembleSwitch = boost::move(ksp_ctx->matAssembleSwitch);
 
  245    CHKERR ksp_ctx->mField.problem_basic_method_preProcess(ksp_ctx->problemName,
 
  248    ksp_ctx->matAssembleSwitch = boost::move(
bit->matAssembleSwitch);
 
  252  for (
auto &lit : ksp_ctx->loopsOperator) {
 
  253    lit.second->matAssembleSwitch = boost::move(ksp_ctx->matAssembleSwitch);
 
  255    CHKERR ksp_ctx->mField.loop_finite_elements(ksp_ctx->problemName, lit.first,
 
  256                                                *(lit.second), 
nullptr,
 
  257                                                ksp_ctx->bH, cache_ptr);
 
  259    ksp_ctx->matAssembleSwitch = boost::move(lit.second->matAssembleSwitch);
 
  263  for (
auto &
bit : ksp_ctx->postProcessOperator) {
 
  264    bit->matAssembleSwitch = boost::move(ksp_ctx->matAssembleSwitch);
 
  266    CHKERR ksp_ctx->mField.problem_basic_method_postProcess(
 
  267        ksp_ctx->problemName, *
bit);
 
  269    ksp_ctx->matAssembleSwitch = boost::move(
bit->matAssembleSwitch);
 
  272  if (ksp_ctx->matAssembleSwitch) {
 
  273    CHKERR MatAssemblyBegin(
B, MAT_FINAL_ASSEMBLY);
 
  274    CHKERR MatAssemblyEnd(
B, MAT_FINAL_ASSEMBLY);
 
  276  PetscLogEventEnd(ksp_ctx->MOFEM_EVENT_KspMat, 0, 0, 0, 0);
 
 
MoFEMTypes
Those types control how functions respond on arguments, f.e. error handling.
#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.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
std::deque< BasicMethodPtr > BasicMethodsSequence
std::deque< PairNameFEMethodPtr > FEMethodsSequence
Deprecated interface functions.
MoFEM::Interface & mField
BasicMethodsSequence preProcessOperator
boost::movelib::unique_ptr< bool > matAssembleSwitch
BasicMethodsSequence & getPreProcSetOperators()
BasicMethodsSequence postProcessOperator
FEMethodsSequence loopsRhs
std::string problemName
Problem name.
FEMethodsSequence & getSetOperators()
PetscLogEvent MOFEM_EVENT_KspMat
MoFEMTypes bH
If set to MF_EXIST check if element exist.
FEMethodsSequence loopsOperator
BasicMethodsSequence & getPostProcComputeRhs()
FEMethodsSequence & getComputeRhs()
virtual ~KspCtxImpl()=default
BasicMethodsSequence postProcessRhs
boost::movelib::unique_ptr< bool > vecAssembleSwitch
PetscLogEvent MOFEM_EVENT_KspRhs
BasicMethodsSequence & getPostProcSetOperators()
BasicMethodsSequence preProcessRhs
BasicMethodsSequence & getPreProcComputeRhs()
Interface for linear (KSP) solver.
boost::movelib::unique_ptr< KspCtxImpl > kspCtxImpl
BasicMethodsSequence & getPostProcComputeRhs()
BasicMethodsSequence & getPreProcComputeRhs()
BasicMethodsSequence & getPreProcSetOperators()
FEMethodsSequence & getSetOperators()
friend PetscErrorCode KspRhs(KSP ksp, Vec f, void *ctx)
Run over elements in the lists.
FEMethodsSequence & getComputeRhs()
MoFEMErrorCode clearLoops()
Clear loops.
friend PetscErrorCode KspMat(KSP ksp, Mat A, Mat B, void *ctx)
Run over elements in the list.
BasicMethodsSequence & getPostProcSetOperators()
@ CTX_KSPNONE
No specific KSP context.
@ CTX_SETFUNCTION
Setting up the linear system function.
@ CTX_OPERATORS
Setting up linear operators.
static constexpr Switches CtxSetA
Jacobian matrix switch.
static constexpr Switches CtxSetNone
No data switch.
static constexpr Switches CtxSetF
Residual vector switch.
static constexpr Switches CtxSetB
Preconditioner matrix switch.