OpenBEM
Open-source framework for electromagnetic simulation with the boundary element method.
Loading...
Searching...
No Matches
structure.tpp
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 BEM_STRUCTURE_I
19#define BEM_STRUCTURE_I
20
21#include <string>
22#include <vector>
23
26
27
28namespace bem
29{
30
31template <typename MeshType>
32std::vector<Component<MeshType>> Structure<MeshType>::components_by_name(
33 const std::string name,
34 const bool search_metacomponents,
35 const bool case_sensitive
36 )
37{
38 std::vector<Component<MeshType>> comps;
39
40 auto run = [&] (const Component<MeshType>& comp)
41 {
42 std::string comp_name;
44 comp_name = comp.name();
45 if (!case_sensitive)
46 comp_name = comp.name().tolower();
47 if (comp_name.find(name) != std::string::npos)
48 comps.push_back(comp);
49 };
50
52 {
53 for (const auto& comp: components())
54 run(comp);
55 }
56 else
57 {
58 for (const auto& comp: metacomponents())
59 run(comp);
60 }
61
62 return comps;
63};
64
65
66template <typename MeshType>
67std::vector<MeshView<MeshType>> Structure<MeshType>::mesh_views_by_name(
68 const std::string name,
69 const bool search_metacomponents,
70 const bool case_sensitive
71 )
72{
73 std::vector<Component<MeshType>> comps = components_by_name(
75 );
76 std::vector<MeshView<MeshType>> mvs;
77 for (const auto& comp: comps)
78 mvs.push_back(comp.mesh_view());
79 return mvs;
80};
81
82}
83
84#endif
std::vector< MeshView< MeshType > > mesh_views_by_name(const std::string name, const bool search_metacomponents=false, const bool case_sensitive=false)
Returns a list of mesh views associated with components whose name contains a given string.
Definition structure.tpp:67
std::vector< Component< MeshType > > components_by_name(const std::string name, const bool search_metacomponents=false, const bool case_sensitive=false)
Returns a list of the components whose name contains a given string.
Definition structure.tpp:32
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