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_LINE_QUAD_H
19#define ITER_GAUSS_LINE_QUAD_H
20
21#include <stdexcept>
22#include <functional>
23
24#include "types.hpp"
27
28
29namespace bem
30{
31
32const Float ITER_GAUSS_LINE_DEFAULT_TOL = 1e-3;
33
48template <uint8_t dim>
50{
51
52 using base = LineQuadratureBase<dim>;
53
54public:
55
61 {
62 starting_order_ = starting_order;
63 base::points_weights_computed_ = false;
64 converged_ = false;
65 return;
66 };
67
68
73 uint8_t starting_order() const { return starting_order_; };
74
75
80 void set_tol(const Float tol)
81 {
82 tol_ = tol;
83 base::points_weights_computed_ = false;
84 converged_ = false;
85 return;
86 };
87
88
93 Float tol() const { return tol_; };
94
95
101 {
102 max_iters_ = max_iters;
103 base::points_weights_computed_ = false;
104 converged_ = false;
105 return;
106 };
107
108
113 uint16_t max_iters() const { return max_iters_; };
114
115
125 std::function<EigRowVec<Complex> (ConstEigRef<EigMatNX<Float, dim>>)> eval = {}
126 ) override;
127
128
133 bool converged() const
134 {
135 if (!base::points_weights_computed_)
136 throw std::runtime_error(
137 "IterativeGaussLineQuadrature::converged(): must call `compute_points_weights()` first.");
138 return converged_;
139 };
140
141
146 uint8_t converged_order() const { return converged_order_; };
147
148
149private:
150
151 bool converged_ = false;
152 uint8_t starting_order_ = 1;
153 uint8_t converged_order_ = 0;
154 uint16_t max_iters_ = LINE_MAX_ORDER;
155 Float tol_ = ITER_GAUSS_LINE_DEFAULT_TOL;
156 GaussLineQuadrature<dim> gauss_quad_ = GaussLineQuadrature<dim> (starting_order_);
157
158};
159
164}
165
166#ifndef BEM_LINKED
168#endif
169
170#endif
Class for iterative Gaussian quadrature over a line segment.
uint8_t converged_order() const
Returns the quadrature order at which the iterations converged.
void set_max_iters(const uint16_t max_iters)
Sets the maximum number of iterations allowed even if not converged.
void set_tol(const Float tol)
Sets the relative convergence tolerance defining when iterations should stop.
void set_starting_order(const uint8_t starting_order)
Sets the quadrature order at which iterations should start.
uint16_t max_iters() const
Returns the maximum number of iterations allowed even if not converged.
uint8_t starting_order() const
Returns the quadrature order at which iterations start.
Float tol() const
Returns the relative convergence tolerance defining when iterations should stop.
void compute_points_weights(ConstEigRef< EigColVecN< Float, dim > > p1, ConstEigRef< EigColVecN< Float, dim > > p2, 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.
bool converged() const
Checks whether the iterations converged.
Base class for quadrature over a line segment.
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