Bridge++  Version 1.5.4
 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 
17 const std::string GaugeConfig::class_name = "GaugeConfig";
18 
19 //====================================================================
21 {
22  public:
23  virtual ~DataSource() {}
24  virtual void set(Field_G *U) = 0;
25 };
26 
27 //--------------------------------------------------------------------
29 {
30  public:
31  virtual void set(Field_G *U)
32  {
33  if (U) U->set_unit();
34  }
35 };
36 
37 //--------------------------------------------------------------------
39 {
40  public:
42  {
44  }
45 
47  {
48  }
49 
50  virtual void set(Field_G *U)
51  {
52  if (U) U->set_random(m_rand);
53  }
54 
55  private:
57 };
58 
59 //====================================================================
61  : m_vl(CommonParameters::Vlevel()),
62  m_fieldio(),
63  m_datasource()
64 {
65  if (type == "Text") {
67  } else if (type == "Text_4x4x4x8") {
69  } else if (type == "Binary") {
71  } else if (type == "Fortran_JLQCD") {
73  } else if (type == "Fortran_ILDG") {
75  } else if (type == "ILDG") {
77  } else if (type == "Binary_Parallel") {
79  } else if (type == "Binary_Distributed") {
81  } else if (type == "ILDG_Parallel") {
83  } else if ((type == "None") || (type == "Null")) { // for backward compatibility
85  } else if (type == "Unit") {
87  } else if (type == "Random") {
89  } else {
90  vout.crucial("Error at %s: unsupported type \"%s\".\n", class_name.c_str(), type.c_str());
91  exit(EXIT_FAILURE);
92  }
93 }
94 
95 
96 //====================================================================
98 {
99  if (m_fieldio) delete m_fieldio;
100  if (m_datasource) delete m_datasource;
101 }
102 
103 
104 //====================================================================
105 void GaugeConfig::read(Field_G *U, const string& filename)
106 {
107  if (m_fieldio) {
108  return m_fieldio->read_file(U, filename);
109  }
110 
111  if (m_datasource) {
112  return m_datasource->set(U);
113  }
114 
115  vout.crucial("Error at %s::read_file(): FieldIO or DataSource not set.\n", class_name.c_str());
116  exit(EXIT_FAILURE);
117 }
118 
119 
120 //====================================================================
121 void GaugeConfig::write(Field_G *U, const string& filename)
122 {
123  if (m_fieldio) {
124  if (filename != "NO_OUTPUT") {
125  return m_fieldio->write_file(U, filename);
126  } else {
127  return; // do nothig
128  }
129  }
130 
131  vout.crucial("Error at %s::write_file(): FieldIO not set.\n", class_name.c_str());
132  exit(EXIT_FAILURE);
133 }
134 
135 
136 //====================================================================
137 //============================================================END=====
static const std::string class_name
Definition: gaugeConfig.h:81
BridgeIO vout
Definition: bridgeIO.cpp:503
virtual ~GaugeConfig()
Definition: gaugeConfig.cpp:97
FieldIO_LIME class for file I/O of Field data in LIME format.
Definition: fieldIO_LIME.h:91
FieldIO * m_fieldio
Definition: gaugeConfig.h:116
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:60
const Format * ILDG
Definition: io_format.cpp:28
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:50
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
const Format * JLQCD
Definition: io_format.cpp:29
const Format * Trivial
Definition: io_format.cpp:27
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
virtual void read_file(Field *v, std::string)=0
read data from file.
virtual void write_file(Field *v, std::string)=0
write data to file.
FieldIO_Binary_Distributed class for file I/O of Field data in binary format.
virtual void set(Field_G *U)
Definition: gaugeConfig.cpp:31
DataSource * m_datasource
Definition: gaugeConfig.h:121
FieldIO_None class for an analogue of /dev/null.
Definition: fieldIO_None.h:32