Bridge++  Version 1.5.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
integrator_Leapfrog.cpp
Go to the documentation of this file.
1 
14 #include "integrator_Leapfrog.h"
15 
16 const std::string Integrator_Leapfrog::class_name = "Integrator_Leapfrog";
17 
18 //====================================================================
20 {
21  const string str_vlevel = params.get_string("verbose_level");
22 
23  m_vl = vout.set_verbose_level(str_vlevel);
24 
25  //- fetch and check input parameters
26  int level;
27  int Nstep;
28 
29  int err = 0;
30  err += params.fetch_int("level", level);
31  err += params.fetch_int("number_of_steps", Nstep);
32 
33  if (err) {
34  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
35  exit(EXIT_FAILURE);
36  }
37 
38  set_parameters(level, Nstep);
39 }
40 
41 
42 //====================================================================
43 void Integrator_Leapfrog::set_parameters(const int level, const int Nstep)
44 {
45  //- print input parameters
46  vout.general(m_vl, "%s:\n", class_name.c_str());
47  vout.general(m_vl, " Level: %4d\n", level);
48  vout.general(m_vl, " Nstep = %4d\n", Nstep);
49 
50  //- range check
51  // NB. level,Estep,Nstep == 0 is allowed.
52 
53  //- store values
54  m_Nstep = Nstep;
55  m_level = level;
56 }
57 
58 
59 //====================================================================
61 {
62  m_level = level;
63 }
64 
65 
66 //====================================================================
68 {
69  m_Nstep = Nstep;
70 }
71 
72 
73 //====================================================================
74 void Integrator_Leapfrog::set_parameter_Nsteps(const std::vector<int>& Nsteps)
75 {
76  if (Nsteps.size() > 0) {
77  set_parameter_Nstep(Nsteps[0]);
78 
79  // transfer to lower levels
80  if (m_update_U && (Nsteps.size() > 1)) {
81  std::vector<int> next_steps(Nsteps.begin() + 1, Nsteps.end());
82  m_update_U->set_parameter_Nsteps(next_steps);
83  }
84  }
85 }
86 
87 
88 //====================================================================
89 void Integrator_Leapfrog::evolve(const double step_size, Field_G& iP, Field_G& U)
90 {
91  const int Nin = U.nin();
92  const int Nvol = U.nvol();
93  const int Nex = U.nex();
94  const int Nc = CommonParameters::Nc();
95 
96  vout.general(m_vl, "Integration level-%d start.\n", m_level);
97 
98  if (m_Nstep > 0) {
99  double estep = step_size / m_Nstep;
100 
101  // initial half step
102  m_update_p->evolve(estep * 0.5, iP, U);
103 
104  for (int istep = 1; istep <= m_Nstep; ++istep) {
105  vout.general(m_vl, "istep = %d\n", istep);
106 
107  m_update_U->evolve(estep, iP, U);
108 
109  if (istep < m_Nstep) {
110  m_update_p->evolve(estep, iP, U);
111  }
112  }
113 
114  // last half step
115  m_update_p->evolve(estep * 0.5, iP, U);
116  } else {
117  vout.general(m_vl, "Nstep is zero. skip.\n");
118  }
119 
120  vout.general(m_vl, "Integration level-%d finished.\n", m_level);
121 }
122 
123 
124 //====================================================================
125 //============================================================END=====
BridgeIO vout
Definition: bridgeIO.cpp:503
void set_parameter_Nstep(const int Nstep)
void general(const char *format,...)
Definition: bridgeIO.cpp:197
void set_parameter_Nsteps(const std::vector< int > &Nsteps)
void set_parameters(const Parameters &params)
int nvol() const
Definition: field.h:127
virtual void set_parameter_Nsteps(const std::vector< int > &Nsteps)
Definition: integrator.h:46
Class for parameters.
Definition: parameters.h:46
int nin() const
Definition: field.h:126
SU(N) gauge field.
Definition: field_G.h:38
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
int nex() const
Definition: field.h:128
virtual void evolve(const double step_size, Field_G &iP, Field_G &U)=0
static const std::string class_name
Bridge::VerboseLevel m_vl
Definition: integrator.h:58
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
void set_parameter_level(const int level)
void evolve(const double step_size, Field_G &iP, Field_G &U)
string get_string(const string &key) const
Definition: parameters.cpp:221
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:131