1#ifndef HILA_GAUGEFIELD_H_
2#define HILA_GAUGEFIELD_H_
25 std::array<Field<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<hila::is_assignable<T &, A>::value,
int> = 0>
97 onsites(
ALL)(*this)[d][X].reunitarize();
117 real(trace((*
this)[dir1][X] * (*
this)[dir2][X + dir1] *
118 (*
this)[dir1][X + dir2].
dagger() * (*
this)[dir2][X].
dagger())) /
128 void write(std::ofstream &outputfile)
const {
130 fdir[d].write(outputfile);
134 void write(
const std::string &filename)
const {
135 std::ofstream outputfile;
136 hila::open_output_file(filename, outputfile);
138 hila::close_file(filename, outputfile);
141 void read(std::ifstream &inputfile) {
143 fdir[d].read(inputfile);
149 fdir[d].read(inputfile, insize);
153 void read(
const std::string &filename) {
154 std::ifstream inputfile;
155 hila::open_input_file(filename, inputfile);
157 hila::close_file(filename, inputfile);
163 std::ofstream outputfile;
164 hila::open_output_file(filename, outputfile);
168 int64_t f = config_flag;
169 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
171 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
173 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
177 outputfile.write(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
182 hila::close_file(filename, outputfile);
185 void config_read(
const std::string &filename) {
186 std::ifstream inputfile;
187 hila::open_input_file(filename, inputfile);
188 std::string conferr(
"CONFIG ERROR in file " + filename +
": ");
194 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
195 ok = (f == config_flag);
197 hila::out0 << conferr <<
"wrong id, should be " << config_flag <<
" is " << f
202 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
205 hila::out0 << conferr <<
"wrong dimensionality, should be " << NDIM <<
" is " << f
210 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
211 ok = (f ==
sizeof(T));
213 hila::out0 << conferr <<
"wrong size of field element, should be " <<
sizeof(T)
214 <<
" is " << f <<
'\n';
220 inputfile.read(
reinterpret_cast<char *
>(&f),
sizeof(int64_t));
222 ok = ok && (lattice.
size(d) % insize[d] == 0);
224 hila::out0 << conferr <<
"incorrect lattice dimension " << hila::prettyprint(d)
225 <<
" is " << f <<
" should be (or divide)" << lattice.
size(d) <<
'\n';
235 read(inputfile, insize);
236 hila::close_file(filename, inputfile);
Array< n, m, hila::arithmetic_type< T > > real(const Array< n, m, T > &arg)
Return real part of Array.
The field class implements the standard methods for accessing Fields. Hilapp replaces the parity acce...
~GaugeField()=default
Destructor.
GaugeField & operator=(std::nullptr_t np)
Separate 0 assignment.
Field< T > & operator[](Direction d)
Access components with [].
GaugeField & operator=(const A &val)
Assign from anything the field allows.
void reunitarize_gauge()
Reunitarize Gauge Field consisting of matrices.
double measure_plaq() const
Computes Wilson action.
void config_write(const std::string &filename) const
config_write writes the gauge field to file, with additional "verifying" header
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.
Special reduction class: enables delayed and non-blocking reductions, which are not possible with the...
const T value()
Return value of the reduction variable. Wait for the comms if needed.
Reduction & allreduce(bool b=true)
allreduce(bool) turns allreduce on or off. By default on.
Complex< T > dagger(const Complex< T > &val)
Return dagger of Complex number.
#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.
constexpr Parity ALL
bit pattern: 011
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)