Bridge++  Ver. 2.0.2
asolver.h
Go to the documentation of this file.
1 #ifndef ASOLVER_H
2 #define ASOLVER_H
3 
4 #include <cstdio>
5 #include <cstdlib>
6 #include <vector>
7 using std::vector;
8 #include <string>
9 using std::string;
10 
12 #include "lib/IO/bridgeIO.h"
13 using Bridge::vout;
14 
15 #include "lib/Fopr/afopr.h"
16 
17 #ifdef USE_FACTORY
18 #include "lib/Tools/factory.h"
19 #include "lib/Tools/director.h"
20 #endif
21 
22 template<typename AFIELD>
23 class ASolver
24 {
25  protected:
27 
28  public:
29  typedef typename AFIELD::real_t real_t;
30 
31  enum InitialGuess { RHS, GIVEN, ZERO };
32 
34  : m_vl(CommonParameters::Vlevel()) {}
35 
36  virtual ~ASolver() {}
37 
38  virtual void set_parameters(const Parameters& params) = 0;
39 
41  { m_vl = vl; }
42 
43  virtual void set_init_mode(const InitialGuess init_guess)
44  {
45  vout.crucial("set_init_mode is called\n");
46  abort();
47  }
48 
49  virtual AFopr<AFIELD> *get_fopr() { return 0; }
50 
51  virtual void solve(AFIELD& x, const AFIELD& b, int& nconv, real_t& diff) { }
52 
53  virtual double flop_count() { return 0.0; }
54 
55 
56 #ifdef USE_FACTORY
57  public:
58  typedef ASolver *(*ProductCreator)(AFopr<AFIELD> *);
59  typedef FactoryTemplate<ASolver, ProductCreator> Factory_fopr;
60 
61  static ASolver *New(const IdentifierType& subtype, AFopr<AFIELD> *afopr)
62  {
63  ProductCreator p = Factory_fopr::Find(subtype);
64  return p ? (*p)(afopr) : 0;
65  }
66 
67  static ASolver *New(const IdentifierType& subtype,
68  unique_ptr<AFopr<AFIELD> >& afopr)
69  {
70  ProductCreator p = Factory_fopr::Find(subtype);
71  return p ? (*p)(afopr.get()) : 0;
72  }
73 
74 #ifdef USE_FACTORY_AUTOREGISTER
75 #else
76  static bool init_factory();
77 #endif
78 #endif // USE_FACTORY
79 };
80 
81 #endif // ASOLVER_H
bridgeIO.h
CommonParameters
Common parameter class: provides parameters as singleton.
Definition: commonParameters.h:42
ASolver::RHS
@ RHS
Definition: asolver.h:31
AFopr
Definition: afopr.h:48
ASolver
Definition: asolver.h:23
factory.h
ASolver::set_parameter_verboselevel
void set_parameter_verboselevel(const Bridge::VerboseLevel vl)
Definition: asolver.h:40
Parameters
Class for parameters.
Definition: parameters.h:46
ASolver::get_fopr
virtual AFopr< AFIELD > * get_fopr()
Definition: asolver.h:49
ASolver::GIVEN
@ GIVEN
Definition: asolver.h:31
director.h
Field::real_t
double real_t
Definition: field.h:51
ASolver::solve
virtual void solve(AFIELD &x, const AFIELD &b, int &nconv, real_t &diff)
Definition: asolver.h:51
ASolver::flop_count
virtual double flop_count()
Definition: asolver.h:53
ASolver::m_vl
Bridge::VerboseLevel m_vl
Definition: asolver.h:26
ParameterCheck::vl
Bridge::VerboseLevel vl
Definition: parameterCheck.cpp:18
ASolver::set_parameters
virtual void set_parameters(const Parameters &params)=0
ASolver::ZERO
@ ZERO
Definition: asolver.h:31
ASolver::~ASolver
virtual ~ASolver()
Definition: asolver.h:36
ASolver::set_init_mode
virtual void set_init_mode(const InitialGuess init_guess)
Definition: asolver.h:43
FactoryTemplate
Definition: factory.h:42
ASolver< Field >::InitialGuess
InitialGuess
Definition: asolver.h:31
commonParameters.h
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field
Container of Field-type object.
Definition: field.h:46
afopr.h
Bridge::VerboseLevel
VerboseLevel
Definition: bridgeIO.h:42
ASolver::ASolver
ASolver()
Definition: asolver.h:33
ASolver::real_t
AFIELD::real_t real_t
Definition: asolver.h:29
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
IdentifierType
std::string IdentifierType
Definition: factory.h:39