v0.13.2
Loading...
Searching...
No Matches
gauss_points_on_outer_product.cpp
Go to the documentation of this file.
1/** \file gauss_points_on_outer_product.cpp
2 \example gauss_points_on_outer_product.cpp
3 \brief Testing gauss points coordinates and weights for a quad face
4
5*/
6
7
8
9#include <MoFEM.hpp>
10
11using namespace MoFEM;
12static char help[] = "...\n\n";
13
14int main(int argc, char *argv[]) {
15
16 MoFEM::Core::Initialize(&argc, &argv, (char *)0, help);
17 try {
18 moab::Core mb_instance;
19 moab::Interface &moab = mb_instance;
20 MoFEM::Core core(moab);
21
22 auto test_quad = [&]() {
24 MatrixDouble pts_quad;
25 int rule_ksi = 6;
26 int rule_eta = 8;
28 rule_eta);
29 int nb_gauss_pts = pts_quad.size2();
30 double sum_coords = 0, sum_gauss_pts = 0;
31 for (int i = 0; i < nb_gauss_pts; ++i) {
32 sum_coords += pts_quad(0, i) + pts_quad(1, i);
33 sum_gauss_pts += pts_quad(2, i);
34 }
35 double eps = 1e-8;
36 if (fabs(20.0 - sum_coords) > eps) {
37 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
38 "wrong result %3.4e", sum_coords);
39 }
40 if (fabs(1.0 - sum_gauss_pts) > eps) {
41 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
42 "wrong result %3.4e", sum_gauss_pts);
43 }
45 };
46
47 auto test_hex = [&]() {
49 MatrixDouble pts_quad;
50 int rule_ksi = 4;
51 int rule_eta = 5;
52 int rule_zet = 6;
54 rule_eta, rule_zet);
55 int nb_gauss_pts = pts_quad.size2();
56 double sum_coords = 0, sum_gauss_pts = 0;
57 for (int i = 0; i < nb_gauss_pts; ++i) {
58 sum_coords += pts_quad(0, i) + pts_quad(1, i) + pts_quad(2, i);
59 sum_gauss_pts += pts_quad(3, i);
60 }
61 double eps = 1e-8;
62 if (fabs(54.0 - sum_coords) > eps) {
63 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
64 "wrong result %3.4e", sum_coords);
65 }
66 if (fabs(1.0 - sum_gauss_pts) > eps) {
67 SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
68 "wrong result %3.4e", sum_gauss_pts);
69 }
71 };
72
73 CHKERR test_quad();
74 CHKERR test_hex();
75 }
77
79}
int main()
Definition: adol-c_atom.cpp:46
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
static char help[]
FTensor::Index< 'i', SPACE_DIM > i
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
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
static MoFEMErrorCode outerProductOfEdgeIntegrationPtsForQuad(MatrixDouble &pts, const int edge0, const int edge1)
Definition: Tools.cpp:579
static MoFEMErrorCode outerProductOfEdgeIntegrationPtsForHex(MatrixDouble &pts, const int edge0, const int edge1, const int edge2)
Definition: Tools.cpp:628