Removed struct mix.

Left old code commented.

Will remove old code next svn revision.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5948 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2011-12-27 18:41:46 +00:00
parent 4bb72929ed
commit 02839d601d
7 changed files with 111 additions and 55 deletions

View File

@ -340,7 +340,7 @@ void Phreeqc::init(void)
count_elements = 0;
count_irrev = 0;
count_master = 0;
count_mix = 0;
//count_mix = 0;
count_phases = 0;
count_s = 0;
count_logk = 0;
@ -405,8 +405,8 @@ void Phreeqc::init(void)
mb_unknowns = 0;
mix = 0;
count_mix = 0;
//mix = 0;
//count_mix = 0;
/* !!!! */
stag_data = 0;
@ -706,7 +706,7 @@ void Phreeqc::init(void)
dbg_pp_assemblage = pp_assemblage;
dbg_kinetics = kinetics;
dbg_irrev = irrev;
dbg_mix = mix;
//dbg_mix = mix;
dbg_master = master;
calculating_deriv = FALSE;
numerical_deriv = FALSE;

View File

@ -30,10 +30,11 @@
#endif
#include "Keywords.h"
#include "Pressure.h"
#include "cxxMix.h"
class cxxNameDouble;
class cxxKinetics;
class cxxMix;
//class cxxMix;
class cxxKineticsComp;
class cxxExchange;
class cxxExchComp;
@ -817,7 +818,8 @@ public:
int add_exchange(struct exchange *exchange_ptr);
int add_gas_phase(struct gas_phase *gas_phase_ptr);
int add_kinetics(struct kinetics *kinetics_ptr);
int add_mix(struct mix *mix_ptr);
//int add_mix(struct mix *mix_ptr);
int add_mix(cxxMix * mix_ptr);
int add_pp_assemblage(struct pp_assemblage *pp_assemblage_ptr);
int add_reaction(struct irrev *irrev_ptr, int step_number,
LDBLE step_fraction);
@ -945,15 +947,15 @@ public:
struct master *master_bsearch_primary(const char *ptr);
struct master *master_bsearch_secondary(char *ptr);
struct master *master_search(char *ptr, int *n);
struct mix *mix_bsearch(int k, int *n);
int mix_copy(struct mix *mix_old_ptr,
struct mix *mix_new_ptr, int n_user_new);
int mix_delete(int n_user_old);
int mix_duplicate(int n_user_old, int n_user_new);
int mix_free(struct mix *mix_ptr);
struct mix *mix_search(int n_user, int *n, int print);
int mix_ptr_to_user(struct mix *mix_ptr_old, int n_user_new);
int mix_sort(void);
//struct mix *mix_bsearch(int k, int *n);
//int mix_copy(struct mix *mix_old_ptr,
//struct mix *mix_new_ptr, int n_user_new);
//int mix_delete(int n_user_old);
//int mix_duplicate(int n_user_old, int n_user_new);
//int mix_free(struct mix *mix_ptr);
//struct mix *mix_search(int n_user, int *n, int print);
//int mix_ptr_to_user(struct mix *mix_ptr_old, int n_user_new);
//int mix_sort(void);
struct pe_data *pe_data_alloc(void);
public:
struct pe_data *pe_data_dup(struct pe_data *pe_ptr_old);
@ -1350,12 +1352,12 @@ protected:
* Temperatures
* ---------------------------------------------------------------------- */
std::map<int, cxxTemperature> Reaction_temperature_map;
std::map<int, cxxTemperature> Rxn_temperature_map;
/* ----------------------------------------------------------------------
* Pressures
* ---------------------------------------------------------------------- */
std::map<int, cxxPressure> Reaction_pressure_map;
std::map<int, cxxPressure> Rxn_pressure_map;
/* ----------------------------------------------------------------------
* Surface
@ -1428,10 +1430,13 @@ protected:
/*----------------------------------------------------------------------
* Mix
*---------------------------------------------------------------------- */
std::map<int, cxxMix> Rxn_mix_map;
std::map<int, cxxMix> Dispersion_mix_map;
//std::map<int, cxxMix> Stagnant_mix_map;
struct mix *mix;
struct mix *dbg_mix;
int count_mix;
//struct mix *mix;
//struct mix *dbg_mix;
//int count_mix;
/*----------------------------------------------------------------------
* Irreversible reaction
*---------------------------------------------------------------------- */

View File

