Bridge++  Ver. 2.0.2
source_Staggered_Wall.cpp
Go to the documentation of this file.
1 
14 #include "source_Staggered_Wall.h"
15 
16 const std::string Source_Staggered_Wall::class_name = "Source_Staggered_Wall";
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 source_position;
28 
29  int err = 0;
30  err += params.fetch_int("source_position", source_position);
31 
32  if (err) {
33  vout.crucial(m_vl, "Error at %s: input parameter not found\n", class_name.c_str());
34  exit(EXIT_FAILURE);
35  }
36 
37 
38  set_parameters(source_position);
39 }
40 
41 
42 //====================================================================
44 {
45  params.set_int("source_position", m_t_src);
46 
47  params.set_string("verbose_level", vout.get_verbose_level(m_vl));
48 }
49 
50 
51 //====================================================================
52 void Source_Staggered_Wall::set_parameters(const int source_position)
53 {
54  const int Lt = CommonParameters::Lt();
55 
56  //- print input parameters
57  vout.general(m_vl, "Source for staggered spinor field - Wall:\n");
58  vout.general(m_vl, " source_position[t] = %d\n", source_position);
59 
60  //- range check
61  int err = 0;
62  // NB. Lt > abs(source_position)
63  err += ParameterCheck::non_negative(Lt - abs(source_position));
64 
65  if (err) {
66  vout.crucial(m_vl, "Error at %s: parameter range check failed\n", class_name.c_str());
67  exit(EXIT_FAILURE);
68  }
69 
70  //- store values
71  m_t_src = source_position;
72 
73  //- post-process
74  init();
75 }
76 
77 
78 //====================================================================
80 {
81  const int Nvol = CommonParameters::Nvol();
82 
83  const int Nx = CommonParameters::Nx();
84  const int Ny = CommonParameters::Ny();
85  const int Nz = CommonParameters::Nz();
86  const int Nt = CommonParameters::Nt();
87 
88  const int ipe_x = Communicator::ipe(0);
89  const int ipe_y = Communicator::ipe(1);
90  const int ipe_z = Communicator::ipe(2);
91  const int ipe_t = Communicator::ipe(3);
92 
93  src_wall_1.reset(1, Nvol, 1);
94  src_wall_2.reset(1, Nvol, 1);
95  src_wall_1.set(0.0);
96  src_wall_2.set(0.0);
97 
98  const int tl_src = m_t_src % Nt;
99  const int ex = 0;
100 
101  if (m_t_src / Nt == ipe_t) {
102  for (int z = 0; z < Nz; ++z) {
103  int z_global = z + ipe_z * Nz;
104 
105  for (int y = 0; y < Ny; ++y) {
106  int y_global = y + ipe_y * Ny;
107 
108  for (int x = 0; x < Nx; ++x) {
109  int x_global = x + ipe_x * Nx;
110 
111  int site = m_index.site(x, y, z, tl_src);
112 
113  if (((x_global + y_global + z_global) % 2) == 0) {
114  src_wall_1.set(0, site, ex, 1.0);
115  src_wall_2.set(0, site, ex, 1.0);
116  } else {
117  src_wall_1.set(0, site, ex, 1.0);
118  src_wall_2.set(0, site, ex, -1.0);
119  }
120  }
121  }
122  }
123  }
124 }
125 
126 
127 //====================================================================
129  const int ic, const int i_src)
130 {
131  const int Nvol = CommonParameters::Nvol();
132 
133  src.set(0.0);
134 
135  const int ex = 0;
136 
137  if (i_src == 0) {
138  for (int site = 0; site < Nvol; ++site) {
139  src.set_r(ic, site, ex, src_wall_1.cmp(0, site, ex));
140  }
141  } else if (i_src == 1) {
142  for (int site = 0; site < Nvol; ++site) {
143  src.set_r(ic, site, ex, src_wall_2.cmp(0, site, ex));
144  }
145  } else {
146  vout.crucial(m_vl, "Error at %s: illegal source index\n", class_name.c_str());
147  exit(EXIT_FAILURE);
148  }
149 }
150 
151 
152 //====================================================================
153 //============================================================END=====
source_Staggered_Wall.h
CommonParameters::Ny
static int Ny()
Definition: commonParameters.h:106
Source_Staggered_Wall::set
void set(Field_F_1spinor &src, const int ic, const int i_src)
Definition: source_Staggered_Wall.cpp:128
CommonParameters::Nz
static int Nz()
Definition: commonParameters.h:107
Source_Staggered_Wall::m_vl
Bridge::VerboseLevel m_vl
Definition: source_Staggered_Wall.h:40
Parameters::set_string
void set_string(const string &key, const string &value)
Definition: parameters.cpp:39
Field::set
void set(const int jin, const int site, const int jex, double v)
Definition: field.h:175
Parameters
Class for parameters.
Definition: parameters.h:46
Source_Staggered_Wall::get_parameters
void get_parameters(Parameters &params) const
Definition: source_Staggered_Wall.cpp:43
CommonParameters::Nvol
static int Nvol()
Definition: commonParameters.h:109
Field_F_1spinor::set_r
void set_r(const int cc, const int site, const int e, const double re)
Definition: field_F_1spinor.h:89
ParameterCheck::non_negative
int non_negative(const int v)
Definition: parameterCheck.cpp:21
Source_Staggered_Wall::class_name
static const std::string class_name
Definition: source_Staggered_Wall.h:37
CommonParameters::Nx
static int Nx()
Definition: commonParameters.h:105
Source_Staggered_Wall::m_t_src
int m_t_src
Definition: source_Staggered_Wall.h:43
CommonParameters::Lt
static int Lt()
Definition: commonParameters.h:94
CommonParameters::Nt
static int Nt()
Definition: commonParameters.h:108
Source_Staggered_Wall::m_index
Index_lex m_index
Definition: source_Staggered_Wall.h:44
Source_Staggered_Wall::set_parameters
void set_parameters(const Parameters &params)
Definition: source_Staggered_Wall.cpp:19
Source_Staggered_Wall::src_wall_1
Field src_wall_1
Definition: source_Staggered_Wall.h:46
Index_lex::site
int site(const int &x, const int &y, const int &z, const int &t) const
Definition: index_lex.h:55
Field::reset
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
Definition: field.h:95
Source_Staggered_Wall::init
void init()
Definition: source_Staggered_Wall.cpp:79
Field::cmp
double cmp(const int jin, const int site, const int jex) const
Definition: field.h:143
Bridge::BridgeIO::set_verbose_level
static VerboseLevel set_verbose_level(const std::string &str)
Definition: bridgeIO.cpp:133
Field_F_1spinor
Staggered-type fermion field.
Definition: field_F_1spinor.h:38
Parameters::set_int
void set_int(const string &key, const int value)
Definition: parameters.cpp:36
Source_Staggered_Wall::src_wall_2
Field src_wall_2
Definition: source_Staggered_Wall.h:47
Communicator::ipe
static int ipe(const int dir)
logical coordinate of current proc.
Definition: communicator.cpp:105
Parameters::fetch_string
int fetch_string(const string &key, string &value) const
Definition: parameters.cpp:378
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
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
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