Testing gauss points coordinates and weights for a quad face.
#ifdef __cplusplus
extern "C" {
#endif
#include <cblas.h>
#ifdef __cplusplus
}
#endif
static char help[] =
"...\n\n";
int main(
int argc,
char *argv[]) {
try {
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
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);
}
if (fabs(20.0 - sum_coords) >
eps) {
"wrong result %3.4e", sum_coords);
}
if (fabs(1.0 - sum_gauss_pts) >
eps) {
"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);
}
if (fabs(54.0 - sum_coords) >
eps) {
"wrong result %3.4e", sum_coords);
}
if (fabs(1.0 - sum_gauss_pts) >
eps) {
"wrong result %3.4e", sum_gauss_pts);
}
};
auto test_refined_triangle = [&]() {
auto refine = Tools::refineTriangle(2);
auto new_gauss_pts = Tools::refineTriangleIntegrationPts(4, refine);
int new_nb_gauss_pts = new_gauss_pts.size2();
double sum_coords = 0, sum_gauss_pts = 0;
for (
int i = 0;
i < new_nb_gauss_pts; ++
i) {
sum_coords += new_gauss_pts(0,
i) + new_gauss_pts(1,
i);
sum_gauss_pts += new_gauss_pts(2,
i);
}
constexpr double eps = 1e-8;
<< "sum_gauss_pts " << sum_gauss_pts << endl;
MOFEM_LOG(
"WORLD", Sev::verbose) <<
"sum_coords " << sum_coords << endl;
if (fabs(64.0 - sum_coords) >
eps) {
"wrong result %3.4e", sum_coords);
}
if (fabs(1.0 - sum_gauss_pts) >
eps) {
"wrong result %3.4e", sum_gauss_pts);
}
constexpr bool debug =
false;
auto [nodes, triangles, level_index] = refine;
auto get_coords = [&](
auto t) {
auto [nodes, triangles, level_index] = refine;
std::array<double, 9> ele_coords;
for (
auto n : {0, 1, 2}) {
ele_coords[3 *
n +
i] = nodes[2 * triangles[6 *
t +
n] +
i];
}
ele_coords[3 *
n + 2] = 0;
}
return ele_coords;
};
moab::Core mb_instance;
moab::Interface &moab = mb_instance;
for (
auto t = level_index[level_index.size() - 2];
t != level_index.back(); ++
t) {
std::array<EntityHandle, 3> conn;
auto ele_coords = get_coords(
t);
for (
auto n : {0, 1, 2}) {
CHKERR moab.create_vertex(&ele_coords[3 *
n], conn[
n]);
<< ele_coords[3 *
n] <<
" " << ele_coords[3 *
n + 1] <<
" "
<< ele_coords[3 *
n + 2];
}
<< triangles[6 *
t + 0] <<
" " << triangles[6 *
t + 1] <<
" "
<< triangles[6 *
t + 2] << std::endl;
CHKERR moab.create_element(MBTRI, conn.data(), 3, tri);
}
for (
int i = 0;
i < new_nb_gauss_pts; ++
i) {
std::array<double, 3> coords{new_gauss_pts(0,
i), new_gauss_pts(1,
i),
0};
CHKERR moab.create_vertex(coords.data(), node);
}
CHKERR moab.write_file(
"gauss_refine.vtk",
"VTK",
"");
}
};
CHKERR test_refined_triangle();
}
}
#define CATCH_ERRORS
Catch errors.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
const double n
refractive index of diffusive medium
implementation of Data Operators for Forces and Sources
constexpr double t
plate stiffness
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.