mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-16 16:44:49 +01:00
Finished with Exchange removing all P_INSTANCE I think.
git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@5650 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
7c9913195a
commit
06f4e08ecf
@ -52,15 +52,15 @@ cxxExchComp::cxxExchComp(struct exch_comp * exch_comp_ptr, PHRQ_io *io)
|
||||
PHRQ_base(io),
|
||||
formula_totals(exch_comp_ptr->formula_totals), totals(exch_comp_ptr->totals)
|
||||
{
|
||||
this->set_formula(exch_comp_ptr->formula);
|
||||
this->Set_formula(exch_comp_ptr->formula);
|
||||
moles = exch_comp_ptr->moles;
|
||||
// totals in constructor
|
||||
//formula_totals in constructor
|
||||
la = exch_comp_ptr->la;
|
||||
charge_balance = exch_comp_ptr->charge_balance;
|
||||
this->set_phase_name(exch_comp_ptr->phase_name);
|
||||
this->Set_phase_name(exch_comp_ptr->phase_name);
|
||||
phase_proportion = exch_comp_ptr->phase_proportion;
|
||||
this->set_rate_name(exch_comp_ptr->rate_name);
|
||||
this->Set_rate_name(exch_comp_ptr->rate_name);
|
||||
formula_z = exch_comp_ptr->formula_z;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ cxxExchComp::cxxExchComp(std::vector < cxxExchComp > &ec_vector,
|
||||
cxxExchComp::~cxxExchComp()
|
||||
{
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct master *
|
||||
cxxExchComp::get_master(PHREEQC_PTR_ARG)
|
||||
{
|
||||
@ -238,6 +238,7 @@ struct exch_comp *
|
||||
}
|
||||
return (exch_comp_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxExchComp::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
|
||||
56
ExchComp.h
56
ExchComp.h
@ -17,10 +17,10 @@ class cxxExchComp: public PHRQ_base
|
||||
cxxExchComp(struct exch_comp *, PHRQ_io *io=NULL);
|
||||
~cxxExchComp();
|
||||
|
||||
struct master *get_master(PHREEQC_PTR_ARG);
|
||||
//struct master *Get_master(PHREEQC_PTR_ARG);
|
||||
|
||||
static struct exch_comp *cxxExchComp2exch_comp(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxExchComp >
|
||||
&el);
|
||||
//static struct exch_comp *cxxExchComp2exch_comp(PHREEQC_PTR_ARG_COMMA std::map < std::string, cxxExchComp >
|
||||
// &el);
|
||||
|
||||
void dump_xml(std::ostream & os, unsigned int indent = 0) const;
|
||||
|
||||
@ -28,108 +28,106 @@ class cxxExchComp: public PHRQ_base
|
||||
|
||||
void read_raw(CParser & parser, bool check=true);
|
||||
|
||||
const std::string &get_formula() const
|
||||
const std::string &Get_formula() const
|
||||
{
|
||||
return this->formula;
|
||||
}
|
||||
void set_formula(char *cstring)
|
||||
void Set_formula(char *cstring)
|
||||
{
|
||||
if (cstring != NULL)
|
||||
this->formula = std::string(cstring);
|
||||
else
|
||||
this->formula.clear();
|
||||
}
|
||||
double get_moles() const
|
||||
double Get_moles() const
|
||||
{
|
||||
return this->moles;
|
||||
}
|
||||
void set_moles(double d)
|
||||
void Set_moles(double d)
|
||||
{
|
||||
this->moles = d;
|
||||
}
|
||||
double get_la() const
|
||||
double Get_la() const
|
||||
{
|
||||
return this->la;
|
||||
}
|
||||
void set_la(double d)
|
||||
void Set_la(double d)
|
||||
{
|
||||
this->la = d;
|
||||
}
|
||||
double get_charge_balance() const
|
||||
double Get_charge_balance() const
|
||||
{
|
||||
return this->charge_balance;
|
||||
}
|
||||
void set_charge_balance(double d)
|
||||
void Set_charge_balance(double d)
|
||||
{
|
||||
this->charge_balance = d;
|
||||
}
|
||||
const std::string &get_phase_name() const
|
||||
const std::string &Get_phase_name() const
|
||||
{
|
||||
return this->phase_name;
|
||||
}
|
||||
void set_phase_name(char *cstring)
|
||||
void Set_phase_name(char *cstring)
|
||||
{
|
||||
if (cstring != NULL)
|
||||
this->phase_name = std::string(cstring);
|
||||
else
|
||||
this->phase_name.clear();
|
||||
}
|
||||
double get_phase_proportion() const
|
||||
double Get_phase_proportion() const
|
||||
{
|
||||
return this->phase_proportion;
|
||||
}
|
||||
void set_phase_proportion(double d)
|
||||
void Set_phase_proportion(double d)
|
||||
{
|
||||
this->phase_proportion = d;
|
||||
}
|
||||
const std::string &get_rate_name() const
|
||||
const std::string &Get_rate_name() const
|
||||
{
|
||||
return this->rate_name;
|
||||
}
|
||||
void set_rate_name(char *cstring)
|
||||
void Set_rate_name(char *cstring)
|
||||
{
|
||||
if (cstring != NULL)
|
||||
this->rate_name = std::string(cstring);
|
||||
else
|
||||
this->rate_name.clear();
|
||||
}
|
||||
double get_formula_z() const
|
||||
double Get_formula_z() const
|
||||
{
|
||||
return this->formula_z;
|
||||
}
|
||||
void set_formula_z(double d)
|
||||
void Set_formula_z(double d)
|
||||
{
|
||||
this->formula_z = d;
|
||||
}
|
||||
void set_totals(struct elt_list *e_l, int count)
|
||||
void Set_totals(struct elt_list *e_l, int count)
|
||||
{
|
||||
this->totals = cxxNameDouble(e_l, count);
|
||||
}
|
||||
void set_totals(struct elt_list *e_l)
|
||||
void Set_totals(struct elt_list *e_l)
|
||||
{
|
||||
this->totals = cxxNameDouble(e_l);
|
||||
}
|
||||
void set_totals(cxxNameDouble nd)
|
||||
void Set_totals(cxxNameDouble nd)
|
||||
{
|
||||
this->totals = nd;
|
||||
}
|
||||
void set_formula_totals(struct elt_list *e_l, int count)
|
||||
void Set_formula_totals(struct elt_list *e_l, int count)
|
||||
{
|
||||
this->formula_totals = cxxNameDouble(e_l, count);
|
||||
}
|
||||
void set_formula_totals(struct elt_list *e_l)
|
||||
void Set_formula_totals(struct elt_list *e_l)
|
||||
{
|
||||
this->formula_totals = cxxNameDouble(e_l);
|
||||
}
|
||||
void set_formula_totals(cxxNameDouble nd)
|
||||
void Set_formula_totals(cxxNameDouble nd)
|
||||
{
|
||||
this->formula_totals = nd;
|
||||
}
|
||||
|
||||
const cxxNameDouble & get_totals() const
|
||||
{
|
||||
return (this->totals);
|
||||
};
|
||||
const cxxNameDouble & Get_totals() const {return (this->totals);};
|
||||
const cxxNameDouble & Get_formula_totals(void) const {return this->formula_totals;};
|
||||
|
||||
|
||||
void add(const cxxExchComp & comp, double extensive);
|
||||
|
||||
44
Exchange.cxx
44
Exchange.cxx
@ -50,7 +50,7 @@ cxxNumKeyword(io)
|
||||
for (i = 0; i < exchange_ptr->count_comps; i++)
|
||||
{
|
||||
cxxExchComp ec(&(exchange_ptr->comps[i]), this->Get_io());
|
||||
std::string str(ec.get_formula());
|
||||
std::string str(ec.Get_formula());
|
||||
exchComps[str] = ec;
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ cxxNumKeyword(io)
|
||||
|
||||
|
||||
}
|
||||
cxxExchange::cxxExchange(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxExchange > &entities,
|
||||
cxxExchange::cxxExchange(const std::map < int, cxxExchange > &entities,
|
||||
cxxMix & mix, int l_n_user, PHRQ_io *io):
|
||||
cxxNumKeyword(io)
|
||||
{
|
||||
@ -92,6 +92,7 @@ cxxNumKeyword(io)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SKIP_OR_MOVE_TO_STRUCTURES
|
||||
cxxExchange::cxxExchange(PHREEQC_PTR_ARG_COMMA int l_n_user, PHRQ_io *io)
|
||||
//
|
||||
// constructor for cxxExchange from reaction calculation
|
||||
@ -116,23 +117,23 @@ cxxNumKeyword(io)
|
||||
{
|
||||
cxxExchComp ec(this->Get_io());
|
||||
//char * formula;
|
||||
ec.set_formula(P_INSTANCE_POINTER x[i]->exch_comp->formula);
|
||||
ec.Set_formula(P_INSTANCE_POINTER x[i]->exch_comp->formula);
|
||||
//double moles;
|
||||
ec.set_moles(0.0);
|
||||
ec.Set_moles(0.0);
|
||||
//cxxNameDouble formula_totals;
|
||||
ec.set_formula_totals(P_INSTANCE_POINTER x[i]->exch_comp->formula_totals);
|
||||
ec.Set_formula_totals(P_INSTANCE_POINTER x[i]->exch_comp->formula_totals);
|
||||
//cxxNameDouble totals; see below
|
||||
//double la;
|
||||
ec.set_la(P_INSTANCE_POINTER x[i]->master[0]->s->la);
|
||||
ec.Set_la(P_INSTANCE_POINTER x[i]->master[0]->s->la);
|
||||
//double charge_balance; see below
|
||||
//char *phase_name;
|
||||
ec.set_phase_name(P_INSTANCE_POINTER x[i]->exch_comp->phase_name);
|
||||
ec.Set_phase_name(P_INSTANCE_POINTER x[i]->exch_comp->phase_name);
|
||||
//double phase_proportion;
|
||||
ec.set_phase_proportion(P_INSTANCE_POINTER x[i]->exch_comp->phase_proportion);
|
||||
ec.Set_phase_proportion(P_INSTANCE_POINTER x[i]->exch_comp->phase_proportion);
|
||||
//char *rate_name;
|
||||
ec.set_rate_name(P_INSTANCE_POINTER x[i]->exch_comp->rate_name);
|
||||
ec.Set_rate_name(P_INSTANCE_POINTER x[i]->exch_comp->rate_name);
|
||||
//double formula_z;
|
||||
ec.set_formula_z(P_INSTANCE_POINTER x[i]->exch_comp->formula_z);
|
||||
ec.Set_formula_z(P_INSTANCE_POINTER x[i]->exch_comp->formula_z);
|
||||
|
||||
// calculate charge and totals
|
||||
P_INSTANCE_POINTER count_elts = 0;
|
||||
@ -154,7 +155,7 @@ cxxNumKeyword(io)
|
||||
P_INSTANCE_POINTER add_elt_list(P_INSTANCE_POINTER x[i]->master[0]->s->next_elt, 1e-20);
|
||||
}
|
||||
//double charge_balance
|
||||
ec.set_charge_balance(charge);
|
||||
ec.Set_charge_balance(charge);
|
||||
//cxxNameDouble totals;
|
||||
if (P_INSTANCE_POINTER count_elts > 0)
|
||||
{
|
||||
@ -162,14 +163,15 @@ cxxNumKeyword(io)
|
||||
(size_t) sizeof(struct elt_list), P_INSTANCE_POINTER elt_list_compare);
|
||||
P_INSTANCE_POINTER elt_list_combine();
|
||||
}
|
||||
ec.set_totals(P_INSTANCE_POINTER elt_list, P_INSTANCE_POINTER count_elts);
|
||||
ec.Set_totals(P_INSTANCE_POINTER elt_list, P_INSTANCE_POINTER count_elts);
|
||||
|
||||
// add to comp list
|
||||
std::string str(ec.get_formula());
|
||||
std::string str(ec.Get_formula());
|
||||
this->exchComps[str] = ec;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
cxxExchange::~cxxExchange()
|
||||
{
|
||||
@ -181,7 +183,7 @@ cxxExchange::get_related_phases()
|
||||
for (std::map < std::string, cxxExchComp >::const_iterator it =
|
||||
this->exchComps.begin(); it != this->exchComps.end(); ++it)
|
||||
{
|
||||
if ((*it).second.get_phase_name().size() == 0)
|
||||
if ((*it).second.Get_phase_name().size() == 0)
|
||||
continue;
|
||||
return (true);
|
||||
}
|
||||
@ -194,13 +196,14 @@ cxxExchange::get_related_rate()
|
||||
for (std::map < std::string, cxxExchComp >::const_iterator it =
|
||||
this->exchComps.begin(); it != this->exchComps.end(); ++it)
|
||||
{
|
||||
if ((*it).second.get_rate_name().size() == 0)
|
||||
if ((*it).second.Get_rate_name().size() == 0)
|
||||
continue;
|
||||
return (true);
|
||||
}
|
||||
return (false);
|
||||
}
|
||||
|
||||
#ifdef MOVE_TO_STRUCTURES
|
||||
struct exchange *
|
||||
cxxExchange::cxxExchange2exchange(PHREEQC_PTR_ARG)
|
||||
//
|
||||
@ -223,6 +226,7 @@ cxxExchange::cxxExchange2exchange(PHREEQC_PTR_ARG)
|
||||
exchange_ptr->comps = cxxExchComp::cxxExchComp2exch_comp(P_INSTANCE_COMMA this->exchComps);
|
||||
return (exchange_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
cxxExchange::dump_xml(std::ostream & s_oss, unsigned int indent) const
|
||||
@ -395,16 +399,16 @@ cxxExchange::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->exchComps.find(ec.get_formula()) != this->exchComps.end())
|
||||
if (this->exchComps.find(ec.Get_formula()) != this->exchComps.end())
|
||||
{
|
||||
cxxExchComp & comp = this->exchComps.find(ec.get_formula())->second;
|
||||
cxxExchComp & comp = this->exchComps.find(ec.Get_formula())->second;
|
||||
comp.read_raw(reread, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
cxxExchComp ec1(this->Get_io());
|
||||
ec1.read_raw(reread, false);
|
||||
std::string str(ec1.get_formula());
|
||||
std::string str(ec1.Get_formula());
|
||||
this->exchComps[str] = ec1;
|
||||
}
|
||||
}
|
||||
@ -559,8 +563,8 @@ cxxExchange::totalize()
|
||||
for (std::map < std::string, cxxExchComp >::const_iterator it = exchComps.begin();
|
||||
it != exchComps.end(); ++it)
|
||||
{
|
||||
this->totals.add_extensive((*it).second.get_totals(), 1.0);
|
||||
this->totals.add("Charge", (*it).second.get_charge_balance());
|
||||
this->totals.add_extensive((*it).second.Get_totals(), 1.0);
|
||||
this->totals.add("Charge", (*it).second.Get_charge_balance());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -16,15 +16,15 @@ class cxxExchange:public cxxNumKeyword
|
||||
|
||||
public:
|
||||
cxxExchange(PHRQ_io *io=NULL);
|
||||
cxxExchange(PHREEQC_PTR_ARG_COMMA int n_user, PHRQ_io *io=NULL);
|
||||
//cxxExchange(PHREEQC_PTR_ARG_COMMA int n_user, PHRQ_io *io=NULL);
|
||||
cxxExchange(struct exchange *, PHRQ_io *io=NULL);
|
||||
cxxExchange(PHREEQC_PTR_ARG_COMMA const std::map < int, cxxExchange > &exchange_map,
|
||||
cxxExchange(const std::map < int, cxxExchange > &exchange_map,
|
||||
cxxMix & mx, int n_user, PHRQ_io *io=NULL);
|
||||
~cxxExchange();
|
||||
|
||||
struct exchange *cxxExchange2exchange(PHREEQC_PTR_ARG);
|
||||
//struct exchange *cxxExchange2exchange(PHREEQC_PTR_ARG);
|
||||
|
||||
struct exch_comp *cxxExchComp2exch_comp();
|
||||
//struct exch_comp *cxxExchComp2exch_comp();
|
||||
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
|
||||
12
Phreeqc.h
12
Phreeqc.h
@ -10,6 +10,7 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <map>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
@ -38,6 +39,9 @@ class cxxNameDouble;
|
||||
class cxxKinetics;
|
||||
class cxxMix;
|
||||
class cxxKineticsComp;
|
||||
class cxxExchange;
|
||||
class cxxExchComp;
|
||||
|
||||
class Phreeqc
|
||||
{
|
||||
public:
|
||||
@ -1235,10 +1239,12 @@ extern void MergeFinalize(void);
|
||||
|
||||
struct mix * cxxMix2mix(cxxMix *mx);
|
||||
struct kinetics *cxxKinetics2kinetics(cxxKinetics * kin);
|
||||
struct elt_list * cxxNameDouble2elt_list(cxxNameDouble * nd);
|
||||
struct elt_list * cxxNameDouble2elt_list(const cxxNameDouble * nd);
|
||||
struct kinetics_comp * cxxKineticsComp2kinetics_comp(std::list < cxxKineticsComp > * el);
|
||||
struct name_coef * cxxNameDouble2name_coef(cxxNameDouble * nd);
|
||||
|
||||
struct name_coef * cxxNameDouble2name_coef(const cxxNameDouble * nd);
|
||||
struct exchange * cxxExchange2exchange(cxxExchange * ex);
|
||||
struct exch_comp * cxxExchComp2exch_comp(const std::map < std::string, cxxExchComp > * el);
|
||||
struct master * Get_exch_master(const cxxExchComp * ec);
|
||||
|
||||
/* tally.c */
|
||||
|
||||
|
||||
@ -204,7 +204,8 @@ read_exchange_raw(void)
|
||||
|
||||
cxxExchange ex(&phrq_io);
|
||||
ex.read_raw(parser);
|
||||
struct exchange *exchange_ptr = ex.cxxExchange2exchange(PHREEQC_THIS);
|
||||
//struct exchange *exchange_ptr = ex.cxxExchange2exchange(PHREEQC_THIS);
|
||||
struct exchange *exchange_ptr = cxxExchange2exchange(&ex);
|
||||
int n;
|
||||
|
||||
/*
|
||||
@ -1516,7 +1517,8 @@ read_exchange_modify(void)
|
||||
entity.read_raw(parser, false);
|
||||
|
||||
// save entity
|
||||
struct exchange *entity_ptr = entity.cxxExchange2exchange(PHREEQC_THIS);
|
||||
//struct exchange *entity_ptr = entity.cxxExchange2exchange(PHREEQC_THIS);
|
||||
struct exchange *entity_ptr = cxxExchange2exchange(&entity);
|
||||
exchange_free(&(exchange[n]));
|
||||
exchange_copy(entity_ptr, &(exchange[n]), entity_ptr->n_user);
|
||||
|
||||
|
||||
@ -1017,8 +1017,10 @@ cxxStorageBin::cxxStorageBin2phreeqc(PHREEQC_PTR_ARG_COMMA int n)
|
||||
std::map < int, cxxExchange >::iterator it = this->Exchangers.find(n);
|
||||
if (it != this->Exchangers.end())
|
||||
{
|
||||
struct exchange *exchange_ptr =
|
||||
(it->second).cxxExchange2exchange(P_INSTANCE);
|
||||
//struct exchange *exchange_ptr =
|
||||
// (it->second).cxxExchange2exchange(P_INSTANCE);
|
||||
struct exchange *exchange_ptr = P_INSTANCE_POINTER cxxExchange2exchange(&it->second);
|
||||
|
||||
P_INSTANCE_POINTER exchange_copy(exchange_ptr, &P_INSTANCE_POINTER exchange[0], n);
|
||||
P_INSTANCE_POINTER count_exchange++;
|
||||
P_INSTANCE_POINTER exchange_free(exchange_ptr);
|
||||
@ -1262,7 +1264,8 @@ cxxStorageBin::cxxStorageBin2system(PHREEQC_PTR_ARG_COMMA int n)
|
||||
// Exchangers
|
||||
if (this->getExchange(n) != NULL)
|
||||
{
|
||||
system_ptr->exchange = (this->getExchange(n))->cxxExchange2exchange(P_INSTANCE);
|
||||
//system_ptr->exchange = (this->getExchange(n))->cxxExchange2exchange(P_INSTANCE);
|
||||
system_ptr->exchange = P_INSTANCE_POINTER cxxExchange2exchange(this->getExchange(n));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user