Reference documentation for deal.II version 8.4.2
petsc_solver.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2004 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #include <deal.II/base/logstream.h>
18 #include <deal.II/lac/petsc_solver.h>
19 
20 #ifdef DEAL_II_WITH_PETSC
21 
22 # include <deal.II/lac/petsc_matrix_base.h>
23 # include <deal.II/lac/petsc_vector_base.h>
24 # include <deal.II/lac/petsc_precondition.h>
25 # include <cmath>
26 
27 #include <petscversion.h>
28 
29 DEAL_II_NAMESPACE_OPEN
30 
31 namespace PETScWrappers
32 {
33 
35  {
36  if (ksp != NULL)
37  {
38  // destroy the solver object
39 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
40  int ierr = KSPDestroy (ksp);
41 #else
42  int ierr = KSPDestroy (&ksp);
43 #endif
44 
45  AssertThrow (ierr == 0, ExcPETScError(ierr));
46  }
47  }
48 
49 
50 
52  const MPI_Comm &mpi_communicator)
53  :
54  solver_control (cn),
55  mpi_communicator (mpi_communicator)
56  {}
57 
58 
59 
61  {}
62 
63 
64 
65  void
67  VectorBase &x,
68  const VectorBase &b,
69  const PreconditionerBase &preconditioner)
70  {
71  int ierr;
72 
73  /*
74  TODO: PETSc duplicates communicators, so this does not work (you put MPI_COMM_SELF in, but get something other out when you ask PETSc for the communicator. This mainly fails due to the MatrixFree classes, that can not ask PETSc for a communicator. //Timo Heister
75  Assert(A.get_mpi_communicator()==mpi_communicator, ExcMessage("PETSc Solver and Matrix need to use the same MPI_Comm."));
76  Assert(x.get_mpi_communicator()==mpi_communicator, ExcMessage("PETSc Solver and Vector need to use the same MPI_Comm."));
77  Assert(b.get_mpi_communicator()==mpi_communicator, ExcMessage("PETSc Solver and Vector need to use the same MPI_Comm."));
78  */
79 
80  // first create a solver object if this
81  // is necessary
82  if (solver_data.get() == 0)
83  {
84  solver_data.reset (new SolverData());
85 
86  ierr = KSPCreate (mpi_communicator, &solver_data->ksp);
87  AssertThrow (ierr == 0, ExcPETScError(ierr));
88 
89  // let derived classes set the solver
90  // type, and the preconditioning
91  // object set the type of
92  // preconditioner
94 
95  ierr = KSPSetPC (solver_data->ksp, preconditioner.get_pc());
96  AssertThrow (ierr == 0, ExcPETScError(ierr));
97 
98  // make sure the preconditioner has an associated matrix set
99  const Mat B = preconditioner;
100  AssertThrow (B != NULL,
101  ExcMessage("PETSc preconditioner should have an"
102  "associated matrix set to be used in solver."));
103 
104  // setting the preconditioner overwrites the used matrices.
105  // hence, we need to set the matrices after the preconditioner.
106 #if DEAL_II_PETSC_VERSION_LT(3, 5, 0)
107  // the last argument is irrelevant here,
108  // since we use the solver only once anyway
109  ierr = KSPSetOperators (solver_data->ksp, A, preconditioner,
110  SAME_PRECONDITIONER);
111 #else
112  ierr = KSPSetOperators (solver_data->ksp, A, preconditioner);
113 #endif
114  AssertThrow (ierr == 0, ExcPETScError(ierr));
115 
116  // then a convergence monitor
117  // function. that function simply
118  // checks with the solver_control
119  // object we have in this object for
120  // convergence
121  KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
122  reinterpret_cast<void *>(&solver_control),
123  PETSC_NULL);
124  }
125 
126  // set the command line option prefix name
127  ierr = KSPSetOptionsPrefix(solver_data->ksp, prefix_name.c_str());
128  AssertThrow (ierr == 0, ExcPETScError(ierr));
129 
130  // set the command line options provided
131  // by the user to override the defaults
132  ierr = KSPSetFromOptions (solver_data->ksp);
133  AssertThrow (ierr == 0, ExcPETScError(ierr));
134 
135  // then do the real work: set up solver
136  // internal data and solve the
137  // system.
138  ierr = KSPSetUp (solver_data->ksp);
139  AssertThrow (ierr == 0, ExcPETScError(ierr));
140 
141  ierr = KSPSolve (solver_data->ksp, b, x);
142  AssertThrow (ierr == 0, ExcPETScError(ierr));
143 
144  // do not destroy solver object
145 // solver_data.reset ();
146 
147  // in case of failure: throw
148  // exception
152  // otherwise exit as normal
153  }
154 
155 
156  void
157  SolverBase::set_prefix(const std::string &prefix)
158  {
159  prefix_name = prefix ;
160  }
161 
162 
163  void
165  {
166  solver_data.reset ();
167  }
168 
169 
170  SolverControl &
172  {
173  return solver_control;
174  }
175 
176 
177  int
179  const PetscInt iteration,
180  const PetscReal residual_norm,
181  KSPConvergedReason *reason,
182  void *solver_control_x)
183  {
184  SolverControl &solver_control = *reinterpret_cast<SolverControl *>(solver_control_x);
185 
186  const SolverControl::State state
187  = solver_control.check (iteration, residual_norm);
188 
189  switch (state)
190  {
191  case ::SolverControl::iterate:
192  *reason = KSP_CONVERGED_ITERATING;
193  break;
194 
195  case ::SolverControl::success:
196  *reason = static_cast<KSPConvergedReason>(1);
197  break;
198 
199  case ::SolverControl::failure:
200  if (solver_control.last_step() > solver_control.max_steps())
201  *reason = KSP_DIVERGED_ITS;
202  else
203  *reason = KSP_DIVERGED_DTOL;
204  break;
205 
206  default:
207  Assert (false, ExcNotImplemented());
208  }
209 
210  // return without failure
211  return 0;
212  }
213 
214  void
216  {
217  int ierr;
218 
219  solver_data.reset (new SolverData());
220 
221  ierr = KSPCreate (mpi_communicator, &solver_data->ksp);
222  AssertThrow (ierr == 0, ExcPETScError(ierr));
223 
224  // let derived classes set the solver
225  // type, and the preconditioning
226  // object set the type of
227  // preconditioner
229 
230  ierr = KSPSetPC (solver_data->ksp, preconditioner.get_pc());
231  AssertThrow (ierr == 0, ExcPETScError(ierr));
232 
233  // then a convergence monitor
234  // function. that function simply
235  // checks with the solver_control
236  // object we have in this object for
237  // convergence
238  KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
239  reinterpret_cast<void *>(&solver_control),
240  PETSC_NULL);
241 
242  // set the command line options provided
243  // by the user to override the defaults
244  ierr = KSPSetFromOptions (solver_data->ksp);
245  AssertThrow (ierr == 0, ExcPETScError(ierr));
246  }
247 
248 
249 
250  /* ---------------------- SolverRichardson ------------------------ */
251 
253  AdditionalData (const double omega)
254  :
255  omega (omega)
256  {}
257 
258 
259 
261  const MPI_Comm &mpi_communicator,
262  const AdditionalData &data)
263  :
264  SolverBase (cn, mpi_communicator),
265  additional_data (data)
266  {}
267 
268 
269  void
271  {
272  int ierr;
273  ierr = KSPSetType (ksp, KSPRICHARDSON);
274  AssertThrow (ierr == 0, ExcPETScError(ierr));
275 
276  // set the damping factor from the data
277  ierr = KSPRichardsonSetScale (ksp, additional_data.omega);
278  AssertThrow (ierr == 0, ExcPETScError(ierr));
279 
280  // in the deal.II solvers, we always
281  // honor the initial guess in the
282  // solution vector. do so here as well:
283  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
284 
285  // Hand over the absolute
286  // tolerance and the maximum
287  // iteration number to the PETSc
288  // convergence criterion. The
289  // custom deal.II SolverControl
290  // object is ignored by the PETSc
291  // Richardson method (when no
292  // PETSc monitoring is present),
293  // since in this case PETSc
294  // uses a faster version of
295  // the Richardson iteration,
296  // where no residual is
297  // available.
298  KSPSetTolerances(ksp, PETSC_DEFAULT, this->solver_control.tolerance(),
299  PETSC_DEFAULT, this->solver_control.max_steps()+1);
300  }
301 
302 
303  /* ---------------------- SolverChebychev ------------------------ */
304 
306  const MPI_Comm &mpi_communicator,
307  const AdditionalData &data)
308  :
309  SolverBase (cn, mpi_communicator),
310  additional_data (data)
311  {}
312 
313 
314  void
316  {
317  // set the type of solver. note the
318  // completely pointless change in
319  // spelling Chebyshev between PETSc 3.2
320  // and 3.3...
321  int ierr;
322 
323 #if DEAL_II_PETSC_VERSION_LT(3,3,0)
324  ierr = KSPSetType (ksp, KSPCHEBYCHEV);
325 #else
326  ierr = KSPSetType (ksp, KSPCHEBYSHEV);
327 #endif
328  AssertThrow (ierr == 0, ExcPETScError(ierr));
329 
330  // in the deal.II solvers, we always
331  // honor the initial guess in the
332  // solution vector. do so here as well:
333  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
334  }
335 
336 
337  /* ---------------------- SolverCG ------------------------ */
338 
340  const MPI_Comm &mpi_communicator,
341  const AdditionalData &data)
342  :
343  SolverBase (cn, mpi_communicator),
344  additional_data (data)
345  {}
346 
347 
348  void
349  SolverCG::set_solver_type (KSP &ksp) const
350  {
351  int ierr;
352  ierr = KSPSetType (ksp, KSPCG);
353  AssertThrow (ierr == 0, ExcPETScError(ierr));
354 
355  // in the deal.II solvers, we always
356  // honor the initial guess in the
357  // solution vector. do so here as well:
358  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
359  }
360 
361 
362  /* ---------------------- SolverBiCG ------------------------ */
363 
365  const MPI_Comm &mpi_communicator,
366  const AdditionalData &data)
367  :
368  SolverBase (cn, mpi_communicator),
369  additional_data (data)
370  {}
371 
372 
373  void
375  {
376  int ierr;
377  ierr = KSPSetType (ksp, KSPBICG);
378  AssertThrow (ierr == 0, ExcPETScError(ierr));
379 
380  // in the deal.II solvers, we always
381  // honor the initial guess in the
382  // solution vector. do so here as well:
383  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
384  }
385 
386 
387  /* ---------------------- SolverGMRES ------------------------ */
388 
390  AdditionalData (const unsigned int restart_parameter,
391  const bool right_preconditioning)
392  :
393  restart_parameter (restart_parameter),
394  right_preconditioning (right_preconditioning)
395  {}
396 
397 
398 
400  const MPI_Comm &mpi_communicator,
401  const AdditionalData &data)
402  :
403  SolverBase (cn, mpi_communicator),
404  additional_data (data)
405  {}
406 
407 
408  void
410  {
411  int ierr;
412  ierr = KSPSetType (ksp, KSPGMRES);
413  AssertThrow (ierr == 0, ExcPETScError(ierr));
414 
415  // set the restart parameter from the
416  // data. we would like to use the simple
417  // code that is commented out, but this
418  // leads to nasty warning and error
419  // messages due to some stupidity on
420  // PETSc's side: KSPGMRESSetRestart is
421  // implemented as a macro in which return
422  // statements are hidden. This may work
423  // if people strictly follow the PETSc
424  // coding style of always having
425  // functions return an integer error
426  // code, but the present function isn't
427  // like this.
428  /*
429  ierr = KSPGMRESSetRestart (ksp, additional_data.restart_parameter);
430  AssertThrow (ierr == 0, ExcPETScError(ierr));
431  */
432  // so rather expand their macros by hand,
433  // and do some equally nasty stuff that at
434  // least doesn't yield warnings...
435  int (*fun_ptr)(KSP,int);
436  ierr = PetscObjectQueryFunction((PetscObject)(ksp),
437  "KSPGMRESSetRestart_C",
438  (void (* *)())&fun_ptr);
439  AssertThrow (ierr == 0, ExcPETScError(ierr));
440 
441  ierr = (*fun_ptr)(ksp,additional_data.restart_parameter);
442  AssertThrow (ierr == 0, ExcPETScError(ierr));
443 
444  // Set preconditioning side to
445  // right
447  {
448 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
449  ierr = KSPSetPreconditionerSide(ksp, PC_RIGHT);
450 #else
451  ierr = KSPSetPCSide(ksp, PC_RIGHT);
452 #endif
453 
454  AssertThrow (ierr == 0, ExcPETScError(ierr));
455  }
456 
457  // in the deal.II solvers, we always
458  // honor the initial guess in the
459  // solution vector. do so here as well:
460  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
461  }
462 
463 
464  /* ---------------------- SolverBicgstab ------------------------ */
465 
467  const MPI_Comm &mpi_communicator,
468  const AdditionalData &data)
469  :
470  SolverBase (cn, mpi_communicator),
471  additional_data (data)
472  {}
473 
474 
475  void
477  {
478  int ierr;
479  ierr = KSPSetType (ksp, KSPBCGS);
480  AssertThrow (ierr == 0, ExcPETScError(ierr));
481 
482  // in the deal.II solvers, we always
483  // honor the initial guess in the
484  // solution vector. do so here as well:
485  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
486  }
487 
488 
489  /* ---------------------- SolverCGS ------------------------ */
490 
492  const MPI_Comm &mpi_communicator,
493  const AdditionalData &data)
494  :
495  SolverBase (cn, mpi_communicator),
496  additional_data (data)
497  {}
498 
499 
500  void
501  SolverCGS::set_solver_type (KSP &ksp) const
502  {
503  int ierr;
504  ierr = KSPSetType (ksp, KSPCGS);
505  AssertThrow (ierr == 0, ExcPETScError(ierr));
506 
507  // in the deal.II solvers, we always
508  // honor the initial guess in the
509  // solution vector. do so here as well:
510  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
511  }
512 
513 
514  /* ---------------------- SolverTFQMR ------------------------ */
515 
517  const MPI_Comm &mpi_communicator,
518  const AdditionalData &data)
519  :
520  SolverBase (cn, mpi_communicator),
521  additional_data (data)
522  {}
523 
524 
525  void
527  {
528  int ierr;
529  ierr = KSPSetType (ksp, KSPTFQMR);
530  AssertThrow (ierr == 0, ExcPETScError(ierr));
531 
532  // in the deal.II solvers, we always
533  // honor the initial guess in the
534  // solution vector. do so here as well:
535  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
536  }
537 
538 
539  /* ---------------------- SolverTCQMR ------------------------ */
540 
542  const MPI_Comm &mpi_communicator,
543  const AdditionalData &data)
544  :
545  SolverBase (cn, mpi_communicator),
546  additional_data (data)
547  {}
548 
549 
550  void
552  {
553  int ierr;
554  ierr = KSPSetType (ksp, KSPTCQMR);
555  AssertThrow (ierr == 0, ExcPETScError(ierr));
556 
557  // in the deal.II solvers, we always
558  // honor the initial guess in the
559  // solution vector. do so here as well:
560  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
561  }
562 
563 
564  /* ---------------------- SolverCR ------------------------ */
565 
567  const MPI_Comm &mpi_communicator,
568  const AdditionalData &data)
569  :
570  SolverBase (cn, mpi_communicator),
571  additional_data (data)
572  {}
573 
574 
575  void
576  SolverCR::set_solver_type (KSP &ksp) const
577  {
578  int ierr;
579  ierr = KSPSetType (ksp, KSPCR);
580  AssertThrow (ierr == 0, ExcPETScError(ierr));
581 
582  // in the deal.II solvers, we always
583  // honor the initial guess in the
584  // solution vector. do so here as well:
585  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
586  }
587 
588 
589  /* ---------------------- SolverLSQR ------------------------ */
590 
592  const MPI_Comm &mpi_communicator,
593  const AdditionalData &data)
594  :
595  SolverBase (cn, mpi_communicator),
596  additional_data (data)
597  {}
598 
599 
600  void
602  {
603  int ierr;
604  ierr = KSPSetType (ksp, KSPLSQR);
605  AssertThrow (ierr == 0, ExcPETScError(ierr));
606 
607  // in the deal.II solvers, we always
608  // honor the initial guess in the
609  // solution vector. do so here as well:
610  KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
611  }
612 
613 
614  /* ---------------------- SolverPreOnly ------------------------ */
615 
617  const MPI_Comm &mpi_communicator,
618  const AdditionalData &data)
619  :
620  SolverBase (cn, mpi_communicator),
621  additional_data (data)
622  {}
623 
624 
625  void
627  {
628  int ierr;
629  ierr = KSPSetType (ksp, KSPPREONLY);
630  AssertThrow (ierr == 0, ExcPETScError(ierr));
631 
632  // The KSPPREONLY solver of
633  // PETSc never calls the convergence
634  // monitor, which leads to failure
635  // even when everything was ok.
636  // Therefore the SolverControl status
637  // is set to some nice values, which
638  // guarantee a nice result at the end
639  // of the solution process.
640  solver_control.check (1, 0.0);
641 
642  // Using the PREONLY solver with
643  // a nonzero initial guess leads
644  // PETSc to produce some error messages.
645  KSPSetInitialGuessNonzero (ksp, PETSC_FALSE);
646  }
647 
648 
649  /* ---------------------- SparseDirectMUMPS------------------------ */
650 
652  {
653  // destroy the solver object
654 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
655  int ierr = KSPDestroy (ksp);
656 #else
657  int ierr = KSPDestroy (&ksp);
658 #endif
659 
660  AssertThrow (ierr == 0, ExcPETScError(ierr));
661  }
662 
663 
665  const MPI_Comm &mpi_communicator,
666  const AdditionalData &data)
667  :
668  SolverBase (cn, mpi_communicator),
669  additional_data (data),
670  symmetric_mode(false)
671  {}
672 
673 
674  void
676  {
682  int ierr;
683  ierr = KSPSetType (ksp, KSPPREONLY);
684  AssertThrow (ierr == 0, ExcPETScError(ierr));
685 
692  solver_control.check (1, 0.0);
693 
698  KSPSetInitialGuessNonzero (ksp, PETSC_FALSE);
699  }
700 
701  void
703  VectorBase &x,
704  const VectorBase &b)
705  {
706 #ifdef PETSC_HAVE_MUMPS
707  int ierr;
708 
712  Mat F;
713 
719  PetscInt ival=2, icntl=7;
723  PetscInt its;
727  PetscReal rnorm;
728 
732  if (solver_data.get() == 0)
733  {
734  solver_data.reset (new SolverDataMUMPS ());
735 
740  ierr = KSPCreate (mpi_communicator, &solver_data->ksp);
741  AssertThrow (ierr == 0, ExcPETScError(ierr));
742 
747 #if DEAL_II_PETSC_VERSION_LT(3, 5, 0)
748  ierr = KSPSetOperators (solver_data->ksp, A, A,
749  DIFFERENT_NONZERO_PATTERN);
750 #else
751  ierr = KSPSetOperators (solver_data->ksp, A, A);
752 #endif
753  AssertThrow (ierr == 0, ExcPETScError(ierr));
754 
758  set_solver_type (solver_data->ksp);
759 
763  ierr = KSPGetPC (solver_data->ksp, & solver_data->pc);
764  AssertThrow (ierr == 0, ExcPETScError(ierr));
765 
770  if (symmetric_mode)
771  ierr = PCSetType (solver_data->pc, PCCHOLESKY);
772  else
773  ierr = PCSetType (solver_data->pc, PCLU);
774  AssertThrow (ierr == 0, ExcPETScError(ierr));
775 
780  KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
781  reinterpret_cast<void *>(&solver_control),
782  PETSC_NULL);
783 
789 #if DEAL_II_PETSC_VERSION_GTE(3,2,0)
790  ierr = PCFactorSetMatSolverPackage (solver_data->pc, MATSOLVERMUMPS);
791 #else
792  ierr = PCFactorSetMatSolverPackage (solver_data->pc, MAT_SOLVER_MUMPS);
793 #endif
794  AssertThrow (ierr == 0, ExcPETScError (ierr));
795 
799  ierr = PCFactorSetUpMatSolverPackage (solver_data->pc);
800  AssertThrow (ierr == 0, ExcPETScError(ierr));
801 
807  ierr = PCFactorGetMatrix(solver_data->pc, &F);
808  AssertThrow (ierr == 0, ExcPETScError(ierr));
809 
813  ierr = MatMumpsSetIcntl (F, icntl, ival);
814  AssertThrow (ierr == 0, ExcPETScError(ierr));
815 
819  ierr = KSPSetOptionsPrefix(solver_data->ksp, prefix_name.c_str());
820  AssertThrow (ierr == 0, ExcPETScError(ierr));
821 
826  ierr = KSPSetFromOptions (solver_data->ksp);
827  AssertThrow (ierr == 0, ExcPETScError(ierr));
828 
829  }
830 
834  ierr = KSPSolve (solver_data->ksp, b, x);
835  AssertThrow (ierr == 0, ExcPETScError(ierr));
836 
841  {
844  }
845  else
846  {
851  ierr = KSPGetIterationNumber (solver_data->ksp, &its);
852  AssertThrow (ierr == 0, ExcPETScError(ierr));
853  ierr = KSPGetResidualNorm (solver_data->ksp, &rnorm);
854  AssertThrow (ierr == 0, ExcPETScError(ierr));
855  }
856 
857 #else // PETSC_HAVE_MUMPS
858  Assert (false,
859  ExcMessage ("Your PETSc installation does not include a copy of "
860  "the MUMPS package necessary for this solver. You will need to configure "
861  "PETSc so that it includes MUMPS, recompile it, and then re-configure "
862  "and recompile deal.II as well."));
863 
864  // Cast to void to silence compiler warnings
865  (void) A;
866  (void) x;
867  (void) b;
868 #endif
869 
870  }
871 
872  PetscErrorCode SparseDirectMUMPS::convergence_test (KSP /*ksp*/,
873  const PetscInt iteration,
874  const PetscReal residual_norm,
875  KSPConvergedReason *reason,
876  void *solver_control_x)
877  {
878  SolverControl &solver_control = *reinterpret_cast<SolverControl *>(solver_control_x);
879 
880  const SolverControl::State state
881  = solver_control.check (iteration, residual_norm);
882 
883  switch (state)
884  {
885  case ::SolverControl::iterate:
886  *reason = KSP_CONVERGED_ITERATING;
887  break;
888 
889  case ::SolverControl::success:
890  *reason = static_cast<KSPConvergedReason>(1);
891  break;
892 
893  case ::SolverControl::failure:
894  if (solver_control.last_step() > solver_control.max_steps())
895  *reason = KSP_DIVERGED_ITS;
896  else
897  *reason = KSP_DIVERGED_DTOL;
898  break;
899 
900  default:
901  Assert (false, ExcNotImplemented());
902  }
903 
904  return 0;
905  }
906 
907  void
909  {
910  symmetric_mode = flag;
911  }
912 
913 }
914 
915 DEAL_II_NAMESPACE_CLOSE
916 
917 #endif // DEAL_II_WITH_PETSC
void solve(const MatrixBase &A, VectorBase &x, const VectorBase &b, const PreconditionerBase &preconditioner)
Definition: petsc_solver.cc:66
virtual void set_solver_type(KSP &ksp) const =0
const AdditionalData additional_data
Definition: petsc_solver.h:415
virtual State check(const unsigned int step, const double check_value)
const AdditionalData additional_data
Definition: petsc_solver.h:839
const AdditionalData additional_data
Definition: petsc_solver.h:314
virtual void set_solver_type(KSP &ksp) const
const AdditionalData additional_data
Definition: petsc_solver.h:365
::ExceptionBase & ExcMessage(std::string arg1)
AdditionalData(const unsigned int restart_parameter=30, const bool right_preconditioning=false)
SolverRichardson(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
Definition: petsc_solver.h:738
virtual void set_solver_type(KSP &ksp) const
std_cxx11::shared_ptr< SolverData > solver_data
Definition: petsc_solver.h:250
const AdditionalData additional_data
Definition: petsc_solver.h:532
virtual void set_solver_type(KSP &ksp) const
#define AssertThrow(cond, exc)
Definition: exceptions.h:358
SparseDirectMUMPS(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
void set_prefix(const std::string &prefix)
const MPI_Comm mpi_communicator
Definition: petsc_solver.h:186
Stop iteration, goal reached.
#define Assert(cond, exc)
Definition: exceptions.h:294
SolverBase(SolverControl &cn, const MPI_Comm &mpi_communicator)
Definition: petsc_solver.cc:51
static PetscErrorCode convergence_test(KSP ksp, const PetscInt iteration, const PetscReal residual_norm, KSPConvergedReason *reason, void *solver_control)
virtual void set_solver_type(KSP &ksp) const
const AdditionalData additional_data
Definition: petsc_solver.h:894
virtual void set_solver_type(KSP &ksp) const
virtual void set_solver_type(KSP &ksp) const
SolverCR(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
SolverControl & solver_control
Definition: petsc_solver.h:181
double last_value() const
SolverBiCG(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
SolverLSQR(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
SolverChebychev(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
double tolerance() const
SolverCGS(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
virtual void set_solver_type(KSP &ksp) const
unsigned int last_step() const
const AdditionalData additional_data
Definition: petsc_solver.h:583
void initialize(const PreconditionerBase &preconditioner)
SolverBicgstab(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
void solve(const MatrixBase &A, VectorBase &x, const VectorBase &b)
virtual void set_solver_type(KSP &ksp) const
virtual void set_solver_type(KSP &ksp) const
SolverTCQMR(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
State last_check() const
SolverControl & control() const
virtual void set_solver_type(KSP &ksp) const
unsigned int max_steps() const
const AdditionalData additional_data
Definition: petsc_solver.h:632
SolverTFQMR(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
void set_symmetric_mode(const bool flag)
virtual void set_solver_type(KSP &ksp) const
virtual void set_solver_type(KSP &ksp) const
static PetscErrorCode convergence_test(KSP ksp, const PetscInt iteration, const PetscReal residual_norm, KSPConvergedReason *reason, void *solver_control)
SolverCG(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
SolverPreOnly(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
Definition: petsc_solver.h:788
SolverGMRES(SolverControl &cn, const MPI_Comm &mpi_communicator=PETSC_COMM_SELF, const AdditionalData &data=AdditionalData())
const AdditionalData additional_data
Definition: petsc_solver.h:682
virtual void set_solver_type(KSP &ksp) const