From 182df9724f4d8e911c7c828aa39d616d80301f70 Mon Sep 17 00:00:00 2001
From: renchao_lu <renchao.lu@gmail.com>
Date: Sat, 13 Jul 2019 16:31:01 +0200
Subject: [PATCH] [CL] Updated KineticReactant output.

---
 ChemistryLib/PhreeqcIO.cpp                     |  8 +++++---
 ChemistryLib/PhreeqcIOData/KineticReactant.cpp | 18 ++++++++----------
 ChemistryLib/PhreeqcIOData/KineticReactant.h   |  3 +--
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp
index 05f942f6376..14d99194946 100644
--- a/ChemistryLib/PhreeqcIO.cpp
+++ b/ChemistryLib/PhreeqcIO.cpp
@@ -220,12 +220,14 @@ std::ostream& operator<<(std::ostream& os, PhreeqcIO const& phreeqc_io)
             os << equilibrium_phases << "\n";
         }
 
-        auto const& kinetic_reactants =
-            phreeqc_io._kinetic_reactants[chemical_system_id];
+        auto const& kinetic_reactants = phreeqc_io._kinetic_reactants;
         if (!kinetic_reactants.empty())
         {
             os << "KINETICS " << chemical_system_id + 1 << "\n";
-            os << kinetic_reactants;
+            for (auto const& kinetic_reactant : kinetic_reactants)
+            {
+                kinetic_reactant.print(os, chemical_system_id);
+            }
             os << "-steps " << phreeqc_io._dt << "\n" << "\n";
         }
 
diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp
index 8f2ab34fd52..f2d7402139b 100644
--- a/ChemistryLib/PhreeqcIOData/KineticReactant.cpp
+++ b/ChemistryLib/PhreeqcIOData/KineticReactant.cpp
@@ -13,28 +13,26 @@
 
 namespace ChemistryLib
 {
-std::ostream& operator<<(std::ostream& os,
-                         KineticReactant const& kinetic_reactant)
+void KineticReactant::print(std::ostream& os,
+                            std::size_t const chemical_system_id) const
 {
-    os << kinetic_reactant.name << "\n";
+    os << name << "\n";
 
-    if (!kinetic_reactant.chemical_formula.empty())
+    if (!chemical_formula.empty())
     {
-        os << "-formula " << kinetic_reactant.chemical_formula << "\n";
+        os << "-formula " << chemical_formula << "\n";
     }
 
-    os << "-m  " << kinetic_reactant.amount << "\n";
+    os << "-m  " << (*amount)[chemical_system_id] << "\n";
 
-    if (!kinetic_reactant.parameters.empty())
+    if (!parameters.empty())
     {
         os << "-parms";
-        for (auto const& parameter : kinetic_reactant.parameters)
+        for (auto const& parameter : parameters)
         {
             os << " " << parameter;
         }
         os << "\n";
     }
-
-    return os;
 }
 }  // namespace ChemistryLib
diff --git a/ChemistryLib/PhreeqcIOData/KineticReactant.h b/ChemistryLib/PhreeqcIOData/KineticReactant.h
index 557582e1d36..dc993e2f31d 100644
--- a/ChemistryLib/PhreeqcIOData/KineticReactant.h
+++ b/ChemistryLib/PhreeqcIOData/KineticReactant.h
@@ -32,8 +32,7 @@ struct KineticReactant
     {
     }
 
-    friend std::ostream& operator<<(std::ostream& os,
-                                    KineticReactant const& kinetic_reactant);
+    void print(std::ostream& os, std::size_t const chemical_system_id) const;
 
     std::string const name;
     std::string const chemical_formula;
-- 
GitLab