Loading [MathJax]/extensions/tex2jax.js
PISM, A Parallel Ice Sheet Model 2.2.2-d6b3a29ca committed by Constantine Khrulev on 2025-03-28
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Quadrature.hh
Go to the documentation of this file.
1/* Copyright (C) 2020, 2025 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#include <vector>
24
25namespace pism {
26namespace fem {
27
28//! Numerical integration of finite element functions.
29/*! The core of the finite element method is the computation of integrals over elements.
30 For nonlinear problems, or problems with non-constant coefficients (%i.e. any real problem)
31 the integration has to be done approximately:
32 \f[
33 \int_E f(x)\; dx \approx \sum_q f(x_q) w_q
34 \f]
35 for certain quadrature points \f$x_q\f$ and weights \f$w_q\f$. A quadrature is used
36 to evaluate finite element functions at quadrature points, and to compute weights \f$w_q\f$
37 for a given element.
38
39 In this concrete implementation, the reference element \f$R\f$ is the square
40 \f$[-1,1]\times[-1,1]\f$. On a given element, nodes (o) and quadrature points (*)
41 are ordered as follows:
42
43 ~~~
44 3 o------------------o 2
45 | 3 2 |
46 | * * |
47 | |
48 | |
49 | * * |
50 | 0 1 |
51 0 o------------------o 1
52 ~~~
53
54 There are four quad points per element, which occur at \f$x,y=\pm 1/\sqrt{3}\f$. This corresponds
55 to the tensor product of Gaussian integration on an interval that is exact for cubic functions on
56 the interval.
57
58 Integration on a physical element can be thought of as being done by change of variables. The
59 quadrature weights need to be modified, and the Quadrature takes care of this. Because all
60 elements in an Grid are congruent, the quadrature weights are the same for each element, and
61 are computed upon initialization.
62*/
64public:
65 const std::vector<QuadPoint>& points() const;
66 const std::vector<double>& weights() const;
67
68 QuadPoint point(int k) const {
69 return m_points[k];
70 }
71
72 double weight(int k) const {
73 return m_weights[k];
74 }
75protected:
76 std::vector<QuadPoint> m_points;
77 std::vector<double> m_weights;
78};
79
80
81/*!
82 * 2-point Gaussian quadrature on an interval of length D.
83 */
84class Gaussian2 : public Quadrature {
85public:
86 Gaussian2(double D);
87};
88
89//! The 1-point Gaussian quadrature on the square [-1,1]*[-1,1]
90class Q1Quadrature1 : public Quadrature {
91public:
93};
94
95//! The 4-point Gaussian quadrature on the square [-1,1]*[-1,1]
96class Q1Quadrature4 : public Quadrature {
97public:
99};
100
101//! The 9-point Gaussian quadrature on the square [-1,1]*[-1,1]
102class Q1Quadrature9 : public Quadrature {
103public:
105};
106
107//! The 16-point Gaussian quadrature on the square [-1,1]*[-1,1]
109public:
111};
112
113/*!
114 * N*N point (NOT Gaussian) quadrature on the square [-1,1]*[-1,1]
115 */
116class Q1QuadratureN : public Quadrature {
117public:
118 Q1QuadratureN(unsigned int n);
119};
120
121/*!
122 * 3-point Gaussian quadrature on the triangle (0,0)-(1,0)-(0,1)
123 */
124class P1Quadrature3 : public Quadrature {
125public:
127};
128
129/*!
130 * 8-point Gaussian quadrature on the cube [-1,1]*[-1,1]*[-1,1]
131 */
133public:
135};
136
137/*!
138 * 1-point Gaussian quadrature on the cube [-1,1]*[-1,1]*[-1,1]
139 */
141public:
143};
144
145/*!
146 * 64-point (4*4*4) Gaussian quadrature on the cube [-1,1]*[-1,1]*[-1,1]
147 */
149public:
151};
152} // end of namespace fem
153} // end of namespace pism
154
155#endif /* PISM_QUADRATURE_H */
The 16-point Gaussian quadrature on the square [-1,1]*[-1,1].
Q1Quadrature1()
One-point quadrature on a rectangle.
Definition Quadrature.cc:71
The 1-point Gaussian quadrature on the square [-1,1]*[-1,1].
Definition Quadrature.hh:90
Q1Quadrature4()
Two-by-two Gaussian quadrature on a rectangle.
Definition Quadrature.cc:77
The 4-point Gaussian quadrature on the square [-1,1]*[-1,1].
Definition Quadrature.hh:96
The 9-point Gaussian quadrature on the square [-1,1]*[-1,1].
double weight(int k) const
Definition Quadrature.hh:72
std::vector< QuadPoint > m_points
Definition Quadrature.hh:76
const std::vector< double > & weights() const
Definition Quadrature.cc:30
std::vector< double > m_weights
Definition Quadrature.hh:77
const std::vector< QuadPoint > & points() const
Definition Quadrature.cc:26
QuadPoint point(int k) const
Definition Quadrature.hh:68
Numerical integration of finite element functions.
Definition Quadrature.hh:63
#define n
Definition exactTestM.c:37
static const double k
Definition exactTestP.cc:42