ug4
ilu.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Authors: Andreas Vogel, Arne Nägel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 
34 #ifndef __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__ILU__
35 #define __H__UG__LIB_DISC__OPERATOR__LINEAR_OPERATOR__ILU__
36 
37 #include <limits>
38 #include "common/error.h"
39 #ifndef NDEBUG
40 #include "common/stopwatch.h"
41 #endif
44 
45 #ifdef UG_PARALLEL
46  #include "pcl/pcl_util.h"
50 #endif
51 
53 #include "lib_algebra/ordering_strategies/algorithms/native_cuthill_mckee.h" // for backward compatibility
54 
56 
57 namespace ug{
58 
59 
60 // ILU(0) solver, i.e. static pattern ILU w/ P=P(A)
61 // (cf. Y Saad, Iterative methods for Sparse Linear Systems, p. 270)
62 template<typename Matrix_type>
63 bool FactorizeILU(Matrix_type &A)
64 {
65  PROFILE_FUNC_GROUP("algebra ILU");
66  typedef typename Matrix_type::row_iterator row_iterator;
67  typedef typename Matrix_type::value_type block_type;
68 
69  // for all rows
70  for(size_t i=1; i < A.num_rows(); i++)
71  {
72  // eliminate all entries A(i, k) with k<i with rows A(k, .) and k<i
73  const row_iterator rowEnd = A.end_row(i);
74  for(row_iterator it_k = A.begin_row(i); it_k != rowEnd && (it_k.index() < i); ++it_k)
75  {
76  const size_t k = it_k.index();
77  block_type &a_ik = it_k.value();
78 
79  // add row k to row i by A(i, .) -= A(k,.) A(i,k) / A(k,k)
80  // so that A(i,k) is zero.
81  // save A(i,k)/A(k,k) in A(i,k)
82  if(fabs(BlockNorm(A(k,k))) < 1e-15*BlockNorm(A(i,k)))
83  UG_THROW("Diag is Zero for k="<<k<<", cannot factorize ILU.");
84 
85  a_ik /= A(k,k);
86 
87  row_iterator it_j = it_k;
88  for(++it_j; it_j != rowEnd; ++it_j)
89  {
90  const size_t j = it_j.index();
91  block_type& a_ij = it_j.value();
92  bool bFound;
93  row_iterator p = A.get_connection(k,j, bFound);
94  if(bFound)
95  {
96  const block_type a_kj = p.value();
97  a_ij -= a_ik *a_kj;
98  }
99  }
100  }
101  }
102 
103  return true;
104 }
105 
106 // ILU(0)-beta solver, i.e.
107 // -> static pattern ILU w/ P=P(A)
108 // -> Fill-in is computed and lumped onto the diagonal
109 template<typename Matrix_type>
110 bool FactorizeILUBeta(Matrix_type &A, number beta)
111 {
112  PROFILE_FUNC_GROUP("algebra ILUBeta");
113  typedef typename Matrix_type::row_iterator row_iterator;
114  typedef typename Matrix_type::value_type block_type;
115 
116  // for all rows i=1:n do
117  for(size_t i=1; i < A.num_rows(); i++)
118  {
119  block_type &Aii = A(i,i);
120  block_type Nii(Aii); Nii*=0.0;
121 
122  // for k=1:(i-1) do
123  // eliminate all entries A(i, k) with k<i with rows A(k, .) and k<i
124  const row_iterator it_iEnd = A.end_row(i);
125  for(row_iterator it_ik = A.begin_row(i); it_ik != it_iEnd && (it_ik.index() < i); ++it_ik)
126  {
127 
128  // add row k to row i by A(i, .) -= [A(i,k) / A(k,k)] A(k,.)
129  // such that A(i,k) is zero.
130 
131  // 1) Contribution to L part:
132  // store A(i,k)/A(k,k) in A(i,k)
133  const size_t k = it_ik.index();
134  block_type &a_ik = it_ik.value();
135  a_ik /= A(k,k);
136 
137  // 2) Contribution to U part:
138  // compute contributions from row k for j=k:N
139  const row_iterator it_kEnd = A.end_row(k);
140  for (row_iterator it_kj=A.begin_row(k); it_kj != it_kEnd ;++it_kj)
141  {
142  const size_t j = it_kj.index();
143  if (j<=k) continue; // index j belongs L part?
144 
145  // this index j belongs U part
146  const block_type& a_kj = it_kj.value();
147 
148  bool aijFound;
149  row_iterator pij = A.get_connection(i,j, aijFound);
150  if(aijFound) {
151  // entry belongs to pattern
152  // -> proceed with standard elimination
153  block_type& a_ij = pij.value();
154  a_ij -= a_ik *a_kj ;
155 
156  } else {
157  // entry DOES NOT belong to pattern
158  // -> we lump it onto the diagonal
159  // TODO : non square matrices!!!
160  Nii -= a_ik * a_kj;
161  }
162 
163  }
164  }
165 
166  // add fill-in to diagonal
167  AddMult(Aii, beta, Nii);
168  }
169 
170  return true;
171 }
172 
173 template<typename Matrix_type>
174 bool FactorizeILUSorted(Matrix_type &A, const number eps = 1e-50)
175 {
176  PROFILE_FUNC_GROUP("algebra ILU");
177  typedef typename Matrix_type::row_iterator row_iterator;
178  typedef typename Matrix_type::value_type block_type;
179 
180  // for all rows
181  for(size_t i=1; i < A.num_rows(); i++)
182  {
183 
184  // eliminate all entries A(i, k) with k<i with rows A(k, .) and k<i
185  for(row_iterator it_k = A.begin_row(i); it_k != A.end_row(i) && (it_k.index() < i); ++it_k)
186  {
187  const size_t k = it_k.index();
188  block_type &a_ik = it_k.value();
189  block_type &a_kk = A(k,k);
190 
191  // add row k to row i by A(i, .) -= A(k,.) A(i,k) / A(k,k)
192  // so that A(i,k) is zero.
193  // safe A(i,k)/A(k,k) in A(i,k)
194  if(fabs(BlockNorm(A(k,k))) < eps * BlockNorm(A(i,k)))
195  UG_THROW("ILU: Blocknorm of diagonal is near-zero for k="<<k<<
196  " with eps: "<< eps <<", ||A_kk||="<<fabs(BlockNorm(A(k,k)))
197  <<", ||A_ik||="<<BlockNorm(A(i,k)));
198 
199  try {a_ik /= a_kk;}
200  UG_CATCH_THROW("Failed to calculate A_ik /= A_kk "
201  "with i = " << i << " and k = " << k << ".");
202 
203 
204  typename Matrix_type::row_iterator it_ij = it_k; // of row i
205  ++it_ij; // skip a_ik
206  typename Matrix_type::row_iterator it_kj = A.begin_row(k); // of row k
207 
208  while(it_ij != A.end_row(i) && it_kj != A.end_row(k))
209  {
210  if(it_ij.index() > it_kj.index())
211  ++it_kj;
212  else if(it_ij.index() < it_kj.index())
213  ++it_ij;
214  else
215  {
216  block_type &a_ij = it_ij.value();
217  const block_type &a_kj = it_kj.value();
218  a_ij -= a_ik * a_kj;
219  ++it_kj; ++it_ij;
220  }
221  }
222  }
223  }
224 
225  return true;
226 }
227 
228 
229 // solve x = L^-1 b
230 // Returns true on success, or false on issues that lead to some changes in the solution
231 // (the solution is computed unless no exceptions are thrown)
232 template<typename Matrix_type, typename Vector_type>
233 bool invert_L(const Matrix_type &A, Vector_type &x, const Vector_type &b)
234 {
235  PROFILE_FUNC_GROUP("algebra ILU");
236  typedef typename Matrix_type::const_row_iterator const_row_iterator;
237 
238  typename Vector_type::value_type s;
239  for(size_t i=0; i < x.size(); i++)
240  {
241  s = b[i];
242  for(const_row_iterator it = A.begin_row(i); it != A.end_row(i); ++it)
243  {
244  if(it.index() >= i) continue;
245  MatMultAdd(s, 1.0, s, -1.0, it.value(), x[it.index()]);
246  }
247  x[i] = s;
248  }
249 
250  return true;
251 }
252 
253 // solve x = U^-1 * b
254 // Returns true on success, or false on issues that lead to some changes in the solution
255 // (the solution is computed unless no exceptions are thrown)
256 template<typename Matrix_type, typename Vector_type>
257 bool invert_U(const Matrix_type &A, Vector_type &x, const Vector_type &b,
258  const number eps = 1e-8)
259 {
260  PROFILE_FUNC_GROUP("algebra ILU");
261  typedef typename Matrix_type::const_row_iterator const_row_iterator;
262 
263  typename Vector_type::value_type s;
264 
265  bool result = true;
266 
267  // last row diagonal U entry might be close to zero with corresponding close to zero rhs
268  // when solving Navier Stokes system, therefore handle separately
269  if(x.size() > 0)
270  {
271  size_t i=x.size()-1;
272  s = b[i];
273 
274  // check if diag part is significantly smaller than rhs
275  // This may happen when matrix is indefinite with one eigenvalue
276  // zero. In that case, the factorization on the last row is
277  // nearly zero due to round-off errors. In order to allow ill-
278  // scaled matrices (i.e. small matrix entries row-wise) this
279  // is compared to the rhs, that is small in this case as well.
280  //TODO: Note that this may happen for problems with naturally
281  // non-zero kernels, e.g. for the Stokes equation. One should
282  // probably suppress this message in those cases but set the
283  // rhs to 0.
284  if (BlockNorm(A(i,i)) <= eps * BlockNorm(s))
285  {
286  UG_LOG("ILU Warning: Near-zero last diagonal entry "
287  "with norm "<<BlockNorm(A(i,i))<<" in U "
288  "for non-near-zero rhs entry with norm "
289  << BlockNorm(s) << ". Setting rhs to zero.\n"
290  "NOTE: Reduce 'eps' using e.g. ILU::set_inversion_eps(...) "
291  "to avoid this warning. Current eps: " << eps << ".\n")
292  // set correction to zero
293  x[i] = 0;
294  result = false;
295  } else {
296  // c[i] = s/uii;
297  InverseMatMult(x[i], 1.0, A(i,i), s);
298  }
299  }
300  if(x.size() <= 1) return result;
301 
302  // handle all other rows
303  for(size_t i = x.size()-2; ; --i)
304  {
305  s = b[i];
306  for(const_row_iterator it = A.begin_row(i); it != A.end_row(i); ++it)
307  {
308  if(it.index() <= i) continue;
309  // s -= it.value() * x[it.index()];
310  MatMultAdd(s, 1.0, s, -1.0, it.value(), x[it.index()]);
311 
312  }
313  // x[i] = s/A(i,i);
314  InverseMatMult(x[i], 1.0, A(i,i), s);
315  if(i == 0) break;
316  }
317 
318  return result;
319 }
320 
322 template <typename TAlgebra>
323 class ILU : public IPreconditioner<TAlgebra>
324 {
325  public:
327  typedef TAlgebra algebra_type;
328 
330  typedef typename TAlgebra::vector_type vector_type;
331 
333  typedef typename TAlgebra::matrix_type matrix_type;
334 
337 
340 
342  typedef std::vector<size_t> ordering_container_type;
344 
345  protected:
346  using base_type::set_debug;
350 
351  public:
352  // Constructor
353  ILU (double beta=0.0) :
354  m_beta(beta),
355  m_sortEps(1.e-50),
356  m_invEps(1.e-8),
359  m_useOverlap(false),
361  m_bSortIsIdentity(false),
362  m_u(nullptr)
363  {};
364 
366  ILU (const ILU<TAlgebra> &parent) :
367  base_type(parent),
368  m_beta(parent.m_beta),
369  m_sortEps(parent.m_sortEps),
370  m_invEps(parent.m_invEps),
373  m_useOverlap(parent.m_useOverlap),
375  m_bSortIsIdentity(false),
376  m_u(nullptr)
377  {}
378 
381  {
382  return make_sp(new ILU<algebra_type>(*this));
383  }
384 
386  virtual ~ILU(){}
387 
389  virtual bool supports_parallel() const {return true;}
390 
392  void set_beta(double beta) {m_beta = beta;}
393 
396  m_spOrderingAlgo = ordering_algo;
397  }
398 
400  void set_sort(bool b)
401  {
402  if(b){
404  }
405  else{
407  }
408 
409  UG_LOG("\nILU: please use 'set_ordering_algorithm(..)' in the future\n");
410  }
411 
413  void set_disable_preprocessing(bool bDisable) {m_bDisablePreprocessing = bDisable;}
414 
416  void set_sort_eps(number eps) {m_sortEps = eps;}
417 
419  void set_inversion_eps(number eps) {m_invEps = eps;}
420 
422 
425 
426  void enable_overlap (bool enable) {m_useOverlap = enable;}
427 
428  protected:
429  // Name of preconditioner
430  virtual const char* name() const {return "ILU";}
431 
433  {
434  if (!m_spOrderingAlgo.valid())
435  return;
436 
437  if (m_useOverlap)
438  UG_THROW ("ILU: Ordering for overlap has not been implemented yet.");
439 
440 #ifndef NDEBUG
441  double start = get_clock_s();
442 #endif
443  if (m_u)
444  m_spOrderingAlgo->init(&m_ILU, *m_u);
445  else
446  m_spOrderingAlgo->init(&m_ILU);
447 
448  m_spOrderingAlgo->compute();
449 #ifndef NDEBUG
450  double end = get_clock_s();
451  UG_LOG("ILU: ordering took " << end-start << " seconds\n");
452 #endif
453  m_ordering = m_spOrderingAlgo->ordering();
454 
456 
457  if (!m_bSortIsIdentity)
458  {
459  matrix_type tmp;
460  tmp = m_ILU;
462  }
463  }
464 
465  protected:
467  const vector_type& u)
468  {
469  // cast to matrix based operator
471  J.template cast_dynamic<MatrixOperator<matrix_type, vector_type> >();
472 
473  // Check that matrix if of correct type
474  if(pOp.invalid())
475  UG_THROW(name() << "::init': Passed Operator is "
476  "not based on matrix. This Preconditioner can only "
477  "handle matrix-based operators.");
478 
479  m_u = &u;
480 
481  // forward request to matrix based implementation
482  return base_type::init(pOp);
483  }
484 
486  {
487  // cast to matrix based operator
489  L.template cast_dynamic<MatrixOperator<matrix_type, vector_type> >();
490 
491  // Check that matrix if of correct type
492  if(pOp.invalid())
493  UG_THROW(name() << "::init': Passed Operator is "
494  "not based on matrix. This Preconditioner can only "
495  "handle matrix-based operators.");
496 
497  m_u = NULL;
498 
499  // forward request to matrix based implementation
500  return base_type::init(pOp);
501  }
502 
504  {
505  m_u = NULL;
506 
507  return base_type::init(Op);
508  }
509 
510  protected:
511 
512  // Preprocess routine
514  {
515  // do not do a thing if preprocessing disabled
516  if (m_bDisablePreprocessing) return true;
517 
518  matrix_type &mat = *pOp;
519  PROFILE_BEGIN_GROUP(ILU_preprocess, "algebra ILU");
520  // Debug output of matrices
521  #ifdef UG_PARALLEL
522  write_overlap_debug(mat, "ILU_prep_01_A_BeforeMakeUnique");
523  #else
524  write_debug(mat, "ILU_PreProcess_orig_A");
525  #endif
526 
527  m_ILU = mat;
528 
529  #ifdef UG_PARALLEL
530  if(m_useOverlap){
532  m_oD.set_layouts(m_ILU.layouts());
533  m_oC.set_layouts(m_ILU.layouts());
534  m_oD.resize(m_ILU.num_rows(), false);
535  m_oC.resize(m_ILU.num_rows(), false);
536 
537  if(debug_writer().valid()){
539  m_overlapWriter->init (*m_ILU.layouts(),
540  *debug_writer(),
541  m_ILU.num_rows());
542  }
543  }
544  else if(m_useConsistentInterfaces){
546  }
547  else {
549  // set dirichlet rows on slaves
550  std::vector<IndexLayout::Element> vIndex;
551  CollectUniqueElements(vIndex, m_ILU.layouts()->slave());
552  SetDirichletRow(m_ILU, vIndex);
553  }
554  #endif
555 
556  m_h.resize(m_ILU.num_cols());
557 
558  #ifdef UG_PARALLEL
559  write_overlap_debug(m_ILU, "ILU_prep_02_A_AfterMakeUnique");
560  #endif
561 
562  apply_ordering();
563 
564  // Debug output of matrices
565  #ifdef UG_PARALLEL
566  write_overlap_debug(m_ILU, "ILU_prep_03_A_BeforeFactorize");
567  #else
568  write_debug(m_ILU, "ILU_PreProcess_U_BeforeFactor");
569  #endif
570 
571 
572  // Compute ILU Factorization
573  if (m_beta!=0.0) FactorizeILUBeta(m_ILU, m_beta);
574  else if(matrix_type::rows_sorted) FactorizeILUSorted(m_ILU, m_sortEps);
575  else FactorizeILU(m_ILU);
576  m_ILU.defragment();
577 
578  // Debug output of matrices
579  #ifdef UG_PARALLEL
580  write_overlap_debug(m_ILU, "ILU_prep_04_A_AfterFactorize");
581  #else
582  write_debug(m_ILU, "ILU_PreProcess_U_AfterFactor");
583  #endif
584 
585  // we're done
586  return true;
587  }
588 
589 
590  void applyLU(vector_type &c, const vector_type &d, vector_type &tmp)
591  {
592 
593  if(m_spOrderingAlgo.invalid() || m_bSortIsIdentity)
594  {
595  // apply iterator: c = LU^{-1}*d
596  if(! invert_L(m_ILU, tmp, d)) // h := L^-1 d
597  print_debugger_message("ILU: There were issues at inverting L\n");
598  if(! invert_U(m_ILU, c, tmp, m_invEps)) // c := U^-1 h = (LU)^-1 d
599  print_debugger_message("ILU: There were issues at inverting U\n");
600  }
602  else
603  {
604  // we save one vector here by renaming
606  if(! invert_L(m_ILU, c, tmp)) // c = L^{-1} d
607  print_debugger_message("ILU: There were issues at inverting L (after permutation)\n");
608  if(! invert_U(m_ILU, tmp, c, m_invEps)) // tmp = (LU)^{-1} d
609  print_debugger_message("ILU: There were issues at inverting U (after permutation)\n");
611  }
612 //*/
613  }
614 
615  // Stepping routine
617  vector_type& c,
618  const vector_type& d)
619  {
620  PROFILE_BEGIN_GROUP(ILU_step, "algebra ILU");
621 
622 
623  // \todo: introduce damping
624  #ifdef UG_PARALLEL
625  // for debug output (only for application is written)
626  static bool first = true;
627 
628  if(first) write_overlap_debug(d, "ILU_step_1_d");
629  if(m_useOverlap){
630  for(size_t i = 0; i < d.size(); ++i)
631  m_oD[i] = d[i];
632  for(size_t i = d.size(); i < m_oD.size(); ++i)
633  m_oD[i] = 0;
634  m_oD.set_storage_type(PST_ADDITIVE);
635  m_oD.change_storage_type(PST_CONSISTENT);
636 
637  if(first) write_overlap_debug(m_oD, "ILU_step_2_oD_consistent");
638 
639  applyLU(m_oC, m_oD, m_h);
640 
641  for(size_t i = 0; i < c.size(); ++i)
642  c[i] = m_oC[i];
643  SetLayoutValues(&c, c.layouts()->slave(), 0);
644  c.set_storage_type(PST_UNIQUE);
645  }
646  else if(m_useConsistentInterfaces){
647  // make defect consistent
648  SmartPtr<vector_type> spDtmp = d.clone();
649  spDtmp->change_storage_type(PST_CONSISTENT);
650  applyLU(c, *spDtmp, m_h);
651 
652  // declare c unique to enforce that only master correction is used
653  // when it is made consistent below
654  c.set_storage_type(PST_UNIQUE);
655  }
656  else{
657  // make defect unique
658  SmartPtr<vector_type> spDtmp = d.clone();
659 // SetVectorAsPermutation(*spDtmp, d, m_ordering);
660 
661  spDtmp->change_storage_type(PST_UNIQUE);
662  if(first) write_debug(*spDtmp, "ILU_step_2_d_unique");
663  applyLU(c, *spDtmp, m_h);
664  c.set_storage_type(PST_ADDITIVE);
665  }
666 
667  // write debug
668  if(first) write_overlap_debug(c, "ILU_step_3_c");
669 
670  c.change_storage_type(PST_CONSISTENT);
671 
672  // write debug
673  if(first) {write_overlap_debug(c, "ILU_step_4_c_consistent"); first = false;}
674 
675  #else
676  write_debug(d, "ILU_step_d");
677  applyLU(c, d, m_h);
678  write_debug(c, "ILU_step_c");
679  #endif
680 
681  // we're done
682  return true;
683  }
684 
686  virtual bool postprocess() {return true;}
687 
688  private:
689  #ifdef UG_PARALLEL
690  template <class T> void write_overlap_debug(const T& t, std::string name)
691  {
692  if(debug_writer().valid()){
693  if(m_useOverlap && m_overlapWriter.valid() && t.layouts()->overlap_enabled())
694  m_overlapWriter->write(t, name);
695  else
696  write_debug(t, name.c_str());
697  }
698  }
699  #endif
700 
701  protected:
704 
707 
711  #ifdef UG_PARALLEL
713  #endif
714 
717 
720 
723 
726 
729 
733  std::vector<size_t> m_newIndex, m_oldIndex;
735 
736  const vector_type* m_u;
737 };
738 
739 } // end namespace ug
740 
741 #endif
parameterString p
parameterString s
Definition: smart_pointer.h:108
bool invalid() const
returns true if the pointer is invalid, false if not.
Definition: smart_pointer.h:212
virtual void set_debug(SmartPtr< IDebugWriter< algebra_type > > spDebugWriter)
set debug writer
Definition: debug_writer.h:384
void write_debug(const matrix_type &mat, const char *filename)
write debug output for a matrix (if debug writer set)
Definition: debug_writer.h:399
SmartPtr< IDebugWriter< algebra_type > > debug_writer()
returns the debug writer
Definition: debug_writer.h:391
TAlgebra::matrix_type matrix_type
type of matrix
Definition: debug_writer.h:363
ILU / ILU(beta) preconditioner.
Definition: ilu.h:324
TAlgebra::matrix_type matrix_type
Matrix type.
Definition: ilu.h:333
virtual SmartPtr< ILinearIterator< vector_type > > clone()
Clone.
Definition: ilu.h:380
virtual bool postprocess()
Postprocess routine.
Definition: ilu.h:686
IOrderingAlgorithm< TAlgebra, ordering_container_type > ordering_algo_type
Definition: ilu.h:343
bool init(SmartPtr< ILinearOperator< vector_type > > L)
Definition: ilu.h:485
vector_type m_oD
for overlaps only
Definition: ilu.h:709
number m_sortEps
smallest allowed value for sorted factorization
Definition: ilu.h:719
vector_type m_h
help vector
Definition: ilu.h:706
void set_disable_preprocessing(bool bDisable)
disable preprocessing (if underlying matrix has not changed)
Definition: ilu.h:413
TAlgebra algebra_type
Algebra type.
Definition: ilu.h:327
void set_beta(double beta)
set factor for
Definition: ilu.h:392
void apply_ordering()
Definition: ilu.h:432
virtual const char * name() const
returns the name of iterator
Definition: ilu.h:430
SmartPtr< OverlapWriter< TAlgebra > > m_overlapWriter
Definition: ilu.h:712
IPreconditioner< TAlgebra > base_type
Base type.
Definition: ilu.h:339
virtual bool preprocess(SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp)
initializes the preconditioner
Definition: ilu.h:513
bool m_bDisablePreprocessing
whether or not to disable preprocessing
Definition: ilu.h:725
void set_ordering_algorithm(SmartPtr< ordering_algo_type > ordering_algo)
sets an ordering algorithm
Definition: ilu.h:395
void enable_overlap(bool enable)
Definition: ilu.h:426
bool init(SmartPtr< MatrixOperator< matrix_type, vector_type > > Op)
Definition: ilu.h:503
bool m_useOverlap
Definition: ilu.h:728
std::vector< size_t > m_oldIndex
Definition: ilu.h:733
SmartPtr< ordering_algo_type > m_spOrderingAlgo
for ordering algorithms
Definition: ilu.h:731
bool m_useConsistentInterfaces
Definition: ilu.h:727
std::vector< size_t > ordering_container_type
Ordering type.
Definition: ilu.h:342
virtual bool supports_parallel() const
returns if parallel solving is supported
Definition: ilu.h:389
ILU(double beta=0.0)
Definition: ilu.h:353
vector_type m_oC
Definition: ilu.h:710
virtual bool step(SmartPtr< MatrixOperator< matrix_type, vector_type > > pOp, vector_type &c, const vector_type &d)
computes a new correction c = B*d
Definition: ilu.h:616
void applyLU(vector_type &c, const vector_type &d, vector_type &tmp)
Definition: ilu.h:590
void enable_consistent_interfaces(bool enable)
enables consistent interfaces.
Definition: ilu.h:424
std::vector< size_t > m_newIndex
Definition: ilu.h:733
number m_beta
factor for ILU-beta
Definition: ilu.h:716
IPreconditioner< TAlgebra >::matrix_operator_type matrix_operator_type
Matrix Operator type.
Definition: ilu.h:336
number m_invEps
smallest allowed value for the Aii/Bi quotient
Definition: ilu.h:722
void set_sort_eps(number eps)
sets the smallest allowed value for sorted factorization
Definition: ilu.h:416
ILU(const ILU< TAlgebra > &parent)
clone constructor
Definition: ilu.h:366
void write_overlap_debug(const T &t, std::string name)
Definition: ilu.h:690
ordering_container_type m_old_ordering
Definition: ilu.h:732
bool m_bSortIsIdentity
Definition: ilu.h:734
TAlgebra::vector_type vector_type
Vector type.
Definition: ilu.h:330
const vector_type * m_u
Definition: ilu.h:736
matrix_type m_ILU
storage for factorization
Definition: ilu.h:703
void set_sort(bool b)
set cuthill-mckee sort on/off
Definition: ilu.h:400
ordering_container_type m_ordering
Definition: ilu.h:732
virtual bool init(SmartPtr< ILinearOperator< vector_type > > J, const vector_type &u)
implements the ILinearIterator-interface for matrix based preconditioner
Definition: ilu.h:466
virtual ~ILU()
Destructor.
Definition: ilu.h:386
void set_inversion_eps(number eps)
sets the smallest allowed value for the Aii/Bi quotient
Definition: ilu.h:419
describes a linear mapping X->Y
Definition: linear_operator.h:80
Definition: IOrderingAlgorithm.h:52
describes a linear iterator that is based on a matrix operator
Definition: preconditioner.h:103
virtual bool init(SmartPtr< ILinearOperator< vector_type > > J, const vector_type &u)
implements the ILinearIterator-interface for matrix based preconditioner
Definition: preconditioner.h:192
Definition: matrix_operator.h:49
Definition: native_cuthill_mckee.h:96
Writes overlapping matrices and vectors.
Definition: overlap_writer.h:52
void print_debugger_message(std::string msg)
prints a debugger message (listing all the sections)
Definition: debug_writer.h:320
void SetLayoutValues(TVector *pVec, const IndexLayout &layout, typename TVector::value_type val)
sets the values of a vector to a given number only on the layout indices
Definition: parallelization_util.h:315
void MatAddSlaveRowsToMasterRowOverlap0(TMatrix &mat)
Generates a set of unique global algebra ids.
Definition: parallelization_util.h:106
void MatMakeConsistentOverlap0(TMatrix &mat)
Generates a set of unique global algebra ids.
Definition: parallelization_util.h:126
@ PST_CONSISTENT
Definition: parallel_storage_type.h:68
@ PST_UNIQUE
Definition: parallel_storage_type.h:70
@ PST_ADDITIVE
Definition: parallel_storage_type.h:69
void SetDirichletRow(TSparseMatrix &A, size_t i, size_t alpha)
Definition: sparsematrix_util.h:796
void CollectUniqueElements(std::vector< typename TLayout::Element > &elemsOut, const TLayout &layout)
writes all elements in the interfaces into the resulting vector. avoids doubles.
Definition: pcl_layout_util.h:142
const NullSmartPtr SPNULL
The equivalent to NULL for smart pointers.
Definition: smart_pointer.h:90
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
double number
Definition: types.h:124
the ug namespace
bool FactorizeILUBeta(Matrix_type &A, number beta)
Definition: ilu.h:110
bool FactorizeILUSorted(Matrix_type &A, const number eps=1e-50)
Definition: ilu.h:174
double get_clock_s()
Definition: stopwatch.h:103
bool invert_L(const Matrix_type &A, Vector_type &x, const Vector_type &b)
Definition: ilu.h:233
static void SetVectorAsPermutation(TVector &Pv, const TVector &v, const std::vector< size_t > &perm)
Definition: permutation_util.h:74
bool MatMultAdd(vector_t &dest, const number &alpha1, const vector_t &v1, const number &beta1, const matrix_t &A1, const vector_t &w1)
calculates dest = alpha1*v1 + beta1 * A1 *w1;
Definition: operations_mat.h:68
void CreateOverlap(TMatrix &matInOut)
Adds coefficients and connections to create an overlapping matrix.
Definition: matrix_overlap_impl.h:434
static void SetMatrixAsPermutation(TMatrix &PA, const TMatrix &A, const std::vector< size_t > &perm)
Definition: permutation_util.h:50
bool GetInversePermutation(const std::vector< size_t > &perm, std::vector< size_t > &invPerm)
Definition: permutation_util.cpp:39
bool invert_U(const Matrix_type &A, Vector_type &x, const Vector_type &b, const number eps=1e-8)
Definition: ilu.h:257
void AddMult(A &dest, const B &b, const C &vec)
bool InverseMatMult(number &dest, const double &beta, const TMat &mat, const TVec &vec)
you can implement this function with GetInverse and MatMult
bool FactorizeILU(Matrix_type &A)
Definition: ilu.h:63
double BlockNorm(const TYPE &v)
Definition: blocks.h:57
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258
#define PROFILE_BEGIN_GROUP(name, groups)
Definition: profiler.h:255
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836
T value_type
Definition: sparsematrix_interface.h:2
stopwatch class for quickly taking times