FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
transfer.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
10
11#include <utility>
12
13namespace FEAT
14{
15 namespace LAFEM
16 {
25 template<typename Matrix_>
27 {
28 public:
30 typedef typename Matrix_::DataType DataType;
32 typedef typename Matrix_::IndexType IndexType;
33
35 typedef Matrix_ MatrixType;
37 typedef typename Matrix_::VectorTypeL VectorType;
38
40 template <typename DT2_, typename IT2_>
42
43 static constexpr bool is_global = false;
44 static constexpr bool is_local = true;
45
46 protected:
48 Matrix_ _mat_prol;
50 Matrix_ _mat_rest;
52 Matrix_ _mat_trunc;
53
54 public:
57 {
58 }
59
69 explicit Transfer(Matrix_&& mat_prol, Matrix_&& mat_rest) :
70 _mat_prol(std::forward<Matrix_>(mat_prol)),
71 _mat_rest(std::forward<Matrix_>(mat_rest)),
73 {
74 }
75
76
89 explicit Transfer(Matrix_&& mat_prol, Matrix_&& mat_rest, Matrix_&& mat_trunc) :
90 _mat_prol(std::forward<Matrix_>(mat_prol)),
91 _mat_rest(std::forward<Matrix_>(mat_rest)),
92 _mat_trunc(std::forward<Matrix_>(mat_trunc))
93 {
94 }
95
97 Transfer(Transfer&& other) :
98 _mat_prol(std::forward<Matrix_>(other._mat_prol)),
99 _mat_rest(std::forward<Matrix_>(other._mat_rest)),
100 _mat_trunc(std::forward<Matrix_>(other._mat_trunc))
101 {
102 }
103
105 virtual ~Transfer()
106 {
107 }
108
111 {
112 if(this == &other)
113 return *this;
114
115 _mat_prol = std::forward<Matrix_>(other._mat_prol);
116 _mat_rest = std::forward<Matrix_>(other._mat_rest);
117 _mat_trunc = std::forward<Matrix_>(other._mat_trunc);
118
119 return *this;
120 }
121
123 template<typename Matrix2_>
124 void convert(const Transfer<Matrix2_>& other)
125 {
126 if((void*)this == (void*)&other)
127 return;
128
129 _mat_prol.convert(other.get_mat_prol());
130 _mat_rest.convert(other.get_mat_rest());
131 _mat_trunc.convert(other.get_mat_trunc());
132 }
133
143 {
144 return Transfer(_mat_prol.clone(clone_mode), _mat_rest.clone(clone_mode), _mat_trunc.clone(clone_mode));
145 }
146
152 std::size_t bytes() const
153 {
154 return _mat_prol.bytes() + _mat_rest.bytes() + _mat_trunc.bytes();
155 }
156
157 void compile()
158 {
159 // nothing to do here...
160 }
161
163 Matrix_& get_mat_prol()
164 {
165 return _mat_prol;
166 }
167
168 const Matrix_& get_mat_prol() const
169 {
170 return _mat_prol;
171 }
172
173 Matrix_& get_mat_rest()
174 {
175 return _mat_rest;
176 }
177
178 const Matrix_& get_mat_rest() const
179 {
180 return _mat_rest;
181 }
182
183 Matrix_& get_mat_trunc()
184 {
185 return _mat_trunc;
186 }
187
188 const Matrix_& get_mat_trunc() const
189 {
190 return _mat_trunc;
191 }
193
197 bool is_ghost() const
198 {
199 return false;
200 }
201
213 bool trunc(const VectorType& vec_fine, VectorType& vec_coarse) const
214 {
215 _mat_trunc.apply(vec_coarse, vec_fine);
216 return true;
217 }
218
229 bool trunc_send(const VectorType& DOXY(vec_fine)) const
230 {
231 XABORTM("This function must not be called");
232 }
233
245 bool rest(const VectorType& vec_fine, VectorType& vec_coarse) const
246 {
247 _mat_rest.apply(vec_coarse, vec_fine);
248 return true;
249 }
250
261 bool rest_send(const VectorType& DOXY(vec_fine)) const
262 {
263 XABORTM("This function must not be called");
264 }
265
277 bool prol(VectorType& vec_fine, const VectorType& vec_coarse) const
278 {
279 _mat_prol.apply(vec_fine, vec_coarse);
280 return true;
281 }
282
293 bool prol_recv(VectorType& DOXY(vec_fine)) const
294 {
295 XABORTM("This function must not be called");
296 }
297
305 void prol_cancel() const
306 {
307 XABORTM("This function must not be called");
308 }
309 }; // class Transfer<...>
310 } // namespace LAFEM
311} // namespace FEAT
#define XABORTM(msg)
Abortion macro definition with custom message.
Definition: assertion.hpp:192
Grid-Transfer operator class template.
Definition: transfer.hpp:27
bool rest(const VectorType &vec_fine, VectorType &vec_coarse) const
Applies the restriction operator.
Definition: transfer.hpp:245
Transfer(Transfer &&other)
move-constructor
Definition: transfer.hpp:97
virtual ~Transfer()
virtual destructor
Definition: transfer.hpp:105
Matrix_ _mat_rest
the internal restriction matrix
Definition: transfer.hpp:50
Matrix_::DataType DataType
the data type
Definition: transfer.hpp:30
bool rest_send(const VectorType &vec_fine) const
Sends the restriction for a ghost operator.
Definition: transfer.hpp:261
void prol_cancel() const
Cancels the prolongation.
Definition: transfer.hpp:305
bool trunc(const VectorType &vec_fine, VectorType &vec_coarse) const
Applies the truncation operator.
Definition: transfer.hpp:213
Transfer(Matrix_ &&mat_prol, Matrix_ &&mat_rest, Matrix_ &&mat_trunc)
Creates the transfer from given prolongation, restriction and reduction matrices.
Definition: transfer.hpp:89
Transfer()
standard constructor
Definition: transfer.hpp:56
bool trunc_send(const VectorType &vec_fine) const
Sends the truncation for a ghost operator.
Definition: transfer.hpp:229
bool prol(VectorType &vec_fine, const VectorType &vec_coarse) const
Applies the prolongation operator.
Definition: transfer.hpp:277
void convert(const Transfer< Matrix2_ > &other)
container conversion function
Definition: transfer.hpp:124
Matrix_::IndexType IndexType
the index type
Definition: transfer.hpp:32
Transfer & operator=(Transfer &&other)
move-assignment operator
Definition: transfer.hpp:110
bool prol_recv(VectorType &vec_fine) const
Receives the prolongation for a ghost operator.
Definition: transfer.hpp:293
bool is_ghost() const
Checks whether this transfer is a ghost-operator.
Definition: transfer.hpp:197
Matrix_ MatrixType
the internal matrix type
Definition: transfer.hpp:35
Matrix_::VectorTypeL VectorType
the compatible vector type
Definition: transfer.hpp:37
Transfer(Matrix_ &&mat_prol, Matrix_ &&mat_rest)
Creates the transfer from given prolongation and restriction matrices.
Definition: transfer.hpp:69
Matrix_ _mat_prol
the internal prolongation matrix
Definition: transfer.hpp:48
std::size_t bytes() const
Returns the internal data size in bytes.
Definition: transfer.hpp:152
Transfer clone(CloneMode clone_mode=CloneMode::Weak) const
Creates a clone of this object.
Definition: transfer.hpp:142
Matrix_ _mat_trunc
the internal truncation matrix
Definition: transfer.hpp:52
LAFEM common type definitions.
FEAT namespace.
Definition: adjactor.hpp:12