Alien  1.3.0
Developer documentation
Loading...
Searching...
No Matches
FILU0Preconditioner.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7
8#pragma once
9
10namespace Alien
11{
12template <typename MatrixT, typename VectorT>
13class FLUFactorisationAlgo
14: public LUFactorisationAlgo<MatrixT, VectorT>
15{
16 public:
17 // clang-format off
18 typedef LUFactorisationAlgo<MatrixT,VectorT> BaseType ;
19 typedef MatrixT MatrixType;
20 typedef VectorT VectorType;
21 typedef typename MatrixType::ProfileType ProfileType ;
22 typedef typename MatrixType::ValueType ValueType;
23 typedef typename MatrixType::TagType TagType ;
24 // clang-format on
25
26 FLUFactorisationAlgo()
27 {}
28
29 virtual ~FLUFactorisationAlgo()
30 {}
31
32 void setParameter(std::string param, int value)
33 {
34 if (param.compare("nb-factor-iter") == 0)
36 else if (param.compare("nb-solver-iter") == 0)
37 m_nb_solver_iter = value;
38 }
39
40 void setParameter(std::string param, double value)
41 {
42 if (param.compare("tol") == 0)
43 m_tol = value;
44 }
45
46 template <typename AlgebraT>
47 void init(AlgebraT& algebra, MatrixT const& matrix)
48 {
49 BaseType::baseInit(algebra, matrix);
50 algebra.allocate(AlgebraT::resource(matrix), m_xk);
51
52 if (m_nb_factorization_iter == 0) {
53 if(this->m_block_size==1)
54 BaseType::factorize(*this->m_lu_matrix, true);
55 else
56 {
57 BaseType::blockFactorize(*this->m_lu_matrix);
58 }
59 }
60 else {
61 factorizeMultiIter(*this->m_lu_matrix);
62 }
63 this->m_work.clear();
64
65 if(this->m_block_size==1)
66 {
67 algebra.allocate(AlgebraT::resource(matrix), m_inv_diag);
68 algebra.assign(m_inv_diag, 1.);
69 algebra.computeInvDiag(*this->m_lu_matrix, m_inv_diag);
70 }
71 else
72 {
73 m_inv_diag.setBlockSize(this->m_block_size*this->m_block_size) ;
74 algebra.allocate(AlgebraT::resource(matrix), m_inv_diag);
75 algebra.computeInvDiag(*this->m_lu_matrix, m_inv_diag);
76
77 }
78
79 if (MatrixType::on_host_only) {
80 if (this->m_is_parallel) {
81 // Need to manage ghost and communications
82 this->m_x.resize((Integer)this->m_alloc_size);
83 m_xk.resize((Integer)this->m_alloc_size);
84 }
85 }
86 }
87
89 //
90 // FACTORIZATION
91 //
92 void factorizeIter(std::size_t nrows,
93 int const* kcol,
94 int const* dcol,
95 int const* cols,
96 ValueType* values,
97 ValueType* values0)
98 {
99 /*
100 *
101 For i = 1, . . . ,N Do:
102 For k = 1, . . . , i - 1 and if (i, k) 2 NZ(A) Do:
103 Compute aik := aik/akj
104 For j = k + 1, . . . and if (i, j) 2 NZ(A), Do:
105 compute aij := aij - aik.ak,j.
106 EndFor
107 EndFor
108 EndFor
109 *
110 */
111
112 for (std::size_t irow = 1; irow < nrows; ++irow) // i=1->nrow
113 {
114 _factorizeRow(irow, kcol, dcol, cols, values, values0);
115 }
116 }
117
118 void factorizeMultiIter(MatrixT const& matrix)
119 {
120 CSRModifierViewT<MatrixT> modifier(*this->m_lu_matrix);
121
122 // clang-format off
123 auto nrows = modifier.nrows() ;
124 auto nnz = modifier.nnz() ;
125 auto kcol = modifier.kcol() ;
126 auto dcol = modifier.dcol() ;
127 auto cols = modifier.cols() ;
128 auto values = modifier.data() ;
129 // clang-format on
130
131 if (this->m_lu_matrix->isParallel()) {
132 typename LUSendRecvTraits<TagType>::matrix_op_type op(*this->m_lu_matrix, this->m_distribution, this->m_work);
133 for (int iter = 0; iter < m_nb_factorization_iter; ++iter) {
134 auto matrix_values = CSRConstViewT<MatrixT>(matrix).data();
135 std::vector<ValueType> guest_values(nnz);
136 std::copy(values, values + nnz, guest_values.data());
137 std::copy(matrix_values, matrix_values + nnz, values);
138 op.recvLowerNeighbLUData(values);
139 op.sendUpperNeighbLUData(guest_values.data());
140 factorizeIter(nrows, kcol, dcol, cols, values, guest_values.data());
141 }
142 }
143 else {
144 for (int iter = 0; iter < m_nb_factorization_iter; ++iter) {
145 auto matrix_values = CSRConstViewT<MatrixT>(matrix).data();
146 std::vector<ValueType> guest_values(nnz);
147 std::copy(values, values + nnz, guest_values.data());
148 std::copy(matrix_values, matrix_values + nnz, values);
149 factorizeIter(nrows, kcol, dcol, cols, values, guest_values.data());
150 }
151 }
152 }
153
155 //
156 // TRIANGULAR RESOLUTION
157 //
158 template <typename AlgebraT>
159 void solveL(AlgebraT& algebra,
160 VectorType const& y,
161 VectorType& x,
162 VectorType& xk) const
163 {
164#ifdef ALIEN_USE_PERF_TIMER
165 typename MatrixType::SentryType sentry(this->m_lu_matrix->timer(), "SolveL");
166#endif
167 if constexpr (MatrixType::on_host_only)
168 {
169 CSRConstViewT<MatrixT> view(*this->m_lu_matrix);
170 // clang-format off
171 auto nrows = view.nrows();
172 auto kcol = view.kcol();
173 auto dcol = view.dcol();
174 auto cols = view.cols();
175 auto values = view.data();
176
177 auto y_ptr = y.data();
178 auto x_ptr = x.data();
179 auto xk_ptr = xk.data();
180 // clang-format on
181
182 std::copy(x_ptr, x_ptr + nrows, xk_ptr);
183 if (this->m_is_parallel)
184 {
185
186 auto& local_row_size = this->m_lu_matrix->getDistStructInfo().m_local_row_size;
187 int first_upper_ghost_index = this->m_lu_matrix->getDistStructInfo().m_first_upper_ghost_index;
188
189 algebra.lowerUpperSynchronize(*this->m_lu_matrix, xk);
190
191 for (std::size_t irow = 0; irow < nrows; ++irow) {
192 ValueType val = y_ptr[irow];
193 for (int k = kcol[irow]; k < dcol[irow]; ++k)
194 val -= values[k] * xk_ptr[cols[k]];
195 for (int k = kcol[irow] + local_row_size[irow]; k < kcol[irow + 1]; ++k) {
196 if (cols[k] < first_upper_ghost_index)
197 val -= values[k] * xk_ptr[cols[k]];
198 }
199 x_ptr[irow] = val;
200 }
201 }
202 else
203 {
204 for (std::size_t irow = 0; irow < nrows; ++irow) {
205 ValueType val = y_ptr[irow];
206 for (int k = kcol[irow]; k < dcol[irow]; ++k)
207 val -= values[k] * xk_ptr[cols[k]];
208 x_ptr[irow] = val;
209 }
210 }
211 }
212 else
213 {
214 algebra.copy(x, xk);
215 algebra.copy(y, x);
216 algebra.addLMult(-1, *this->m_lu_matrix, xk, x);
217 }
218 }
219
220 template <typename AlgebraT>
221 void blockSolveL(AlgebraT& algebra,
222 VectorType const& y,
223 VectorType& x,
224 VectorType& xk) const
225 {
226#ifdef ALIEN_USE_PERF_TIMER
227 typename MatrixType::SentryType sentry(this->m_lu_matrix->timer(), "SolveL");
228#endif
229 if constexpr (MatrixType::on_host_only)
230 {
231#if defined (ALIEN_USE_EIGEN3) && !defined(EIGEN3_DISABLED)
232 using namespace Eigen;
233 using Block2D = Eigen::Matrix<ValueType,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> ;
234 using Block2DView = Eigen::Map<Block2D> ;
235 using Block1D = Eigen::Matrix<ValueType,Dynamic,1> ;
236 using Block1DView = Eigen::Map<Block1D> ;
237
238 int N = this->m_block_size ;
239 int NxN = N*N;
240
241 Block1D val(N);
242 CSRConstViewT<MatrixT> view(*this->m_lu_matrix);
243 // clang-format off
244 auto nrows = view.nrows();
245 auto kcol = view.kcol();
246 auto dcol = view.dcol();
247 auto cols = view.cols();
248 auto values = view.data();
249
250 auto y_ptr = y.data();
251 auto x_ptr = x.data();
252 auto xk_ptr = xk.data();
253 // clang-format on
254
255 std::copy(x_ptr, x_ptr + nrows*N, xk_ptr);
256 if (this->m_is_parallel)
257 {
258 auto& local_row_size = this->m_lu_matrix->getDistStructInfo().m_local_row_size;
259 int first_upper_ghost_index = this->m_lu_matrix->getDistStructInfo().m_first_upper_ghost_index;
260
261 algebra.lowerUpperSynchronize(*this->m_lu_matrix, xk);
262
263 for (std::size_t irow = 0; irow < nrows; ++irow)
264 {
265 //ValueType val = y_ptr[irow];
266 val = Block1DView(const_cast<ValueType*>(y_ptr+irow*N),N) ;
267 for (int k = kcol[irow]; k < dcol[irow]; ++k)
268 {
269 //val -= values[k] * xk_ptr[cols[k]];
270 val -= Block2DView(const_cast<ValueType*>(values+k*NxN),N,N) * Block1DView(xk_ptr+cols[k]*N,N) ;
271 }
272 for (int k = kcol[irow] + local_row_size[irow]; k < kcol[irow + 1]; ++k)
273 {
274 if (cols[k] < first_upper_ghost_index)
275 {
276 //val -= values[k] * xk_ptr[cols[k]];
277 val -= Block2DView(const_cast<ValueType*>(values+k*NxN),N,N) * Block1DView(xk_ptr+cols[k]*N,N) ;
278 }
279 }
280 //x_ptr[irow] = val;
281 Block1DView(x_ptr+irow*N,N) = val ;
282 }
283
284 algebra.endDistAddLMult(-1, *this->m_lu_matrix, xk, x);
285 //alien_info([&]{ cout()<<"ADD BLMULT "<<algebra.norm2(x)<<" "<<algebra.norm2(xk);});
286 }
287 else
288 {
289#ifdef PRINT_DEBUG_INFO
290 alien_info([&]
291 {
292 for (std::size_t irow = 0; irow < nrows; ++irow)
293 {
294 cout()<<"XK["<<irow<<"]=\n";
295 for(int i=0;i<N;++i)
296 cout()<<'\t'<<xk_ptr[irow*N+i]<<" ";
297 }
298 });
299#endif
300 for (std::size_t irow = 0; irow < nrows; ++irow)
301 {
302 //ValueType val = y_ptr[irow];
303 val = Block1DView(const_cast<ValueType*>(y_ptr+irow*N),N) ;
304#ifdef PRINT_DEBUG_INFO
305 std::cout<<"LSOLVE MAT["<<irow<<"]:"<<std::endl;
306#endif
307 for (int k = kcol[irow]; k < dcol[irow]; ++k)
308 {
309 //val -= values[k] * xk_ptr[cols[k]];
310 val -= Block2DView(const_cast<ValueType*>(values+k*NxN),N,N) * Block1DView(xk_ptr+cols[k]*N,N) ;
311#ifdef PRINT_DEBUG_INFO
312 std::cout<<Block2DView(const_cast<ValueType*>(values+k*NxN),N,N)<<std::endl;
313#endif
314 }
315 //x_ptr[irow] = val;
316 Block1DView(x_ptr+irow*N,N) = val ;
317#ifdef PRINT_DEBUG_INFO
318 alien_info([&]{ cout()<<"Y = "<<Block1DView(const_cast<ValueType*>(y_ptr+irow*N),N);}) ;
319#endif
320 }
321 //alien_info([&]{ cout()<<"ADD BLMULT "<<algebra.norm2(x)<<" "<<algebra.norm2(xk);});
322 }
323#endif
324 }
325 else
326 {
327 algebra.copy(x, xk);
328 algebra.copy(y, x);
329 algebra.addLMult(-1, *this->m_lu_matrix, xk, x);
330 }
331 }
332
333 template <typename AlgebraT>
334 void solveU(AlgebraT& algebra, VectorType const& y, VectorType& x, VectorType& xk) const
335 {
336#ifdef ALIEN_USE_PERF_TIMER
337 typename MatrixType::SentryType sentry(this->m_lu_matrix->timer(), "SolveU");
338#endif
339 if constexpr (MatrixType::on_host_only)
340 {
341 CSRConstViewT<MatrixT> view(*this->m_lu_matrix);
342 // clang-format off
343 auto nrows = view.nrows();
344 auto kcol = view.kcol();
345 auto dcol = view.dcol();
346 auto cols = view.cols();
347 auto values = view.data();
348
349 auto y_ptr = y.data();
350 auto x_ptr = x.data();
351 auto xk_ptr = xk.data();
352 // clang-format on
353
354 std::copy(x_ptr, x_ptr + nrows, xk_ptr);
355 if (this->m_is_parallel) {
356 auto& local_row_size = this->m_lu_matrix->getDistStructInfo().m_local_row_size;
357 int first_upper_ghost_index = this->m_lu_matrix->getDistStructInfo().m_first_upper_ghost_index;
358
359 algebra.upperLowerSynchronize(*this->m_lu_matrix, xk);
360
361 for (std::size_t irow = 0; irow < nrows; ++irow) {
362 int dk = dcol[irow];
363 ValueType val = y_ptr[irow];
364 for (int k = dk + 1; k < kcol[irow] + local_row_size[irow]; ++k) {
365 val -= values[k] * xk_ptr[cols[k]];
366 }
367 for (int k = kcol[irow] + local_row_size[irow]; k < kcol[irow + 1]; ++k) {
368 if (cols[k] >= first_upper_ghost_index)
369 val -= values[k] * xk_ptr[cols[k]];
370 }
371 val = val / values[dk];
372 x_ptr[irow] = val;
373 }
374 }
375 else {
376 for (std::size_t irow = 0; irow < nrows; ++irow) {
377 int dk = dcol[irow];
378 ValueType val = y_ptr[irow];
379 for (int k = dk + 1; k < kcol[irow + 1]; ++k) {
380 val -= values[k] * xk_ptr[cols[k]];
381 }
382 val = val / values[dk];
383 x_ptr[irow] = val;
384 }
385 }
386 }
387 else
388 {
389 algebra.copy(x, xk);
390 algebra.copy(y, x);
391 algebra.addUMult(-1., *this->m_lu_matrix, xk, x);
392 algebra.pointwiseMult(m_inv_diag, x, x);
393 //algebra.multInvDiag(*this->m_lu_matrix,x) ;
394 }
395 }
396
397 template <typename AlgebraT>
398 void blockSolveU(AlgebraT& algebra, VectorType const& y, VectorType& x, VectorType& xk) const
399 {
400#ifdef ALIEN_USE_PERF_TIMER
401 typename MatrixType::SentryType sentry(this->m_lu_matrix->timer(), "SolveU");
402#endif
403 if constexpr (MatrixType::on_host_only)
404 {
405#if defined (ALIEN_USE_EIGEN3) && !defined(EIGEN3_DISABLED)
406 using namespace Eigen;
407 using Block2D = Eigen::Matrix<ValueType,Eigen::Dynamic,Eigen::Dynamic,Eigen::RowMajor> ;
408 using Block2DView = Eigen::Map<Block2D> ;
409 using Block1D = Eigen::Matrix<ValueType,Dynamic,1> ;
410 using Block1DView = Eigen::Map<Block1D> ;
411
412 int N = this->m_block_size ;
413 int NxN = N*N;
414
415 Block1D val(N);
416
417 CSRConstViewT<MatrixT> view(*this->m_lu_matrix);
418 // clang-format off
419 auto nrows = view.nrows();
420 auto kcol = view.kcol();
421 auto dcol = view.dcol();
422 auto cols = view.cols();
423 auto values = view.data();
424
425 auto y_ptr = y.data();
426 auto x_ptr = x.data();
427 auto xk_ptr = xk.data();
428
429 auto inv_diag = m_inv_diag.data() ;
430 // clang-format on
431
432 std::copy(x_ptr, x_ptr + nrows*N, xk_ptr);
433 if (this->m_is_parallel)
434 {
435 auto& local_row_size = this->m_lu_matrix->getDistStructInfo().m_local_row_size;
436 int first_upper_ghost_index = this->m_lu_matrix->getDistStructInfo().m_first_upper_ghost_index;
437
438 algebra.upperLowerSynchronize(*this->m_lu_matrix, xk);
439
440 algebra.endDistAddUMult(-1, *this->m_lu_matrix, xk, x);
441
442 for (std::size_t irow = 0; irow < nrows; ++irow)
443 {
444 int dk = dcol[irow];
445 //ValueType val = y_ptr[irow];
446 val = Block1DView(const_cast<ValueType*>(y_ptr+irow*N),N) ;
447 for (int k = dk + 1; k < kcol[irow] + local_row_size[irow]; ++k) {
448 //val -= values[k] * xk_ptr[cols[k]];
449 val -= Block2DView(const_cast<ValueType*>(values+k*NxN),N,N) * Block1DView(xk_ptr+cols[k]*N,N) ;
450 }
451 for (int k = kcol[irow] + local_row_size[irow]; k < kcol[irow + 1]; ++k) {
452 if (cols[k] >= first_upper_ghost_index)
453 {
454 //val -= values[k] * xk_ptr[cols[k]];
455 val -= Block2DView(const_cast<ValueType*>(values+k*NxN),N,N) * Block1DView(xk_ptr+cols[k]*N,N) ;
456 }
457 }
458 //val = val / values[dk];
459 //x_ptr[irow] = val;
460 Block1DView(x_ptr+irow*N,N) = BaseType::inv(Block2DView(const_cast<ValueType*>(values+dk*NxN),N,N)) * val;
461#ifdef PRINT_DEBUG_INFO
462 alien_info([&] { cout()<<"Y["<<irow<<"]=\n"<<Block1DView(x_ptr+irow*N,N);});
463#endif
464 }
465 }
466 else
467 {
468
469#ifdef PRINT_DEBUG_INFO
470 for (std::size_t irow = 0; irow < nrows; ++irow)
471 {
472 std::cout<<"XK["<<irow<<"]=\n";
473 for(int i=0;i<N;++i)
474 std::cout<<xk_ptr[irow*N+i]<<std::endl;
475 }
476#endif
477 for (std::size_t irow = 0; irow < nrows; ++irow)
478 {
479#ifdef PRINT_DEBUG_INFO
480 std::cout<<"U SOLVE MAT["<<irow<<"]:"<<std::endl ;
481#endif
482 int dk = dcol[irow];
483 //ValueType val = y_ptr[irow];
484 val = Block1DView(const_cast<ValueType*>(y_ptr+irow*N),N) ;
485 for (int k = dk + 1; k < kcol[irow + 1]; ++k) {
486 //val -= values[k] * xk_ptr[cols[k]];
487 val -= Block2DView(const_cast<ValueType*>(values+k*NxN),N,N) * Block1DView(xk_ptr+cols[k]*N,N) ;
488#ifdef PRINT_DEBUG_INFO
489 std::cout<<Block2DView(const_cast<ValueType*>(values+k*NxN),N,N)<<std::endl;
490#endif
491 }
492
493 Block1DView(x_ptr+irow*N,N) = BaseType::inv(Block2DView(const_cast<ValueType*>(values+dk*NxN),N,N)) * val;
494#ifdef PRINT_DEBUG_INFO
495 alien_info([&] { cout()<<"Y["<<irow<<"]=\n"<<Block1DView(x_ptr+irow*N,N);});
496#endif
497 }
498
499#ifdef PRINT_DEBUG_INFO
500 for (std::size_t irow = 0; irow < nrows; ++irow)
501 {
502 int dk = dcol[irow];
503 std::cout<<"INV DIAG["<<irow<<"]:\n";
504 Block2D diag(N,N) ;
505 diag = BaseType::inv(Block2DView(const_cast<ValueType*>(values+dk*NxN),N,N));
506 for(int i=0;i<N;++i)
507 {
508 for(int j=0;j<N;++j)
509 std::cout<<diag(i,j)<<" ";
510 std::cout<<std::endl;
511 }
512 std::cout<<"Y["<<irow<<"]=\n";
513 for(int i=0;i<N;++i)
514 std::cout<<x_ptr[irow*N+i]<<std::endl;
515 }
516#endif
517 }
518#endif
519 }
520 else
521 {
522 algebra.copy(x, xk);
523 algebra.copy(y, x);
524 algebra.addUMult(-1., *this->m_lu_matrix, xk, x);
525 algebra.copy(x, xk);
526 algebra.multDiag(m_inv_diag, xk, x);
527 //algebra.multInvDiag(*this->m_lu_matrix,x) ;
528 }
529 }
530
531 template <typename AlgebraT>
532 void solve(AlgebraT& algebra, VectorType const& x, VectorType& y) const
533 {
534
536 //
537 // L.X1 = Y
538 //
539 algebra.copy(x, this->m_x);
540 if(this->m_block_size==1)
541 {
542 for (int iter = 0; iter < m_nb_solver_iter; ++iter) {
543 solveL(algebra, x, this->m_x, m_xk);
544 }
545 }
546 else
547 {
548 for (int iter = 0; iter < m_nb_solver_iter; ++iter) {
549 blockSolveL(algebra, x, this->m_x, m_xk);
550 }
551 }
552
554 //
555 // Solve U.X = L-1(Y)
556 //
557 algebra.copy(this->m_x, y);
558 if(this->m_block_size==1)
559 {
560 for (int iter = 0; iter < m_nb_solver_iter; ++iter) {
561 solveU(algebra, this->m_x, y, m_xk);
562 }
563 }
564 else
565 {
566 for (int iter = 0; iter < m_nb_solver_iter; ++iter) {
567 blockSolveU(algebra, this->m_x, y, m_xk);
568 }
569 }
570 }
571
572 private:
573 void _factorizeRow(std::size_t irow,
574 int const* kcol,
575 int const* dcol,
576 int const* cols,
577 ValueType* values,
578 ValueType* values0)
579 {
580 /*
581 *
582 For k = 1, . . . , i - 1 and if (i, k) 2 NZ(A) Do:
583 Compute aik := aik/akj
584 For j = k + 1, . . . and if (i, j) 2 NZ(A), Do:
585 compute aij := aij - aik.ak,j.
586 EndFor
587 EndFor
588 *
589 */
590
591 for (int k = kcol[irow]; k < dcol[irow]; ++k) // k=1 ->i-1
592 {
593 int krow = cols[k];
594 typename BaseType::ValueType aik = values[k] / values0[dcol[krow]];
595 values[k] = aik; // aik = aik/akk
596 for (int l = kcol[krow]; l < kcol[krow + 1]; ++l)
597 this->m_work[cols[l]] = l;
598 for (int j = k + 1; j < kcol[irow + 1]; ++j) // j=k+1->n
599 {
600 int jcol = cols[j];
601 int kj = this->m_work[jcol];
602 if (kj != -1) {
603 values[j] -= aik * values0[kj]; // aij = aij - aik*akj
604 }
605 }
606 for (int l = kcol[krow]; l < kcol[krow + 1]; ++l)
607 this->m_work[cols[l]] = -1;
608 }
609 }
610
611 // clang-format off
612 mutable VectorType m_xk ;
613 mutable VectorType m_inv_diag ;
614 // clang-format on
615
616 public:
618 // clang-format off
620 int m_nb_solver_iter = 0 ;
621 ValueType m_tol = 0 ;
622 // clang-format on
623};
624
625template <typename AlgebraT>
626class FILU0Preconditioner
627{
628 public:
629 // clang-format off
630 typedef AlgebraT AlgebraType ;
631 typedef typename AlgebraType::Matrix MatrixType;
632 typedef typename AlgebraType::Vector VectorType;
633 typedef typename MatrixType::ValueType ValueType;
634 // clang-format on
635
637
638 FILU0Preconditioner(AlgebraType& algebra,
639 MatrixType const& matrix,
640 ITraceMng* trace_mng = nullptr)
641 : m_algebra(algebra)
642 , m_matrix(matrix)
643 , m_trace_mng(trace_mng)
644 {}
645
646 virtual ~FILU0Preconditioner()
647 {}
648
649 void setParameter(std::string param, int value)
650 {
651 m_algo.setParameter(param, value);
652 }
653
654 void setParameter(std::string param, double value)
655 {
656 m_algo.setParameter(param, value);
657 }
658
659 void init()
660 {
661 m_algo.init(m_algebra, m_matrix);
662 if (m_trace_mng) {
663 m_trace_mng->info() << "FILU Preconditioner :";
664 m_trace_mng->info() << " Nb Factor iter :" << m_algo.m_nb_factorization_iter;
665 m_trace_mng->info() << " Nb Solver iter :" << m_algo.m_nb_solver_iter;
666 m_trace_mng->info() << " Tolerance :" << m_algo.m_tol;
667 }
668 }
669
670 void solve(VectorType const& y, VectorType& x) const
671 {
672 m_algo.solve(m_algebra, y, x);
673 }
674
675 void solve(AlgebraType& algebra, VectorType const& y, VectorType& x) const
676 {
677 m_algo.solve(algebra, y, x);
678 }
679
680 private:
681 // clang-format off
682 AlgebraType& m_algebra ;
683 MatrixType const& m_matrix;
684 AlgoType m_algo ;
685
686 ITraceMng* m_trace_mng = nullptr ;
687 bool m_verbose = false ;
688 // clang-format on
689};
690
691} // namespace Alien
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Definition BackEnd.h:17