Finished PPassemblage and Reaction P_INSTANCE removal.

Removed some commented PHREEQC_PTR_ARG from headers.

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5652 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2011-09-27 19:59:49 +00:00
parent 2dab6f8ed8
commit 02ab5c208c
19 changed files with 85 additions and 100 deletions

View File

@ -16,7 +16,6 @@ class cxxExchange:public cxxNumKeyword
public:
cxxExchange(PHRQ_io *io=NULL);
//cxxExchange(PHREEQC_PTR_ARG_COMMA int n_user, PHRQ_io *io=NULL);
cxxExchange(struct exchange *, PHRQ_io *io=NULL);
cxxExchange(const std::map < int, cxxExchange > &exchange_map,
cxxMix & mx, int n_user, PHRQ_io *io=NULL);

View File

@ -27,10 +27,6 @@ class cxxGasPhase:public cxxNumKeyword
GP_VOLUME = 1
};
// struct gas_phase *cxxGasPhase2gas_phase(PHREEQC_PTR_ARG);
// struct gas_comp *cxxGasPhaseComp2gas_comp(PHREEQC_PTR_ARG);
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream & s_oss, unsigned int indent) const;

View File

@ -40,6 +40,7 @@ units("mMol/kgw")
pes = NULL;
}
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
cxxISolution::cxxISolution(PHREEQC_PTR_ARG_COMMA struct solution *solution_ptr, PHRQ_io *io)
:
cxxSolution(solution_ptr, io)
@ -58,12 +59,14 @@ cxxSolution(solution_ptr, io)
// pe_data
pes = P_INSTANCE_POINTER pe_data_dup(solution_ptr->pe);
}
#endif
cxxISolution::~cxxISolution()
{
//// ToDo //pe_data_free(this->pes);
}
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
struct solution *
cxxISolution::cxxISolution2solution(PHREEQC_PTR_ARG)
//
@ -86,7 +89,9 @@ cxxISolution::cxxISolution2solution(PHREEQC_PTR_ARG)
soln_ptr->totals = cxxISolutionComp::cxxISolutionComp2conc(P_INSTANCE_COMMA this->comps);
return (soln_ptr);
}
#endif
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
void
cxxISolution::ConvertUnits(PHREEQC_PTR_ARG)
//
@ -177,6 +182,7 @@ cxxISolution::ConvertUnits(PHREEQC_PTR_ARG)
iter->second.set_moles(iter->second.get_moles() * l_mass_water);
}
}
#endif
#ifdef SKIP
cxxISolution & cxxISolution::read(CParser & parser)

View File

@ -20,16 +20,10 @@ class cxxISolution:public cxxSolution
public:
cxxISolution(PHRQ_io *io=NULL);
cxxISolution(PHREEQC_PTR_ARG_COMMA struct solution *, PHRQ_io *io=NULL);
//cxxISolution(const cxxISolution&);
~cxxISolution();
//static cxxISolution& read(CParser& parser);
//void add(cxxISolutionComp conc) { this->concs.push_back(conc); }
struct solution *cxxISolution2solution(PHREEQC_PTR_ARG);
double get_density() const
{
return this->density;
@ -56,30 +50,13 @@ class cxxISolution:public cxxSolution
}
//char * get_redox()const {return this->pe[this->default_pe].get_name();}
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void ConvertUnits(PHREEQC_PTR_ARG);
#ifdef ORCHESTRA
void ORCH_write(std::ostream & chemistry_dat, std::ostream & input_dat,
std::ostream & output_dat);
void ORCH_write_chemistry(std::ostream & chemistry_dat);
void ORCH_write_input(std::ostream & input_dat);
void ORCH_write_output_vars(std::ostream & input_dat);
private:
void ORCH_write_chemistry_water(std::ostream & chemistry_dat);
void ORCH_write_chemistry_primary(std::ostream & chemistry_dat);
void ORCH_write_chemistry_total_O_H(std::ostream & chemistry_dat);
void ORCH_write_chemistry_alkalinity(std::ostream & chemistry_dat);
void ORCH_write_chemistry_minerals(std::ostream & chemistry_dat);
#endif
//void ConvertUnits(PHREEQC_PTR_ARG);
protected:
friend class cxxISolutionComp; // for this->pe access
double density;
std::string units;
//std::map < char *, cxxISolutionComp, CHARSTAR_LESS > comps;
std::map < std::string, cxxISolutionComp > comps;
struct pe_data *pes;
int default_pe;

