OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
edge.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 "types.hpp"
22
23
24namespace bem
25{
26
27template <uint8_t dim>
29{
30 v_ = v;
31 edge_vec_ = compute_edge_vec();
32 length_ = compute_length();
33 unit_vec_ = compute_unit_vec();
34 centroid_ = compute_centroid();
35 return;
36};
37
38
39template <uint8_t dim>
41{
43 v.setZero();
44 v(0, 1) = 1.0;
45 Edge<dim> edge (v);
46 return edge;
47};
48
49
50template <uint8_t dim>
52{
53
55
56 if constexpr (dim == 1)
57 v_2d.row(0) = v_;
58 else
59 {
60 v_2d.col(0) << 0.0, 0.0;
61 v_2d.col(1) << length(), 0.0;
62 }
63
65 return edge_2d;
66
67};
68
69
70template <uint8_t dim>
72{
74 v_3d.topRows(dim) = v_.topRows(dim);
76 return edge_3d;
77};
78
79
80template <uint8_t dim>
82{
83 Float abs_tol = tol * length();
84
85 Float length_1 = (v().col(0) - r).norm();
86 Float length_2 = (v().col(1) - r).norm();
88
89 if (std::abs(test_length - length()) < abs_tol)
90 return true;
91
92 return false;
93};
94
95
96template class Edge<1>;
97template class Edge<2>;
98template class Edge<3>;
99
100}
Edge< 2 > to_2d() const
Returns an equivalent edge with coordinates in a local 2D system, and with the local origin at this e...
Definition edge.cpp:51
void set_v(ConstEigRef< EigMatMN< Float, dim, 2 > > v)
Sets the vertices of this Edge.
Definition edge.cpp:28
static Edge< dim > reference_edge()
Returns a reference edge in the specified dimension from 0 to 1 along the first axis.
Definition edge.cpp:40
bool point_on_edge(ConstEigRef< EigColVecN< Float, dim > > r, const Float tol=EDGE_DEFAULT_TOL) const
Returns true if the given point is on the edge, inclusive of vertices.
Definition edge.cpp:81
Edge< 3 > to_3d() const
Adds a 0-valued third dimension if this Edge is in 2D, adds a 0-valued second and third dimension if ...
Definition edge.cpp:71
const Eigen::Ref< const EigObj > ConstEigRef
Read-only reference to an Eigen object.
Definition types.hpp:98
Eigen::Matrix< T, M, N > EigMatMN
Fixed-size matrix with M rows and N columns containing type T.
Definition types.hpp:70
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