PETScFabric.hh

Go to the documentation of this file.
1 
6 #ifndef petscFabric_hh
7 #define petscFabric_hh
8 
9 #include <list>
10 #include "operator/PETSc.hh"
11 #include "operator/solverFabric.hh"
12 
13 namespace concepts {
14 
15  // *********************************************************** PETScFabric **
16 
30  class PETScFabric : public SolverFabric<Real> {
31  public:
37  PETScFabric(const Real maxeps, const std::string ksptype,
38  const std::string pctype = std::string("none"))
39  : maxeps_(maxeps), ksptype_(ksptype), pctype_(pctype) {}
41  if (pctype_ == "none" || dynamic_cast<concepts::PETScMat*>(&matrix)) {
42  return new PETSc(matrix, maxeps_, ksptype_, pctype_);
43  } else {
44  concepts::SparseMatrix<Real>* sparsemat =
45  dynamic_cast<concepts::SparseMatrix<Real>*>(&matrix);
46  if (sparsemat) {
47  petscmat_.push_front(new concepts::PETScMat(*sparsemat));
48  } else {
49  sparsemat = new concepts::SparseMatrix<Real>(matrix);
50  petscmat_.push_front(new concepts::PETScMat(*sparsemat));
51  delete sparsemat;
52  }
53  return new PETSc(*(petscmat_.front()), maxeps_, ksptype_, pctype_);
54  }
55  }
57  while (!petscmat_.empty()) {
58  delete petscmat_.front();
59  petscmat_.pop_front();
60  }
61  }
62  protected:
63  virtual std::ostream& info(std::ostream& os) const {
64  return os << concepts::typeOf(*this)<<"(maxeps = " << maxeps_ << ", ksptype = "
65  << ksptype_ << ", pctype = " << pctype_ << ")";
66  }
67  private:
69  const Real maxeps_;
71  const std::string ksptype_;
73  const std::string pctype_;
75  std::list<concepts::PETScMat*> petscmat_;
76  };
77 
78 } // concepts
79 
80 #endif // petscFabric_hh
Interface to the iterative solvers of the PETSc library.
Definition: PETSc.hh:74
PETScFabric(const Real maxeps, const std::string ksptype, const std::string pctype=std::string("none"))
Constructor.
Definition: PETScFabric.hh:37
virtual std::ostream & info(std::ostream &os) const
Definition: PETScFabric.hh:63
virtual Operator< Real > * operator()(Operator< Real > &matrix)
Definition: PETScFabric.hh:40
const std::string pctype_
Type of preconditioner.
Definition: PETScFabric.hh:73
Abstract fabric class for linear solvers.
Definition: jdbsym.hh:16
Fabric class for PETSc solvers.
Definition: PETScFabric.hh:30
const Real maxeps_
Maximal residual.
Definition: PETScFabric.hh:69
std::list< concepts::PETScMat * > petscmat_
Created auxiliary PETSc Matrices.
Definition: PETScFabric.hh:75
Interface to the sparse matrices from PETSc.
Definition: PETSc.hh:148
const std::string ksptype_
Type of Krylov Subspace Solver.
Definition: PETScFabric.hh:71
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich