v0.14.0
Public Member Functions | Public Attributes | List of all members
MoFEM::PCMGSetUpViaApproxOrdersCtx Struct Reference
Collaboration diagram for MoFEM::PCMGSetUpViaApproxOrdersCtx:
[legend]

Public Member Functions

 PCMGSetUpViaApproxOrdersCtx (DM dm, Mat a, bool shell_sub_a)
 
virtual ~PCMGSetUpViaApproxOrdersCtx ()=default
 
virtual MoFEMErrorCode getOptions ()
 get options from line command More...
 
virtual MoFEMErrorCode createIsAtLevel (int kk, IS *is)
 Set IS for levels. More...
 
virtual MoFEMErrorCode destroyIsAtLevel (int kk, IS *is)
 Destroy IS if internally created. More...
 
virtual MoFEMErrorCode buildProlongationOperator (bool use_mat_a, int verb=0)
 Set up data structures for MG. More...
 

Public Attributes

DM dM
 Distributed mesh manager. More...
 
Mat A
 Matrix at fine level. More...
 
int nbLevels
 number of multi-grid levels More...
 
int coarseOrder
 approximation order of coarse level More...
 
int orderAtLastLevel
 set maximal evaluated order More...
 
bool shellSubA
 
int verboseLevel
 

Detailed Description

Definition at line 92 of file PCMGSetUpViaApproxOrders.cpp.

Constructor & Destructor Documentation

◆ PCMGSetUpViaApproxOrdersCtx()

MoFEM::PCMGSetUpViaApproxOrdersCtx::PCMGSetUpViaApproxOrdersCtx ( DM  dm,
Mat  a,
bool  shell_sub_a 
)
inline

Definition at line 94 of file PCMGSetUpViaApproxOrders.cpp.

95  : dM(dm), A(a), nbLevels(2), coarseOrder(2), orderAtLastLevel(1000),
96  shellSubA(shell_sub_a), verboseLevel(0) {}

◆ ~PCMGSetUpViaApproxOrdersCtx()

virtual MoFEM::PCMGSetUpViaApproxOrdersCtx::~PCMGSetUpViaApproxOrdersCtx ( )
virtualdefault

Member Function Documentation

◆ buildProlongationOperator()

MoFEMErrorCode MoFEM::PCMGSetUpViaApproxOrdersCtx::buildProlongationOperator ( bool  use_mat_a,
int  verb = 0 
)
virtual

Set up data structures for MG.

Parameters
pcMG pre-conditioner http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/PC/PCMG.html
verbverbosity level
Returns
error code

Definition at line 567 of file PCMGSetUpViaApproxOrders.cpp.

568  {
570  verb = verb > verboseLevel ? verb : verboseLevel;
571 
572  MPI_Comm comm;
573  CHKERR PetscObjectGetComm((PetscObject)dM, &comm);
574 
575  MOFEM_LOG_C("PCMGViaApproximationOrders", Sev::inform, "set MG levels %u\n",
576  nbLevels);
577 
578  MOFEM_LOG_CHANNEL("SYNC");
579  MOFEM_LOG_TAG("SYNC", "PCMGViaApproximationOrders")
580 
581  std::vector<IS> is_vec(nbLevels + 1);
582  std::vector<int> is_glob_size(nbLevels + 1), is_loc_size(nbLevels + 1);
583 
584  for (int kk = 0; kk < nbLevels; kk++) {
585 
586  // get indices up to up to give approximation order
587  CHKERR createIsAtLevel(kk, &is_vec[kk]);
588  CHKERR ISGetSize(is_vec[kk], &is_glob_size[kk]);
589  CHKERR ISGetLocalSize(is_vec[kk], &is_loc_size[kk]);
590 
591  MOFEM_LOG_C("SYNC", Sev::inform,
592  "Nb. dofs at level [ %d ] global %u local %d\n", kk,
593  is_glob_size[kk], is_loc_size[kk]);
594 
595  // if no dofs on level kk finish here
596  if (is_glob_size[kk] == 0) {
597  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "no dofs at level");
598  }
599  }
600 
601  for (int kk = 0; kk != nbLevels; kk++) {
602  if (kk == nbLevels - 1 && use_mat_a) {
604  false);
605  } else {
606  if (kk > 0) {
607  // Not coarse level
609  shellSubA);
610  } else {
611  // Coarse lave is compressed matrix allowing for factorization when
612  // needed
614  false);
615  }
616  }
617  }
618 
619  for (unsigned int kk = 0; kk < is_vec.size(); kk++) {
620  CHKERR destroyIsAtLevel(kk, &is_vec[kk]);
621  }
622 
623  MOFEM_LOG_SEVERITY_SYNC(comm, Sev::inform);
624  MOFEM_LOG_CHANNEL("SYNC");
625 
627 }

