Bridge++  Version 1.6.1
 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"
16 #include "io_format_gauge.h"
17 
18 const std::string GaugeConfig::class_name = "GaugeConfig";
19 
20 //====================================================================
22 {
23  public:
24  virtual ~DataSource() {}
25  virtual void set(Field_G *U) = 0;
26 };
27 
28 //--------------------------------------------------------------------
30 {
31  public:
32  virtual void set(Field_G *U)
33  {
34  if (U) U->set_unit();
35  }
36 };
37 
38 //--------------------------------------------------------------------
40 {
41  public:
43  {
45  }
46 
48  {
49  }
50 
51  virtual void set(Field_G *U)
52  {
53  if (U) U->set_random(m_rand);
54  }
55 
56  private:
58 };
59 
60 //====================================================================
62  : m_vl(CommonParameters::Vlevel())
63  , m_fieldio(NULL)
64  , m_format(NULL)
65  , m_datasource(NULL)
66 {
67  if (type == "Text") {
70  } else if (type == "Text_4x4x4x8") {
73  } else if (type == "Binary") {
76  } else if (type == "Fortran_JLQCD") {
79  } else if (type == "Fortran_ILDG") {
82  } else if (type == "ILDG") {
85  } else if (type == "Binary_Parallel") {
88  } else if (type == "Binary_Distributed") {
91  } else if (type == "ILDG_Parallel") {
94  } else if (type == "None" || type == "Null") { // for backward compatibility
97  } else if (type == "Unit") {
99  } else if (type == "Random") {
101  } else {
102  vout.crucial("Error at %s: unsupported type \"%s\".\n", class_name.c_str(), type.c_str());
103  exit(EXIT_FAILURE);
104  }
105 }
106 
107 
108 //====================================================================
110 {
111  if (m_fieldio) delete m_fieldio;
112  if (m_format) delete m_format;
113  if (m_datasource) delete m_datasource;
114 }
115 
116 
117 //====================================================================
118 void GaugeConfig::read(Field_G *U, const string& filename)
119 {
120  if (m_fieldio) {
121  return m_fieldio->read_file(U, filename);
122  }
123 
124  if (m_datasource) {
125  return m_datasource->set(U);
126  }
127 
128  vout.crucial("Error at %s::read_file(): FieldIO or DataSource not set.\n", class_name.c_str());
129  exit(EXIT_FAILURE);
130 }
131 
132 
133 //====================================================================
134 void GaugeConfig::write(Field_G *U, const string& filename)
135 {
136  if (m_fieldio) {
137  if (filename != "NO_OUTPUT") {
138  return m_fieldio->write_file(U, filename);
139  } else {
140  return; // do nothig
141  }
142  }
143 
144  vout.crucial("Error at %s::write_file(): FieldIO not set.\n", class_name.c_str());
145  exit(EXIT_FAILURE);
146 }
147 
148 
149 //====================================================================
150 //============================================================END=====
static const std::string class_name
Definition: gaugeConfig.h:82
BridgeIO vout
Definition: bridgeIO.cpp:503
IO_Format::Format * m_format
Definition: gaugeConfig.h:118
virtual ~GaugeConfig()
virtual void read_file(Field *v, const std::string)=0
read data from file. (`const' is added [18 Mar 2021])
FieldIO_LIME class for file I/O of Field data in LIME format.
Definition: fieldIO_LIME.h:91
FieldIO * m_fieldio
Definition: gaugeConfig.h:117
static RandomNumbers * getInstance()
FieldIO_LIME_Parallel class for file I/O of Field data in LIME format.
FieldIO_Text class for file I/O of Field data in plain text format.
Definition: fieldIO_Text.h:37
GaugeConfig(const string &type)
Definition: gaugeConfig.cpp:61
void set_random(RandomNumbers *rand)
Definition: field_G_imp.cpp:60
void set_unit()
Definition: field_G_imp.cpp:37
virtual void set(Field_G *U)
Definition: gaugeConfig.cpp:51
FieldIO_Fortran class for file I/O of Field data in Fortran binary format.
FieldIO_Binary_Parallel class for file I/O of Field data in binary format using MPI parallel I/O...
SU(N) gauge field.
Definition: field_G.h:38
void read(Field_G *U, const string &filename=string())
void write(Field_G *U, const string &filename=string())
FieldIO_Text class for file I/O of Field data in plain text format.
Common parameter class: provides parameters as singleton.
void crucial(const char *format,...)
Definition: bridgeIO.cpp:178
virtual void set(Field_G *U)=0
FieldIO_Binary class for file I/O of Field data in binary format.
Base class of random number generators.
Definition: randomNumbers.h:43
FieldIO_Binary_Distributed class for file I/O of Field data in binary format.
virtual void write_file(Field *v, const std::string)=0
write data to file. (`const' is added [18 Mar 2021])
virtual void set(Field_G *U)
Definition: gaugeConfig.cpp:32
DataSource * m_datasource
Definition: gaugeConfig.h:123
FieldIO_None class for an analogue of /dev/null.
Definition: fieldIO_None.h:32