Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
gauss.hpp
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// Copyright (C) 2024 - 2026 by the Vulpes authors.
4// This file is part of Vulpes.
5//
6// Vulpes is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Vulpes is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18//
19// ----------------------------------------------------------------------
20
21// Author: Matteo Caldana <matteo.caldana@polimi.it>
22// Author: Pedro Peixoto <ppeixoto@usp.br>
23
24#ifndef VULPES_QUADRATURE_GAUSS_HPP_
25#define VULPES_QUADRATURE_GAUSS_HPP_
26
27#include <gmpxx.h>
28
29#include <cstddef>
30
33
34namespace vulpes {
35namespace qrule {
36
40
61 std::size_t n, std::size_t precision = 256);
62
86 std::size_t n, std::size_t precision = 256);
87
105template <std::size_t dim, typename T>
107 const QuadratureRule1D<T>& rule1d) {
108 if constexpr (dim == 1) {
109 return rule1d;
110 }
112 const std::size_t size_1d = rule1d.nodes.size();
113 const std::size_t size_nd = vmath::upow(size_1d, dim);
114 rule.nodes.resize(size_nd);
115 for (std::size_t i = 0; i < size_nd; ++i) {
116 rule.nodes[i].weight = T(1);
117 // this is like writing `i` in radix `size_1d`
118 std::size_t idx = i;
119 for (std::size_t d = 0; d < dim; ++d) {
120 std::size_t digit = idx % size_1d;
121 idx /= size_1d;
122 rule.nodes[i].weight *= rule1d.nodes[digit].weight;
123 rule.nodes[i].point[d] = rule1d.nodes[digit].point[0];
124 }
125 }
126 return rule;
127}
128
129} // namespace qrule
130} // namespace vulpes
131#endif // VULPES_QUADRATURE_GAUSS_HPP_
Definition gauss.cpp:39
QuadratureRule< T, dim > buildTensorQuadrature(const QuadratureRule1D< T > &rule1d)
Constructs a tensor-product quadrature rule from a 1D quadrature rule.
Definition gauss.hpp:106
QuadratureRule1Dmp gmpGaussLegendreQuadrature(std::size_t n, std::size_t precision)
Computes a Gauss-Legendre quadrature rule with arbitrary precision.
Definition gauss.cpp:41
QuadratureRule1D< mpf_class > QuadratureRule1Dmp
Definition gauss.hpp:39
QuadratureRule< T, 1 > QuadratureRule1D
Alias for a 1-dimensional quadrature rule.
Definition qrule.hpp:83
QuadratureRule1Dmp gmpGaussLobattoQuadrature(std::size_t n, std::size_t precision)
Generates a Gauss-Lobatto quadrature rule in 1D with arbitrary-precision arithmetic.
Definition gauss.cpp:112
constexpr U upow(U base, V exp, U result=U(1))
Computes the unsigned power of a number.
Definition vmath.hpp:107
Definition cell_manager.hpp:38
Represents a quadrature rule consisting of a set of points and associated weights.
Definition qrule.hpp:69
std::vector< QuadraturePoint< T, Dim > > nodes
List of quadrature points.
Definition qrule.hpp:71