Bridge++  Ver. 2.0.2
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  std::string vlevel;
22  if (!params.fetch_string("verbose_level", vlevel)) {
23  m_vl = vout.set_verbose_level(vlevel);
24  }
25 
26  //- fetch and check input parameters
27  int level;
28  int Nstep;
29 
30  int err = 0;
31  err += params.fetch_int("level", level);
32  err += params.fetch_int("number_of_steps", Nstep);
33 
34  if (err) {
35  vout.crucial(m_vl, "Error at %s: input parameter not found.\n", class_name.c_str());
36  exit(EXIT_FAILURE);
37  }
38 
39  set_parameters(level, Nstep);
40 }
41 
42 
43 //====================================================================
45 {
46  params.set_int("level", m_level);
47  params.set_int("number_of_steps", m_Nstep);
48 
49  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
50 }
51 
52 
53 //====================================================================
54 void Integrator_Leapfrog::set_parameters(const int level, const int Nstep)
55 {
56  //- print input parameters
57  vout.general(m_vl, "%s:\n", class_name.c_str());
58  vout.general(m_vl, " Level: %4d\n", level);
59  vout.general(m_vl, " Nstep = %4d\n", Nstep);
60 
61  //- range check
62  // NB. level,Estep,Nstep == 0 is allowed.
63 
64  //- store values
65  m_Nstep = Nstep;
66  m_level = level;
67 }
68 
69 
70 //====================================================================
72 {
73  m_level = level;
74 }
75 
76 
77 //====================================================================
79 {
80  m_Nstep = Nstep;
81 }
82 
83 
84 //====================================================================
85 void Integrator_Leapfrog::set_parameter_Nsteps(const std::vector<int>& Nsteps)
86 {
87  if (Nsteps.size() > 0) {
88  set_parameter_Nstep(Nsteps[0]);
89 
90  // transfer to lower levels
91  if (m_update_U && (Nsteps.size() > 1)) {
92  std::vector<int> next_steps(Nsteps.begin() + 1, Nsteps.end());
93  m_update_U->set_parameter_Nsteps(next_steps);
94  }
95  }
96 }
97 
98 
99 //====================================================================
100 void Integrator_Leapfrog::evolve(const double step_size, Field_G& iP, Field_G& U)
101 {
102  const int Nin = U.nin();
103  const int Nvol = U.nvol();
104  const int Nex = U.nex();
105  const int Nc = CommonParameters::Nc();
106 
107  vout.general(m_vl, "Integration level-%d start.\n", m_level);
108 
109  if (m_Nstep > 0) {
110  double estep = step_size / m_Nstep;
111 
112  // initial half step
113  m_update_p->evolve(estep * 0.5, iP, U);
114 
115  for (int istep = 1; istep <= m_Nstep; ++istep) {
116  vout.general(m_vl, "istep = %d\n", istep);
117 
118  m_update_U->evolve(estep, iP, U);
119 
120  if (istep < m_Nstep) {
121  m_update_p->evolve(estep, iP, U);
122  }
123  }
124 
125  // last half step
126  m_update_p->evolve(estep * 0.5, iP, U);
127  } else {
128  vout.general(m_vl, "Nstep is zero. skip.\n");
129  }
130 
131  vout.general(m_vl, "Integration level-%d finished.\n", m_level);
132 }
133 
134 
135 //====================================================================
136 //============================================================END=====
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Integrator_Leapfrog::set_parameters
void set_parameters(const Parameters &params)
Definition: integrator_Leapfrog.cpp:19
Parameters
Class for parameters.
Definition: parameters.h:46
Field::nex
int nex() const
Definition: field.h:128
Integrator_Leapfrog::set_parameter_Nsteps
void set_parameter_Nsteps(const std::vector< int > &Nsteps)
Definition: integrator_Leapfrog.cpp:85
Integrator_Leapfrog::m_Nstep
int m_Nstep
Definition: integrator_Leapfrog.h:38
Integrator_Leapfrog::set_parameter_level
void set_parameter_level(const int level)
Definition: integrator_Leapfrog.cpp:71
Field::nin
int nin() const
Definition: field.h:126
Integrator_Leapfrog::class_name
static const std::string class_name
Definition: integrator_Leapfrog.h:34
CommonParameters::Nc
static int Nc()
Definition: commonParameters.h:115
Integrator_Leapfrog::m_update_U
Integrator * m_update_U
Definition: integrator_Leapfrog.h:41
Integrator::set_parameter_Nsteps
virtual void set_parameter_Nsteps(const std::vector< int > &Nsteps)
Definition: integrator.h:46
integrator_Leapfrog.h
Field::nvol
int nvol() const
Definition: field.h:127
Integrator_Leapfrog::evolve
void evolve(const double step_size, Field_G &iP, Field_G &U)
Definition: integrator_Leapfrog.cpp:100
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Integrator_Leapfrog::set_parameter_Nstep
void set_parameter_Nstep(const int Nstep)
Definition: integrator_Leapfrog.cpp:78
Parameters::set_int
void set_int(const string &key, const int value)
Definition: parameters.cpp:36
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Integrator_Leapfrog::m_level
int m_level
Definition: integrator_Leapfrog.h:37
Integrator_Leapfrog::get_parameters
void get_parameters(Parameters &params) const
Definition: integrator_Leapfrog.cpp:44
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
Field_G
SU(N) gauge field.
Definition: field_G.h:38
Integrator::evolve
virtual void evolve(const double step_size, Field_G &iP, Field_G &U)=0
Parameters::fetch_int
int fetch_int(const string &key, int &value) const
Definition: parameters.cpp:346
Bridge::BridgeIO::general
void general(const char *format,...)
Definition: bridgeIO.cpp:200
Integrator_Leapfrog::m_update_p
Integrator * m_update_p
Definition: integrator_Leapfrog.h:40
Integrator::m_vl
Bridge::VerboseLevel m_vl
Definition: integrator.h:60
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
Bridge::BridgeIO::get_verbose_level
static std::string get_verbose_level(const VerboseLevel vl)
Definition: bridgeIO.cpp:154