OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
trapz.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 TRAPZ_LINE_QUAD_H
19#define TRAPZ_LINE_QUAD_H
20
21#include <functional>
22
23#include "types.hpp"
25
26
27namespace bem
28{
29
30const uint16_t TRAPZ_LINE_DEFAULT_NUM_SEGMENTS = 10;
31const uint16_t TRAPZ_LINE_MAX_NUM_SEGMENTS = 1000;
32
42template <uint8_t dim>
44{
45
46 using base = LineQuadratureBase<dim>;
47
48public:
49
54 TrapzLineQuadrature(const uint8_t num_segments = TRAPZ_LINE_DEFAULT_NUM_SEGMENTS)
55 {
57 return;
58 };
59
60
66
67
72 uint16_t num_segments() const { return num_segments_; };
73
74
84 std::function<EigRowVec<Complex> (ConstEigRef<EigMatNX<Float, dim>>)> eval = {}
85 ) override;
86
87
93 { return EigRowVec<Float>::LinSpaced(num_segments_ + 1, 0.0, 1.0); };
94
95
101 {
102 EigRowVec<Float> weights = EigRowVec<Float>::Constant(1, num_segments_ + 1, 1.0 / num_segments_);
103 weights[0] = 0.5 / num_segments_;
104 weights[num_segments_] = 0.5 / num_segments_;
105 return weights;
106 };
107
108
109private:
110
111 uint16_t num_segments_ = TRAPZ_LINE_DEFAULT_NUM_SEGMENTS;
112
113};
114
119}
120
121#ifndef BEM_LINKED
123#endif
124
125#endif
Base class for quadrature over a line segment.
Definition base.hpp:46
const EigRowVec< Float > & weights() const
Returns the weights associated with the points on which the integrand is evaluated.
Definition base.hpp:96
Class for trapezoidal integration over a line segment.
Definition trapz.hpp:44
EigRowVec< Float > ref_points() const
Returns the evaluation points in the reference unit line segment.
Definition trapz.hpp:92
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.
Definition trapz.cpp:48
TrapzLineQuadrature(const uint8_t num_segments=TRAPZ_LINE_DEFAULT_NUM_SEGMENTS)
Constructs a TrapzLineQuadrature object with a specified number of subdivisions.
Definition trapz.hpp:54
EigRowVec< Float > ref_weights() const
Returns the weights associated with the evaluation points in the reference unit line segment.
Definition trapz.hpp:100
uint16_t num_segments() const
Returns the number of sub-segments into which the given line segment is divided.
Definition trapz.hpp:72
void set_num_segments(const uint16_t num_segments)
Sets the number of sub-segments into which the given line segment is divided.
Definition trapz.cpp:31
const Eigen::Ref< const EigObj > ConstEigRef
Read-only reference to an Eigen object.
Definition types.hpp:98
Eigen::Matrix< T, 1, Eigen::Dynamic > EigRowVec
Dynamic-size row vector containing type T.
Definition types.hpp:90
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