TRIQS/triqs_ctseg 4.0.0
A TRIQS application
Loading...
Searching...
No Matches
visualize_config.hpp
1// Copyright (c) 2025--present, The Simons Foundation
2// Copyright (c) 2025--present, Max Planck Institute for Polymer Research, Mainz, Germany
3// This file is part of TRIQS/ctseg and is licensed under the terms of GPLv3 or later.
4// SPDX-License-Identifier: GPL-3.0-or-later
5// See LICENSE in the root of this distribution for details.
6
7#pragma once
8#include <triqs/mc_tools/mc_generic.hpp>
9#include <triqs/utility/callbacks.hpp>
10#include "../configuration.hpp"
11
12namespace triqs_ctseg::measures {
13
14 struct visualize_config {
15
16 mpi::communicator _c;
17
18 configuration_t const &config;
19
20 double Z = 0;
21
22 visualize_config(configuration_t const &config): config{config} {};
23
24 void accumulate(double s) {
25
26 Z += s;
27
28 if (_c.rank() == 0) {
29
30 std::ofstream outFile("configuration.txt", std::ios::app);
31
32 outFile << "Configuration is " << config << std::endl;
33
34 outFile.close();
35
36 }
37
38 }
39
40 void collect_results(mpi::communicator const &c) {
41
42 Z = mpi::all_reduce(Z, c);
43
44 }
45
46 };
47
48} // namespace triqs_ctseg::measures