Class documentation of Concepts

Loading...
Searching...
No Matches
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"
12
13namespace 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) {}
40 virtual Operator<Real>* operator()(Operator<Real>& matrix) {
41 if (pctype_ == "none" || dynamic_cast<concepts::PETScMat*>(&matrix)) {
42 return new PETSc(matrix, maxeps_, ksptype_, pctype_);
43 } else {
45 dynamic_cast<concepts::SparseMatrix<Real>*>(&matrix);
46 if (sparsemat) {
47 petscmat_.push_front(new concepts::PETScMat(*sparsemat));
48 } else {
50 petscmat_.push_front(new concepts::PETScMat(*sparsemat));
51 delete sparsemat;
52 }
53 return new PETSc(*(petscmat_.front()), maxeps_, ksptype_, pctype_);
54 }
55 }
56 ~PETScFabric() {
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
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
PETScFabric(const Real maxeps, const std::string ksptype, const std::string pctype=std::string("none"))
virtual Operator< Real > * operator()()=0
std::string typeOf(const T &t)
Definition output.hh:43
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320