OGS
Output.cpp
Go to the documentation of this file.
1
11#include "Output.h"
12
13#include <ostream>
14
15#ifdef USE_PETSC
16#include <mpi.h>
17#endif
18
19namespace ChemistryLib
20{
21namespace PhreeqcIOData
22{
23std::string specifyFileName(std::string const& project_file_name,
24 std::string const& file_extension)
25{
26#ifdef USE_PETSC
27 int mpi_rank;
28
29 MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
30 return project_file_name + "_phreeqc_pid_" + std::to_string(mpi_rank) +
31 file_extension;
32#endif
33
34 return project_file_name + "_phreeqc" + file_extension;
35}
36
37BasicOutputSetups::BasicOutputSetups(std::string const& project_file_name,
38 bool const use_high_precision_)
39 : output_file(specifyFileName(project_file_name, ".out")),
40 use_high_precision(use_high_precision_)
41{
42}
43
44std::ostream& operator<<(std::ostream& os,
45 BasicOutputSetups const& basic_output_setups)
46{
47 os << "SELECTED_OUTPUT"
48 << "\n";
49 os << "-file " << basic_output_setups.output_file << "\n";
50 os << "-high_precision " << std::boolalpha
51 << basic_output_setups.use_high_precision << "\n";
52 os << "-simulation " << std::boolalpha
54 os << "-state " << std::boolalpha << BasicOutputSetups::display_state
55 << "\n";
56 os << "-distance " << std::boolalpha << BasicOutputSetups::display_distance
57 << "\n";
58 os << "-time " << std::boolalpha << BasicOutputSetups::display_current_time
59 << "\n";
60 os << "-step " << std::boolalpha << BasicOutputSetups::display_time_step
61 << "\n";
62
63 return os;
64}
65
66std::ostream& operator<<(std::ostream& os, Output const& output)
67{
68 os << output.basic_output_setups;
69
70 auto const component_items =
72 os << "-totals";
73 for (auto const& component_item : component_items)
74 {
75 os << " " << component_item.name;
76 }
77 os << "\n";
78
79 auto const equilibrium_phase_items =
81 if (!equilibrium_phase_items.empty())
82 {
83 os << "-equilibrium_phases";
84 for (auto const& equilibrium_phase_item : equilibrium_phase_items)
85 {
86 os << " " << equilibrium_phase_item.name;
87 }
88 os << "\n";
89 }
90
91 auto const kinetic_reactant_items =
93 if (!kinetic_reactant_items.empty())
94 {
95 os << "-kinetic_reactants";
96 for (auto const& kinetic_reactant_item : kinetic_reactant_items)
97 {
98 os << " " << kinetic_reactant_item.name;
99 }
100 os << "\n";
101 }
102
103 return os;
104}
105} // namespace PhreeqcIOData
106} // namespace ChemistryLib
BasicOutputSetups(std::string const &project_file_name, bool const use_high_precision_)
Definition Output.cpp:37
std::ostream & operator<<(std::ostream &os, PhreeqcIO const &phreeqc_io)
std::string specifyFileName(std::string const &project_file_name, std::string const &file_extension)
Definition Output.cpp:23
BasicOutputSetups const basic_output_setups
Definition Output.h:104
std::vector< OutputItem > getOutputItemsByItemType(ItemType item_type) const
Definition Output.h:91