◆ createIsAtLevel()

MoFEMErrorCode MoFEM::PCMGSetUpViaApproxOrdersCtx::createIsAtLevel ( int  kk,
IS *  is 
)
virtual

Set IS for levels.

Parameters
kklevel
ispointer to IS
Returns
error code

Definition at line 533 of file PCMGSetUpViaApproxOrders.cpp.

533  {
534  MoFEM::Interface *m_field_ptr;
535  MoFEM::ISManager *is_manager_ptr;
537  // if is last level, take all remaining orders dofs, if any left
538  CHKERR DMoFEMGetInterfacePtr(dM, &m_field_ptr);
539  CHKERR m_field_ptr->getInterface(is_manager_ptr);
540  const Problem *problem_ptr;
541  CHKERR DMMoFEMGetProblemPtr(dM, &problem_ptr);
542  int order_at_next_level = kk + coarseOrder;
543  if (kk == nbLevels - 1) {
544  int first = problem_ptr->getNumeredRowDofsPtr()
545  ->get<PetscGlobalIdx_mi_tag>()
546  .lower_bound(0)
547  ->get()
548  ->getPetscGlobalDofIdx();
549  CHKERR ISCreateStride(PETSC_COMM_WORLD, problem_ptr->getNbLocalDofsRow(),
550  first, 1, is);
552  // order_at_next_level = orderAtLastLevel;
553  }
554  string problem_name = problem_ptr->getName();
555  CHKERR is_manager_ptr->isCreateProblemOrder(problem_name, ROW, 0,
556  order_at_next_level, is);
558 }

◆ destroyIsAtLevel()

MoFEMErrorCode MoFEM::PCMGSetUpViaApproxOrdersCtx::destroyIsAtLevel ( int  kk,
IS *  is 
)
virtual

Destroy IS if internally created.

Parameters
kklevel
ispointer to is
Returns
error code

Definition at line 560 of file PCMGSetUpViaApproxOrders.cpp.

560  {
562  CHKERR ISDestroy(is);
564 }

◆ getOptions()

MoFEMErrorCode MoFEM::PCMGSetUpViaApproxOrdersCtx::getOptions ( )
virtual

get options from line command

Returns
error code

Definition at line 508 of file PCMGSetUpViaApproxOrders.cpp.

508  {
510  ierr = PetscOptionsBegin(PETSC_COMM_WORLD, "",
511  "MOFEM Multi-Grid (Orders) pre-conditioner", "none");
512  CHKERRG(ierr);
513 
514  CHKERR PetscOptionsInt("-mofem_mg_levels", "nb levels of multi-grid solver",
515  "", 2, &nbLevels, PETSC_NULL);
516  CHKERR PetscOptionsInt("-mofem_mg_coarse_order",
517  "approximation order of coarse level", "", 2,
518  &coarseOrder, PETSC_NULL);
519  CHKERR PetscOptionsInt("-mofem_mg_order_at_last_level", "order at last level",
520  "", 100, &orderAtLastLevel, PETSC_NULL);
521  CHKERR PetscOptionsInt("-mofem_mg_verbose", "nb levels of multi-grid solver",
522  "", 0, &verboseLevel, PETSC_NULL);
523  PetscBool shell_sub_a = shellSubA ? PETSC_TRUE : PETSC_FALSE;
524  CHKERR PetscOptionsBool("-mofem_mg_shell_a", "use shell matrix as sub matrix",
525  "", shell_sub_a, &shell_sub_a, NULL);
526  shellSubA = (shellSubA == PETSC_TRUE);
527 
528  ierr = PetscOptionsEnd();
529  CHKERRG(ierr);
531 }

Member Data Documentation

◆ A

Mat MoFEM::PCMGSetUpViaApproxOrdersCtx::A

Matrix at fine level.

Definition at line 133 of file PCMGSetUpViaApproxOrders.cpp.

◆ coarseOrder

int MoFEM::PCMGSetUpViaApproxOrdersCtx::coarseOrder

approximation order of coarse level

Definition at line 136 of file PCMGSetUpViaApproxOrders.cpp.

◆ dM

DM MoFEM::PCMGSetUpViaApproxOrdersCtx::dM

