Bridge++  Ver. 2.0.2
MultiGrid_Clover.h
Go to the documentation of this file.
1 
16 //====================================================================
17 #ifndef MULTIGRID_CLOVER_H_INCLUDED
18 #define MULTIGRID_CLOVER_H_INCLUDED
19 
20 #include "MultiGrid.h"
21 
22 
23 //====================================================================
24 template<class AFIELD1, class AFIELD2>
25 class MultiGrid_Clover : public MultiGrid<AFIELD1, AFIELD2>
26 {
27  public:
28  typedef AFIELD1 AField_coarse_t;
29  typedef AFIELD2 AField_fine_t;
31  // typedef AFopr_Clover<AFIELD2> Afopr_fine_t;
33  typedef void Afopr_coarse_t;
34  static const std::string class_name;
35 
36  protected:
38  // AFopr<AFIELD1> *m_afopr_coarse; // only the fine op. is needed
41  std::vector<AFIELD2> m_testvectors;
42  mutable AFIELD2 m_tmp1, m_tmp2;
44 
45  int m_nin;
46  int m_nvec;
47  size_t m_fine_nvol;
48  mutable std::vector<typename AFIELD2::real_t> m_real_array;
49  mutable std::vector<typename AFIELD2::complex_t> m_complex_array;
50  mutable std::vector<typename AFIELD2::complex_t> m_complex_array2;
51 
52  mutable std::vector<typename AFIELD2::complex_t> m_coarse_array;
53 
54  public:
56  MultiGrid_Clover(const std::vector<int>& coarse_lattice,
57  const std::vector<int>& fine_lattice,
58  const int nin, const int nvec)
59  {
60  init(coarse_lattice, fine_lattice, nin, nvec);
61  }
62 
64  {
65  tidyup();
66  }
67 
68  void init(const std::vector<int>& coarse_lattice, const std::vector<int>& fine_lattice,
69  const int nin, const int nvec)
70  {
71  m_block_index.init(coarse_lattice, fine_lattice);
72  size_t fine_nvol = 1;
73  for (int i = 0; i < fine_lattice.size(); i++) {
74  fine_nvol *= fine_lattice[i];
75  }
76  m_testvectors.resize(nvec);
77  for (int i = 0; i < nvec; i++) {
78  m_testvectors[i].reset(nin, fine_nvol, 1);
79  }
80 
81  m_fine_nvol = fine_nvol;
82  m_nin = nin;
83  m_nvec = nvec;
85  }
86 
87  void init_resources();
88 
89  void tidyup() {}
90 
91  const Index_t *get_block_index() const
92  {
93  return &m_block_index;
94  }
95 
96  std::vector<AFIELD2> *get_testvectors()
97  {
98  return &m_testvectors;
99  }
100 
101  const std::vector<AFIELD2> *get_testvectors() const
102  {
103  return &m_testvectors;
104  }
105 
106  void set_testvectors();
107 
108  void set_testvectors(const std::vector<AFIELD2>&);
109 
111  void set_coarse_array(const AFIELD1& coarse_vector) const;
112 
114  void set_coarse_vector(AFIELD1& coarse_vector) const;
115 
117  {
118  // check if downcasting is safe
119  { // Clover_dd
120  Afopr_fine_dd_t *afopr_tmp = dynamic_cast<Afopr_fine_dd_t *>(afopr);
121  if (afopr_tmp != nullptr) {
122  m_afopr_fine = afopr_tmp;
123  return;
124  }
125  }
126  vout.crucial("MultiGrid_Clover: bad afopr: only AFopr_Clover_dd is vaild\n");
127  exit(EXIT_FAILURE);
128  }
129 
131  {
132  // do nothing
133  }
134 
135  void gramschmidt();
136  void gramschmidt(std::vector<AFIELD2>& fine_vectors) const;
137  void gramschmidt_double(std::vector<AFIELD2>& fine_vectors) const;
138 
139  void make_fine_vector(AFIELD2& fine_vector, const AFIELD1& coarse_vector) const;
140  void make_coarse_vector(AFIELD1& coarse_vector, const AFIELD2& fine_vector) const;
141 };
142 
143 #endif // MULTIGRID_CLOVER_H_INCLUDED
144 //============================================================END=====
MultiGrid_Clover::MultiGrid_Clover
MultiGrid_Clover(const std::vector< int > &coarse_lattice, const std::vector< int > &fine_lattice, const int nin, const int nvec)
Definition: MultiGrid_Clover.h:56
MultiGrid_Clover::set_coarse_array
void set_coarse_array(const AFIELD1 &coarse_vector) const
array <- vector (function for optimization)
Definition: MultiGrid_Clover-tmpl.h:412
AFopr< AFIELD2 >
MultiGrid_Clover::Afopr_coarse_t
void Afopr_coarse_t
Definition: MultiGrid_Clover.h:33
MultiGrid_Clover::m_real_array
std::vector< typename AFIELD2::real_t > m_real_array
Definition: MultiGrid_Clover.h:48
MultiGrid_Clover::MultiGrid_Clover
MultiGrid_Clover()
Definition: MultiGrid_Clover.h:55
MultiGrid_Clover::Index_t
AIndex_block_lex< typename AFIELD2::real_t, AFIELD2::IMPL > Index_t
Definition: MultiGrid_Clover.h:30
MultiGrid_Clover::class_name
static const std::string class_name
Definition: MultiGrid_Clover.h:34
MultiGrid_Clover::m_fine_nvol
size_t m_fine_nvol
Definition: MultiGrid_Clover.h:47
MultiGrid_Clover::~MultiGrid_Clover
~MultiGrid_Clover()
Definition: MultiGrid_Clover.h:63
MultiGrid_Clover::m_nvec
int m_nvec
Definition: MultiGrid_Clover.h:46
MultiGrid_Clover::AField_fine_t
AFIELD2 AField_fine_t
Definition: MultiGrid_Clover.h:29
MultiGrid_Clover::init
void init(const std::vector< int > &coarse_lattice, const std::vector< int > &fine_lattice, const int nin, const int nvec)
Definition: MultiGrid_Clover.h:68
MultiGrid_Clover::m_complex_array2
std::vector< typename AFIELD2::complex_t > m_complex_array2
Definition: MultiGrid_Clover.h:50
AIndex_block_lex< typename AFIELD2::real_t, AFIELD2::IMPL >
MultiGrid_Clover::set_afopr_fine
void set_afopr_fine(AFopr_dd< AFIELD2 > *afopr)
Definition: MultiGrid_Clover.h:116
AFopr_dd
Base class of fermion operator family.
Definition: afopr_dd.h:24
MultiGrid_Clover::make_fine_vector
void make_fine_vector(AFIELD2 &fine_vector, const AFIELD1 &coarse_vector) const
Definition: MultiGrid_Clover-tmpl.h:521
MultiGrid.h
MultiGrid_Clover::get_testvectors
std::vector< AFIELD2 > * get_testvectors()
Definition: MultiGrid_Clover.h:96
MultiGrid_Clover::m_field_tmp
Field m_field_tmp
Definition: MultiGrid_Clover.h:43
MultiGrid_Clover::set_testvectors
void set_testvectors()
Definition: MultiGrid_Clover-tmpl.h:395
MultiGrid_Clover::m_testvectors
std::vector< AFIELD2 > m_testvectors
Definition: MultiGrid_Clover.h:41
MultiGrid
Definition: MultiGrid.h:24
MultiGrid_Clover::gramschmidt_double
void gramschmidt_double(std::vector< AFIELD2 > &fine_vectors) const
Definition: MultiGrid_Clover-tmpl.h:664
MultiGrid_Clover::m_tmp1
AFIELD2 m_tmp1
Definition: MultiGrid_Clover.h:42
MultiGrid_Clover::m_block_index
Index_t m_block_index
Definition: MultiGrid_Clover.h:40
MultiGrid_Clover::gramschmidt
void gramschmidt()
Definition: MultiGrid_Clover-tmpl.h:639
MultiGrid_Clover::tidyup
void tidyup()
Definition: MultiGrid_Clover.h:89
MultiGrid_Clover::get_block_index
const Index_t * get_block_index() const
Definition: MultiGrid_Clover.h:91
MultiGrid_Clover::set_coarse_vector
void set_coarse_vector(AFIELD1 &coarse_vector) const
vector <- array (function for optimization)
Definition: MultiGrid_Clover-tmpl.h:472
MultiGrid_Clover::init_resources
void init_resources()
Definition: MultiGrid_Clover-tmpl.h:370
MultiGrid_Clover::m_coarse_array
std::vector< typename AFIELD2::complex_t > m_coarse_array
Definition: MultiGrid_Clover.h:52
MultiGrid_Clover::AField_coarse_t
AFIELD1 AField_coarse_t
Definition: MultiGrid_Clover.h:28
AFopr_Clover_dd
Definition: afopr_Clover_dd.h:45
MultiGrid_Clover::m_nin
int m_nin
Definition: MultiGrid_Clover.h:45
MultiGrid_Clover::m_tmp2
AFIELD2 m_tmp2
Definition: MultiGrid_Clover.h:42
MultiGrid_Clover::Afopr_fine_dd_t
AFopr_Clover_dd< AFIELD2 > Afopr_fine_dd_t
Definition: MultiGrid_Clover.h:32
MultiGrid_Clover::m_complex_array
std::vector< typename AFIELD2::complex_t > m_complex_array
Definition: MultiGrid_Clover.h:49
MultiGrid_Clover::m_afopr_fine
AFopr< AFIELD2 > * m_afopr_fine
Definition: MultiGrid_Clover.h:39
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
MultiGrid_Clover::get_testvectors
const std::vector< AFIELD2 > * get_testvectors() const
Definition: MultiGrid_Clover.h:101
MultiGrid_Clover::make_coarse_vector
void make_coarse_vector(AFIELD1 &coarse_vector, const AFIELD2 &fine_vector) const
Definition: MultiGrid_Clover-tmpl.h:589
Field
Container of Field-type object.
Definition: field.h:46
MultiGrid_Clover
Definition: MultiGrid_Clover.h:25
MultiGrid_Clover::set_afopr_coarse
void set_afopr_coarse(AFopr< AFIELD1 > *afopr)
Definition: MultiGrid_Clover.h:130
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512