v0.14.0
Public Member Functions | Private Attributes | List of all members
PoissonExample::AuxFunctions Struct Reference

#include <tutorials/cor-2to5/src/AuxPoissonFunctions.hpp>

Collaboration diagram for PoissonExample::AuxFunctions:
[legend]

Public Member Functions

 AuxFunctions (const MoFEM::Interface &m_field)
 
MoFEMErrorCode createGhostVec (Vec *ghost_vec) const
 
MoFEMErrorCode assembleGhostVector (Vec ghost_vec) const
 Assemble error vector. More...
 
MoFEMErrorCode printError (Vec ghost_vec)
 Print error. More...
 
MoFEMErrorCode testError (Vec ghost_vec)
 Test error. More...
 

Private Attributes

MPI_Comm cOmm
 
const int rAnk
 

Detailed Description

Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, and analytical_poisson_field_split.cpp.

Definition at line 14 of file AuxPoissonFunctions.hpp.

Constructor & Destructor Documentation

◆ AuxFunctions()

PoissonExample::AuxFunctions::AuxFunctions ( const MoFEM::Interface m_field)
inline
Examples
AuxPoissonFunctions.hpp.

Definition at line 16 of file AuxPoissonFunctions.hpp.

17  : cOmm(m_field.get_comm()), rAnk(m_field.get_comm_rank()) {}

Member Function Documentation

◆ assembleGhostVector()

MoFEMErrorCode PoissonExample::AuxFunctions::assembleGhostVector ( Vec  ghost_vec) const
inline

Assemble error vector.

Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, and AuxPoissonFunctions.hpp.

Definition at line 43 of file AuxPoissonFunctions.hpp.

43  {
44 
46  CHKERR VecAssemblyBegin(ghost_vec);
47  CHKERR VecAssemblyEnd(ghost_vec);
48  // accumulate errors from processors
49  CHKERR VecGhostUpdateBegin(ghost_vec, ADD_VALUES, SCATTER_REVERSE);
50  CHKERR VecGhostUpdateEnd(ghost_vec, ADD_VALUES, SCATTER_REVERSE);
51  // scatter errors to all processors
52  CHKERR VecGhostUpdateBegin(ghost_vec, INSERT_VALUES, SCATTER_FORWARD);
53  CHKERR VecGhostUpdateEnd(ghost_vec, INSERT_VALUES, SCATTER_FORWARD);
55  }

◆ createGhostVec()

MoFEMErrorCode PoissonExample::AuxFunctions::createGhostVec ( Vec *  ghost_vec) const
inline

Create ghost vector to assemble errors from all element on distributed mesh. Ghost vector has size 1, where one element is owned by processor 0, other processor have one ghost element of zero element at processor 0.

[createGhostVec description]

Parameters
ghost_vecpointer to created ghost vector
Returns
error code
Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, and AuxPoissonFunctions.hpp.

Definition at line 30 of file AuxPoissonFunctions.hpp.

30  {
31 
33  int ghosts[] = {0};
34  int nb_locals = rAnk == 0 ? 1 : 0;
35  int nb_ghosts = rAnk > 0 ? 1 : 0;
36  CHKERR VecCreateGhost(cOmm, nb_locals, 1, nb_ghosts, ghosts, ghost_vec);
38  }

◆ printError()

MoFEMErrorCode PoissonExample::AuxFunctions::printError ( Vec  ghost_vec)
inline

Print error.

Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, and AuxPoissonFunctions.hpp.

Definition at line 60 of file AuxPoissonFunctions.hpp.

60  {
61 
63  double *e;
64  CHKERR VecGetArray(ghost_vec, &e);
65  CHKERR PetscPrintf(cOmm, "Approximation error %4.3e\n", sqrt(e[0]));
66  CHKERR VecRestoreArray(ghost_vec, &e);
68  }

◆ testError()

MoFEMErrorCode PoissonExample::AuxFunctions::testError ( Vec  ghost_vec)
inline

Test error.

Examples
analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, and AuxPoissonFunctions.hpp.

Definition at line 73 of file AuxPoissonFunctions.hpp.

73  {
74 
76  double *e;
77  CHKERR VecGetArray(ghost_vec, &e);
78  // Check if error is zero, otherwise throw error
79  const double eps = 1e-8;
80  if ((sqrt(e[0]) > eps) || (!boost::math::isnormal(e[0]))) {
81  SETERRQ(PETSC_COMM_SELF, MOFEM_ATOM_TEST_INVALID,
82  "Test failed, error too big");
83  }
84  CHKERR VecRestoreArray(ghost_vec, &e);
86  }

Member Data Documentation

◆ cOmm

MPI_Comm PoissonExample::AuxFunctions::cOmm
private
Examples
AuxPoissonFunctions.hpp.

Definition at line 89 of file AuxPoissonFunctions.hpp.

◆ rAnk

const int PoissonExample::AuxFunctions::rAnk
private
Examples
AuxPoissonFunctions.hpp.

Definition at line 90 of file AuxPoissonFunctions.hpp.


The documentation for this struct was generated from the following file:
PoissonExample::AuxFunctions::rAnk
const int rAnk
Definition: AuxPoissonFunctions.hpp:90
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
MoFEM::CoreInterface::get_comm_rank
virtual int get_comm_rank() const =0
PoissonExample::AuxFunctions::cOmm
MPI_Comm cOmm
Definition: AuxPoissonFunctions.hpp:89
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
eps
static const double eps
Definition: check_base_functions_derivatives_on_tet.cpp:11
MOFEM_ATOM_TEST_INVALID
@ MOFEM_ATOM_TEST_INVALID
Definition: definitions.h:40
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359