PISM, A Parallel Ice Sheet Model  stable v2.1.1 committed by Constantine Khrulev on 2024-12-04 13:36:58 -0900
Quadrature.hh
Go to the documentation of this file.
1 /* Copyright (C) 2020 PISM Authors
2  *
3  * This file is part of PISM.
4  *
5  * PISM is free software; you can redistribute it and/or modify it under the
6  * terms of the GNU General Public License as published by the Free Software
7  * Foundation; either version 3 of the License, or (at your option) any later
8  * version.
9  *
10  * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13  * details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with PISM; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 #ifndef PISM_QUADRATURE_H
20 #define PISM_QUADRATURE_H
21 
22 #include "pism/util/fem/FEM.hh"
23 
24 namespace pism {
25 namespace fem {
26 
27 //! Numerical integration of finite element functions.
28 /*! The core of the finite element method is the computation of integrals over elements.
29  For nonlinear problems, or problems with non-constant coefficients (%i.e. any real problem)
30  the integration has to be done approximately:
31  \f[
32  \int_E f(x)\; dx \approx \sum_q f(x_q) w_q
33  \f]
34  for certain quadrature points \f$x_q\f$ and weights \f$w_q\f$. A quadrature is used
35  to evaluate finite element functions at quadrature points, and to compute weights \f$w_q\f$
36  for a given element.
37 
38  In this concrete implementation, the reference element \f$R\f$ is the square
39  \f$[-1,1]\times[-1,1]\f$. On a given element, nodes (o) and quadrature points (*)
40  are ordered as follows:
41 
42  ~~~
43  3 o------------------o 2
44  | 3 2 |
45  | * * |
46  | |
47  | |
48  | * * |
49  | 0 1 |
50  0 o------------------o 1
51  ~~~
52 
53  There are four quad points per element, which occur at \f$x,y=\pm 1/\sqrt{3}\f$. This corresponds
54  to the tensor product of Gaussian integration on an interval that is exact for cubic functions on
55  the interval.
56 
57  Integration on a physical element can be thought of as being done by change of variables. The
58  quadrature weights need to be modified, and the Quadrature takes care of this. Because all
59  elements in an Grid are congruent, the quadrature weights are the same for each element, and
60  are computed upon initialization.
61 */
62 class Quadrature {
63 public:
64  const std::vector<QuadPoint>& points() const;
65  const std::vector<double>& weights() const;
66 
67  QuadPoint point(int k) const {
68  return m_points[k];
69  }
70 
71  double weight(int k) const {
72  return m_weights[k];
73  }
74 protected:
75  std::vector<QuadPoint> m_points;
76  std::vector<double> m_weights;
77 };
78 
79 
80 /*!
81  * 2-point Gaussian quadrature on an interval of length D.
82  */
83 class Gaussian2 : public Quadrature {
84 public:
85  Gaussian2(double D);
86 };
87 
88 //! The 1-point Gaussian quadrature on the square [-1,1]*[-1,1]
89 class Q1Quadrature1 : public Quadrature {
90 public:
91  Q1Quadrature1();
92 };
93 
94 //! The 4-point Gaussian quadrature on the square [-1,1]*[-1,1]
95 class Q1Quadrature4 : public Quadrature {
96 public:
97  Q1Quadrature4();
98 };
99 
100 //! The 9-point Gaussian quadrature on the square [-1,1]*[-1,1]
101 class Q1Quadrature9 : public Quadrature {
102 public:
103  Q1Quadrature9();
104 };
105 
106 //! The 16-point Gaussian quadrature on the square [-1,1]*[-1,1]
107 class Q1Quadrature16 : public Quadrature {
108 public:
109  Q1Quadrature16();
110 };
111 
112 /*!
113  * N*N point (NOT Gaussian) quadrature on the square [-1,1]*[-1,1]
114  */
115 class Q1QuadratureN : public Quadrature {
116 public:
117  Q1QuadratureN(unsigned int n);
118 };
119 
120 /*!
121  * 3-point Gaussian quadrature on the triangle (0,0)-(1,0)-(0,1)
122  */
123 class P1Quadrature3 : public Quadrature {
124 public:
125  P1Quadrature3();
126 };
127 
128 /*!
129  * 8-point Gaussian quadrature on the cube [-1,1]*[-1,1]*[-1,1]
130  */
131 class Q13DQuadrature8 : public Quadrature {
132 public:
133  Q13DQuadrature8();
134 };
135 
136 /*!
137  * 1-point Gaussian quadrature on the cube [-1,1]*[-1,1]*[-1,1]
138  */
139 class Q13DQuadrature1 : public Quadrature {
140 public:
141  Q13DQuadrature1();
142 };
143 
144 /*!
145  * 64-point (4*4*4) Gaussian quadrature on the cube [-1,1]*[-1,1]*[-1,1]
146  */
147 class Q13DQuadrature64 : public Quadrature {
148 public:
150 };
151 } // end of namespace fem
152 } // end of namespace pism
153 
154 #endif /* PISM_QUADRATURE_H */
The 16-point Gaussian quadrature on the square [-1,1]*[-1,1].
Definition: Quadrature.hh:107
Q1Quadrature1()
One-point quadrature on a rectangle.
Definition: Quadrature.cc:70
The 1-point Gaussian quadrature on the square [-1,1]*[-1,1].
Definition: Quadrature.hh:89
Q1Quadrature4()
Two-by-two Gaussian quadrature on a rectangle.
Definition: Quadrature.cc:76
The 4-point Gaussian quadrature on the square [-1,1]*[-1,1].
Definition: Quadrature.hh:95
The 9-point Gaussian quadrature on the square [-1,1]*[-1,1].
Definition: Quadrature.hh:101
Q1QuadratureN(unsigned int n)
N*N-point uniform (not Gaussian) quadrature for integrating discontinuous functions.
Definition: Quadrature.cc:120
double weight(int k) const
Definition: Quadrature.hh:71
std::vector< QuadPoint > m_points
Definition: Quadrature.hh:75
const std::vector< double > & weights() const
Definition: Quadrature.cc:29
std::vector< double > m_weights
Definition: Quadrature.hh:76
const std::vector< QuadPoint > & points() const
Definition: Quadrature.cc:25
QuadPoint point(int k) const
Definition: Quadrature.hh:67
Numerical integration of finite element functions.
Definition: Quadrature.hh:62
#define n
Definition: exactTestM.c:37
static const double k
Definition: exactTestP.cc:42