9 #ifndef ___AUX_FUNCTIONS_HPP__
10 #define ___AUX_FUNCTIONS_HPP__
17 :
cOmm(m_field.get_comm()),
rAnk(m_field.get_comm_rank()) {}
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);
46 CHKERR VecAssemblyBegin(ghost_vec);
47 CHKERR VecAssemblyEnd(ghost_vec);
49 CHKERR VecGhostUpdateBegin(ghost_vec, ADD_VALUES, SCATTER_REVERSE);
50 CHKERR VecGhostUpdateEnd(ghost_vec, ADD_VALUES, SCATTER_REVERSE);
52 CHKERR VecGhostUpdateBegin(ghost_vec, INSERT_VALUES, SCATTER_FORWARD);
53 CHKERR VecGhostUpdateEnd(ghost_vec, INSERT_VALUES, SCATTER_FORWARD);
64 CHKERR VecGetArray(ghost_vec, &e);
65 CHKERR PetscPrintf(
cOmm,
"Approximation error %4.3e\n", sqrt(e[0]));
66 CHKERR VecRestoreArray(ghost_vec, &e);
77 CHKERR VecGetArray(ghost_vec, &e);
79 const double eps = 1e-8;
80 if ((sqrt(e[0]) >
eps) || (!boost::math::isnormal(e[0]))) {
82 "Test failed, error too big");
84 CHKERR VecRestoreArray(ghost_vec, &e);
95 #endif //___AUX_FUNCTIONS_HPP__