diff --git a/phreeqcpp/Phreeqc.h b/phreeqcpp/Phreeqc.h index eca08283..ed8003cb 100644 --- a/phreeqcpp/Phreeqc.h +++ b/phreeqcpp/Phreeqc.h @@ -2071,6 +2071,22 @@ namespace Utilities return; } + template < typename T > + void Rxn_dump_raw_range(const T & b, std::ostream & s_oss, int start, int end, unsigned int indent) + { + typename T::const_iterator it; + for (int i = start; i <= end; i++) + { + if (i < 0) continue; + it = b.find(i); + if (it != b.end()) + { + it->second.dump_raw(s_oss, indent); + } + } + return; + } + template < typename T > T * Rxn_find(std::map < int, T > &b, int i) { diff --git a/phreeqcpp/StorageBin.cxx b/phreeqcpp/StorageBin.cxx index efe3ffb2..56663587 100644 --- a/phreeqcpp/StorageBin.cxx +++ b/phreeqcpp/StorageBin.cxx @@ -186,6 +186,155 @@ cxxStorageBin::Add(cxxStorageBin &src, int n) } } void +cxxStorageBin::Add_uz(cxxStorageBin &uzbin) +{ + cxxMix mx; + mx.Add(0, 1.0); + mx.Add(1, 1.0); + + // Solution + + // Exchange + { + std::map::iterator it_uz = uzbin.Get_Exchangers().begin(); + std::map temp_map; + for (; it_uz != uzbin.Get_Exchangers().end(); it_uz++) + { + int n_user = it_uz->second.Get_n_user(); + std::map < int, cxxExchange >::iterator it_sz = this->Exchangers.find(n_user); + if (it_sz == this->Exchangers.end()) + { + this->Exchangers[n_user] = it_uz->second; + } + else + { + temp_map[0] = it_uz->second; + temp_map[1] = it_sz->second; + cxxExchange temp_entity(temp_map, mx, n_user); + this->Exchangers[n_user] = temp_entity; + } + } + } + + // gas_phase + { + std::map::iterator it_uz = uzbin.Get_GasPhases().begin(); + std::map temp_map; + for (; it_uz != uzbin.Get_GasPhases().end(); it_uz++) + { + int n_user = it_uz->second.Get_n_user(); + std::map < int, cxxGasPhase >::iterator it_sz = this->GasPhases.find(n_user); + if (it_sz == this->GasPhases.end()) + { + this->GasPhases[n_user] = it_uz->second; + } + else + { + temp_map[0] = it_uz->second; + temp_map[1] = it_sz->second; + cxxGasPhase temp_entity(temp_map, mx, n_user); + this->GasPhases[n_user] = temp_entity; + } + } + } + + // kinetics + { + std::map::iterator it_uz = uzbin.Get_Kinetics().begin(); + std::map temp_map; + for (; it_uz != uzbin.Get_Kinetics().end(); it_uz++) + { + int n_user = it_uz->second.Get_n_user(); + std::map < int, cxxKinetics >::iterator it_sz = this->Kinetics.find(n_user); + if (it_sz == this->Kinetics.end()) + { + this->Kinetics[n_user] = it_uz->second; + } + else + { + temp_map[0] = it_uz->second; + temp_map[1] = it_sz->second; + cxxKinetics temp_entity(temp_map, mx, n_user); + this->Kinetics[n_user] = temp_entity; + } + } + } + + // pp_assemblage + { + std::map::iterator it_uz = uzbin.Get_PPassemblages().begin(); + std::map temp_map; + for (; it_uz != uzbin.Get_PPassemblages().end(); it_uz++) + { + int n_user = it_uz->second.Get_n_user(); + std::map < int, cxxPPassemblage >::iterator it_sz = this->PPassemblages.find(n_user); + if (it_sz == this->PPassemblages.end()) + { + this->PPassemblages[n_user] = it_uz->second; + } + else + { + temp_map[0] = it_uz->second; + temp_map[1] = it_sz->second; + cxxPPassemblage temp_entity(temp_map, mx, n_user); + this->PPassemblages[n_user] = temp_entity; + } + } + } + + // ss_assemblage + { + std::map::iterator it_uz = uzbin.Get_SSassemblages().begin(); + std::map temp_map; + for (; it_uz != uzbin.Get_SSassemblages().end(); it_uz++) + { + int n_user = it_uz->second.Get_n_user(); + std::map < int, cxxSSassemblage >::iterator it_sz = this->SSassemblages.find(n_user); + if (it_sz == this->SSassemblages.end()) + { + this->SSassemblages[n_user] = it_uz->second; + } + else + { + temp_map[0] = it_uz->second; + temp_map[1] = it_sz->second; + cxxSSassemblage temp_entity(temp_map, mx, n_user); + this->SSassemblages[n_user] = temp_entity; + } + } + } + + // surface + { + std::map::iterator it_uz = uzbin.Get_Surfaces().begin(); + std::map temp_map; + for (; it_uz != uzbin.Get_Surfaces().end(); it_uz++) + { + int n_user = it_uz->second.Get_n_user(); + std::map < int, cxxSurface >::iterator it_sz = this->Surfaces.find(n_user); + if (it_sz == this->Surfaces.end()) + { + this->Surfaces[n_user] = it_uz->second; + } + else + { + temp_map[0] = it_uz->second; + temp_map[1] = it_sz->second; + cxxSurface temp_entity(temp_map, mx, n_user); + this->Surfaces[n_user] = temp_entity; + } + } + } + + // mix + + // reaction + + // reaction temperature + + // reaction pressure +} +void cxxStorageBin::Copy(int destination, int source) { if (destination == source) @@ -793,6 +942,43 @@ cxxStorageBin::dump_raw(std::ostream & s_oss, int n, unsigned int indent, int *n } } +void +cxxStorageBin::dump_raw_range(std::ostream & s_oss, int start, int end, unsigned int indent) const +{ + // Dump all data + s_oss.precision(DBL_DIG - 1); + + // Solutions + Utilities::Rxn_dump_raw_range(Solutions, s_oss, start, end, indent); + + // Exchange + Utilities::Rxn_dump_raw_range(Exchangers, s_oss, start, end, indent); + + // Gas Phases + Utilities::Rxn_dump_raw_range(GasPhases, s_oss, start, end, indent); + + // Kinetics + Utilities::Rxn_dump_raw_range(Kinetics, s_oss, start, end, indent); + + // PPassemblage + Utilities::Rxn_dump_raw_range(PPassemblages, s_oss, start, end, indent); + + // SSassemblage + Utilities::Rxn_dump_raw_range(SSassemblages, s_oss, start, end, indent); + + // Surface + Utilities::Rxn_dump_raw_range(Surfaces, s_oss, start, end, indent); + + // Mix + Utilities::Rxn_dump_raw_range(Mixes, s_oss, start, end, indent); + + // Reactions + Utilities::Rxn_dump_raw_range(Reactions, s_oss, start, end, indent); + + // Temperature + Utilities::Rxn_dump_raw_range(Temperatures, s_oss, start, end, indent); +} + void cxxStorageBin::read_raw(CParser & parser) { diff --git a/phreeqcpp/StorageBin.h b/phreeqcpp/StorageBin.h index cf83d7f7..1cf5c9c7 100644 --- a/phreeqcpp/StorageBin.h +++ b/phreeqcpp/StorageBin.h @@ -94,11 +94,13 @@ class cxxStorageBin: public PHRQ_base void dump_raw(std::ostream & s_oss, unsigned int indent) const; void dump_raw(std::ostream & s_oss, int i, unsigned int indent, int *n_out=NULL); + void dump_raw_range(std::ostream & s_oss, int start, int end, unsigned int indent) const; void read_raw(CParser & parser); int read_raw_keyword(CParser & parser); void Add(cxxStorageBin &src, int n); + void Add_uz(cxxStorageBin &uzbin); //cxxSolution *mix_cxxSolutions(cxxMix &mixmap); cxxExchange *mix_cxxExchange(cxxMix & mixmap);