FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
symmetric_lumped_schur_matrix.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
11namespace FEAT
12{
13 namespace Global
14 {
42 template
43 <
44 typename LumpedMatrixA_,
45 typename MatrixB_,
46 typename MatrixD_,
47 typename FilterA_
48 >
50 {
51 public:
53 typedef LumpedMatrixA_ LumpedMatrixTypeA;
55 typedef MatrixB_ MatrixTypeB;
57 typedef MatrixD_ MatrixTypeD;
59 typedef FilterA_ FilterTypeA;
60
62 typedef typename LumpedMatrixA_::DataType DataType;
64 typedef typename MatrixD_::VectorTypeL VectorTypeL;
66 typedef typename MatrixB_::VectorTypeR VectorTypeR;
67
69 typedef LumpedMatrixA_ VectorTypeML;
71 typedef LumpedMatrixA_ VectorTypeMR;
72
74 typedef typename MatrixD_::GateRowType GateRowType;
76 typedef typename MatrixB_::GateColType GateColType;
77
78 static constexpr bool is_global = true;
79 static constexpr bool is_local = false;
80
82 LumpedMatrixA_ inv_lumped_matrix_a;
84 const MatrixB_& matrix_b;
86 const MatrixD_& matrix_d;
88 const FilterA_& filter_a;
89
90 private:
91 // These two need to be modified even when apply() (which is const) is called
96
97 public:
114 const LumpedMatrixA_& lumped_matrix_a_,
115 const MatrixB_& matrix_b_,
116 const MatrixD_& matrix_d_,
117 const FilterA_& filter_a_) :
118 inv_lumped_matrix_a(lumped_matrix_a_.clone(LAFEM::CloneMode::Layout)),
119 matrix_b(matrix_b_),
120 matrix_d(matrix_d_),
121 filter_a(filter_a_),
122 _vec_ml(lumped_matrix_a_.clone(LAFEM::CloneMode::Layout)),
123 _vec_mr(lumped_matrix_a_.clone(LAFEM::CloneMode::Layout))
124 {
125 ASSERT(matrix_d.num_cols() == matrix_b.num_rows());
126 ASSERT(matrix_d.num_nzes() == matrix_b.num_nzes());
127
128 inv_lumped_matrix_a.component_invert(lumped_matrix_a_);
129 }
130
135 {
136 }
137
138 const Dist::Comm* get_comm() const
139 {
140 return inv_lumped_matrix_a.get_comm();
141 }
142
143 void update_lumped_a(const LumpedMatrixA_& lumped_matrix_a_)
144 {
145 // If these were initialized empty (as it frequently happens with Global containers), adjust the sizes
146 if(_vec_ml.local().size() == Index(0))
147 {
148 _vec_ml.local().clone(lumped_matrix_a_.local(), LAFEM::CloneMode::Layout);
149 }
150 if(_vec_mr.local().size() == Index(0))
151 {
152 _vec_mr.local().clone(lumped_matrix_a_.local(), LAFEM::CloneMode::Layout);
153 }
154 if(inv_lumped_matrix_a.local().size() == Index(0))
155 {
156 inv_lumped_matrix_a.local().clone(lumped_matrix_a_.local(), LAFEM::CloneMode::Layout);
157 }
158
159 inv_lumped_matrix_a.component_invert(lumped_matrix_a_);
160
161 }
162
172 {
173 return SymmetricSchurMatrix(inv_lumped_matrix_a.clone(mode), matrix_b.clone(mode), matrix_d.clone(mode),
174 filter_a.clone(mode));
175 }
176
183 {
184 return matrix_d.create_vector_l();
185 }
186
193 {
194 return matrix_b.create_vector_r();
195 }
196
206 {
207 return matrix_b.num_cols();
208 }
209
219 {
220 return matrix_d.num_rows();
221 }
222
231 {
232 return inv_lumped_matrix_a.num_nzes() + matrix_b.num_nzes() + matrix_d.num_nzes();
233 }
234
236 std::size_t bytes() const
237 {
238 return _vec_ml.bytes() + _vec_mr.bytes();
239 }
240
250 void apply(VectorTypeL& r, const VectorTypeR& x) const
251 {
252 matrix_b.apply(_vec_mr, x);
253
254 filter_a.filter_def(_vec_mr);
255 _vec_ml.component_product(_vec_mr, inv_lumped_matrix_a);
256 filter_a.filter_cor(_vec_ml);
257
258 matrix_d.apply(r, _vec_ml);
259 }
260
270 void preproc_rhs(VectorTypeML& r, const VectorTypeMR& x) const
271 {
272 _vec_mr.copy(x);
273 filter_a.filter_def(_vec_mr);
274 _vec_ml.component_product(_vec_mr, inv_lumped_matrix_a);
275 filter_a.filter_cor(_vec_ml);
276
277 matrix_d.apply(r, _vec_ml);
278 }
279
295 void apply(VectorTypeL& r, const VectorTypeR& x, const VectorTypeL& y, const DataType alpha = DataType(1)) const
296 {
297 // r <- y + alpha*(D A^(-1) B)*x
298 matrix_b.apply(_vec_mr, x);
299
300 filter_a.filter_def(_vec_mr);
301 _vec_ml.component_product(_vec_mr, inv_lumped_matrix_a);
302 filter_a.filter_cor(_vec_ml);
303
304 matrix_d.apply(r, _vec_ml, y, alpha);
305 }
306
307 //LocalMatrix convert_to_1() const
308 //{
309 // LocalMatrix locmat = _matrix.clone(LAFEM::CloneMode::Weak);
310 // if((_row_gate != nullptr) && (_col_gate != nullptr))
311 // synch_matrix(locmat, *_row_gate->_comm, _row_gate->_ranks, _row_gate->_mirrors, _col_gate->_mirrors);
312 // return locmat;
313 //}
314
315 }; // class SymmetricLumpedSchurMatrix<...>
316 } // namespace Global
317} // namespace FEAT
#define ASSERT(expr)
Debug-Assertion macro definition.
Definition: assertion.hpp:229
FEAT Kernel base header.
Communicator class.
Definition: dist.hpp:1657
Symmetric lumped Schur complement matrix.
Index num_nzes() const
Returns the total number of non-zeros in this matrix.
std::size_t bytes() const
Returns the total amount of bytes allocated.
VectorTypeL create_vector_l() const
Returns a left-vector.
void apply(VectorTypeL &r, const VectorTypeR &x, const VectorTypeL &y, const DataType alpha=DataType(1)) const
Calculate .
SymmetricLumpedSchurMatrix clone(LAFEM::CloneMode mode=LAFEM::CloneMode::Weak) const
Clone operation.
void apply(VectorTypeL &r, const VectorTypeR &x) const
Calculate .
Index num_rows() const
Gets the total number of rows in this matrix.
MatrixB_::GateColType GateColType
The column-gate type (used by SFINAE)
MatrixB_::VectorTypeR VectorTypeR
The vector for right-multiplication with S.
VectorTypeML _vec_ml
Buffer vector for receiving v <- x^T A.
MatrixD_::GateRowType GateRowType
The row-gate type (used by SFINAE)
VectorTypeR create_vector_r() const
Returns a right-vector.
Index num_cols() const
Gets the total number of columns in this matrix.
VectorTypeMR _vec_mr
Buffer vector for receiving v <- A x.
SymmetricLumpedSchurMatrix(const LumpedMatrixA_ &lumped_matrix_a_, const MatrixB_ &matrix_b_, const MatrixD_ &matrix_d_, const FilterA_ &filter_a_)
Constructor.
void preproc_rhs(VectorTypeML &r, const VectorTypeMR &x) const
Calculate .
LumpedMatrixA_ LumpedMatrixTypeA
The type of A = diag(a)
MatrixD_::VectorTypeL VectorTypeL
The vector for left-multiplication with S.
LumpedMatrixA_::DataType DataType
The floating point precision.
LumpedMatrixA_ VectorTypeML
The left-vector type for A.
LumpedMatrixA_ VectorTypeMR
The right-vector type for A.
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.