7enum class APPEND_FILE { TRUE, FALSE };
8enum class CLOSE_FILE { TRUE, FALSE };
11 return (z + lattice.size(e_z)) % lattice.size(e_z);
15void print_formatted_numbers(
const std::vector<
Complex<T>> &numbers, std::string label,
16 bool indices,
bool sum =
false) {
20 for (
int i = 0; i < numbers.size() - 1; i++) {
30 for (
int i = 0; i < numbers.size() - 1; i++) {
31 hila::out0 << std::setprecision(12) << numbers[i].re <<
" " << numbers[i].im <<
", ";
33 hila::out0 << std::setprecision(12) << numbers[numbers.size() - 1].re <<
" "
34 << numbers[numbers.size() - 1].im <<
"\n";
39void print_formatted_numbers(
const std::vector<T> &numbers, std::string label,
bool indices,
44 for (
int i = 0; i < numbers.size() - 1; i++) {
54 for (
int i = 0; i < numbers.size() - 1; i++) {
55 hila::out0 << std::setprecision(12) << numbers[i] <<
", ";
57 hila::out0 << std::setprecision(12) << numbers[numbers.size() - 1] <<
"\n";
101void write_surface(std::vector<T> surf, std::string file_name, APPEND_FILE append_true,
102 CLOSE_FILE close_file) {
107 if (append_true == APPEND_FILE::TRUE)
108 MFile.open(file_name, std::ios::app);
110 MFile.open(file_name);
112 if (!MFile.is_open()) {
113 std::cerr <<
"Error: Failed to open file " << file_name << std::endl;
118 MFile <<
"volume: " << lattice.size(e_x) <<
" " << lattice.size(e_y) <<
" " << lattice.size(e_z)
119 <<
" " << lattice.size(e_t) << std::endl;
120 MFile <<
"x y z" << std::endl;
122 for (
int y = 0; y < lattice.size(e_y); y++) {
123 for (
int x = 0; x < lattice.size(e_x); x++) {
125 MFile << x <<
' ' << y <<
' ' << surf[x + y * lattice.size(e_x)] << std::endl;
131 if (close_file == CLOSE_FILE::TRUE) {
133 std::cout <<
"Closed file " << file_name << std::endl;
178void write_fourier(std::vector<T> npow, std::vector<int> hits,
int pow_size, std::string file_name,
179 APPEND_FILE append_true, CLOSE_FILE close_file) {
184 if (append_true == APPEND_FILE::TRUE)
185 MFile.open(file_name, std::ios::app);
187 MFile.open(file_name);
189 if (!MFile.is_open()) {
190 std::cerr <<
"Error: Failed to open file " << file_name << std::endl;
195 MFile <<
"volume: " << lattice.size(e_x) <<
" " << lattice.size(e_y) <<
" " << lattice.size(e_z)
196 <<
" " << lattice.size(e_t) << std::endl;
199 <<
" h" << std::endl;
200 for (
int i = 0; i < pow_size; i++) {
202 MFile << i <<
' ' << npow[i] / hits[i] <<
' ' << hits[i] <<
'\n';
206 if (close_file == CLOSE_FILE::TRUE) {
208 std::cout <<
"Closed file " << file_name << std::endl;
int myrank()
rank of this node
std::ostream out0
This writes output only from main process (node 0)
int z_ind(int z)
Helper function to get valid z-coordinate index.