6#ifndef PlaquetteField_H_
7#define PlaquetteField_H_
25 std::array<VectorField<T>, NDIM> fdir;
28 static constexpr int64_t config_flag = 394824242;
38 template <typename A, std::enable_if_t<std::is_convertible<A, T>::value,
int> = 0>
44 template <typename A, std::enable_if_t<std::is_convertible<A, T>::value,
int> = 0>
50 template <typename A, std::enable_if_t<hila::is_assignable<T &, A>::value,
int> = 0>
100 void write(std::ofstream &outputfile)
const {
102 fdir[d1].write(outputfile);
106 void write(
const std::string &filename)
const {
107 std::ofstream outputfile;
108 hila::open_output_file(filename, outputfile);
110 hila::close_file(filename, outputfile);
113 void read(std::ifstream &inputfile) {
115 fdir[d1].read(inputfile);
121 fdir[d1].read(inputfile, insize);
125 void read(
const std::string &filename) {
126 std::ifstream inputfile;
127 hila::open_input_file(filename, inputfile);
129 hila::close_file(filename, inputfile);
135 std::ofstream outputfile;
136 hila::open_output_file(filename, outputfile);
140 int64_t f = config_flag;
141 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
143 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
145 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
149 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
154 hila::close_file(filename, outputfile);
157 void config_read(
const std::string &filename) {
158 std::ifstream inputfile;
159 hila::open_input_file(filename, inputfile);
160 std::string conferr(
"CONFIG ERROR in file " + filename +
": ");
166 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
167 ok = (f == config_flag);
169 hila::out0 << conferr <<
"wrong id, should be " << config_flag <<
" is " << f
174 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
177 hila::out0 << conferr <<
"wrong dimensionality, should be " << NDIM <<
" is " << f
182 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
183 ok = (f ==
sizeof(T));
185 hila::out0 << conferr <<
"wrong size of field element, should be " <<
sizeof(T)
186 <<
" is " << f <<
'\n';
193 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
195 ok = ok && (lattice.
size(d) % insize[d] == 0);
197 hila::out0 << conferr <<
"incorrect lattice dimension " << hila::prettyprint(d)
198 <<
" is " << f <<
" should be (or divide) " << lattice.
size(d) <<
'\n';
208 read(inputfile, insize);
209 hila::close_file(filename, inputfile);
int size(Direction d) const
lattice.size() -> CoordinateVector or lattice.size(d) -> int returns the dimensions of the lattice,...
T c[n *m]
The data as a one dimensional array.
PlaquetteField & operator=(const A &val)
Assign from anything the field allows.
PlaquetteField & operator=(std::nullptr_t np)
Separate 0 assignment.
void config_write(const std::string &filename) const
config_write writes the gauge field to file, with additional "verifying" header
VectorField< T > & operator[](Direction d1)
Access components with [].
~PlaquetteField()=default
Destructor.
#define foralldir(d)
Macro to loop over (all) Direction(s)
Direction
Enumerator for direction that assigns integer to direction to be interpreted as unit vector.
Implement hila::swap for gauge fields.
void broadcast_array(T *var, int n, int rank=0)
Broadcast for arrays where size must be known and same for all nodes.
int myrank()
rank of this node
std::ostream out0
This writes output only from main process (node 0)
T broadcast(T &var, int rank=0)
Broadcast the value of var to all MPI ranks from rank (default=0).
void terminate(int status)