HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
tetra_quad.hpp
Go to the documentation of this file.
1 /*
2  CREDITS:
3  Gianmarco Manzini
4  IMATI-CNR
5  via Ferrata 1
6  27100 Pavia
7 
8  DATE: Nov 29, 2008
9 
10  SEPARATE hpp/cpp implementation by Jerome Droniou (jerome.droniou@monash.edu)
11 
12  PREVIOUS CREDITS: this set of routines is a C++ re-implementation of
13  part of John Burkardt's software for geometric calculations (2005), which
14  is freely available on Internet (see his homepage)
15 
16  COPY-LEFT: Feel free to use this software under GNU Public Licence (GPL) terms.
17 */
18 
19 #ifndef _TETRA_QUAD_HPP
20 #define _TETRA_QUAD_HPP
21 
22 #include <cassert>
23 #include <cmath>
24 #include <ctime>
25 #include <cstdlib>
26 
27 #include <iostream>
28 #include <iomanip>
29 
30 namespace HArDCore3D {
31 
37 // -------------------------------------------------------------------------------------------
38 // Volume of a tetrahedron in 3D.
39 // input : ( x[0:3], y[0:3], z[0:3] ) coordinates of the tetrahedron vertices.
40 double tetra_volume(double x[4], double y[4], double z[4]);
41 
42 // -------------------------------------------------------------------------------------------
43 // Apply a quadrature rule in a GENERIC tetrahedron
44 // func ( double x, double y, double z ), the function to be integrated.
45 // x[0:3], y[0:3], z[0:3], the coordinates of the tetrahedron vertices.
46 // nq, the number of quadrature nodes
47 // cq0[0:nq-1], cq1[0:nq-1], cq2[0:nq-1], the first three barycentric coordinates of the quad nodes
48 double tetra_sum(double func(double x, double y, double z),
49  double x[4], double y[4], double z[4],
50  int nq, double cq0[], double cq1[], double cq2[], double wq[]);
51 
52 // -------------------------------------------------------------------------------------------
53 // Given the unit tetrahedron { (x,y,z) | 0<=x && 0<=y && 0<=z && x+y+z<=1 }, it sets
54 // - cq0, cq1, cq2, the first three barycentric coordinates of the quadrature nodes
55 // - wq, the weights the weights of the quadrature nodes
56 // - nq, the number of nodes
57 //
58 // References:
59 //
60 // Hermann Engels,
61 // Numerical Quadrature and Cubature,
62 // Academic Press, 1980,
63 //
64 // Patrick Keast,
65 // Moderate Degree Tetrahedral Quadrature Formulas,
66 // Computer Methods in Applied Mechanics and Engineering,
67 // Volume 55, Number 3, May 1986, pages 339-348.
68 //
69 // Olgierd Zienkiewicz,
70 // The Finite Element Method,
71 // Sixth Edition,
72 // Butterworth-Heinemann, 2005,
73 //
74 size_t tetra_unit_size(size_t rule);
75 
76 void tetra_unit_set(size_t rule, size_t nq, double cq0[], double cq1[], double cq2[], double wq[]);
77 
78 // -------------------------------------------------------------------------------------------
79 // Volume of a (3D) parallelipiped
80 // input: ( x[0:3], y[0:3], z[0:3] ) coordinates of one corner and
81 // its three immediate neighbors.
82 double parallelipiped_volume_3d(double x[4], double y[4], double z[4]);
83 
84 // -------------------------------------------------------------------------------------------
85 // Volume of the 3D unit tetrahedron: { (x,y,z) | 0<=x && 0<=y && 0<=z && x+y+z<=1 }
86 double tetra_unit_volume();
87 
88 // -------------------------------------------------------------------------------------------
89 // Apply a quadrature rule to func(x,y,z) in the UNIT tetrahedron.
90 // func(x,y,z) : the function to be integrated
91 // nq : the number of nodes
92 // xq[iq],yq[iq],zq[iq] : the coordinates of the quad node iq=0..nq-1
93 // wq[iq] : the weight of the quad node iq=0..nq-1
94 double tetra_unit_sum(double func(double x, double y, double z),
95  size_t nq, double xq[], double yq[], double zq[], double wq[]);
96 
97 } // end of namespace HArDCore3D
98 
99 #endif // end of _TETRA_QUAD_HPP
size_t tetra_unit_size(size_t rule)
Definition: tetra_quad.cpp:63
double parallelipiped_volume_3d(double x[4], double y[4], double z[4])
Definition: tetra_quad.cpp:24
void tetra_unit_set(size_t rule, size_t nq, double cq0[], double cq1[], double cq2[], double wq[])
Definition: tetra_quad.cpp:148
double tetra_unit_sum(double func(double x, double y, double z), size_t nq, double xq[], double yq[], double zq[], double wq[])
Definition: tetra_quad.cpp:54
double tetra_volume(double x[4], double y[4], double z[4])
Definition: tetra_quad.cpp:36
double tetra_unit_volume()
Definition: tetra_quad.cpp:34
Definition: ddr-magnetostatics.hpp:40
double tetra_sum(double func(double x, double y, double z), double x[4], double y[4], double z[4], size_t nq, double cq0[], double cq1[], double cq2[], double wq[])
Definition: tetra_quad.cpp:40