FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
slip_filter.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7
8// includes, FEAT
10#include <kernel/lafem/sparse_matrix_bcsr.hpp>
11#include <kernel/lafem/dense_vector_blocked.hpp>
12#include <kernel/lafem/sparse_vector_blocked.hpp>
13#include <kernel/lafem/arch/slip_filter_block.hpp>
14
15namespace FEAT
16{
17 namespace LAFEM
18 {
62 template<
63 typename DT_,
64 typename IT_,
65 int block_size_>
67 {
68 public:
70 typedef DT_ DataType;
72 typedef IT_ IndexType;
74 static constexpr int block_size = block_size_;
79
81 template <typename DT2_ = DT_, typename IT2_ = IT_>
83
85 template <typename DT2_ = DT_, typename IT2_ = IT_>
87
88 static_assert(block_size > 1, "block_size has to be >= 2 in SlipFilter!");
89
90 private:
95
96 public:
99 _nu(),
100 _sv()
101 {
102 }
103
114 explicit SlipFilter(Index num_vertices, Index num_dofs, Index num_nzes) :
115 _nu(num_vertices, num_nzes),
116 _sv(num_dofs, num_nzes)
117 {
118 }
119
122 _nu(std::move(other._nu)),
123 _sv(std::move(other._sv))
124 {
125 }
126
129 {
130 if(this != &other)
131 {
132 _sv = std::forward<decltype(other._sv)>(other._sv);
133 _nu = std::forward<decltype(other._nu)>(other._nu);
134 }
135 return *this;
136 }
137
139 virtual ~SlipFilter()
140 {
141 }
142
145 {
146 SlipFilter other;
147 other.clone(*this, clone_mode);
148 return other;
149 }
150
152 void clone(const SlipFilter & other, CloneMode clone_mode = CloneMode::Deep)
153 {
154 _nu.clone(other.get_nu(), clone_mode);
155 _sv.clone(other.get_filter_vector(), clone_mode);
156 }
157
159 template<typename DT2_, typename IT2_, int BS_>
161 {
162 _nu.convert(other.get_nu());
163 _sv.convert(other.get_filter_vector());
164 }
165
167 void clear()
168 {
169 _nu.clear();
170 _sv.clear();
171 }
172
174 std::size_t bytes() const
175 {
176 return _nu.bytes() + _sv.bytes();
177 }
178
181 {
182 return _sv;
183 }
184 const SparseVectorBlocked<DT_, IT_, block_size>& get_filter_vector() const
185 {
186 return _sv;
187 }
188
189 SparseVectorBlocked<DT_, IT_, block_size>& get_nu()
190 {
191 return _nu;
192 }
193 const SparseVectorBlocked<DT_, IT_, block_size>& get_nu() const
194 {
195 return _nu;
196 }
198
200 Index size() const
201 {
202 return _sv.size();
203 }
204
207 {
208 return _sv.size_raw();
209 }
210
213 {
214 return _sv.num_nzes();
215 }
216
219 {
220 return _sv.num_nzes_raw();
221 }
222
224 bool empty() const
225 {
226 return _sv.empty();
227 }
228
230 bool hollow() const
231 {
232 return _sv.hollow();
233 }
234
241 void filter_rhs(VectorType& vector) const
242 {
243 if(empty())
244 return;
245 XASSERTM(_sv.size() == vector.size(), "Vector size does not match!");
246
247 if(!hollow())
248 {
249 Arch::SlipFilterBlock::template exec<DT_, IT_, block_size_>(
250 vector.elements_arbiter(), _sv.elements_arbiter(), _sv.indices_arbiter(), _sv.num_nzes());
251 }
252 }
253
260 void filter_sol(VectorType& vector) const
261 {
262 // same as rhs
263 filter_rhs(vector);
264 }
265
272 void filter_def(VectorType& vector) const
273 {
274 // same as rhs
275 filter_rhs(vector);
276 }
277
284 void filter_cor(VectorType& vector) const
285 {
286 // same as rhs
287 filter_rhs(vector);
288 }
289 }; // class SlipFilter<...>
290 } // namespace LAFEM
291} // namespace FEAT
#define XASSERTM(expr, msg)
Assertion macro definition with custom message.
Definition: assertion.hpp:263
FEAT Kernel base header.
Blocked Dense data vector class template.
Index size() const
Returns the size of this vector, i.e. its number of entries.
Memory::Arbiter & elements_arbiter()
Returns a reference to the element array arbiter.
Slip Filter class template.
Definition: slip_filter.hpp:67
DT_ DataType
data-type typedef
Definition: slip_filter.hpp:70
Index size() const
Returns the total native size of the filter.
void convert(const SlipFilter< DT2_, IT2_, BS_ > &other)
Converts data from another UnitFilter.
void filter_rhs(VectorType &vector) const
Applies the filter onto the right-hand-side vector.
Index num_nzes_raw() const
Returns the raw number of non-zero entries in the filter.
SparseVectorBlocked< DT_, IT_, block_size_ > _sv
This will contain the data for filtering.
Definition: slip_filter.hpp:94
Tiny::Vector< DataType, block_size > ValueType
Value type.
Definition: slip_filter.hpp:76
SparseVectorBlocked< DT_, IT_, block_size_ > _nu
This will contain the pointwise outer unit normal in all vertices.
Definition: slip_filter.hpp:92
void filter_sol(VectorType &vector) const
Applies the filter onto the solution vector.
Index size_raw() const
Returns the total raw size of the filter.
void clear()
Clears the underlying data (namely the SparseVector)
bool hollow() const
Checks whether the filter does not contain any non-zero elements.
void clone(const SlipFilter &other, CloneMode clone_mode=CloneMode::Deep)
Clones data from another SlipFilter.
void filter_def(VectorType &vector) const
Applies the filter onto a defect vector.
IT_ IndexType
index-type typedef
Definition: slip_filter.hpp:72
static constexpr int block_size
The block size.
Definition: slip_filter.hpp:74
std::size_t bytes() const
Returns the total amount of bytes allocated.
SlipFilter & operator=(SlipFilter &&other)
move-assignment operator
Index num_nzes() const
Returns the number of non-zero entries in the filter.
SlipFilter clone(CloneMode clone_mode=CloneMode::Deep) const
Creates a clone of itself.
DenseVectorBlocked< DT_, IT_, block_size_ > VectorType
Our supported vector type.
Definition: slip_filter.hpp:78
SlipFilter(SlipFilter &&other)
move-ctor
SlipFilter()
default constructor
Definition: slip_filter.hpp:98
SlipFilter(Index num_vertices, Index num_dofs, Index num_nzes)
Constructor.
void filter_cor(VectorType &vector) const
Applies the filter onto a correction vector.
virtual ~SlipFilter()
virtual destructor
bool empty() const
Checks whether the size of the filter is zero.
Sparse vector class template.
Tiny Vector class template.
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.