OGS
Dump.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "Dump.h"
5
6#include <iostream>
7
8namespace ChemistryLib
9{
10namespace PhreeqcIOData
11{
12void Dump::print(std::ostream& os, std::size_t const num_chemical_systems) const
13{
14 os << "DUMP"
15 << "\n";
16 os << "-file " << dump_file << "\n";
17 os << "-append false"
18 << "\n";
19 os << "-solution 1-" << num_chemical_systems << "\n";
20 os << "END"
21 << "\n";
22}
23
24void Dump::readDumpFile(std::istream& in,
25 std::size_t const num_chemical_systems)
26{
28 aqueous_solutions_prev.reserve(num_chemical_systems);
29
30 std::string line;
31 std::string aqueous_solution_prev_;
32 std::size_t chemical_system_id = 0;
33 while (std::getline(in, line))
34 {
35 if (line.find("USE reaction_pressure none") != std::string::npos)
36 {
37 break;
38 }
39
40 if (line.find("SOLUTION_RAW") != std::string::npos)
41 {
42 aqueous_solution_prev_ =
43 "SOLUTION_RAW " +
44 std::to_string(num_chemical_systems + chemical_system_id + 1) +
45 "\n";
46 continue;
47 }
48
49 aqueous_solution_prev_ += line + "\n";
50
51 if (line.find("-gammas") != std::string::npos)
52 {
53 aqueous_solutions_prev.push_back(aqueous_solution_prev_);
54 aqueous_solution_prev_.clear();
55 ++chemical_system_id;
56 }
57 }
58}
59} // namespace PhreeqcIOData
60} // namespace ChemistryLib
std::string const dump_file
Definition Dump.h:43
void readDumpFile(std::istream &in, std::size_t const num_chemical_systems)
Definition Dump.cpp:24
void print(std::ostream &os, std::size_t const num_chemical_systems) const
Definition Dump.cpp:12
std::vector< std::string > aqueous_solutions_prev
Definition Dump.h:44