BubbleProfiler  0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
observers.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of BubbleProfiler.
3  *
4  * BubbleProfiler is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * BubbleProfiler is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with BubbleProfiler. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef BUBBLEPROFILER_OBSERVERS_HPP_INCLUDED
19 #define BUBBLEPROFILER_OBSERVERS_HPP_INCLUDED
20 
21 #include "basic_logger.hpp"
22 
23 #include <fstream>
24 #include <string>
25 #include <vector>
26 
27 namespace BubbleProfiler {
28 
29 class Field_profiles;
30 class Potential;
31 
42  void operator()(const Field_profiles&, const Field_profiles&) const {}
43 };
44 
51 public:
52  Profile_observer(const std::vector<std::string>& fields_,
53  const std::string& output_path_,
54  const Potential& potential_);
55  Profile_observer(const Profile_observer&) = delete;
56  Profile_observer& operator=(const Profile_observer&) = delete;
57 
58  void operator()(const Field_profiles& profile,
59  const Field_profiles& perturbation);
60 private:
61  int iteration_count{0};
62  std::vector<std::string> fields{};
63  std::string output_path{};
65  std::ofstream action_file;
66  std::ofstream profiles_file;
67  std::ofstream perturbations_file;
69 
70  void write_initial_action_to_file(const Field_profiles& profiles);
71  void write_initial_profiles_to_file(const Field_profiles& profiles);
72  void write_initial_perturbations_to_file();
73 
74  void write_field_profiles_to_file(std::ofstream& stream,
75  const Field_profiles& profiles);
76  void write_action_to_file(const Field_profiles& profiles);
77 };
78 
79 } // namespace BubbleProfiler
80 
81 #endif
A default observer that does not perform any actions when called.
Definition: observers.hpp:41
void operator()(const Field_profiles &, const Field_profiles &) const
Definition: observers.hpp:42
Observes the profile during iteration and writes out profile, perturbations and action for each step ...
Definition: observers.hpp:50
Abstract base class for a generic potential.
Definition: potential.hpp:36
Discretized set of field profiles.