Bridge++
Version 1.5.4
Main Page
Namespaces
Classes
Files
File List
File Members
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
#include "
Tools/randomNumberManager.h
"
16
17
const
std::string
GaugeConfig::class_name
=
"GaugeConfig"
;
18
19
//====================================================================
20
class
GaugeConfig::DataSource
21
{
22
public
:
23
virtual
~DataSource
() {}
24
virtual
void
set
(
Field_G
*U) = 0;
25
};
26
27
//--------------------------------------------------------------------
28
class
GaugeConfig::DataSource_Unit
:
public
DataSource
29
{
30
public
:
31
virtual
void
set
(
Field_G
*U)
32
{
33
if
(U) U->
set_unit
();
34
}
35
};
36
37
//--------------------------------------------------------------------
38
class
GaugeConfig::DataSource_Random
:
public
DataSource
39
{
40
public
:
41
DataSource_Random
()
42
{
43
m_rand
=
RandomNumberManager::getInstance
();
44
}
45
46
~DataSource_Random
()
47
{
48
}
49
50
virtual
void
set
(
Field_G
*U)
51
{
52
if
(U) U->
set_random
(
m_rand
);
53
}
54
55
private
:
56
RandomNumbers
*
m_rand
;
57
};
58
59
//====================================================================
60
GaugeConfig::GaugeConfig
(
const
string
&
type
)
61
: m_vl(
CommonParameters
::Vlevel()),
62
m_fieldio(),
63
m_datasource()
64
{
65
if
(type ==
"Text"
) {
66
m_fieldio
=
new
FieldIO_Text
(
IO_Format::Gauge::ILDG
);
67
}
else
if
(type ==
"Text_4x4x4x8"
) {
68
m_fieldio
=
new
FieldIO_Text_4x4x4x8
(
IO_Format::Gauge::ILDG
);
69
}
else
if
(type ==
"Binary"
) {
70
m_fieldio
=
new
FieldIO_Binary
(
IO_Format::Gauge::ILDG
);
71
}
else
if
(type ==
"Fortran_JLQCD"
) {
72
m_fieldio
=
new
FieldIO_Fortran
(
IO_Format::Gauge::JLQCD
);
73
}
else
if
(type ==
"Fortran_ILDG"
) {
74
m_fieldio
=
new
FieldIO_Fortran
(
IO_Format::Gauge::ILDG
);
75
}
else
if
(type ==
"ILDG"
) {
76
m_fieldio
=
new
FieldIO_LIME
(
IO_Format::Gauge::ILDG
);
77
}
else
if
(type ==
"Binary_Parallel"
) {
78
m_fieldio
=
new
FieldIO_Binary_Parallel
(
IO_Format::Gauge::ILDG
);
79
}
else
if
(type ==
"Binary_Distributed"
) {
80
m_fieldio
=
new
FieldIO_Binary_Distributed
(
IO_Format::Gauge::ILDG
);
81
}
else
if
(type ==
"ILDG_Parallel"
) {
82
m_fieldio
=
new
FieldIO_LIME_Parallel
(
IO_Format::Gauge::ILDG
);
83
}
else
if
((type ==
"None"
) || (type ==
"Null"
)) {
// for backward compatibility
84
m_fieldio
=
new
FieldIO_None
(
IO_Format::Trivial
);
85
}
else
if
(type ==
"Unit"
) {
86
m_datasource
=
new
DataSource_Unit
;
87
}
else
if
(type ==
"Random"
) {
88
m_datasource
=
new
DataSource_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
//====================================================================
97
GaugeConfig::~GaugeConfig
()
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=====
GaugeConfig::DataSource::~DataSource
virtual ~DataSource()
Definition:
gaugeConfig.cpp:23
GaugeConfig::class_name
static const std::string class_name
Definition:
gaugeConfig.h:81
Bridge::vout
BridgeIO vout
Definition:
bridgeIO.cpp:503
Element_type::type
type
Definition:
bridge_defs.h:41
GaugeConfig::DataSource_Random::m_rand
RandomNumbers * m_rand
Definition:
gaugeConfig.cpp:56
GaugeConfig::~GaugeConfig
virtual ~GaugeConfig()
Definition:
gaugeConfig.cpp:97
GaugeConfig::DataSource
Definition:
gaugeConfig.cpp:20
FieldIO_LIME
FieldIO_LIME class for file I/O of Field data in LIME format.
Definition:
fieldIO_LIME.h:91
GaugeConfig::m_fieldio
FieldIO * m_fieldio
Definition:
gaugeConfig.h:116
gaugeConfig.h
RandomNumberManager::getInstance
static RandomNumbers * getInstance()
Definition:
randomNumberManager.cpp:45
FieldIO_LIME_Parallel
FieldIO_LIME_Parallel class for file I/O of Field data in LIME format.
Definition:
fieldIO_LIME_Parallel.h:84
FieldIO_Text
FieldIO_Text class for file I/O of Field data in plain text format.
Definition:
fieldIO_Text.h:37
GaugeConfig::GaugeConfig
GaugeConfig(const string &type)
Definition:
gaugeConfig.cpp:60
IO_Format::Gauge::ILDG
const Format * ILDG
Definition:
io_format.cpp:28
Field_G::set_random
void set_random(RandomNumbers *rand)
Definition:
field_G_imp.cpp:60
Field_G::set_unit
void set_unit()
Definition:
field_G_imp.cpp:37
GaugeConfig::DataSource_Random::set
virtual void set(Field_G *U)
Definition:
gaugeConfig.cpp:50
FieldIO_Fortran
FieldIO_Fortran class for file I/O of Field data in Fortran binary format.
Definition:
fieldIO_Fortran.h:52
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:83
GaugeConfig::DataSource_Random::~DataSource_Random
~DataSource_Random()
Definition:
gaugeConfig.cpp:46
Field_G
SU(N) gauge field.
Definition:
field_G.h:38
GaugeConfig::read
void read(Field_G *U, const string &filename=string())
Definition:
gaugeConfig.cpp:105
randomNumberManager.h
GaugeConfig::write
void write(Field_G *U, const string &filename=string())
Definition:
gaugeConfig.cpp:121
FieldIO_Text_4x4x4x8
FieldIO_Text class for file I/O of Field data in plain text format.
Definition:
fieldIO_Text_4x4x4x8.h:32
CommonParameters
Common parameter class: provides parameters as singleton.
Definition:
commonParameters.h:42
GaugeConfig::DataSource_Random::DataSource_Random
DataSource_Random()
Definition:
gaugeConfig.cpp:41
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition:
bridgeIO.cpp:178
IO_Format::Gauge::JLQCD
const Format * JLQCD
Definition:
io_format.cpp:29
IO_Format::Trivial
const Format * Trivial
Definition:
io_format.cpp:27
GaugeConfig::DataSource::set
virtual void set(Field_G *U)=0
FieldIO_Binary
FieldIO_Binary class for file I/O of Field data in binary format.
Definition:
fieldIO_Binary.h:47
RandomNumbers
Base class of random number generators.
Definition:
randomNumbers.h:43
FieldIO::read_file
virtual void read_file(Field *v, std::string)=0
read data from file.
FieldIO::write_file
virtual void write_file(Field *v, std::string)=0
write data to file.
FieldIO_Binary_Distributed
FieldIO_Binary_Distributed class for file I/O of Field data in binary format.
Definition:
fieldIO_Binary_Distributed.h:39
GaugeConfig::DataSource_Unit
Definition:
gaugeConfig.cpp:28
GaugeConfig::DataSource_Unit::set
virtual void set(Field_G *U)
Definition:
gaugeConfig.cpp:31
GaugeConfig::DataSource_Random
Definition:
gaugeConfig.cpp:38
GaugeConfig::m_datasource
DataSource * m_datasource
Definition:
gaugeConfig.h:121
FieldIO_None
FieldIO_None class for an analogue of /dev/null.
Definition:
fieldIO_None.h:32
src
lib
IO
gaugeConfig.cpp
Generated on Thu Mar 19 2020 10:28:23 for Bridge++ by
1.8.6