HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
quad3d.hpp
Go to the documentation of this file.
1 # ifndef _QUADTD_HPP
2 # define _QUADTD_HPP
3 
4 /*
5 
6  1) Classes implementing some (most used) quadrature formulas on tetrahedra
7 
8  2) This implementation does not require any specific mesh structures, but
9  only arrays of coordinates of triangles vertices given as double[].
10 
11 */
12 
13 #include <cassert>
14 #include <cmath>
15 
16 #include <algorithm>
17 #include <array>
18 #include <iostream>
19 #include <vector>
20 
21 #include <tetra_quad.hpp>
22 
23 
24 /*
25 
26  cq0[0..nqn-1], barycentric coordinates of tetrahedron's vertices V0,V1,V2,V3
27  cq1[0..nqn-1],
28  cq2[0..nqn-1],
29  cq3[0..nqn-1],
30 
31  cqw[0..nqn-1], weights
32 
33 */
34 
35 namespace HArDCore3D {
36 
43 protected:
44  static constexpr size_t num_rules = 15;
45 
46  const size_t rule;
47  const size_t nqn;
48 
49  double vol_T;
50 
51  std::vector<double> xV, yV, zV;
52  std::vector<double> cq0, cq1, cq2, cq3, cwq;
53 
54  void init();
55 
57 
58  size_t required_rule(size_t doe) const;
59 
60 public:
61 
63 
65  QuadRuleTetra(size_t doe, bool warn);
66 
67  QuadRuleTetra(size_t _rule = 0);
68 
69  inline size_t nq() const;
70 
71  inline double xq(int iq) const;
72 
73  inline double yq(int iq) const;
74 
75  inline double zq(int iq) const;
76 
77  inline double wq(int iq) const;
78 
79 
80  void setup(double (&_xV)[4], double (&_yV)[4], double (&_zV)[4]);
81 
82  void get_quadrule(int iq, double &_xq, double &_yq, double &_zq, double &_wq) const;
83 
84 };
85 // --------------------------------------------------------------------------------------------
86 
87 inline size_t QuadRuleTetra::nq() const { return nqn; }
88 
89 inline double QuadRuleTetra::xq(int iq) const { return cq0[iq] * xV[0] + cq1[iq] * xV[1] + cq2[iq] * xV[2] + cq3[iq] * xV[3]; }
90 
91 inline double QuadRuleTetra::yq(int iq) const { return cq0[iq] * yV[0] + cq1[iq] * yV[1] + cq2[iq] * yV[2] + cq3[iq] * yV[3]; }
92 
93 inline double QuadRuleTetra::zq(int iq) const { return cq0[iq] * zV[0] + cq1[iq] * zV[1] + cq2[iq] * zV[2] + cq3[iq] * zV[3]; }
94 
95 inline double QuadRuleTetra::wq(int iq) const { return cwq[iq] * vol_T; }
96 
98 } // end of namespace HArDCore3D
99 
100 #endif // end of _QUADTD_HPP
Definition: quad3d.hpp:42
std::vector< double > cq2
Definition: quad3d.hpp:52
void get_quadrule(int iq, double &_xq, double &_yq, double &_zq, double &_wq) const
Definition: quad3d.cpp:79
double yq(int iq) const
Definition: quad3d.hpp:91
const size_t rule
Definition: quad3d.hpp:46
double zq(int iq) const
Definition: quad3d.hpp:93
std::vector< double > cwq
Definition: quad3d.hpp:52
std::vector< double > cq1
Definition: quad3d.hpp:52
std::vector< double > xV
Definition: quad3d.hpp:51
std::vector< double > cq3
Definition: quad3d.hpp:52
double vol_T
Definition: quad3d.hpp:49
std::vector< double > zV
Definition: quad3d.hpp:51
void setup(double(&_xV)[4], double(&_yV)[4], double(&_zV)[4])
Definition: quad3d.cpp:72
QuadRuleTetra(size_t doe, bool warn)
Create a quadrature rule with at least the given degree of exactness (if available).
Definition: quad3d.cpp:28
size_t required_rule(size_t doe) const
Compute the minimum rule required to achieve the desired degree of exactness.
Definition: quad3d.cpp:64
static constexpr size_t num_rules
Definition: quad3d.hpp:44
size_t nq() const
Definition: quad3d.hpp:87
double xq(int iq) const
Definition: quad3d.hpp:89
const size_t nqn
Definition: quad3d.hpp:47
std::vector< double > cq0
Definition: quad3d.hpp:52
double wq(int iq) const
Definition: quad3d.hpp:95
void init()
Definition: quad3d.cpp:46
std::vector< double > yV
Definition: quad3d.hpp:51
Definition: ddr-magnetostatics.hpp:40