View File

@ -76,6 +76,8 @@ struct conc *cxxISolutionComp::concarray(std::map <char *, double, CHARSTAR_LESS
return(c);
}
*/
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
struct conc *
cxxISolutionComp::cxxISolutionComp2conc(PHREEQC_PTR_ARG_COMMA const std::map < std::string,
cxxISolutionComp > &totals)
@ -114,7 +116,9 @@ cxxISolutionComp::cxxISolutionComp2conc(PHREEQC_PTR_ARG_COMMA const std::map < s
c[i].description = NULL;
return (c);
}
#endif
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
void
cxxISolutionComp::set_gfw(PHREEQC_PTR_ARG)
{
@ -158,6 +162,7 @@ cxxISolutionComp::set_gfw(PHREEQC_PTR_ARG)
//P_INSTANCE_POINTER input_error++;
return;
}
#endif
#ifdef SKIP

View File

@ -117,15 +117,13 @@ class cxxISolutionComp: public PHRQ_base
{
this->gfw = l_gfw;
}
void set_gfw(PHREEQC_PTR_ARG);
//void set_gfw(PHREEQC_PTR_ARG);
bool operator<(const cxxISolutionComp & conc) const
{
return ::strcmp(this->description.c_str(), conc.description.c_str()) < 0;
}
static struct conc *cxxISolutionComp2conc(PHREEQC_PTR_ARG_COMMA const std::map < std::string, cxxISolutionComp > &t);
private:
std::string description;
double moles;

View File

@ -17,8 +17,6 @@ public:
cxxKineticsComp(struct kinetics_comp *, PHRQ_io *io=NULL);
~cxxKineticsComp();
//static struct kinetics_comp *cxxKineticsComp2kinetics_comp(PHREEQC_PTR_ARG_COMMA std::list < cxxKineticsComp > &el);
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream & s_oss, unsigned int indent) const;

View File

