Bridge++
Ver. 2.0.2
gaugeConfig.cpp
Go to the documentation of this file.
1
14
#include "
gaugeConfig.h
"
15
#include "
Tools/randomNumberManager.h
"
16
#include "
io_format_gauge.h
"
17
18
const
std::string
GaugeConfig::class_name
=
"GaugeConfig"
;
19
20
//====================================================================
21
class
GaugeConfig::DataSource
22
{
23
public
:
24
virtual
~DataSource
() {}
25
virtual
void
set
(
Field_G
& U) = 0;
26
};
27
28
//--------------------------------------------------------------------
29
class
GaugeConfig::DataSource_Unit
:
public
DataSource
30
{
31
public
:
32
virtual
void
set
(
Field_G
& U)
33
{
34
U.
set_unit
();
35
}
36
};
37
38
//--------------------------------------------------------------------
39
class
GaugeConfig::DataSource_Random
:
public
DataSource
40
{
41
public
:
42
DataSource_Random
()
43
{
44
m_rand
=
RandomNumberManager::getInstance
();
45
}
46
47
~DataSource_Random
()
48
{
49
}
50
51
virtual
void
set
(
Field_G
& U)
52
{
53
U.
set_random
(
m_rand
);
54
}
55
56
private
:
57
RandomNumbers
*
m_rand
;
58
};
59
60
//====================================================================
61
GaugeConfig::GaugeConfig
(
const
string
&
type
)
62
: m_vl(
CommonParameters
::Vlevel())
63
, m_fieldio(NULL)
64
, m_format(NULL)
65
, m_datasource(NULL)
66
{
67
if
(
type
==
"Text"
) {
68
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
69
m_fieldio
=
new
FieldIO_Text
(
m_format
);
70
}
else
if
(
type
==
"Text_4x4x4x8"
) {
71
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
72
m_fieldio
=
new
FieldIO_Text_4x4x4x8
(
m_format
);
73
}
else
if
(
type
==
"Binary"
) {
74
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
75
m_fieldio
=
new
FieldIO_Binary
(
m_format
);
76
}
else
if
(
type
==
"Fortran_JLQCD"
) {
77
m_format
=
new
IO_Format::Gauge::JLQCD_Format
;
78
m_fieldio
=
new
FieldIO_Fortran
(
m_format
);
79
}
else
if
(
type
==
"Fortran_ILDG"
) {
80
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
81
m_fieldio
=
new
FieldIO_Fortran
(
m_format
);
82
}
else
if
(
type
==
"ILDG"
) {
83
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
84
m_fieldio
=
new
FieldIO_LIME
(
m_format
);
85
}
else
if
(
type
==
"Binary_Parallel"
) {
86
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
87
m_fieldio
=
new
FieldIO_Binary_Parallel
(
m_format
);
88
}
else
if
(
type
==
"Binary_Distributed"
) {
89
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
90
m_fieldio
=
new
FieldIO_Binary_Distributed
(
m_format
);
91
}
else
if
(
type
==
"ILDG_Parallel"
) {
92
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
93
m_fieldio
=
new
FieldIO_LIME_Parallel
(
m_format
);
94
}
else
if
(
type
==
"NERSC"
) {
95
m_format
=
new
IO_Format::Gauge::ILDG_Format
;
96
m_fieldio
=
new
FieldIO_NERSC
(
m_format
);
97
}
else
if
((
type
==
"None"
) || (
type
==
"Null"
)) {
// for backward compatibility
98
m_format
=
new
IO_Format::Trivial_Format
;
99
m_fieldio
=
new
FieldIO_None
(
m_format
);
100
}
else
if
(
type
==
"Unit"
) {
101
m_datasource
=
new
DataSource_Unit
;
102
}
else
if
(
type
==
"Random"
) {
103
m_datasource
=
new
DataSource_Random
;
104
}
else
{
105
vout
.
crucial
(
"Error at %s: unsupported type \"%s\".\n"
,
class_name
.c_str(),
type
.c_str());
106
exit(EXIT_FAILURE);
107
}
108
}
109
110
111
//====================================================================
112
GaugeConfig::~GaugeConfig
()
113
{
114
if
(
m_fieldio
)
delete
m_fieldio
;
115
if
(
m_format
)
delete
m_format
;
116
if
(
m_datasource
)
delete
m_datasource
;
117
}
118
119
120
//====================================================================
121
void
GaugeConfig::read
(
Field_G
& U,
const
string
& filename)
122
{
123
if
(
m_fieldio
) {
124
return
m_fieldio
->
read_file
(U, filename);
125
}
126
127
if
(
m_datasource
) {
128
return
m_datasource
->
set
(U);
129
}
130
131
vout
.
crucial
(
"Error at %s::read_file(): FieldIO or DataSource not set.\n"
,
class_name
.c_str());
132
exit(EXIT_FAILURE);
133
}
134
135
136
//====================================================================
137
void
GaugeConfig::write
(
Field_G
& U,
const
string
& filename)
138
{
139
if
(
m_fieldio
) {
140
if
(filename !=
"NO_OUTPUT"
) {
141
return
m_fieldio
->
write_file
(U, filename);
142
}
else
{
143
return
;
// do nothig
144
}
145
}
146
147
vout
.
crucial
(
"Error at %s::write_file(): FieldIO not set.\n"
,
class_name
.c_str());
148
exit(EXIT_FAILURE);
149
}
150
151
152
//====================================================================
153
//============================================================END=====
GaugeConfig::~GaugeConfig
virtual ~GaugeConfig()
Definition:
gaugeConfig.cpp:112
GaugeConfig::DataSource_Random
Definition:
gaugeConfig.cpp:39
FieldIO_Fortran
FieldIO_Fortran class for file I/O of Field data in Fortran binary format.
Definition:
fieldIO_Fortran.h:52
Field_G::set_unit
void set_unit()
Definition:
field_G_imp.cpp:39
GaugeConfig::DataSource_Random::set
virtual void set(Field_G &U)
Definition:
gaugeConfig.cpp:51
CommonParameters
Common parameter class: provides parameters as singleton.
Definition:
commonParameters.h:42
GaugeConfig::DataSource_Unit
Definition:
gaugeConfig.cpp:29
GaugeConfig::DataSource_Unit::set
virtual void set(Field_G &U)
Definition:
gaugeConfig.cpp:32
FieldIO_None
FieldIO_None class for an analogue of /dev/null.
Definition:
fieldIO_None.h:32
GaugeConfig::GaugeConfig
GaugeConfig(const string &type)
Definition:
gaugeConfig.cpp:61
GaugeConfig::read
void read(Field_G &U, const string &filename=string())
Definition:
gaugeConfig.cpp:121
RandomNumbers
Base class of random number generators.
Definition:
randomNumbers.h:43
gaugeConfig.h
io_format_gauge.h
GaugeConfig::m_fieldio
FieldIO * m_fieldio
Definition:
gaugeConfig.h:108
GaugeConfig::DataSource::set
virtual void set(Field_G &U)=0
GaugeConfig::DataSource
Definition:
gaugeConfig.cpp:21
GaugeConfig::DataSource_Random::DataSource_Random
DataSource_Random()
Definition:
gaugeConfig.cpp:42
GaugeConfig::DataSource_Random::m_rand
RandomNumbers * m_rand
Definition:
gaugeConfig.cpp:57
GaugeConfig::DataSource::~DataSource
virtual ~DataSource()
Definition:
gaugeConfig.cpp:24
GaugeConfig::write
void write(Field_G &U, const string &filename=string())
Definition:
gaugeConfig.cpp:137
IO_Format::Gauge::JLQCD_Format
Definition:
io_format_gauge.h:81
FieldIO_Binary
FieldIO_Binary class for file I/O of Field data in binary format.
Definition:
fieldIO_Binary.h:47
IO_Format::Gauge::ILDG_Format
Definition:
io_format_gauge.h:43
FieldIO_NERSC
FieldIO_NERSC class for file I/O of Field data in binary format.
Definition:
fieldIO_NERSC.h:44
RandomNumberManager::getInstance
static RandomNumbers * getInstance()
Definition:
randomNumberManager.cpp:45
FieldIO::read_file
virtual void read_file(Field &v, const std::string &)=0
read data from file. (‘const’ is added [18 Mar 2021])
FieldIO_Text_4x4x4x8
FieldIO_Text class for file I/O of Field data in plain text format.
Definition:
fieldIO_Text_4x4x4x8.h:32
GaugeConfig::DataSource_Random::~DataSource_Random
~DataSource_Random()
Definition:
gaugeConfig.cpp:47
randomNumberManager.h
IO_Format::Trivial_Format
Definition:
io_format.h:46
FieldIO_LIME
FieldIO_LIME class for file I/O of Field data in LIME format.
Definition:
fieldIO_LIME.h:78
GaugeConfig::m_datasource
DataSource * m_datasource
Definition:
gaugeConfig.h:114
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition:
bridgeIO.cpp:180
GaugeConfig::class_name
static const std::string class_name
Definition:
gaugeConfig.h:83
Field_G
SU(N) gauge field.
Definition:
field_G.h:38
GaugeConfig::m_format
IO_Format::Format * m_format
Definition:
gaugeConfig.h:109
FieldIO_Text
FieldIO_Text class for file I/O of Field data in plain text format.
Definition:
fieldIO_Text.h:37
FieldIO::write_file
virtual void write_file(Field &v, const std::string &)=0
write data to file. (‘const’ is added [18 Mar 2021])
Field_G::set_random
void set_random(RandomNumbers *rand)
Definition:
field_G_imp.cpp:57
FieldIO_LIME_Parallel
FieldIO_LIME_Parallel class for file I/O of Field data in LIME format.
Definition:
fieldIO_LIME_Parallel.h:81
Element_type::type
type
Definition:
bridge_defs.h:41
Bridge::vout
BridgeIO vout
Definition:
bridgeIO.cpp:512
FieldIO_Binary_Distributed
FieldIO_Binary_Distributed class for file I/O of Field data in binary format.
Definition:
fieldIO_Binary_Distributed.h:39
FieldIO_Binary_Parallel
FieldIO_Binary_Parallel class for file I/O of Field data in binary format using MPI parallel I/O.
Definition:
fieldIO_Binary_Parallel.h:80
src
lib
IO
gaugeConfig.cpp
Generated on Sat Feb 10 2024 14:20:00 for Bridge++ by
1.8.17