OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
iterative_gauss.hpp
Go to the documentation of this file.
1// OpenBEM - Copyright (C) 2026 Shashwat Sharma
2
3// This file is part of OpenBEM.
4
5// OpenBEM is free software: you can redistribute it and/or modify it under the terms of the
6// GNU General Public License as published by the Free Software Foundation, either version 3
7// of the License, or (at your option) any later version.
8
9// You should have received a copy of the GNU General Public License along with OpenBEM.
10// If not, see <https://www.gnu.org/licenses/>.
11
12
18#ifndef ITER_GAUSS_TRI_QUAD_H
19#define ITER_GAUSS_TRI_QUAD_H
20
21#include <functional>
22
23#include "types.hpp"
27
28
29namespace bem
30{
31
32const Float ITER_GAUSS_TRI_DEFAULT_TOL = 1e-3;
33
48template <uint8_t dim>
50{
51
52 using base = TriangleQuadratureBase<dim>;
53
54public:
55
61 {
62 starting_order_ = starting_order;
63 converged_ = false;
64 return;
65 };
66
67
72 uint8_t starting_order() const { return starting_order_; };
73
74
79 void set_tol(const Float tol)
80 {
81 tol_ = tol;
82 converged_ = false;
83 return;
84 };
85
86
91 Float tol() const { return tol_; };
92
93
99 {
100 max_iters_ = max_iters;
101 converged_ = false;
102 return;
103 };
104
105
110 uint16_t max_iters() const { return max_iters_; };
111
112
119 const Triangle<dim>& tri,
120 std::function<EigRowVec<Complex> (ConstEigRef<EigMatNX<Float, dim>>)> eval = {}
121 ) override;
122
123
128 bool converged() const
129 {
130 if (!base::points_weights_computed_)
131 throw std::runtime_error(
132 "IterativeGaussTriangleQuadrature::converged(): must call `compute_points_weights()` first.");
133 return converged_;
134 };
135
136
142 {
143 if (!base::points_weights_computed_)
144 throw std::runtime_error(
145 "IterativeGaussTriangleQuadrature::converged_order(): must call `compute_points_weights()` first.");
146 return converged_order_;
147 };
148
149
150private:
151
152 bool converged_ = false;
153 uint8_t starting_order_ = 1;
154 uint8_t converged_order_ = 0;
155 uint16_t max_iters_ = TRI_MAX_ORDER;
156 Float tol_ = ITER_GAUSS_TRI_DEFAULT_TOL;
157 GaussTriangleQuadrature<dim> gauss_quad_ = GaussTriangleQuadrature<dim> (starting_order_);
158
159};
160
165}
166
167#ifndef BEM_LINKED
169#endif
170
171#endif
Class for iterative Gaussian quadrature over a triangle.
bool converged() const
Checks whether the iterations converged.
void compute_points_weights(const Triangle< dim > &tri, std::function< EigRowVec< Complex >(ConstEigRef< EigMatNX< Float, dim > >)> eval={}) override
Computes and stores the points on which to evaluate the integrand, and the corresponding weights.
uint8_t converged_order() const
Returns the quadrature order at which the iterations converged.
void set_starting_order(const uint8_t starting_order)
Sets the quadrature order at which iterations should start.
uint8_t starting_order() const
Returns the quadrature order at which iterations start.
uint16_t max_iters() const
Returns the maximum number of iterations allowed even if not converged.
Float tol() const
Returns the relative convergence tolerance defining when iterations should stop.
void set_tol(const Float tol)
Sets the relative convergence tolerance defining when iterations should stop.
void set_max_iters(const uint16_t max_iters)
Sets the maximum number of iterations allowed even if not converged.
Base class for quadrature over a triangle.
Definition base.hpp:46
const Eigen::Ref< const EigObj > ConstEigRef
Read-only reference to an Eigen object.
Definition types.hpp:98
double Float
Floating point number.
Definition types.hpp:47
Eigen::Matrix< T, N, 1 > EigColVecN
Fixed-size column vector of size N containing type T.
Definition types.hpp:86
Primary namespace for the OpenBEM library.
Definition constants.hpp:31