@ -49,11 +49,12 @@ eltList(pp_assemblage_ptr->next_elt)
{
cxxPPassemblageComp ppComp(&(pp_assemblage_ptr->pure_phases[i]), this->Get_io());
//ppAssemblageComps.push_back(ppComp);
std::string str(ppComp.get_name());
std::string str(ppComp.Get_name());
this->ppAssemblageComps[str] = ppComp;
}
}
cxxPPassemblage::cxxPPassemblage(PHREEQC_PTR_ARG_COMMA const std::map < int,
cxxPPassemblage::cxxPPassemblage(const std::map < int,
cxxPPassemblage > &entities, cxxMix & mix,
int l_n_user, PHRQ_io * io):
cxxNumKeyword(io)
@ -71,7 +72,7 @@ cxxNumKeyword(io)
{
const cxxPPassemblage *entity_ptr =
&(entities.find(it->first)->second);
this->add(P_INSTANCE_COMMA *entity_ptr, it->second);
this->add(*entity_ptr, it->second);
}
}
}
@ -80,6 +81,7 @@ cxxPPassemblage::~cxxPPassemblage()
{
}
#ifdef MOVE_TO_STRUCTURES
struct pp_assemblage *
cxxPPassemblage::cxxPPassemblage2pp_assemblage(PHREEQC_PTR_ARG)
//
@ -100,7 +102,7 @@ cxxPPassemblage::cxxPPassemblage2pp_assemblage(PHREEQC_PTR_ARG)
pp_assemblage_ptr->next_elt = this->eltList.elt_list(P_INSTANCE);
return (pp_assemblage_ptr);
}
#endif
void
cxxPPassemblage::dump_xml(std::ostream & s_oss, unsigned int indent) const
{
@ -271,16 +273,16 @@ cxxPPassemblage::read_raw(CParser & parser, bool check)
CParser reread(is, this->Get_io());
reread.set_echo_file(CParser::EO_NONE);
reread.set_echo_stream(CParser::EO_NONE);
if (this->ppAssemblageComps.find(ec.get_name()) != this->ppAssemblageComps.end())
if (this->ppAssemblageComps.find(ec.Get_name()) != this->ppAssemblageComps.end())
{
cxxPPassemblageComp & comp = this->ppAssemblageComps.find(ec.get_name())->second;
cxxPPassemblageComp & comp = this->ppAssemblageComps.find(ec.Get_name())->second;
comp.read_raw(reread, false);
}
else
{
cxxPPassemblageComp ppComp1(this->Get_io());
ppComp1.read_raw(reread, false);
std::string str(ppComp1.get_name());
std::string str(ppComp1.Get_name());
this->ppAssemblageComps[str] = ppComp1;
}
}
@ -348,13 +350,13 @@ cxxPPassemblage::totalize(PHREEQC_PTR_ARG)
ppAssemblageComps.begin(); it != ppAssemblageComps.end(); ++it)
{
(*it).second.totalize(P_INSTANCE);
this->totals.add_extensive((*it).second.get_totals(), 1.0);
this->totals.add_extensive((*it).second.Get_totals(), 1.0);
}
return;
}
void
cxxPPassemblage::add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblage & addee, double extensive)
cxxPPassemblage::add(const cxxPPassemblage & addee, double extensive)
//
// Add to existing ppassemblage to "this" ppassemblage
//
@ -370,7 +372,7 @@ cxxPPassemblage::add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblage & addee, double
this->ppAssemblageComps.begin();
it != this->ppAssemblageComps.end(); ++it)
{
if ((*it).second.get_name() == itadd->second.get_name())
if ((*it).second.Get_name() == itadd->second.Get_name())
{
(*it).second.add((*itadd).second, extensive);
found = true;
@ -381,7 +383,7 @@ cxxPPassemblage::add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblage & addee, double
{
cxxPPassemblageComp entity = (*itadd).second;
entity.multiply(extensive);
std::string str(entity.get_name());
std::string str(entity.Get_name());
this->ppAssemblageComps[str] = entity;
}
}

View File

@ -17,27 +17,23 @@ class cxxPPassemblage:public cxxNumKeyword
public:
cxxPPassemblage(PHRQ_io * io=NULL);
cxxPPassemblage(struct pp_assemblage *, PHRQ_io * io=NULL);
cxxPPassemblage(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxPPassemblage > &entity_map,
cxxPPassemblage(const std::map < int, cxxPPassemblage > &entity_map,
cxxMix & mx, int n_user, PHRQ_io * io=NULL);
~cxxPPassemblage();
struct pp_assemblage *cxxPPassemblage2pp_assemblage(PHREEQC_PTR_ARG);
struct pure_phase *cxxPPassemblageComp2pure_phase();
~cxxPPassemblage();
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser & parser, bool check = true);
const cxxNameDouble & get_totals() const
const cxxNameDouble & Get_totals() const
{
return this->totals;
};
const cxxNameDouble & get_eltList() const
const cxxNameDouble & Get_eltList() const
{
return this->eltList;
};
std::map <std::string, cxxPPassemblageComp > & get_ppAssemblageComps()
const std::map <std::string, cxxPPassemblageComp > & Get_ppAssemblageComps() const
{
return this->ppAssemblageComps;
};
@ -58,7 +54,7 @@ class cxxPPassemblage:public cxxNumKeyword
#endif
private:
void add(PHREEQC_PTR_ARG_COMMA const cxxPPassemblage & addee, double extensive);
void add(const cxxPPassemblage & addee, double extensive);
// not written
void dump_xml(std::ostream & os, unsigned int indent = 0) const;

View File

@ -48,8 +48,8 @@ PHRQ_base(io)
// constructor for cxxPPassemblageComp from struct pure_phase
//
{
this->set_name(pure_phase_ptr->name);
this->set_add_formula(pure_phase_ptr->add_formula);
this->Set_name(pure_phase_ptr->name);
this->Set_add_formula(pure_phase_ptr->add_formula);
si = pure_phase_ptr->si;
moles = pure_phase_ptr->moles;
delta = pure_phase_ptr->delta;
@ -63,13 +63,7 @@ cxxPPassemblageComp::~cxxPPassemblageComp()
{
}
struct phase *
cxxPPassemblageComp::get_phase(PHREEQC_PTR_ARG)
{
int i;
return P_INSTANCE_POINTER phase_bsearch(this->name.c_str(), &i, FALSE);
}
#ifdef MOVE_TO_STRUCTURES
struct pure_phase *
cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxPPassemblageComp > &el)
//
@ -106,7 +100,7 @@ cxxPPassemblageComp::cxxPPassemblageComp2pure_phase(PHREEQC_PTR_ARG_COMMA std::m
}
return (pure_phase_ptr);
}
#endif
void
cxxPPassemblageComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
{

View File

@ -17,44 +17,45 @@ class cxxPPassemblageComp: public PHRQ_base
cxxPPassemblageComp(struct pure_phase *, PHRQ_io *io=NULL);
~cxxPPassemblageComp();
static struct pure_phase *cxxPPassemblageComp2pure_phase(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxPPassemblageComp > &el);
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser & parser, bool check = true);
const std::string &get_name() const
const std::string &Get_name() const
{
return this->name;
}
void set_name(char * s)
void Set_name(char * s)
{
if(s != NULL)
this->name = std::string(s);
else
this->name.clear();
}
const std::string &get_add_formula() const
const std::string &Get_add_formula() const
{
return this->add_formula;
}
void set_add_formula(char * s)
void Set_add_formula(char * s)
{
if(s != NULL)
this->add_formula = std::string(s);
else
this->add_formula.clear();
}
struct phase *get_phase(PHREEQC_PTR_ARG);
void totalize(PHREEQC_PTR_ARG);
const cxxNameDouble & get_totals() const
const cxxNameDouble & Get_totals() const
{
return (this->totals);
};
double Get_si() const {return this->si;};
double Get_moles() const {return this->moles;};
double Get_delta() const {return this->delta;};
double Get_initial_moles() const {return this->initial_moles;};
bool Get_force_equality() const {return this->force_equality;};
bool Get_dissolve_only() const {return this->dissolve_only;};
bool Get_precipitate_only() const {return this->precipitate_only;};
void add(const cxxPPassemblageComp & comp, double extensive);
void multiply(double extensive);

