Bridge++  Ver. 1.1.x
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gaugeConfig.cpp
Go to the documentation of this file.
1 
14 #include "gaugeConfig.h"
15 
16 #include "commonParameters.h"
17 #include "communicator.h"
18 #include "bridgeIO.h"
19 using Bridge::vout;
20 
21 #include "field.h"
22 #include "mat_SU_N.h"
23 
24 #include "fieldIO.h"
25 #include "fieldIO_Text.h"
26 #include "fieldIO_Binary.h"
28 #include "fieldIO_Fortran.h"
29 #include "fieldIO_LIME.h"
30 #include "io_format.h"
31 #include "io_format_gauge.h"
32 
33 
34 //====================================================================
36 {
37  int Nc = CommonParameters::Nc();
38  int Nvol = CommonParameters::Nvol();
39  int Ndim = CommonParameters::Ndim();
40 
41  Field_G *up = (Field_G *)U;
42  Mat_SU_N ut(Nc);
43 
44  ut.unit();
45 
46  for (int mu = 0; mu < Ndim; ++mu) {
47  for (int site = 0; site < Nvol; ++site) {
48  up->set_mat(site, mu, ut);
49  }
50  }
51 
52  vout.detailed("gauge config. was set to unity.\n");
53 }
54 
55 
56 //====================================================================
57 GaugeConfig::GaugeConfig(const string& type)
58  : m_prefix(), m_postfix(), m_vl(CommonParameters::Vlevel()), m_fieldio()
59 {
60  if (type == "Text") {
62  } else if (type == "Binary") {
64  } else if (type == "Fortran_JLQCD") {
66  } else if (type == "Fortran_ILDG") {
68  } else if (type == "ILDG") {
70  } else if (type == "Binary_Parallel") {
72  } else {
73  vout.crucial("GaugeConfig: unsupported type \"%s\".\n", type.c_str());
74  abort();
75  }
76 }
77 
78 
79 //====================================================================
81 {
82  if (m_fieldio) delete m_fieldio;
83  m_fieldio = 0;
84 }
85 
86 
87 //====================================================================
88 string GaugeConfig::config_filename(const int confnum)
89 {
90  const size_t filename_len = 256;
91  char buf[filename_len];
92 
93  snprintf(buf, filename_len, "%s%06d%s", m_prefix.c_str(), confnum, m_postfix.c_str());
94 
95  return string(buf);
96 }
97 
98 
99 //====================================================================
100 void GaugeConfig::read_file(Field *u, const string& filename)
101 {
102  if (!m_fieldio) {
103  vout.crucial("GaugeConfig::read_config(): FieldIO not set.");
104  abort();
105  }
106 
107  m_fieldio->read_file(u, filename);
108 }
109 
110 
111 //====================================================================
112 void GaugeConfig::write_file(Field *u, const string& filename)
113 {
114  if (!m_fieldio) {
115  vout.crucial("GaugeConfig::read_config(): FieldIO not set.");
116  abort();
117  }
118 
119  m_fieldio->write_file(u, filename);
120 }
121 
122 
123 //====================================================================
124 void GaugeConfig::read_config(Field *U, int confnum)
125 {
126  return read_file(U, config_filename(confnum));
127 }
128 
129 
130 //====================================================================
131 void GaugeConfig::write_config(Field *U, int confnum)
132 {
133  return write_file(U, config_filename(confnum));
134 }
135 
136 
137 //====================================================================
138 //============================================================END=====