Bridge++  Ver. 1.3.x
integrator_UpdateP.cpp
Go to the documentation of this file.
1 
13 #include "integrator_UpdateP.h"
14 
15 #ifdef USE_PARAMETERS_FACTORY
16 #include "parameters_factory.h"
17 #endif
18 
19 //- parameter entry
20 namespace {
21  void append_entry(Parameters& param)
22  {
23  param.Register_string("verbose_level", "NULL");
24  }
25 
26 
27 #ifdef USE_PARAMETERS_FACTORY
28  bool init_param = ParametersFactory::Register("Integrator.UpdateP", append_entry);
29 #endif
30 }
31 //- end
32 
33 //- parameters class
35 //- end
36 
37 const std::string Integrator_UpdateP::class_name = "Integrator_UpdateP";
38 
39 //====================================================================
41 {
42  const string str_vlevel = params.get_string("verbose_level");
43 
44  m_vl = vout.set_verbose_level(str_vlevel);
45 
46  //- fetch and check input parameters
47  int err = 0;
48 
49  if (err) {
50  vout.crucial(m_vl, "%s: fetch error, input parameter not found.\n", class_name.c_str());
51  exit(EXIT_FAILURE);
52  }
53 
55 }
56 
57 
58 //====================================================================
60 {
61  //- print input parameters
62  vout.general(m_vl, "Parameters of %s:\n", class_name.c_str());
63 
64  //- range check
65  int err = 0;
66 
67  if (err) {
68  vout.crucial(m_vl, "%s: parameter range check failed.\n", class_name.c_str());
69  exit(EXIT_FAILURE);
70  }
71 
72  //- store values
73 }
74 
75 
76 //====================================================================
77 void Integrator_UpdateP::evolve(const double step_size, Field_G& iP, Field_G& U)
78 {
79  if (not is_cache_valid()) { // recalc force
80  m_force.set(0.0);
81 
82  Field force_tmp(iP.nin(), iP.nvol(), iP.nex());
83  for (unsigned int i = 0, n = m_action.size(); i < n; ++i) {
84  vout.general(m_vl, "update p by action %d\n", i);
85  m_action[i]->force(force_tmp);
86  vout.general(m_vl, "updated p by action %d\n", i);
87  axpy(m_force, 1.0, force_tmp);
88  }
89 
91 
92  vout.detailed(m_vl, "%s: force updated.\n", class_name.c_str());
93  } else {
94  vout.general(m_vl, "%s: returns previous force.\n", class_name.c_str());
95  }
96 
97  axpy(iP, step_size, m_force);
98 }
99 
100 
101 //====================================================================
102 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:278
void detailed(const char *format,...)
Definition: bridgeIO.cpp:82
void Register_string(const string &, const string &)
Definition: parameters.cpp:351
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:155
void general(const char *format,...)
Definition: bridgeIO.cpp:65
Container of Field-type object.
Definition: field.h:39
int nvol() const
Definition: field.h:116
static const std::string class_name
Class for parameters.
Definition: parameters.h:38
int nin() const
Definition: field.h:115
SU(N) gauge field.
Definition: field_G.h:38
void evolve(const double step_size, Field_G &iP, Field_G &U)
int nex() const
Definition: field.h:117
Bridge::VerboseLevel m_vl
Definition: integrator.h:62
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:168
void crucial(const char *format,...)
Definition: bridgeIO.cpp:48
static bool Register(const std::string &realm, const creator_callback &cb)
bool is_cache_valid() const
string get_string(const string &key) const
Definition: parameters.cpp:87
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:28
std::vector< Action * > m_action