View File

@ -464,7 +464,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
{
reaction_calc(&irrev[i]);
cxxReaction entity(&irrev[i]);
accumulator.add_extensive(entity.get_elementList(), 1.0);
accumulator.add_extensive(entity.Get_elementList(), 1.0);
}
// pure phases
@ -472,7 +472,7 @@ size_t Phreeqc::list_components(std::list<std::string> &list_c)
{
cxxPPassemblage entity(&pp_assemblage[i], &phrq_io);
entity.totalize(this);
accumulator.add_extensive(entity.get_totals(), 1.0);
accumulator.add_extensive(entity.Get_totals(), 1.0);
}
// exchangers

View File

@ -43,6 +43,9 @@ class cxxExchange;
class cxxExchComp;
class cxxGasPhase;
class cxxTemperature;
class cxxPPassemblage;
class cxxPPassemblageComp;
class cxxReaction;
class Phreeqc
{
@ -1250,6 +1253,10 @@ struct master * Get_exch_master(const cxxExchComp * ec);
struct gas_phase * cxxGasPhase2gas_phase(const cxxGasPhase * gp);
struct gas_comp * cxxGasPhaseComp2gas_comp(const cxxGasPhase * gp);
struct temperature * cxxTemperature2temperature(const cxxTemperature *temp);
struct pp_assemblage * cxxPPassemblage2pp_assemblage(const cxxPPassemblage * pp);
struct pure_phase * cxxPPassemblageComp2pure_phase(const std::map < std::string, cxxPPassemblageComp > * ppc);
struct irrev * cxxReaction2irrev(const cxxReaction * rxn);
/* tally.c */
void add_all_components_tally(void);

View File

@ -28,7 +28,7 @@ cxxReaction::cxxReaction(PHRQ_io *io)
//
: cxxNumKeyword(io)
{
this->set_units("Mol");
this->Set_units("Mol");
countSteps = 0;
equalIncrements = false;
reactantList.type = cxxNameDouble::ND_NAME_COEF;
@ -48,7 +48,7 @@ elementList(irrev_ptr->elts)
this->set_description(irrev_ptr->description);
this->n_user = irrev_ptr->n_user;
this->n_user_end = irrev_ptr->n_user_end;
this->set_units(irrev_ptr->units);
this->Set_units(irrev_ptr->units);
// steps
if (irrev_ptr->count_steps < 0)
{
@ -74,7 +74,7 @@ cxxReaction::~cxxReaction()
{
}
#ifdef MOVE_TO_STRUCTURES
struct irrev *
cxxReaction::cxxReaction2irrev(PHREEQC_PTR_ARG)
//
@ -126,6 +126,7 @@ cxxReaction::cxxReaction2irrev(PHREEQC_PTR_ARG)
irrev_ptr->units = P_INSTANCE_POINTER string_hsave(this->units.c_str());
return (irrev_ptr);
}
#endif
#ifdef SKIP
void
@ -291,7 +292,7 @@ cxxReaction::read_raw(CParser & parser, const bool check)
j = parser.copy_token(token, next_char);
if (j == CParser::TT_EMPTY)
break;
this->set_units(token.c_str());
this->Set_units(token.c_str());
opt_save = CParser::OPT_DEFAULT;
useLastLine = false;
units_defined = true;

View File

@ -18,19 +18,19 @@ class cxxReaction:public cxxNumKeyword
cxxReaction(struct irrev *, PHRQ_io *io = NULL);
~cxxReaction();
struct irrev *cxxReaction2irrev(PHREEQC_PTR_ARG);
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser & parser, bool check);
cxxNameDouble &get_elementList(void)
{
return this->elementList;
}
const cxxNameDouble &Get_elementList(void) const {return this->elementList;};
const cxxNameDouble &Get_reactantList(void) const {return this->reactantList;};
const std::vector < double > &Get_steps(void) const {return this->steps;};
int Get_countSteps(void) const {return this->countSteps;};
bool Get_equalIncrements(void) const {return this->equalIncrements;};
const std::string &Get_units(void) const {return this->units;};
void set_units(const char * s)
void Set_units(const char * s)
{
if (s != NULL)
this->units = std::string(s);

View File

@ -394,7 +394,8 @@ read_equilibrium_phases_raw(void)
cxxPPassemblage ex(&phrq_io);
ex.read_raw(parser);
struct pp_assemblage *pp_assemblage_ptr = ex.cxxPPassemblage2pp_assemblage(PHREEQC_THIS);
//struct pp_assemblage *pp_assemblage_ptr = ex.cxxPPassemblage2pp_assemblage(PHREEQC_THIS);
struct pp_assemblage *pp_assemblage_ptr = cxxPPassemblage2pp_assemblage(&ex);
int n;
/*
@ -778,7 +779,8 @@ read_reaction_raw(void)
cxxReaction ex;
ex.read_raw(parser, true);
struct irrev *irrev_ptr = ex.cxxReaction2irrev(PHREEQC_THIS);
//struct irrev *irrev_ptr = ex.cxxReaction2irrev(PHREEQC_THIS);
struct irrev *irrev_ptr = cxxReaction2irrev(&ex);
int n;
/*
@ -1426,7 +1428,8 @@ read_equilibrium_phases_modify(void)
entity.read_raw(parser, false);
// save entity
struct pp_assemblage *entity_ptr = entity.cxxPPassemblage2pp_assemblage(PHREEQC_THIS);
//struct pp_assemblage *entity_ptr = entity.cxxPPassemblage2pp_assemblage(PHREEQC_THIS);
struct pp_assemblage *entity_ptr = cxxPPassemblage2pp_assemblage(&entity);
pp_assemblage_free(&(pp_assemblage[n]));
pp_assemblage_copy(entity_ptr, &(pp_assemblage[n]), entity_ptr->n_user);
free_check_null(pp_assemblage[n].description);
@ -1982,7 +1985,8 @@ read_reaction_modify(void)
cxxReaction entity(&(irrev[n]));
entity.read_raw(parser, false);
// save entity
struct irrev *entity_ptr = entity.cxxReaction2irrev(PHREEQC_THIS);
//struct irrev *entity_ptr = entity.cxxReaction2irrev(PHREEQC_THIS);
struct irrev *entity_ptr = cxxReaction2irrev(&entity);
irrev_free(&(irrev[n]));
irrev_copy(entity_ptr, &(irrev[n]), entity_ptr->n_user);
free_check_null(irrev[n].description);

View File

@ -1065,8 +1065,9 @@ cxxStorageBin::cxxStorageBin2phreeqc(PHREEQC_PTR_ARG_COMMA int n)
this->PPassemblages.find(n);
if (it != this->PPassemblages.end())
{
struct pp_assemblage *pp_assemblage_ptr =
(it->second).cxxPPassemblage2pp_assemblage(P_INSTANCE);
//struct pp_assemblage *pp_assemblage_ptr =
// (it->second).cxxPPassemblage2pp_assemblage(P_INSTANCE);
struct pp_assemblage *pp_assemblage_ptr = P_INSTANCE_POINTER cxxPPassemblage2pp_assemblage(&(it->second));
P_INSTANCE_POINTER pp_assemblage_copy(pp_assemblage_ptr, &P_INSTANCE_POINTER pp_assemblage[0], n);
P_INSTANCE_POINTER count_pp_assemblage++;
P_INSTANCE_POINTER pp_assemblage_free(pp_assemblage_ptr);
@ -1299,8 +1300,10 @@ cxxStorageBin::cxxStorageBin2system(PHREEQC_PTR_ARG_COMMA int n)
// PPassemblages
if (this->getPPassemblage(n) != NULL)
{
//system_ptr->pp_assemblage =
// (this->getPPassemblage(n))->cxxPPassemblage2pp_assemblage(P_INSTANCE);
system_ptr->pp_assemblage =
(this->getPPassemblage(n))->cxxPPassemblage2pp_assemblage(P_INSTANCE);
P_INSTANCE_POINTER cxxPPassemblage2pp_assemblage(this->getPPassemblage(n));
}
else
{

View File

@ -79,7 +79,7 @@ cxxSystem::totalize(PHREEQC_PTR_ARG)
if (this->ppassemblage != NULL)
{
this->ppassemblage->totalize(P_INSTANCE);
this->totals.add_extensive(this->ppassemblage->get_totals(), 1.0);
this->totals.add_extensive(this->ppassemblage->Get_totals(), 1.0);
}
if (this->gasphase != NULL)
{

View File

@ -18,8 +18,6 @@ class cxxTemperature:public cxxNumKeyword
cxxTemperature(struct temperature *, PHRQ_io *io=NULL);
~cxxTemperature();
//struct temperature *cxxTemperature2temperature(PHREEQC_PTR_ARG);
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream & s_oss, unsigned int indent) const;