OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
trapz.cpp
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
19
20#include <functional>
21
22#include "types.hpp"
23#include "constants.hpp"
25
26
27namespace bem
28{
29
30template <uint8_t dim>
32{
33 if (num_segments > TRAPZ_LINE_MAX_NUM_SEGMENTS)
34 throw std::domain_error(
35 "TrapzLineQuadrature::set_num_segments(): max number of segments must be less than "
36 + std::to_string(TRAPZ_LINE_MAX_NUM_SEGMENTS) + ".");
37
38 num_segments_ = num_segments;
39
40 base::points_.resize(dim, num_segments_ + 1);
41 base::weights_.resize(1, num_segments_ + 1);
42 base::points_weights_computed_ = false;
43 return;
44};
45
46
47template <uint8_t dim>
52 )
53{
55 Float p_len = p.norm();
56
57 base::points_.noalias() = (p * ref_points()).colwise() + p1;
58 base::weights_.noalias() = ref_weights() * p_len;
59 base::points_weights_computed_ = true;
60
61 return;
62};
63
64
65template class TrapzLineQuadrature<1>;
66template class TrapzLineQuadrature<2>;
67template class TrapzLineQuadrature<3>;
68
69}
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
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
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