Distributed mesh manager.

Definition at line 132 of file PCMGSetUpViaApproxOrders.cpp.

◆ nbLevels

int MoFEM::PCMGSetUpViaApproxOrdersCtx::nbLevels

number of multi-grid levels

Definition at line 135 of file PCMGSetUpViaApproxOrders.cpp.

◆ orderAtLastLevel

int MoFEM::PCMGSetUpViaApproxOrdersCtx::orderAtLastLevel

set maximal evaluated order

Definition at line 137 of file PCMGSetUpViaApproxOrders.cpp.

◆ shellSubA

bool MoFEM::PCMGSetUpViaApproxOrdersCtx::shellSubA

Definition at line 139 of file PCMGSetUpViaApproxOrders.cpp.

◆ verboseLevel

int MoFEM::PCMGSetUpViaApproxOrdersCtx::verboseLevel

Definition at line 140 of file PCMGSetUpViaApproxOrders.cpp.


The documentation for this struct was generated from the following file:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
MoFEM::PCMGSetUpViaApproxOrdersCtx::destroyIsAtLevel
virtual MoFEMErrorCode destroyIsAtLevel(int kk, IS *is)
Destroy IS if internally created.
Definition: PCMGSetUpViaApproxOrders.cpp:560
MOFEM_LOG_SEVERITY_SYNC
#define MOFEM_LOG_SEVERITY_SYNC(comm, severity)
Synchronise "SYNC" on curtain severity level.
Definition: LogManager.hpp:352
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEM::PCMGSetUpViaApproxOrdersCtx::nbLevels
int nbLevels
number of multi-grid levels
Definition: PCMGSetUpViaApproxOrders.cpp:135
MoFEM::PCMGSetUpViaApproxOrdersCtx::dM
DM dM
Distributed mesh manager.
Definition: PCMGSetUpViaApproxOrders.cpp:132
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
ROW
@ ROW
Definition: definitions.h:136
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::ISManager
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
a
constexpr double a
Definition: approx_sphere.cpp:30
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
MoFEM::PCMGSetUpViaApproxOrdersCtx::A
Mat A
Matrix at fine level.
Definition: PCMGSetUpViaApproxOrders.cpp:133
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
MoFEM::PCMGSetUpViaApproxOrdersCtx::verboseLevel
int verboseLevel
Definition: PCMGSetUpViaApproxOrders.cpp:140
MoFEM::PCMGSetUpViaApproxOrdersCtx::shellSubA
bool shellSubA
Definition: PCMGSetUpViaApproxOrders.cpp:139
std
Definition: enable_if.hpp:5
MoFEM::DMoFEMGetInterfacePtr
PetscErrorCode DMoFEMGetInterfacePtr(DM dm, MoFEM::Interface **m_field_ptr)
Get pointer to MoFEM::Interface.
Definition: DMMoFEM.cpp:414
MoFEM::PCMGSetUpViaApproxOrdersCtx::orderAtLastLevel
int orderAtLastLevel
set maximal evaluated order
Definition: PCMGSetUpViaApproxOrders.cpp:137
MoFEM::Exceptions::ierr
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::DMMoFEMGetProblemPtr
PetscErrorCode DMMoFEMGetProblemPtr(DM dm, const MoFEM::Problem **problem_ptr)
Get pointer to problem data structure.
Definition: DMMoFEM.cpp:426
MoFEM::DMMGViaApproxOrdersPushBackCoarseningIS
MoFEMErrorCode DMMGViaApproxOrdersPushBackCoarseningIS(DM dm, IS is, Mat A, bool create_sub_matrix, bool shell_sub_a)
Push back coarsening level to MG via approximation orders.
Definition: PCMGSetUpViaApproxOrders.cpp:227
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
MoFEM::ISManager::isCreateProblemOrder
MoFEMErrorCode isCreateProblemOrder(const std::string problem_name, RowColData rc, int min_order, int max_order, IS *is) const
create IS for given order range (collective)
Definition: ISManager.cpp:204
MoFEM::PCMGSetUpViaApproxOrdersCtx::coarseOrder
int coarseOrder
approximation order of coarse level
Definition: PCMGSetUpViaApproxOrders.cpp:136
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEM::PCMGSetUpViaApproxOrdersCtx::createIsAtLevel
virtual MoFEMErrorCode createIsAtLevel(int kk, IS *is)
Set IS for levels.
Definition: PCMGSetUpViaApproxOrders.cpp:533
CHKERRG
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:496
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359