v0.13.1
gauss_points_on_outer_product.cpp

Testing gauss points coordinates and weights for a quad face.

Testing gauss points coordinates and weights for a quad face

/** \file gauss_points_on_outer_product.cpp
\example gauss_points_on_outer_product.cpp
\brief Testing gauss points coordinates and weights for a quad face
*/
#include <MoFEM.hpp>
using namespace MoFEM;
static char help[] = "...\n\n";
int main(int argc, char *argv[]) {
MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
try {
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
MoFEM::Core core(moab);
auto test_quad = [&]() {
MatrixDouble pts_quad;
int rule_ksi = 6;
int rule_eta = 8;
CHKERR Tools::outerProductOfEdgeIntegrationPtsForQuad(pts_quad, rule_ksi,
rule_eta);
int nb_gauss_pts = pts_quad.size2();
double sum_coords = 0, sum_gauss_pts = 0;
for (int i = 0; i < nb_gauss_pts; ++i) {
sum_coords += pts_quad(0, i) + pts_quad(1, i);
sum_gauss_pts += pts_quad(2, i);
}
double eps = 1e-8;
if (fabs(20.0 - sum_coords) > eps) {
SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
"wrong result %3.4e", sum_coords);
}
if (fabs(1.0 - sum_gauss_pts) > eps) {
SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
"wrong result %3.4e", sum_gauss_pts);
}
};
auto test_hex = [&]() {
MatrixDouble pts_quad;
int rule_ksi = 4;
int rule_eta = 5;
int rule_zet = 6;
CHKERR Tools::outerProductOfEdgeIntegrationPtsForHex(pts_quad, rule_ksi,
rule_eta, rule_zet);
int nb_gauss_pts = pts_quad.size2();
double sum_coords = 0, sum_gauss_pts = 0;
for (int i = 0; i < nb_gauss_pts; ++i) {
sum_coords += pts_quad(0, i) + pts_quad(1, i) + pts_quad(2, i);
sum_gauss_pts += pts_quad(3, i);
}
double eps = 1e-8;
if (fabs(54.0 - sum_coords) > eps) {
SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
"wrong result %3.4e", sum_coords);
}
if (fabs(1.0 - sum_gauss_pts) > eps) {
SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
"wrong result %3.4e", sum_gauss_pts);
}
};
CHKERR test_quad();
CHKERR test_hex();
}
}
static const double eps
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:372
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
int main(int argc, char *argv[])
static char help[]
FTensor::Index< 'i', SPACE_DIM > i
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
implementation of Data Operators for Forces and Sources
Definition: MoFEM.hpp:24
CoreTmp< 0 > Core
Definition: Core.hpp:1086
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1955
Core (interface) class.
Definition: Core.hpp:82
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:72
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:112