IgANet
IgANets - Isogeometric Analysis Networks
Loading...
Searching...
No Matches
multipatch.hpp
Go to the documentation of this file.
1
15#pragma once
16
17namespace iganet {
18
24template <typename Patch> class MultiPatch {
25
26public:
29
32
34 MultiPatch(MultiPatch &&other) { patches_.swap(other.patches_); }
35
36public:
38 auto begin() { return patches_.begin(); }
39
42 auto begin() const { return patches_.begin(); }
43 auto cbegin() const noexcept { return patches_.cbegin(); }
45
47 auto end() { return patches_.end(); }
48
51 auto end() const { return patches_.end(); }
52 auto cend() const noexcept { return patches_.cend(); }
54
56 auto rbegin() { return patches_.rbegin(); }
57
60 auto rbegin() const { return patches_.rbegin(); }
61 auto crbegin() const noexcept { return patches_.crbegin(); }
63
65 auto rend() { return patches_.rend(); }
66
69 auto rend() const { return patches_.rend(); }
70 auto crend() const noexcept { return patches_.crend(); }
72
73public:
75 std::size_t npatches() const { return patches_.size(); }
76
78 std::size_t ninterfaces() const { return patches_.size(); }
79
81 std::size_t nboundaries() const { return patches_.size(); }
82
83public:
86 std::size_t addPatch(std::shared_ptr<Patch> patch) {
87 std::size_t index = patches_.size();
88 patches_.push_back(patch);
89 return index;
90 }
91
92 std::size_t addPatch(std::unique_ptr<Patch> patch) {
93 std::size_t index = patches_.size();
94 patches_.push_back(patch.release());
95 return index;
96 }
98
100 void clear() { patches_.clear(); }
101
103 Patch &patch(std::size_t index) {
104 assert(index >= 0 && index < patches_.size());
105 return *patches_[index];
106 }
107
109 const Patch &patch(std::size_t index) const {
110 assert(index >= 0 && index < patches_.size());
111 return *patches_[index];
112 }
113
115 std::vector<std::shared_ptr<Patch>> &patches() const { return patches_; }
116
119 std::size_t findPatchIndex(const Patch &patch) const {
120 return findPatchIndex(&patch);
121 }
122
123 std::size_t findPatchIndex(const Patch *patch) const {
124 auto it = std::find(patches_.begin(), patches_.end(), patch);
125 if (it != patches_.end())
126 throw std::runtime_error("Did not find the patch index");
127
128 return it - patches_.begin();
129 }
131
132private:
134 std::vector<std::shared_ptr<Patch>> patches_;
135};
136
137} // namespace iganet
Multi-patch container class.
Definition multipatch.hpp:24
MultiPatch(const MultiPatch &other)
Copy constructor.
Definition multipatch.hpp:31
auto rbegin() const
Returns a reverse const-iterator to the patches.
Definition multipatch.hpp:60
std::size_t findPatchIndex(const Patch *patch) const
Returns the index of a given single patch.
Definition multipatch.hpp:123
auto rend()
Returns a reverse iterator to the end of the patches.
Definition multipatch.hpp:65
void clear()
Removes all patches.
Definition multipatch.hpp:100
std::size_t npatches() const
Returns the number of patches.
Definition multipatch.hpp:75
auto crbegin() const noexcept
Returns a reverse const-iterator to the patches.
Definition multipatch.hpp:61
auto end() const
Returns a const-iterator to the end of the patches.
Definition multipatch.hpp:51
std::size_t findPatchIndex(const Patch &patch) const
Returns the index of a given single patch.
Definition multipatch.hpp:119
MultiPatch()
Default constructor.
Definition multipatch.hpp:28
auto begin()
Returns an iterator to the patches.
Definition multipatch.hpp:38
std::size_t addPatch(std::shared_ptr< Patch > patch)
Adds a single patch.
Definition multipatch.hpp:86
const Patch & patch(std::size_t index) const
Returns a constant reference to a single patch.
Definition multipatch.hpp:109
std::size_t ninterfaces() const
Returns the number of interfaces.
Definition multipatch.hpp:78
auto rend() const
Returns a reverse const-iterator to the end of the patches.
Definition multipatch.hpp:69
std::vector< std::shared_ptr< Patch > > patches_
Vector of single-patch objects.
Definition multipatch.hpp:134
std::size_t addPatch(std::unique_ptr< Patch > patch)
Adds a single patch.
Definition multipatch.hpp:92
auto rbegin()
Returns a reverse iterator to the patches.
Definition multipatch.hpp:56
auto begin() const
Returns a const-iterator to the patches.
Definition multipatch.hpp:42
std::vector< std::shared_ptr< Patch > > & patches() const
Returns a constant reference to the vector of patches.
Definition multipatch.hpp:115
std::size_t nboundaries() const
Returns the number of outer boundaries.
Definition multipatch.hpp:81
MultiPatch(MultiPatch &&other)
Move constructor.
Definition multipatch.hpp:34
auto cbegin() const noexcept
Returns a const-iterator to the patches.
Definition multipatch.hpp:43
Patch & patch(std::size_t index)
Returns a non-constant reference to a single patch.
Definition multipatch.hpp:103
auto crend() const noexcept
Returns a reverse const-iterator to the end of the patches.
Definition multipatch.hpp:70
auto cend() const noexcept
Returns a const-iterator to the end of the patches.
Definition multipatch.hpp:52
auto end()
Returns an iterator to the end of the patches.
Definition multipatch.hpp:47
Definition boundary.hpp:22
constexpr bool is_SplineType_v
Alias to the value of is_SplineType.
Definition bspline.hpp:3243