@ -792,7 +792,7 @@ read_reaction_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#ifdef SKIP
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_mix_raw(void)
@ -888,6 +888,7 @@ read_mix_raw(void)
if (return_value == KEYWORD) echo_msg(sformatf( "\t%s\n", line));
return (return_value);
}
#endif
/* ---------------------------------------------------------------------- */
int Phreeqc::
read_dump(void)
@ -2058,6 +2059,22 @@ delete_entities(void)
}
}
// mixes
if (delete_info.Get_mix().Get_defined())
{
if (delete_info.Get_mix().Get_numbers().size() == 0)
{
Rxn_mix_map.clear();
}
else
{
std::set < int >::iterator it;
for (it = delete_info.Get_mix().Get_numbers().begin(); it != delete_info.Get_mix().Get_numbers().end(); it++)
{
Rxn_mix_map.erase(*it);
}
}
}
#ifdef SKIP
if (delete_info.Get_mix().Get_defined())
{
if (delete_info.Get_mix().Get_numbers().size() == 0)
@ -2079,6 +2096,7 @@ delete_entities(void)
}
}
}
#endif
// reactions
if (delete_info.Get_reaction().Get_defined())
{
@ -2106,14 +2124,14 @@ delete_entities(void)
{
if (delete_info.Get_temperature().Get_numbers().size() == 0)
{
Reaction_temperature_map.clear();
Rxn_temperature_map.clear();
}
else
{
std::set < int >::iterator it;
for (it = delete_info.Get_temperature().Get_numbers().begin(); it != delete_info.Get_temperature().Get_numbers().end(); it++)
{
Reaction_temperature_map.erase(*it);
Rxn_temperature_map.erase(*it);
}
}
}
@ -2122,14 +2140,14 @@ delete_entities(void)
{
if (delete_info.Get_pressure().Get_numbers().size() == 0)
{
Reaction_pressure_map.clear();
Rxn_pressure_map.clear();
}
else
{
std::set < int >::iterator it;
for (it = delete_info.Get_pressure().Get_numbers().begin(); it != delete_info.Get_pressure().Get_numbers().end(); it++)
{
Reaction_pressure_map.erase(*it);
Rxn_pressure_map.erase(*it);
}
}
}
@ -2545,6 +2563,27 @@ dump_ostream(std::ostream& os)
}
// mix
if (dump_info.Get_bool_mix())
{
if (dump_info.Get_mix().size() == 0)
{
Utilities::Rxn_dump_raw(Rxn_mix_map, os, 0);
}
else
{
std::set < int >::iterator it;
for (it = dump_info.Get_mix().begin(); it != dump_info.Get_mix().end(); it++)
{
cxxMix *p = Utilities::Rxn_find(Rxn_mix_map, *it);
if (p != NULL)
{
p->dump_raw(os, 0);
}
}
}
}
#ifdef SKIP
if (dump_info.Get_bool_mix())
{
if (dump_info.Get_mix().size() == 0)
@ -2569,7 +2608,7 @@ dump_ostream(std::ostream& os)
}
}
}
#endif
// reaction
if (dump_info.Get_bool_reaction())
{
@ -2601,14 +2640,14 @@ dump_ostream(std::ostream& os)
{
if (dump_info.Get_temperature().size() == 0)
{
Utilities::Reactant_dump_map_raw(Reaction_temperature_map, os, 0);
Utilities::Rxn_dump_raw(Rxn_temperature_map, os, 0);
}
else
{
std::set < int >::iterator it;
for (it = dump_info.Get_temperature().begin(); it != dump_info.Get_temperature().end(); it++)
{
cxxTemperature *p = Utilities::Reactant_find(Reaction_temperature_map, *it);
cxxTemperature *p = Utilities::Rxn_find(Rxn_temperature_map, *it);
if (p != NULL)
{
@ -2622,14 +2661,14 @@ dump_ostream(std::ostream& os)
{
if (dump_info.Get_pressure().size() == 0)
{
Utilities::Reactant_dump_map_raw(Reaction_pressure_map, os, 0);
Utilities::Rxn_dump_raw(Rxn_pressure_map, os, 0);
}
else
{
std::set < int >::iterator it;
for (it = dump_info.Get_pressure().begin(); it != dump_info.Get_pressure().end(); it++)
{
cxxPressure *p = Utilities::Reactant_find(Reaction_pressure_map, *it);
cxxPressure *p = Utilities::Rxn_find(Rxn_pressure_map, *it);
if (p != NULL)
{

View File

@ -286,7 +286,7 @@ cxxStorageBin::Remove_Temperature(int n_user)
cxxPressure *
cxxStorageBin::Get_Pressure(int n_user)
{
return Utilities::Reactant_find(this->Pressures, n_user);
return Utilities::Rxn_find(this->Pressures, n_user);
}
void
@ -403,34 +403,34 @@ cxxStorageBin::dump_raw(std::ostream & s_oss, unsigned int indent) const
s_oss.precision(DBL_DIG - 1);
// Solutions
Utilities::Reactant_dump_map_raw(Solutions, s_oss, indent);
Utilities::Rxn_dump_raw(Solutions, s_oss, indent);
// Exchange
Utilities::Reactant_dump_map_raw(Exchangers, s_oss, indent);
Utilities::Rxn_dump_raw(Exchangers, s_oss, indent);
// Gas Phases
Utilities::Reactant_dump_map_raw(GasPhases, s_oss, indent);
Utilities::Rxn_dump_raw(GasPhases, s_oss, indent);
// Kinetics
Utilities::Reactant_dump_map_raw(Kinetics, s_oss, indent);
Utilities::Rxn_dump_raw(Kinetics, s_oss, indent);
// PPassemblage
Utilities::Reactant_dump_map_raw(PPassemblages, s_oss, indent);
Utilities::Rxn_dump_raw(PPassemblages, s_oss, indent);
// SSassemblage
Utilities::Reactant_dump_map_raw(SSassemblages, s_oss, indent);
Utilities::Rxn_dump_raw(SSassemblages, s_oss, indent);
// Surface
Utilities::Reactant_dump_map_raw(Surfaces, s_oss, indent);
Utilities::Rxn_dump_raw(Surfaces, s_oss, indent);
// Mix
Utilities::Reactant_dump_map_raw(Mixes, s_oss, indent);
Utilities::Rxn_dump_raw(Mixes, s_oss, indent);
// Reactions
Utilities::Reactant_dump_map_raw(Reactions, s_oss, indent);
Utilities::Rxn_dump_raw(Reactions, s_oss, indent);
// Temperature
Utilities::Reactant_dump_map_raw(Temperatures, s_oss, indent);
Utilities::Rxn_dump_raw(Temperatures, s_oss, indent);
}
void
@ -1525,7 +1525,7 @@ cxxStorageBin::Set_System(struct Use *use_ptr)
// reaction pressure
if (use_ptr->pressure_ptr != NULL)
{
cxxPressure * p = Utilities::Reactant_find(this->Pressures, use_ptr->n_pressure_user);
cxxPressure * p = Utilities::Rxn_find(this->Pressures, use_ptr->n_pressure_user);
if (p != NULL)
{
this->system.Set_Pressure(p);
@ -1622,6 +1622,6 @@ cxxStorageBin::Set_System(int i)
// reaction pressure
{
this->system.Set_Pressure(Utilities::Reactant_find(this->Pressures, i));
this->system.Set_Pressure(Utilities::Rxn_find(this->Pressures, i));
}
}

View File

@ -36,7 +36,7 @@ namespace Utilities
// operations on maps of entities (Solution, Exchange, ...)
template < typename T >
void Reactant_dump_map_raw(const T & b, std::ostream & s_oss, unsigned int indent)
void Rxn_dump_raw(const T & b, std::ostream & s_oss, unsigned int indent)
{
//std :: map < int, T > :: const_iterator it;
typename T::const_iterator it;
@ -52,7 +52,7 @@ namespace Utilities
//}
template < typename T >
T * Reactant_find(std::map < int, T > &b, int i)
T * Rxn_find(std::map < int, T > &b, int i)
{
if (b.find(i) != b.end())
{
@ -65,7 +65,7 @@ namespace Utilities
}
template < typename T >
T * Reactant_copy(std::map < int, T > &b, int i, int j)
T * Rxn_copy(std::map < int, T > &b, int i, int j)
{
typename std::map < int, T >::iterator it;
it = b.find(i);

View File

@ -26,7 +26,7 @@ cxxMix::cxxMix(PHRQ_io *io)
: cxxNumKeyword(io)
{
}
#ifdef SKIP
cxxMix::cxxMix(struct mix *mix_ptr, PHRQ_io *io)
//
// constructor for cxxMix from struct mix
@ -49,7 +49,7 @@ cxxNumKeyword(io)
}
}
}
#endif
cxxMix::~cxxMix()
{
}
@ -200,3 +200,14 @@ cxxMix::read_raw(CParser & parser)
}
// members that must be defined
}
void cxxMix::Vectorize(std::vector<int> &n, std::vector<LDBLE> &f)
{
n.clear();
f.clear();
for (std::map < int, double >::const_iterator it = this->mixComps.begin();
it != this->mixComps.end(); it++)
{
n.push_back(it->first);
f.push_back(it->second);
}
}

View File

@ -8,13 +8,14 @@
#include <vector> // std::vector
#include "NumKeyword.h"
#include "PHRQ_base.h"
#include "phrqtype.h"
class cxxMix:public cxxNumKeyword
{
public:
cxxMix(PHRQ_io *io=NULL);
cxxMix(struct mix *, PHRQ_io *io=NULL);
//cxxMix(struct mix *, PHRQ_io *io=NULL);
~cxxMix();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
@ -23,7 +24,7 @@ class cxxMix:public cxxNumKeyword
void read_raw(CParser & parser);
void add(int n, double f)
void Add(int n, LDBLE f)
{
if (this->mixComps.find(n) != this->mixComps.end())
{
@ -34,23 +35,23 @@ class cxxMix:public cxxNumKeyword
mixComps[n] = f;
}
};
void multiply(double f)
void Multiply(LDBLE f)
{
for (std::map < int, double >::iterator it = this->mixComps.begin();
for (std::map < int, LDBLE >::iterator it = this->mixComps.begin();
it != this->mixComps.end(); it++)
{
it->second *= f;
}
};
const std::map < int, double > & Get_mixComps() const
const std::map < int, LDBLE > & Get_mixComps() const
{
return mixComps;
}
void Vectorize(std::vector<int> &n, std::vector<LDBLE> &f);
protected:
friend class cxxStorageBin;
std::map < int, double >mixComps;
std::map < int, LDBLE >mixComps;
};