indented header files.

removed ^M from System.h





git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@3169 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2008-10-31 15:32:53 +00:00
parent 3313c814a9
commit d37ed2c6ae
30 changed files with 1776 additions and 1227 deletions

View File

@ -1,44 +1,45 @@
#if !defined(DICTIONARY_H_INCLUDED) #if !defined(DICTIONARY_H_INCLUDED)
#define DICTIONARY_H_INCLUDED #define DICTIONARY_H_INCLUDED
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "Solution.h" #include "Solution.h"
#include "NameDouble.h" #include "NameDouble.h"
class cxxDictionary class cxxDictionary
{ {
public: public:
cxxDictionary(); cxxDictionary();
~cxxDictionary(); ~cxxDictionary();
void add_phreeqc(); void add_phreeqc();
int size() { int size()
{
return (int) stringkey.size(); return (int) stringkey.size();
} }
int putString(std::string str); int putString(std::string str);
int putString(char * str); int putString(char *str);
int string2int(std::string str); int string2int(std::string str);
int string2int(char * str); int string2int(char *str);
std::string *int2string(int i); std::string * int2string(int i);
char *int2char(int i); char *int2char(int i);
protected: protected:
std::map<std::string, int> stringkey; std::map < std::string, int >stringkey;
std::map<int, std::string> intkey; std::map < int, std::string > intkey;
public: public:
}; };

View File

@ -4,88 +4,149 @@
#include "NameDouble.h" #include "NameDouble.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxExchComp class cxxExchComp
{ {
public: public:
cxxExchComp(); cxxExchComp();
cxxExchComp(struct exch_comp *); cxxExchComp(struct exch_comp *);
~cxxExchComp(); ~cxxExchComp();
struct master *get_master(); struct master *get_master();
static struct exch_comp *cxxExchComp2exch_comp(std::list<cxxExchComp>& el); static struct exch_comp *cxxExchComp2exch_comp(std::list < cxxExchComp >
&el);
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
char * get_formula()const { return this->formula;} char *get_formula() const
void set_formula(char * cstring) { this->formula = cstring;}
double get_moles()const { return this->moles;}
void set_moles(double d) { this->moles = d;}
double get_la()const { return this->la;}
void set_la(double d) { this->la = d;}
double get_charge_balance()const { return this->charge_balance;}
void set_charge_balance(double d) { this->charge_balance = d;}
char * get_phase_name()const { return this->phase_name;}
void set_phase_name(char * cstring) { this->phase_name = cstring;}
double get_phase_proportion()const { return this->phase_proportion;}
void set_phase_proportion(double d) { this->phase_proportion = d;}
char * get_rate_name()const { return this->rate_name;}
void set_rate_name(char * cstring) { this->rate_name = cstring;}
double get_formula_z()const { return this->formula_z;}
void set_formula_z(double d) { this->formula_z = d;}
void set_totals(struct elt_list *e_l, int count)
{this->totals = cxxNameDouble(e_l, count);}
void set_totals(struct elt_list *e_l)
{this->totals = cxxNameDouble(e_l);}
void set_totals(cxxNameDouble nd)
{this->totals = nd;}
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)
{this->formula_totals = cxxNameDouble(e_l);}
void set_formula_totals(cxxNameDouble nd)
{this->formula_totals = nd;}
const cxxNameDouble &get_totals()const
{ {
return (this->totals); return this->formula;
}
void set_formula(char *cstring)
{
this->formula = cstring;
}
double get_moles() const
{
return this->moles;
}
void set_moles(double d)
{
this->moles = d;
}
double get_la() const
{
return this->la;
}
void set_la(double d)
{
this->la = d;
}
double get_charge_balance() const
{
return this->charge_balance;
}
void set_charge_balance(double d)
{
this->charge_balance = d;
}
char *get_phase_name() const
{
return this->phase_name;
}
void set_phase_name(char *cstring)
{
this->phase_name = cstring;
}
double get_phase_proportion() const
{
return this->phase_proportion;
}
void set_phase_proportion(double d)
{
this->phase_proportion = d;
}
char *get_rate_name() const
{
return this->rate_name;
}
void set_rate_name(char *cstring)
{
this->rate_name = cstring;
}
double get_formula_z() const
{
return this->formula_z;
}
void set_formula_z(double d)
{
this->formula_z = d;
}
void set_totals(struct elt_list *e_l, int count)
{
this->totals = cxxNameDouble(e_l, count);
}
void set_totals(struct elt_list *e_l)
{
this->totals = cxxNameDouble(e_l);
}
void set_totals(cxxNameDouble nd)
{
this->totals = nd;
}
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)
{
this->formula_totals = cxxNameDouble(e_l);
}
void set_formula_totals(cxxNameDouble nd)
{
this->formula_totals = nd;
}
const cxxNameDouble & get_totals() const
{
return (this->totals);
}; };
void add(const cxxExchComp &comp, double extensive); void add(const cxxExchComp & comp, double extensive);
void multiply(double extensive); void multiply(double extensive);
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
protected: protected:
char * formula; char *formula;
double moles; double moles;
cxxNameDouble formula_totals; cxxNameDouble formula_totals;
cxxNameDouble totals; cxxNameDouble totals;
double la; double la;
double charge_balance; double charge_balance;
char *phase_name; char *phase_name;
double phase_proportion; double phase_proportion;
char *rate_name; char *rate_name;
double formula_z; // charge on formula double formula_z; // charge on formula
public: public:
}; };

View File

@ -3,67 +3,71 @@
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include "ExchComp.h" #include "ExchComp.h"
#include "cxxMix.h" #include "cxxMix.h"
class cxxExchange : public cxxNumKeyword class cxxExchange:public cxxNumKeyword
{ {
public: public:
cxxExchange(); cxxExchange();
cxxExchange(int n_user); cxxExchange(int n_user);
cxxExchange(struct exchange *); cxxExchange(struct exchange *);
cxxExchange(const std::map<int, cxxExchange> &exchange_map, cxxMix &mx, int n_user); cxxExchange(const std::map < int, cxxExchange > &exchange_map,
~cxxExchange(); cxxMix & mx, int n_user);
~cxxExchange();
struct exchange *cxxExchange2exchange(); struct exchange *cxxExchange2exchange();
struct exch_comp *cxxExchComp2exch_comp(); struct exch_comp *cxxExchComp2exch_comp();
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
bool get_related_phases(void); bool get_related_phases(void);
bool get_related_rate(void); bool get_related_rate(void);
bool get_pitzer_exchange_gammas() { bool get_pitzer_exchange_gammas()
{
return this->pitzer_exchange_gammas; return this->pitzer_exchange_gammas;
} }
void set_pitzer_exchange_gammas(bool b) { void set_pitzer_exchange_gammas(bool b)
{
this->pitzer_exchange_gammas = b; this->pitzer_exchange_gammas = b;
} }
std::list<cxxExchComp> &get_exchComps(void) { std::list < cxxExchComp > &get_exchComps(void)
return(this->exchComps); {
return (this->exchComps);
} }
void totalize(); void totalize();
const cxxNameDouble& get_totals()const const cxxNameDouble & get_totals() const
{ {
return totals; return totals;
}; };
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
private: private:
void add(const cxxExchange &addee, double extensive); void add(const cxxExchange & addee, double extensive);
// not written // not written
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
protected: protected:
std::list<cxxExchComp> exchComps; std::list < cxxExchComp > exchComps;
bool pitzer_exchange_gammas; bool pitzer_exchange_gammas;
cxxNameDouble totals; cxxNameDouble totals;
public: public:
}; };

View File

@ -5,63 +5,65 @@
#include "NameDouble.h" #include "NameDouble.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
#include "cxxMix.h" #include "cxxMix.h"
class cxxGasPhase : public cxxNumKeyword class cxxGasPhase:public cxxNumKeyword
{ {
public: public:
cxxGasPhase(); cxxGasPhase();
cxxGasPhase(struct gas_phase *); cxxGasPhase(struct gas_phase *);
cxxGasPhase(const std::map<int, cxxGasPhase> &entity_map, cxxMix &mx, int n_user); cxxGasPhase(const std::map < int, cxxGasPhase > &entity_map,
~cxxGasPhase(); cxxMix & mx, int n_user);
~cxxGasPhase();
enum GP_TYPE { enum GP_TYPE
GP_PRESSURE = 0, {
GP_VOLUME = 1 GP_PRESSURE = 0,
}; GP_VOLUME = 1
};
struct gas_phase *cxxGasPhase2gas_phase(); struct gas_phase *cxxGasPhase2gas_phase();
struct gas_comp *cxxGasPhaseComp2gas_comp(); struct gas_comp *cxxGasPhaseComp2gas_comp();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
void totalize(); void totalize();
const cxxNameDouble& get_totals()const const cxxNameDouble & get_totals() const
{ {
return this->totals; return this->totals;
}; };
private: private:
void add(const cxxGasPhase &addee, double extensive); void add(const cxxGasPhase & addee, double extensive);
protected: protected:
cxxNameDouble gasPhaseComps; cxxNameDouble gasPhaseComps;
GP_TYPE type; GP_TYPE type;
double total_p; double total_p;
double volume; double volume;
cxxNameDouble totals; cxxNameDouble totals;
public: public:
//static std::map<int, cxxGasPhase>& map; //static std::map<int, cxxGasPhase>& map;
}; };

View File

@ -6,65 +6,78 @@
#include "NumKeyword.h" #include "NumKeyword.h"
#include "Solution.h" #include "Solution.h"
//#include "Isotope.h" //#include "Isotope.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include <set> // std::set #include <set> // std::set
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <fstream> #include <fstream>
class cxxISolution : public cxxSolution class cxxISolution:public cxxSolution
{ {
public: public:
cxxISolution(); cxxISolution();
cxxISolution(struct solution *); cxxISolution(struct solution *);
//cxxISolution(const cxxISolution&); //cxxISolution(const cxxISolution&);
~cxxISolution(); ~cxxISolution();
//static cxxISolution& read(CParser& parser); //static cxxISolution& read(CParser& parser);
//void add(cxxISolutionComp conc) { this->concs.push_back(conc); } //void add(cxxISolutionComp conc) { this->concs.push_back(conc); }
struct solution *cxxISolution2solution(); struct solution *cxxISolution2solution();
double get_density()const {return this->density;} double get_density() const
void set_density(double density) {this->density = density;} {
return this->density;
}
void set_density(double density)
{
this->density = density;
}
std::string get_units()const {return units;} std::string get_units() const
void set_units(std::string units) {units = units;} {
return units;
}
void set_units(std::string units)
{
units = units;
}
//char * get_redox()const {return this->pe[this->default_pe].get_name();} //char * get_redox()const {return this->pe[this->default_pe].get_name();}
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void ConvertUnits(); void ConvertUnits();
#ifdef ORCHESTRA #ifdef ORCHESTRA
void ORCH_write(std::ostream &chemistry_dat, std::ostream &input_dat, std::ostream &output_dat); void ORCH_write(std::ostream & chemistry_dat, std::ostream & input_dat,
void ORCH_write_chemistry(std::ostream &chemistry_dat); std::ostream & output_dat);
void ORCH_write_input(std::ostream &input_dat); void ORCH_write_chemistry(std::ostream & chemistry_dat);
void ORCH_write_output_vars(std::ostream &input_dat); void ORCH_write_input(std::ostream & input_dat);
private: void ORCH_write_output_vars(std::ostream & input_dat);
void ORCH_write_chemistry_water(std::ostream &chemistry_dat); private:
void ORCH_write_chemistry_primary(std::ostream &chemistry_dat); void ORCH_write_chemistry_water(std::ostream & chemistry_dat);
void ORCH_write_chemistry_total_O_H(std::ostream &chemistry_dat); void ORCH_write_chemistry_primary(std::ostream & chemistry_dat);
void ORCH_write_chemistry_alkalinity(std::ostream &chemistry_dat); void ORCH_write_chemistry_total_O_H(std::ostream & chemistry_dat);
void ORCH_write_chemistry_minerals(std::ostream &chemistry_dat); void ORCH_write_chemistry_alkalinity(std::ostream & chemistry_dat);
void ORCH_write_chemistry_minerals(std::ostream & chemistry_dat);
#endif #endif
protected: protected:
friend class cxxISolutionComp; // for this->pe access friend class cxxISolutionComp; // for this->pe access
double density; double density;
std::string units; std::string units;
std::map<char *, cxxISolutionComp, CHARSTAR_LESS> comps; std::map < char *, cxxISolutionComp, CHARSTAR_LESS > comps;
struct pe_data *pes; struct pe_data *pes;
int default_pe; int default_pe;
public: public:
//static std::map<int, cxxISolution>& map; //static std::map<int, cxxISolution>& map;
}; };

View File

@ -9,70 +9,129 @@
#include "phrqproto.h" #include "phrqproto.h"
#include <string> #include <string>
#include <map> // std::map #include <map> // std::map
#include <vector> #include <vector>
#include <set> #include <set>
#include "char_star.h" #include "char_star.h"
// forward declarations // forward declarations
class cxxISolution; // reqd for read and dump_xml class cxxISolution; // reqd for read and dump_xml
class cxxISolutionComp class cxxISolutionComp
{ {
public: public:
cxxISolutionComp(void); cxxISolutionComp(void);
cxxISolutionComp(struct conc *conc_ptr); cxxISolutionComp(struct conc *conc_ptr);
~cxxISolutionComp(void); ~cxxISolutionComp(void);
public: public:
//STATUS_TYPE read(CParser& parser, CSolution& sol); //STATUS_TYPE read(CParser& parser, CSolution& sol);
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
char * get_description()const {return this->description;} char *get_description() const
void set_description(char * description) {this->description = description;} {
return this->description;
}
void set_description(char *description)
{
this->description = description;
}
double get_moles()const {return this->moles;} double get_moles() const
void set_moles(double moles) {this->moles = moles;} {
return this->moles;
}
void set_moles(double moles)
{
this->moles = moles;
}
double get_input_conc()const {return this->input_conc;} double get_input_conc() const
void set_input_conc(double input_conc) {this->input_conc = input_conc;} {
return this->input_conc;
}
void set_input_conc(double input_conc)
{
this->input_conc = input_conc;
}
std::string get_units()const {return this->units;} std::string get_units()const
void set_units(char * units) {this->units = units;} {
return this->units;
}
void set_units(char *units)
{
this->units = units;
}
char * get_equation_name()const {return this->equation_name;} char *get_equation_name() const
void set_equation_name(char * equation_name) {this->equation_name = equation_name;} {
return this->equation_name;
}
void set_equation_name(char *equation_name)
{
this->equation_name = equation_name;
}
double get_phase_si()const {return this->phase_si;} double get_phase_si() const
void set_phase_si(int phase_si) {this->phase_si = phase_si;} {
return this->phase_si;
}
void set_phase_si(int phase_si)
{
this->phase_si = phase_si;
}
int get_n_pe()const {return this->n_pe;} int get_n_pe() const
void set_n_pe(int n_pe) {this->n_pe = n_pe;} {
return this->n_pe;
}
void set_n_pe(int n_pe)
{
this->n_pe = n_pe;
}
char *get_as()const {return this->as;} char *get_as() const
void set_as(char *as) {this->as = as;} {
return this->as;
}
void set_as(char *as)
{
this->as = as;
}
//double get_gfw()const {return this->gfw;} //double get_gfw()const {return this->gfw;}
double get_gfw()const {return this->gfw;}; double get_gfw() const
void set_gfw(double gfw) {this->gfw = gfw;} {
return this->gfw;
};
void set_gfw(double gfw)
{
this->gfw = gfw;
}
void set_gfw(); void set_gfw();
bool operator<(const cxxISolutionComp& conc)const { return ::strcmp(this->description, conc.description) < 0; } bool operator<(const cxxISolutionComp & conc) const
{
return::strcmp(this->description, conc.description) < 0;
}
static struct conc * cxxISolutionComp2conc(const std::map <char *, cxxISolutionComp, CHARSTAR_LESS> &t ); static struct conc *cxxISolutionComp2conc(const std::map < char *,
cxxISolutionComp,
CHARSTAR_LESS > &t);
private: private:
char * description; char *description;
double moles; double moles;
double input_conc; double input_conc;
char * units; char *units;
char * equation_name; char *equation_name;
double phase_si; double phase_si;
int n_pe; int n_pe;
char * as; char *as;
double gfw; double gfw;
}; };
#endif // ISOLUTIONCOMP_H_INCLUDED #endif // ISOLUTIONCOMP_H_INCLUDED

View File

@ -4,49 +4,54 @@
#include "NameDouble.h" #include "NameDouble.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxKineticsComp class cxxKineticsComp
{ {
public: public:
cxxKineticsComp(); cxxKineticsComp();
cxxKineticsComp(struct kinetics_comp *); cxxKineticsComp(struct kinetics_comp *);
~cxxKineticsComp(); ~cxxKineticsComp();
static struct kinetics_comp *cxxKineticsComp2kinetics_comp(std::list<cxxKineticsComp>& el); static struct kinetics_comp *cxxKineticsComp2kinetics_comp(std::list <
cxxKineticsComp
> &el);
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
char *get_rate_name()const {return this->rate_name;} char *get_rate_name() const
{
return this->rate_name;
}
#ifdef USE_MPI #ifdef USE_MPI
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
#endif #endif
void add(const cxxKineticsComp &comp, double extensive); void add(const cxxKineticsComp & comp, double extensive);
void multiply(double extensive); void multiply(double extensive);
protected: protected:
char * rate_name; char *rate_name;
cxxNameDouble namecoef; //stoichiometry of reaction cxxNameDouble namecoef; //stoichiometry of reaction
double tol; double tol;
double m; double m;
double m0; double m0;
double moles; double moles;
std::vector<double> d_params; std::vector < double >d_params;
public: public:
}; };

View File

@ -2,73 +2,95 @@
#define NAMEDOUBLE_H_INCLUDED #define NAMEDOUBLE_H_INCLUDED
//#define EXTERNAL extern //#define EXTERNAL extern
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
//#include "global.h" //#include "global.h"
#include "char_star.h" #include "char_star.h"
#include "Parser.h" #include "Parser.h"
class cxxNameDouble : public std::map <char *, double, CHARSTAR_LESS> class cxxNameDouble:public
std::map < char *, double,
CHARSTAR_LESS >
{ {
public: public:
enum ND_TYPE { enum ND_TYPE
ND_ELT_MOLES = 1, {
ND_SPECIES_LA = 2, ND_ELT_MOLES = 1,
ND_SPECIES_GAMMA = 3, ND_SPECIES_LA = 2,
ND_NAME_COEF = 4 ND_SPECIES_GAMMA = 3,
}; ND_NAME_COEF = 4
};
cxxNameDouble(); cxxNameDouble();
cxxNameDouble(struct elt_list *); cxxNameDouble(struct elt_list *);
cxxNameDouble(struct elt_list *, int count); cxxNameDouble(struct elt_list *, int count);
cxxNameDouble(struct conc *); cxxNameDouble(struct conc *);
cxxNameDouble(struct master_activity *ma, int count, ND_TYPE); cxxNameDouble(struct master_activity *ma, int count, ND_TYPE);
cxxNameDouble(struct name_coef *nc, int count); cxxNameDouble(struct name_coef *nc, int count);
cxxNameDouble(const cxxNameDouble &old, double factor); cxxNameDouble(const cxxNameDouble & old, double factor);
~cxxNameDouble(); ~
cxxNameDouble();
struct elt_list *elt_list(); struct elt_list *
elt_list();
struct master_activity *master_activity()const; struct master_activity *
master_activity() const;
struct conc *conc()const; struct conc *
conc() const;
struct name_coef *name_coef()const; struct name_coef *
name_coef() const;
void dump_xml(std::ostream& s_oss, unsigned int indent)const; void
dump_xml(std::ostream & s_oss, unsigned int indent) const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void
dump_raw(std::ostream & s_oss, unsigned int indent) const;
CParser::STATUS_TYPE read_raw(CParser& parser, std::istream::pos_type& pos); CParser::STATUS_TYPE
read_raw(CParser & parser, std::istream::pos_type & pos);
void add_extensive(const cxxNameDouble &old, double factor); void
void add_intensive(const cxxNameDouble &addee, double fthis, double f2); add_extensive(const cxxNameDouble & old, double factor);
void add_log_activities(const cxxNameDouble &addee, double fthis, double f2); void
void add(const char * key, double total); add_intensive(const cxxNameDouble & addee, double fthis, double f2);
void multiply(double factor); void
add_log_activities(const cxxNameDouble & addee, double fthis, double f2);
void
add(const char *key, double total);
void
multiply(double factor);
void insert(char *str, double d) { void
insert(char *str, double d)
{
(*this)[str] = d; (*this)[str] = d;
} }
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void
void mpi_pack(int *ints, int *ii, double *doubles, int *dd); mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void
mpi_pack(int *ints, int *ii, double *doubles, int *dd);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void
mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
enum ND_TYPE type; enum ND_TYPE
type;
protected:
//std::map <char *, double, CHARSTAR_LESS> totals; protected:
//std::map <char *, double, CHARSTAR_LESS> totals;
public: public:
//static std::map<int, cxxNameDouble>& map; //static std::map<int, cxxNameDouble>& map;
}; };

View File

@ -2,8 +2,8 @@
#define NUMKEYWORD_H_INCLUDED #define NUMKEYWORD_H_INCLUDED
#include "Parser.h" #include "Parser.h"
#include <ostream> // std::ostream #include <ostream> // std::ostream
#include <string> // std::string #include <string> // std::string
//#define EXTERNAL extern //#define EXTERNAL extern
//#include "global.h" //#include "global.h"
//#include "phrqproto.h" //#include "phrqproto.h"
@ -11,33 +11,58 @@ extern char *string_duplicate(const char *);
class cxxNumKeyword class cxxNumKeyword
{ {
public: public:
cxxNumKeyword(); cxxNumKeyword();
virtual ~cxxNumKeyword(); virtual ~ cxxNumKeyword();
char * get_description()const { return string_duplicate(this->description.c_str()); } char *get_description() const
void set_description(std::string str) { this->description = str; } {
void set_description(char * str) { if (str != NULL) this->description = str; } return string_duplicate(this->description.c_str());
}
void set_description(std::string str)
{
this->description = str;
}
void set_description(char *str)
{
if (str != NULL)
this->description = str;
}
int get_n_user()const { return this->n_user; } int get_n_user() const
void set_n_user(int user) { this->n_user = user; } {
return this->n_user;
}
void set_n_user(int user)
{
this->n_user = user;
}
int get_n_user_end()const { return this->n_user_end; } int get_n_user_end() const
void set_n_user_end(int user_end) { this->n_user_end = user_end; } {
return this->n_user_end;
}
void set_n_user_end(int user_end)
{
this->n_user_end = user_end;
}
bool operator<(const cxxNumKeyword& key)const { return (this->n_user < key.n_user); } bool operator<(const cxxNumKeyword & key) const
{
return (this->n_user < key.n_user);
}
virtual void dump_xml(std::ostream& os, unsigned int indent = 0)const; virtual void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void read_number_description(CParser& parser); void read_number_description(CParser & parser);
protected: protected:
int n_user; int n_user;
int n_user_end; int n_user_end;
std::string description; std::string description;
private: private:
void read_number_description(std::istream& is); void read_number_description(std::istream & is);
}; };
#endif // !defined(NUMKEYWORD_H_INCLUDED) #endif // !defined(NUMKEYWORD_H_INCLUDED)

View File

@ -4,63 +4,67 @@
#include "NumKeyword.h" #include "NumKeyword.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
#include "PPassemblageComp.h" #include "PPassemblageComp.h"
#include "cxxMix.h" #include "cxxMix.h"
class cxxPPassemblage : public cxxNumKeyword class cxxPPassemblage:public cxxNumKeyword
{ {
public: public:
cxxPPassemblage(); cxxPPassemblage();
cxxPPassemblage(struct pp_assemblage *); cxxPPassemblage(struct pp_assemblage *);
cxxPPassemblage(const std::map<int, cxxPPassemblage> &entity_map, cxxMix &mx, int n_user); cxxPPassemblage(const std::map < int, cxxPPassemblage > &entity_map,
~cxxPPassemblage(); cxxMix & mx, int n_user);
~cxxPPassemblage();
struct pp_assemblage *cxxPPassemblage2pp_assemblage(); struct pp_assemblage *cxxPPassemblage2pp_assemblage();
struct pure_phase *cxxPPassemblageComp2pure_phase(); struct pure_phase *cxxPPassemblageComp2pure_phase();
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
const cxxNameDouble& get_totals()const const cxxNameDouble & get_totals() const
{ {
return this->totals; return this->totals;
}; };
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
void totalize(); void totalize();
#ifdef ORCHESTRA #ifdef ORCHESTRA
void ORCH_write_chemistry(std::ostream &chemistry_dat); void ORCH_write_chemistry(std::ostream & chemistry_dat);
void ORCH_write_output_vars(std::ostream &outstream); void ORCH_write_output_vars(std::ostream & outstream);
void ORCH_read(std::vector <std::pair <std::string, double> > output_vector, std::vector < std::pair < std::string, double > >::iterator &it); void ORCH_read(std::vector < std::pair < std::string,
void ORCH_store_global(std::map < std::string, double > output_map); double >>output_vector,
std::vector < std::pair < std::string,
double >>::iterator & it);
void ORCH_store_global(std::map < std::string, double >output_map);
#endif #endif
private: private:
void add(const cxxPPassemblage &addee, double extensive); void add(const cxxPPassemblage & addee, double extensive);
// not written // not written
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
protected: protected:
std::list<cxxPPassemblageComp> ppAssemblageComps; std::list < cxxPPassemblageComp > ppAssemblageComps;
cxxNameDouble eltList; cxxNameDouble eltList;
cxxNameDouble totals; cxxNameDouble totals;
public: public:
//static std::map<int, cxxPPassemblage>& map; //static std::map<int, cxxPPassemblage>& map;
}; };

View File

@ -4,60 +4,65 @@
#include "NameDouble.h" #include "NameDouble.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxPPassemblageComp class cxxPPassemblageComp
{ {
public: public:
cxxPPassemblageComp(); cxxPPassemblageComp();
cxxPPassemblageComp(struct pure_phase *); cxxPPassemblageComp(struct pure_phase *);
~cxxPPassemblageComp(); ~cxxPPassemblageComp();
static struct pure_phase *cxxPPassemblageComp2pure_phase(std::list<cxxPPassemblageComp>& el); static struct pure_phase *cxxPPassemblageComp2pure_phase(std::list <
cxxPPassemblageComp
> &el);
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
char *get_name()const {return this->name;} char *get_name() const
{
return this->name;
}
struct phase *get_phase(); struct phase *get_phase();
void totalize(); void totalize();
const cxxNameDouble &get_totals()const const cxxNameDouble & get_totals() const
{ {
return (this->totals); return (this->totals);
}; };
void add(const cxxPPassemblageComp &comp, double extensive); void add(const cxxPPassemblageComp & comp, double extensive);
void multiply(double extensive); void multiply(double extensive);
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
protected: protected:
char *name; char *name;
char *add_formula; char *add_formula;
double si; double si;
double moles; double moles;
double delta; double delta;
double initial_moles; double initial_moles;
bool force_equality; bool force_equality;
bool dissolve_only; bool dissolve_only;
cxxNameDouble totals; cxxNameDouble totals;
public: public:
}; };

286
Parser.h
View File

@ -2,84 +2,92 @@
#define PARSER_H_INCLUDED #define PARSER_H_INCLUDED
extern int input_error; extern int input_error;
#include <string> // std::string #include <string> // std::string
#include <map> // std::map #include <map> // std::map
#include <vector> // std::vector #include <vector> // std::vector
#include <sstream> // std::istringstream std::ostringstream #include <sstream> // std::istringstream std::ostringstream
#include <ostream> // std::ostream #include <ostream> // std::ostream
#include <istream> // std::istream #include <istream> // std::istream
#include "char_star.h" #include "char_star.h"
class CParser class CParser
{ {
public: public:
CParser(std::istream& input); CParser(std::istream & input);
CParser(std::istream& input, std::ostream& output); CParser(std::istream & input, std::ostream & output);
CParser(std::istream& input, std::ostream& output, std::ostream& error); CParser(std::istream & input, std::ostream & output,
std::ostream & error);
virtual ~CParser(); virtual ~ CParser();
enum LINE_TYPE { enum LINE_TYPE
LT_EOF = -1, {
LT_OK = 1, LT_EOF = -1,
LT_EMPTY = 2, LT_OK = 1,
LT_KEYWORD = 3, LT_EMPTY = 2,
LT_OPTION = 8 LT_KEYWORD = 3,
}; LT_OPTION = 8
};
enum TOKEN_TYPE { enum TOKEN_TYPE
TT_EMPTY = 2, {
TT_UPPER = 4, TT_EMPTY = 2,
TT_LOWER = 5, TT_UPPER = 4,
TT_DIGIT = 6, TT_LOWER = 5,
TT_UNKNOWN = 7 TT_DIGIT = 6,
}; TT_UNKNOWN = 7
};
enum FIND_TYPE { enum FIND_TYPE
FT_OK = 0, {
FT_ERROR = 1 FT_OK = 0,
}; FT_ERROR = 1
};
enum KEY_TYPE { enum KEY_TYPE
KT_NONE = -1, {
KT_END = 0, KT_NONE = -1,
KT_EOF = 1, KT_END = 0,
KT_SOLUTION_RAW = 5, KT_EOF = 1,
KT_EXCHANGE_RAW = 6, KT_SOLUTION_RAW = 5,
KT_GASPHASE_RAW = 7, KT_EXCHANGE_RAW = 6,
KT_KINETICS_RAW = 8, KT_GASPHASE_RAW = 7,
KT_PPASSEMBLAGE_RAW = 9, KT_KINETICS_RAW = 8,
KT_SSASSEMBLAGE_RAW = 10, KT_PPASSEMBLAGE_RAW = 9,
KT_SURFACE_RAW = 11 KT_SSASSEMBLAGE_RAW = 10,
KT_SURFACE_RAW = 11
};
}; enum OPT_TYPE
{
OPT_DEFAULT = -4,
OPT_ERROR = -3,
OPT_KEYWORD = -2,
OPT_EOF = -1
};
enum OPT_TYPE { enum ONERROR_TYPE
OPT_DEFAULT = -4, {
OPT_ERROR = -3, OT_CONTINUE = 0,
OPT_KEYWORD = -2, OT_STOP = 1
OPT_EOF = -1 };
};
enum ONERROR_TYPE { enum ECHO_OPTION
OT_CONTINUE = 0, {
OT_STOP = 1 EO_NONE = 0,
}; EO_ALL = 1,
EO_KEYWORDS = 2,
enum ECHO_OPTION { EO_NOKEYWORDS = 3
EO_NONE = 0, };
EO_ALL = 1,
EO_KEYWORDS = 2,
EO_NOKEYWORDS = 3
};
enum STATUS_TYPE { enum STATUS_TYPE
PARSER_ERROR = 0, {
PARSER_OK = 1 PARSER_ERROR = 0,
}; PARSER_OK = 1
};
/** /**
Function gets a new line and checks for empty, eof, and keywords. Function gets a new line and checks for empty, eof, and keywords.
Arguments: Arguments:
@ -98,9 +106,10 @@ public:
Terminates if EOF and allow_eof == false. Terminates if EOF and allow_eof == false.
*/ */
LINE_TYPE check_line(const std::string& str, bool allow_empty, bool allow_eof, bool allow_keyword, bool print); LINE_TYPE check_line(const std::string & str, bool allow_empty,
bool allow_eof, bool allow_keyword, bool print);
/** /**
Read a line from input file put in "line". Read a line from input file put in "line".
Copy of input line is stored in "line_save". Copy of input line is stored in "line_save".
Characters after # are discarded in line but retained in "line_save" Characters after # are discarded in line but retained in "line_save"
@ -114,30 +123,54 @@ public:
LT_OK, LT_OK,
LT_OPTION LT_OPTION
*/ */
LINE_TYPE get_line(); LINE_TYPE get_line();
// bool check_key(const std::string::iterator ptr); // bool check_key(const std::string::iterator ptr);
bool check_key(std::string::iterator begin, std::string::iterator end); bool check_key(std::string::iterator begin, std::string::iterator end);
STATUS_TYPE check_units(std::string& tot_units, bool alkalinity, bool check_compatibility, STATUS_TYPE check_units(std::string & tot_units, bool alkalinity,
const std::string& default_units, bool print); bool check_compatibility,
const std::string & default_units, bool print);
KEY_TYPE next_keyword()const { return m_next_keyword; } KEY_TYPE next_keyword() const
int get_option(const std::vector<std::string>& opt_list, std::string::iterator& next_char); {
int get_option(const std::vector<std::string>& opt_list, std::istream::pos_type& next_pos); return m_next_keyword;
int getOptionFromLastLine(const std::vector<std::string>& opt_list, std::string::iterator& next_char); }
int getOptionFromLastLine(const std::vector<std::string>& opt_list, std::istream::pos_type& next_pos); int get_option(const std::vector < std::string > &opt_list,
std::string::iterator & next_char);
int get_option(const std::vector < std::string > &opt_list,
std::istream::pos_type & next_pos);
int getOptionFromLastLine(const std::vector < std::string > &opt_list,
std::string::iterator & next_char);
int getOptionFromLastLine(const std::vector < std::string > &opt_list,
std::istream::pos_type & next_pos);
std::string& line() {return m_line;} std::string & line()
std::istringstream& get_iss() {return m_line_iss;} {
int incr_input_error() {++::input_error; return ++m_input_error;} return m_line;
std::ostream& get_output() {return m_output_stream;} }
int get_input_error() {return m_input_error;} std::istringstream & get_iss()
{
return m_line_iss;
}
int incr_input_error()
{
++::input_error;
return ++m_input_error;
}
std::ostream & get_output()
{
return m_output_stream;
}
int get_input_error()
{
return m_input_error;
}
/** /**
Copies from begin to token until first space is encountered. Copies from begin to token until first space is encountered.
Arguments: Arguments:
@ -152,13 +185,15 @@ public:
TT_DIGIT TT_DIGIT
TT_UNKNOWN TT_UNKNOWN
*/ */
static TOKEN_TYPE copy_token(std::string& token, std::string::iterator& begin, std::string::iterator& end); static TOKEN_TYPE copy_token(std::string & token,
static TOKEN_TYPE token_type(const std::string& token); std::string::iterator & begin,
static TOKEN_TYPE copy_token(std::string& token, std::istream& is); std::string::iterator & end);
TOKEN_TYPE copy_token(std::string& token, std::istream::pos_type& pos); static TOKEN_TYPE token_type(const std::string & token);
CParser::TOKEN_TYPE peek_token(); static TOKEN_TYPE copy_token(std::string & token, std::istream & is);
TOKEN_TYPE copy_token(std::string & token, std::istream::pos_type & pos);
CParser::TOKEN_TYPE peek_token();
/** /**
Function reads an element name out of the equation string. Function reads an element name out of the equation string.
An element name is composed of a capital letter followed by any number An element name is composed of a capital letter followed by any number
of lower case characters. of lower case characters.
@ -170,10 +205,12 @@ public:
end input, points to last position in the equation end input, points to last position in the equation
element input pointer to place to return element character string element input pointer to place to return element character string
*/ */
STATUS_TYPE get_elt(std::string::iterator& begin, const std::string::iterator end, std::string& element); STATUS_TYPE get_elt(std::string::iterator & begin,
const std::string::iterator end,
std::string & element);
/** /**
Compares a string value to match beginning letters of a list of options Compares a string value to match beginning letters of a list of options
Arguments: Arguments:
@ -189,39 +226,58 @@ public:
n -1 item not matched n -1 item not matched
i position of match in list i position of match in list
*/ */
static FIND_TYPE find_option(const std::string& item, int *n, const std::vector<std::string>& list, bool exact); static FIND_TYPE find_option(const std::string & item, int *n,
const std::vector < std::string > &list,
bool exact);
int error_msg(const std::ostringstream& err_str, ONERROR_TYPE stop) {return error_msg(err_str.str().c_str(), stop);} int error_msg(const std::ostringstream & err_str, ONERROR_TYPE stop)
int error_msg(const char *err_str, ONERROR_TYPE stop); {
int warning_msg(const char *err_str); return error_msg(err_str.str().c_str(), stop);
}
void set_echo_file(ECHO_OPTION opt) {echo_file = opt;} int error_msg(const char *err_str, ONERROR_TYPE stop);
ECHO_OPTION get_echo_file() {return this->echo_file;}; int warning_msg(const char *err_str);
void set_echo_stream(ECHO_OPTION opt) {echo_stream = opt;} void set_echo_file(ECHO_OPTION opt)
ECHO_OPTION get_echo_stream() {return this->echo_stream;}; {
echo_file = opt;
}
ECHO_OPTION get_echo_file()
{
return this->echo_file;
};
STATUS_TYPE parse_couple(std::string& token); void set_echo_stream(ECHO_OPTION opt)
{
echo_stream = opt;
}
ECHO_OPTION get_echo_stream()
{
return this->echo_stream;
};
STATUS_TYPE addPair(std::map<char *, double, CHARSTAR_LESS> &totals, std::istream::pos_type& pos); STATUS_TYPE parse_couple(std::string & token);
STATUS_TYPE addPair(std::map<char *, double> &totals, std::istream::pos_type& pos);
protected: STATUS_TYPE addPair(std::map < char *, double, CHARSTAR_LESS > &totals,
LINE_TYPE get_logical_line(); std::istream::pos_type & pos);
STATUS_TYPE addPair(std::map < char *, double >&totals,
std::istream::pos_type & pos);
private: protected:
std::istream& m_input_stream; LINE_TYPE get_logical_line();
std::ostream& m_output_stream;
std::ostream& m_error_stream; private:
int m_input_error; std::istream & m_input_stream;
KEY_TYPE m_next_keyword; std::ostream & m_output_stream;
std::string m_line; std::ostream & m_error_stream;
std::string m_line_save; int m_input_error;
std::istringstream m_line_iss; KEY_TYPE m_next_keyword;
LINE_TYPE m_line_type; std::string m_line;
ECHO_OPTION echo_stream; std::string m_line_save;
ECHO_OPTION echo_file; std::istringstream m_line_iss;
LINE_TYPE m_line_type;
ECHO_OPTION echo_stream;
ECHO_OPTION echo_file;
}; };
#endif // PARSER_H_INCLUDED #endif // PARSER_H_INCLUDED

View File

@ -5,40 +5,40 @@
#include "NameDouble.h" #include "NameDouble.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxReaction : public cxxNumKeyword class cxxReaction:public cxxNumKeyword
{ {
public: public:
cxxReaction(); cxxReaction();
cxxReaction(struct irrev *); cxxReaction(struct irrev *);
~cxxReaction(); ~cxxReaction();
struct irrev *cxxReaction2irrev(); struct irrev *cxxReaction2irrev();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
protected: protected:
cxxNameDouble reactantList; cxxNameDouble reactantList;
cxxNameDouble elementList; cxxNameDouble elementList;
std::vector<double> steps; std::vector < double >steps;
int countSteps; int countSteps;
bool equalIncrements; bool equalIncrements;
char *units; char *units;
public: public:
//static std::map<int, cxxReaction>& map; //static std::map<int, cxxReaction>& map;
}; };

View File

@ -2,15 +2,16 @@
#define _INC_SAXPHREEQC_H #define _INC_SAXPHREEQC_H
#if defined(__cplusplus) | defined(_CPP) #if defined(__cplusplus) | defined(_CPP)
extern "C" { extern "C"
{
#endif #endif
void SAX_StartSystem (); void SAX_StartSystem();
int SAX_AddSolution (struct solution* solution_ptr); int SAX_AddSolution(struct solution *solution_ptr);
void SAX_EndSystem (); void SAX_EndSystem();
int SAX_GetXMLLength (); int SAX_GetXMLLength();
const char* SAX_GetXMLStr (); const char *SAX_GetXMLStr();
int SAX_UnpackSolutions(void* pvBuffer, int buf_size); int SAX_UnpackSolutions(void *pvBuffer, int buf_size);
#if defined(__cplusplus) | defined(_CPP) #if defined(__cplusplus) | defined(_CPP)

View File

@ -4,56 +4,57 @@
#include "NumKeyword.h" #include "NumKeyword.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
#include "SSassemblageSS.h" #include "SSassemblageSS.h"
#include "cxxMix.h" #include "cxxMix.h"
class cxxSSassemblage : public cxxNumKeyword class cxxSSassemblage:public cxxNumKeyword
{ {
public: public:
cxxSSassemblage(); cxxSSassemblage();
cxxSSassemblage(struct s_s_assemblage *); cxxSSassemblage(struct s_s_assemblage *);
cxxSSassemblage(const std::map<int, cxxSSassemblage> &entity_map, cxxMix &mx, int n_user); cxxSSassemblage(const std::map < int, cxxSSassemblage > &entity_map,
~cxxSSassemblage(); cxxMix & mx, int n_user);
~cxxSSassemblage();
struct s_s_assemblage *cxxSSassemblage2s_s_assemblage(); struct s_s_assemblage *cxxSSassemblage2s_s_assemblage();
struct s_s *cxxSSassemblageComp2s_s(); struct s_s *cxxSSassemblageComp2s_s();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
void totalize(); void totalize();
const cxxNameDouble& get_totals()const const cxxNameDouble & get_totals() const
{ {
return this->totals; return this->totals;
}; };
private: private:
void add(const cxxSSassemblage &addee, double extensive); void add(const cxxSSassemblage & addee, double extensive);
protected: protected:
std::list<cxxSSassemblageSS> ssAssemblageSSs; std::list < cxxSSassemblageSS > ssAssemblageSSs;
cxxNameDouble totals; cxxNameDouble totals;
public: public:
//static std::map<int, cxxSSassemblage>& map; //static std::map<int, cxxSSassemblage>& map;
}; };

View File

@ -4,70 +4,75 @@
#include "NameDouble.h" #include "NameDouble.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxSSassemblageSS class cxxSSassemblageSS
{ {
public: public:
cxxSSassemblageSS(); cxxSSassemblageSS();
cxxSSassemblageSS(struct s_s *); cxxSSassemblageSS(struct s_s *);
~cxxSSassemblageSS(); ~cxxSSassemblageSS();
enum SS_PARAMETER_TYPE { enum SS_PARAMETER_TYPE
SS_PARM_NONE = -1, {
SS_PARM_A0_A1 = 0, SS_PARM_NONE = -1,
SS_PARM_GAMMAS = 1, SS_PARM_A0_A1 = 0,
SS_PARM_DIST_COEF = 2, SS_PARM_GAMMAS = 1,
SS_PARM_MISCIBILITY = 3, SS_PARM_DIST_COEF = 2,
SS_PARM_SPINODAL = 4, SS_PARM_MISCIBILITY = 3,
SS_PARM_CRITICAL = 5, SS_PARM_SPINODAL = 4,
SS_PARM_ALYOTROPIC = 6, SS_PARM_CRITICAL = 5,
SS_PARM_DIM_GUGG = 7, SS_PARM_ALYOTROPIC = 6,
SS_PARM_WALDBAUM = 8, SS_PARM_DIM_GUGG = 7,
SS_PARM_MARGULES = 9 SS_PARM_WALDBAUM = 8,
}; SS_PARM_MARGULES = 9
};
static struct s_s *cxxSSassemblageSS2s_s(std::list<cxxSSassemblageSS>& el); static struct s_s *cxxSSassemblageSS2s_s(std::list < cxxSSassemblageSS >
&el);
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
char *get_name()const {return this->name;} char *get_name() const
{
return this->name;
}
void totalize(); void totalize();
const cxxNameDouble &get_totals()const const cxxNameDouble & get_totals() const
{ {
return (this->totals); return (this->totals);
}; };
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
void add(const cxxSSassemblageSS &comp, double extensive); void add(const cxxSSassemblageSS & comp, double extensive);
void multiply(double extensive); void multiply(double extensive);
protected: protected:
char *name; char *name;
cxxNameDouble comps; cxxNameDouble comps;
double a0, a1; double a0, a1;
double ag0, ag1; double ag0, ag1;
bool miscibility; bool miscibility;
double xb1, xb2; double xb1, xb2;
cxxNameDouble totals; cxxNameDouble totals;
public: public:
}; };

View File

@ -9,8 +9,8 @@
#pragma once #pragma once
#endif // _MSC_VER > 1000 #endif // _MSC_VER > 1000
#include <wchar.h> // iswspace sprintf #include <wchar.h> // iswspace sprintf
#include <xercesc/sax2/DefaultHandler.hpp> // SAX2XMLReader #include <xercesc/sax2/DefaultHandler.hpp> // SAX2XMLReader
/** /**
#include <hash_map> #include <hash_map>
**/ **/
@ -25,10 +25,17 @@
#define LDBLE double #define LDBLE double
#endif #endif
struct XMLCH_LESS : std::binary_function<const XMLCh*, const XMLCh*, bool> { struct XMLCH_LESS:
bool operator()(const XMLCh* _X, const XMLCh* _Y) const std::binary_function < const XMLCh *, const XMLCh *,
bool >
{ {
return xns::XMLString::compareString( _X, _Y) < 0;} bool
operator() (const XMLCh * _X, const XMLCh * _Y) const
{
return
xns::XMLString::compareString(_X, _Y) <
0;
}
}; };
#include <math.h> #include <math.h>
@ -41,114 +48,159 @@ bool operator()(const XMLCh* _X, const XMLCh* _Y) const
//} //}
class Cconc : public conc class
Cconc:
public
conc
{ {
public: public:
Cconc() { conc_init(this); } Cconc()
~Cconc() { ; } {
conc_init(this);
}
~
Cconc()
{;
}
}; };
class SaxPhreeqcHandlers : public xns::DefaultHandler class
SaxPhreeqcHandlers:
public
xns::DefaultHandler
{ {
public: public:
SaxPhreeqcHandlers(); SaxPhreeqcHandlers();
virtual ~SaxPhreeqcHandlers(); virtual ~
SaxPhreeqcHandlers();
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
// Implementations of the SAX DocumentHandler interface // Implementations of the SAX DocumentHandler interface
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void endDocument(); void
endDocument();
void endElement(const XMLCh* const uri, const XMLCh* const name, const XMLCh* const qname); void
endElement(const XMLCh * const uri, const XMLCh * const name,
const XMLCh * const qname);
void characters(const XMLCh* const chars, const unsigned int length); void
characters(const XMLCh * const chars, const unsigned int length);
void ignorableWhitespace(const XMLCh* const chars, const unsigned int length); void
ignorableWhitespace(const XMLCh * const chars, const unsigned int length);
void processingInstruction(const XMLCh* const target, const XMLCh* const data); void
processingInstruction(const XMLCh * const target,
const XMLCh * const data);
void startDocument(); void
startDocument();
void startElement(const XMLCh* const uri, const XMLCh* const name, const XMLCh* const qname, const xns::Attributes& attributes); void
startElement(const XMLCh * const uri, const XMLCh * const name,
const XMLCh * const qname,
const xns::Attributes & attributes);
// element types // element types
enum elementType enum elementType
{ {
typeNULL, typeNULL,
typePHAST_STATE, typePHAST_STATE,
typeSYSTEM, typeSYSTEM,
typeSOLUTION, typeSOLUTION,
typeSOLN_PE, typeSOLN_PE,
typeSOLN_TOTAL, typeSOLN_TOTAL,
typeSOLN_MASTER_ACTIVITY, typeSOLN_MASTER_ACTIVITY,
typeSOLN_ISOTOPE, typeSOLN_ISOTOPE,
typeSOLN_SPECIES_GAMMA typeSOLN_SPECIES_GAMMA
} eltType; } eltType;
// attribute types // attribute types
enum attributeType enum attributeType
{ {
attNULL, attNULL,
attSOLN_new_def, attSOLN_new_def,
attSOLN_n_user, attSOLN_n_user,
attSOLN_n_user_end, attSOLN_n_user_end,
attSOLN_description, attSOLN_description,
attSOLN_tc, attSOLN_tc,
attSOLN_ph, attSOLN_ph,
attSOLN_solution_pe, attSOLN_solution_pe,
attSOLN_mu, attSOLN_mu,
attSOLN_ah2o, attSOLN_ah2o,
attSOLN_density, attSOLN_density,
attSOLN_total_h, attSOLN_total_h,
attSOLN_total_o, attSOLN_total_o,
attSOLN_cb, attSOLN_cb,
attSOLN_mass_water, attSOLN_mass_water,
attSOLN_total_alkalinity, attSOLN_total_alkalinity,
attSOLN_total_co2, attSOLN_total_co2,
attSOLN_units, attSOLN_units,
attSOLN_default_pe, attSOLN_default_pe,
attSOLN_count_master_activity, attSOLN_count_master_activity,
attSOLN_count_isotopes, attSOLN_count_isotopes,
attSOLN_count_species_gamma, attSOLN_count_species_gamma,
attSOLN_PE_name, attSOLN_PE_name,
attM_A_description, attM_A_description,
attM_A_la, attM_A_la,
attM_A_list, attM_A_list,
attISO_isotope_number, attISO_isotope_number,
attISO_elt_name, attISO_elt_name,
attISO_isotope_name, attISO_isotope_name,
attISO_total, attISO_total,
attISO_ratio, attISO_ratio,
attISO_ratio_uncertainty, attISO_ratio_uncertainty,
attISO_x_ratio_uncertainty, attISO_x_ratio_uncertainty,
attISO_coef, attISO_coef,
attCONC_description, attCONC_description,
attCONC_moles, attCONC_moles,
attCONC_input_conc, attCONC_input_conc,
attCONC_units, attCONC_units,
attCONC_equation_name, attCONC_equation_name,
attCONC_phase_si, attCONC_phase_si,
attCONC_n_pe, attCONC_n_pe,
attCONC_as, attCONC_as,
attCONC_gfw, attCONC_gfw,
} attType; } attType;
int processSolutionAttributes(const xns::Attributes& attributes); int
int processSolutionTotalAttributes(const xns::Attributes& attributes, struct conc *c); processSolutionAttributes(const xns::Attributes & attributes);
int processMasterActivityAttributes(const xns::Attributes& attributes, struct master_activity *ma); int
//int processMasterActivityAttributes(const xns::Attributes& attributes, std::vector<struct master_activity> *v); processSolutionTotalAttributes(const xns::Attributes & attributes,
int processIsotopeAttributes(const xns::Attributes& attributes, struct isotope *iso); struct conc *c);
int
processMasterActivityAttributes(const xns::Attributes & attributes,
struct master_activity *ma);
//int processMasterActivityAttributes(const xns::Attributes& attributes, std::vector<struct master_activity> *v);
int
processIsotopeAttributes(const xns::Attributes & attributes,
struct isotope *iso);
protected: protected:
std::vector<conc> totals; std::vector <
std::vector<master_activity> acts, s_gammas; conc >
std::vector<isotope> isotopes; totals;
std::map< const XMLCh*, elementType, XMLCH_LESS > mapXMLCh2Type; std::vector <
std::map< const XMLCh*, attributeType, XMLCH_LESS > mapXMLCh2AttType; master_activity >
/** acts,
s_gammas;
std::vector <
isotope >
isotopes;
std::map < const XMLCh *,
elementType,
XMLCH_LESS >
mapXMLCh2Type;
std::map < const XMLCh *,
attributeType,
XMLCH_LESS >
mapXMLCh2AttType;
/**
std::hash_map<const XMLCh*, ElementType, hash<const XMLCh*>, XMLCH_EQUALS> m_hashmapXMLCh2Type; std::hash_map<const XMLCh*, ElementType, hash<const XMLCh*>, XMLCH_EQUALS> m_hashmapXMLCh2Type;
**/ **/
struct solution* solution_ptr; struct solution *
solution_ptr;
}; };
#endif // !defined(AFX_SAXPHREEQCHANDLERS_H__4A69D5F5_2E57_4001_911D_4ABF6F2C0A0B__INCLUDED_) #endif // !defined(AFX_SAXPHREEQCHANDLERS_H__4A69D5F5_2E57_4001_911D_4ABF6F2C0A0B__INCLUDED_)

View File

@ -8,116 +8,193 @@
//#define EXTERNAL extern //#define EXTERNAL extern
//#include "global.h" //#include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <vector> // std::vector #include <vector> // std::vector
#include <iostream> #include <iostream>
#include "char_star.h" #include "char_star.h"
class cxxSolution : public cxxNumKeyword class cxxSolution:public cxxNumKeyword
{ {
public: public:
cxxSolution(); cxxSolution();
cxxSolution(struct solution *); cxxSolution(struct solution *);
cxxSolution(int n_user); cxxSolution(int n_user);
cxxSolution(const std::map<int, cxxSolution> &solution_map, cxxMix &mx, int n_user); cxxSolution(const std::map < int, cxxSolution > &solution_map,
~cxxSolution(); cxxMix & mx, int n_user);
~cxxSolution();
//static cxxSolution& read(CParser& parser); //static cxxSolution& read(CParser& parser);
double get_tc()const {return this->tc;} double get_tc() const
void set_tc(double tc) {this->tc = tc;} {
return this->tc;
}
void set_tc(double tc)
{
this->tc = tc;
}
double get_ph()const {return this->ph;} double get_ph() const
void set_ph(double pH) {this->ph = pH;} {
return this->ph;
}
void set_ph(double pH)
{
this->ph = pH;
}
double get_pe()const {return this->pe;} double get_pe() const
void set_pe(double pe) {this->pe =pe;} {
return this->pe;
}
void set_pe(double pe)
{
this->pe = pe;
}
double get_mu()const {return this->mu;} double get_mu() const
void set_mu(double mu) {this->mu = mu;} {
return this->mu;
}
void set_mu(double mu)
{
this->mu = mu;
}
double get_ah2o()const {return this->ah2o;} double get_ah2o() const
void set_ah2o(double ah2o) {this->ah2o = ah2o;} {
return this->ah2o;
}
void set_ah2o(double ah2o)
{
this->ah2o = ah2o;
}
double get_total_h()const {return this->total_h;} double get_total_h() const
void set_total_h(double total_h) {this->total_h = total_h;} {
return this->total_h;
}
void set_total_h(double total_h)
{
this->total_h = total_h;
}
double get_total_o()const {return this->total_o;} double get_total_o() const
void set_total_o(double total_o) {this->total_o = total_o;} {
return this->total_o;
}
void set_total_o(double total_o)
{
this->total_o = total_o;
}
double get_cb()const {return this->cb;} double get_cb() const
void set_cb(double cb) {this->cb = cb;} {
return this->cb;
}
void set_cb(double cb)
{
this->cb = cb;
}
double get_mass_water()const {return this->mass_water;} double get_mass_water() const
void set_mass_water(long double mass_water) {this->mass_water = mass_water;} {
return this->mass_water;
}
void set_mass_water(long double mass_water)
{
this->mass_water = mass_water;
}
double get_total_alkalinity()const {return this->total_alkalinity;} double get_total_alkalinity() const
void set_total_alkalinity(double total_alkalinity) {this->total_alkalinity = total_alkalinity;} {
return this->total_alkalinity;
}
void set_total_alkalinity(double total_alkalinity)
{
this->total_alkalinity = total_alkalinity;
}
double get_total(char *string)const; double get_total(char *string) const;
double get_total_element(char *string)const; double get_total_element(char *string) const;
void set_total(char *string, double value); void set_total(char *string, double value);
const cxxNameDouble& get_totals(void)const {return this->totals;} const cxxNameDouble & get_totals(void) const
void set_totals(cxxNameDouble &nd) {this->totals = nd; this->totals.type = cxxNameDouble::ND_ELT_MOLES;} {
void clear_totals() {this->totals.clear();} return this->totals;
}
void set_totals(cxxNameDouble & nd)
{
this->totals = nd;
this->totals.type = cxxNameDouble::ND_ELT_MOLES;
}
void clear_totals()
{
this->totals.clear();
}
const cxxNameDouble& get_master_activity(void)const {return this->master_activity;} const cxxNameDouble & get_master_activity(void) const
double get_master_activity(char *string)const; {
return this->master_activity;
}
double get_master_activity(char *string) const;
void set_master_activity(char *string, double value); void set_master_activity(char *string, double value);
/* /*
double get_species_gamma(char *string)const; double get_species_gamma(char *string)const;
void set_species_gamma(char *string, double value); void set_species_gamma(char *string, double value);
double get_isotope(char *string)const; double get_isotope(char *string)const;
void set_isotope(char *string, double value); void set_isotope(char *string, double value);
*/ */
struct solution *cxxSolution2solution(); struct solution *cxxSolution2solution();
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
void multiply(double extensive); void multiply(double extensive);
#ifdef ORCHESTRA #ifdef ORCHESTRA
void ORCH_write(std::ostream& headings, std::ostream& input_data)const; void ORCH_write(std::ostream & headings, std::ostream & input_data) const;
void ORCH_read(std::vector <std::pair <std::string, double> > output_vector, std::vector < std::pair < std::string, double > >::iterator &it); void ORCH_read(std::vector < std::pair < std::string,
void ORCH_store_global(std::map < std::string, double > output_map); double >>output_vector,
std::vector < std::pair < std::string,
double >>::iterator & it);
void ORCH_store_global(std::map < std::string, double >output_map);
#endif #endif
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
void mpi_send(int task_number); void mpi_send(int task_number);
void mpi_recv(int task_number); void mpi_recv(int task_number);
#endif #endif
private: private:
void zero(); void zero();
void add(const cxxSolution &addee, double extensive); void add(const cxxSolution & addee, double extensive);
// not checked // not checked
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
protected: protected:
double tc; double tc;
double ph; double ph;
double pe; double pe;
double mu; double mu;
double ah2o; double ah2o;
double total_h; double total_h;
double total_o; double total_o;
double cb; double cb;
double mass_water; double mass_water;
double total_alkalinity; double total_alkalinity;
cxxNameDouble totals; cxxNameDouble totals;
//std::list<cxxSolutionIsotope> isotopes; //std::list<cxxSolutionIsotope> isotopes;
cxxNameDouble master_activity; cxxNameDouble master_activity;
cxxNameDouble species_gamma; cxxNameDouble species_gamma;
cxxSolutionIsotopeList isotopes; cxxSolutionIsotopeList isotopes;
}; };

View File

@ -2,64 +2,98 @@
#define SOLUTIONISOTOPE_H_INCLUDED #define SOLUTIONISOTOPE_H_INCLUDED
#include "Parser.h" #include "Parser.h"
#include <ostream> // std::ostream #include <ostream> // std::ostream
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
class cxxSolutionIsotope class cxxSolutionIsotope
{ {
public: public:
cxxSolutionIsotope(void); cxxSolutionIsotope(void);
cxxSolutionIsotope(struct isotope *isotope_ptr); cxxSolutionIsotope(struct isotope *isotope_ptr);
~cxxSolutionIsotope(void); ~cxxSolutionIsotope(void);
/* /*
enum STATUS { enum STATUS {
ERROR = 0, ERROR = 0,
OK = 1 OK = 1
}; };
*/ */
//cxxSolutionIsotope::STATUS read(CParser& parser); //cxxSolutionIsotope::STATUS read(CParser& parser);
static struct isotope * list2isotope(std::list<cxxSolutionIsotope> &t); static struct isotope *list2isotope(std::list < cxxSolutionIsotope > &t);
void dump_xml(std::ostream& os, unsigned int indent)const; void dump_xml(std::ostream & os, unsigned int indent) const;
void dump_raw(std::ostream& os, unsigned int indent)const; void dump_raw(std::ostream & os, unsigned int indent) const;
CParser::STATUS_TYPE read_raw(CParser& parser); CParser::STATUS_TYPE read_raw(CParser & parser);
double get_isotope_number()const { return this->isotope_number;} double get_isotope_number() const
void set_isotope_number(double d) { this->isotope_number = d;} {
char * get_elt_name()const { return this->elt_name;} return this->isotope_number;
void set_elt_name(char * cstring) { this->elt_name = cstring;} }
char * get_isotope_name()const { return this->isotope_name;} void set_isotope_number(double d)
void set_isotope_name(char * cstring) { this->isotope_name = cstring;} {
double get_total()const { return this->total;} this->isotope_number = d;
void set_total(double d) { this->total = d;} }
char *get_elt_name() const
{
return this->elt_name;
}
void set_elt_name(char *cstring)
{
this->elt_name = cstring;
}
char *get_isotope_name() const
{
return this->isotope_name;
}
void set_isotope_name(char *cstring)
{
this->isotope_name = cstring;
}
double get_total() const
{
return this->total;
}
void set_total(double d)
{
this->total = d;
}
double get_ratio()const { return this->ratio; } double get_ratio() const
{
return this->ratio;
}
double get_ratio_uncertainty()const { return this->ratio_uncertainty; } double get_ratio_uncertainty() const
{
return this->ratio_uncertainty;
}
bool get_ratio_uncertainty_defined()const { return this->ratio_uncertainty_defined; } bool get_ratio_uncertainty_defined() const
{
return this->ratio_uncertainty_defined;
}
bool operator<(const cxxSolutionIsotope& conc)const; bool operator<(const cxxSolutionIsotope & conc) const;
struct master *master(void);
struct master *primary(void);
void add(const cxxSolutionIsotope &isotope_ptr, double intensive, double extensive); struct master *master(void);
struct master *primary(void);
void add(const cxxSolutionIsotope & isotope_ptr, double intensive,
double extensive);
void multiply(double extensive); void multiply(double extensive);
protected: protected:
friend class cxxSolutionIsotopeList; friend class cxxSolutionIsotopeList;
double isotope_number; double isotope_number;
char * elt_name; char *elt_name;
char * isotope_name; char *isotope_name;
double total; double total;
double ratio; double ratio;
double ratio_uncertainty; double ratio_uncertainty;
//struct master *master; //struct master *master;
//struct master *primary; //struct master *primary;
bool ratio_uncertainty_defined; bool ratio_uncertainty_defined;
}; };
#endif // SOLUTIONISOTOPE_H_INCLUDED #endif // SOLUTIONISOTOPE_H_INCLUDED

View File

@ -4,32 +4,38 @@
//#define EXTERNAL extern //#define EXTERNAL extern
#include "SolutionIsotope.h" #include "SolutionIsotope.h"
//#include "global.h" //#include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include "char_star.h" #include "char_star.h"
#include "Parser.h" #include "Parser.h"
class cxxSolutionIsotopeList : public std::list <cxxSolutionIsotope> class cxxSolutionIsotopeList:public
std::list <
cxxSolutionIsotope >
{ {
public: public:
cxxSolutionIsotopeList(); cxxSolutionIsotopeList();
cxxSolutionIsotopeList(struct solution *solution_ptr); cxxSolutionIsotopeList(struct solution *solution_ptr);
~cxxSolutionIsotopeList(); ~
cxxSolutionIsotopeList();
struct isotope *cxxSolutionIsotopeList2isotope(); struct isotope *
cxxSolutionIsotopeList2isotope();
void add(cxxSolutionIsotopeList oldlist, double intensive, double extensive); void
void multiply(double extensive); add(cxxSolutionIsotopeList oldlist, double intensive, double extensive);
void
protected: multiply(double extensive);
protected:
public: public:
}; };

View File

@ -15,21 +15,21 @@
#include "Reaction.h" #include "Reaction.h"
#include "Temperature.h" #include "Temperature.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
class cxxStorageBin class cxxStorageBin
{ {
public: public:
cxxStorageBin(); cxxStorageBin();
cxxStorageBin(struct Use *use_ptr); cxxStorageBin(struct Use *use_ptr);
~cxxStorageBin(); ~cxxStorageBin();
void import_phreeqc(void); void import_phreeqc(void);
void cxxStorageBin2phreeqc(int n); void cxxStorageBin2phreeqc(int n);
@ -37,200 +37,270 @@ public:
void remove(int n); void remove(int n);
cxxSolution *getSolution(int n_user) { cxxSolution *getSolution(int n_user)
if (this->Solutions.find(n_user) != this->Solutions.end()) { {
return(&(this->Solutions.find(n_user)->second)); if (this->Solutions.find(n_user) != this->Solutions.end())
} {
return (&(this->Solutions.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setSolution(int n_user, cxxSolution *entity) { void setSolution(int n_user, cxxSolution * entity)
if (entity == NULL) return; {
if (entity == NULL)
return;
Solutions[n_user] = *entity; Solutions[n_user] = *entity;
} }
void removeSolution(int n_user) { void removeSolution(int n_user)
{
Solutions.erase(n_user); Solutions.erase(n_user);
} }
cxxExchange *getExchange(int n_user) { cxxExchange *getExchange(int n_user)
if (this->Exchangers.find(n_user) != this->Exchangers.end()) { {
return(&(this->Exchangers.find(n_user)->second)); if (this->Exchangers.find(n_user) != this->Exchangers.end())
} {
return (&(this->Exchangers.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setExchange(int n_user, cxxExchange *entity) { void setExchange(int n_user, cxxExchange * entity)
if (entity == NULL) return; {
Exchangers[n_user] = *entity; if (entity == NULL)
return;
Exchangers[n_user] = *entity;
} }
void removeExchange(int n_user) { void removeExchange(int n_user)
{
Exchangers.erase(n_user); Exchangers.erase(n_user);
} }
cxxPPassemblage *getPPassemblage(int n_user) { cxxPPassemblage *getPPassemblage(int n_user)
if (this->PPassemblages.find(n_user) != this->PPassemblages.end()) { {
return(&(this->PPassemblages.find(n_user)->second)); if (this->PPassemblages.find(n_user) != this->PPassemblages.end())
} {
return (&(this->PPassemblages.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setPPassemblage(int n_user, cxxPPassemblage *entity) { void setPPassemblage(int n_user, cxxPPassemblage * entity)
if (entity == NULL) return; {
if (entity == NULL)
return;
PPassemblages[n_user] = *entity; PPassemblages[n_user] = *entity;
} }
void removePPassemblage(int n_user) { void removePPassemblage(int n_user)
{
PPassemblages.erase(n_user); PPassemblages.erase(n_user);
} }
cxxGasPhase *getGasPhase(int n_user) { cxxGasPhase *getGasPhase(int n_user)
if (this->GasPhases.find(n_user) != this->GasPhases.end()) { {
return(&(this->GasPhases.find(n_user)->second)); if (this->GasPhases.find(n_user) != this->GasPhases.end())
} {
return (&(this->GasPhases.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setGasPhase(int n_user, cxxGasPhase *entity) { void setGasPhase(int n_user, cxxGasPhase * entity)
if (entity == NULL) return; {
GasPhases[n_user] = *entity; if (entity == NULL)
return;
GasPhases[n_user] = *entity;
} }
void removeGasPhase(int n_user) { void removeGasPhase(int n_user)
{
GasPhases.erase(n_user); GasPhases.erase(n_user);
} }
cxxSSassemblage *getSSassemblage(int n_user) { cxxSSassemblage *getSSassemblage(int n_user)
if (this->SSassemblages.find(n_user) != this->SSassemblages.end()) { {
return(&(this->SSassemblages.find(n_user)->second)); if (this->SSassemblages.find(n_user) != this->SSassemblages.end())
} {
return (&(this->SSassemblages.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setSSassemblage(int n_user, cxxSSassemblage *entity) { void setSSassemblage(int n_user, cxxSSassemblage * entity)
if (entity == NULL) return; {
SSassemblages[n_user] = *entity; if (entity == NULL)
return;
SSassemblages[n_user] = *entity;
} }
void removeSSassemblage(int n_user) { void removeSSassemblage(int n_user)
{
SSassemblages.erase(n_user); SSassemblages.erase(n_user);
} }
cxxKinetics *getKinetics(int n_user) { cxxKinetics *getKinetics(int n_user)
if (this->Kinetics.find(n_user) != this->Kinetics.end()) { {
return(&(this->Kinetics.find(n_user)->second)); if (this->Kinetics.find(n_user) != this->Kinetics.end())
} {
return (&(this->Kinetics.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setKinetics(int n_user, cxxKinetics *entity) { void setKinetics(int n_user, cxxKinetics * entity)
if (entity == NULL) return; {
Kinetics[n_user] = *entity; if (entity == NULL)
return;
Kinetics[n_user] = *entity;
} }
void removeKinetics(int n_user) { void removeKinetics(int n_user)
{
Kinetics.erase(n_user); Kinetics.erase(n_user);
} }
cxxSurface *getSurface(int n_user) cxxSurface *getSurface(int n_user)
{ {
if (this->Surfaces.find(n_user) != this->Surfaces.end()) if (this->Surfaces.find(n_user) != this->Surfaces.end())
{ {
return(&(this->Surfaces.find(n_user)->second)); return (&(this->Surfaces.find(n_user)->second));
} }
return (NULL); return (NULL);
} }
void setSurface(int n_user, cxxSurface *entity) { void setSurface(int n_user, cxxSurface * entity)
if (entity == NULL) return; {
Surfaces[n_user] = *entity; if (entity == NULL)
return;
Surfaces[n_user] = *entity;
} }
void removeSurface(int n_user) { void removeSurface(int n_user)
{
Surfaces.erase(n_user); Surfaces.erase(n_user);
} }
cxxMix *getMix(int n_user) { cxxMix *getMix(int n_user)
if (this->Mixes.find(n_user) != this->Mixes.end()) { {
return(&(this->Mixes.find(n_user)->second)); if (this->Mixes.find(n_user) != this->Mixes.end())
} {
return (&(this->Mixes.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setMix(int n_user, cxxMix *entity) { void setMix(int n_user, cxxMix * entity)
if (entity == NULL) return; {
Mixes[n_user] = *entity; if (entity == NULL)
return;
Mixes[n_user] = *entity;
} }
void removeMix(int n_user) { void removeMix(int n_user)
{
Mixes.erase(n_user); Mixes.erase(n_user);
} }
cxxReaction *getReaction(int n_user) { cxxReaction *getReaction(int n_user)
if (this->Reactions.find(n_user) != this->Reactions.end()) { {
return(&(this->Reactions.find(n_user)->second)); if (this->Reactions.find(n_user) != this->Reactions.end())
} {
return (&(this->Reactions.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setReaction(int n_user, cxxReaction *entity) { void setReaction(int n_user, cxxReaction * entity)
if (entity == NULL) return; {
Reactions[n_user] = *entity; if (entity == NULL)
return;
Reactions[n_user] = *entity;
} }
void removeReaction(int n_user) { void removeReaction(int n_user)
{
Reactions.erase(n_user); Reactions.erase(n_user);
} }
cxxTemperature *getTemperature(int n_user) { cxxTemperature *getTemperature(int n_user)
if (this->Temperatures.find(n_user) != this->Temperatures.end()) { {
return(&(this->Temperatures.find(n_user)->second)); if (this->Temperatures.find(n_user) != this->Temperatures.end())
} {
return (&(this->Temperatures.find(n_user)->second));
}
return (NULL); return (NULL);
} }
void setTemperature(int n_user, cxxTemperature *entity) { void setTemperature(int n_user, cxxTemperature * entity)
if (entity == NULL) return; {
Temperatures[n_user] = *entity; if (entity == NULL)
return;
Temperatures[n_user] = *entity;
} }
void removeTemperature(int n_user) { void removeTemperature(int n_user)
{
Temperatures.erase(n_user); Temperatures.erase(n_user);
} }
void setSystem(struct Use *use_ptr); void setSystem(struct Use *use_ptr);
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void dump_raw(std::ostream& s_oss, int i, unsigned int indent); void dump_raw(std::ostream & s_oss, int i, unsigned int indent);
void read_raw(CParser& parser); void read_raw(CParser & parser);
int read_raw_keyword(CParser& parser); int read_raw_keyword(CParser & parser);
void add(struct system *sys_ptr); void add(struct system *sys_ptr);
struct system *cxxStorageBin2system(int i); struct system *cxxStorageBin2system(int i);
//cxxSolution *mix_cxxSolutions(cxxMix &mixmap); //cxxSolution *mix_cxxSolutions(cxxMix &mixmap);
cxxExchange *mix_cxxExchange(cxxMix &mixmap); cxxExchange *mix_cxxExchange(cxxMix & mixmap);
const std::map<int, cxxSolution>& getSolutions()const {return this->Solutions;}; const std::map < int, cxxSolution > &getSolutions() const
const std::map<int, cxxExchange>& getExchangers()const {return this->Exchangers;}; {
const std::map<int, cxxGasPhase>& getGasPhases()const {return this->GasPhases;}; return this->Solutions;
const std::map<int, cxxKinetics>& getKinetics()const {return this->Kinetics;}; };
const std::map<int, cxxPPassemblage>& getPPassemblages()const {return this->PPassemblages;}; const std::map < int, cxxExchange > &getExchangers() const
const std::map<int, cxxSSassemblage>& getSSassemblages()const {return this->SSassemblages;}; {
const std::map<int, cxxSurface>& getSurfaces()const {return this->Surfaces;}; return this->Exchangers;
};
const std::map < int, cxxGasPhase > &getGasPhases() const
{
return this->GasPhases;
};
const std::map < int, cxxKinetics > &getKinetics() const
{
return this->Kinetics;
};
const std::map < int, cxxPPassemblage > &getPPassemblages() const
{
return this->PPassemblages;
};
const std::map < int, cxxSSassemblage > &getSSassemblages() const
{
return this->SSassemblages;
};
const std::map < int, cxxSurface > &getSurfaces() const
{
return this->Surfaces;
};
#ifdef USE_MPI #ifdef USE_MPI
void mpi_send(int n, int task_number); void mpi_send(int n, int task_number);
void mpi_recv(int task_number); void mpi_recv(int task_number);
#endif #endif
#ifdef ORCHESTRA #ifdef ORCHESTRA
void ORCH_write(std::ostream &chemistry_dat, std::ostream &input_dat, std::ostream &output_dat); void ORCH_write(std::ostream & chemistry_dat, std::ostream & input_dat,
std::ostream & output_dat);
#endif #endif
protected: protected:
// Tidied classes // Tidied classes
std::map<int, cxxSolution> Solutions; std::map < int, cxxSolution > Solutions;
std::map<int, cxxExchange> Exchangers; std::map < int, cxxExchange > Exchangers;
std::map<int, cxxGasPhase> GasPhases; std::map < int, cxxGasPhase > GasPhases;
std::map<int, cxxKinetics> Kinetics; std::map < int, cxxKinetics > Kinetics;
std::map<int, cxxPPassemblage> PPassemblages; std::map < int, cxxPPassemblage > PPassemblages;
std::map<int, cxxSSassemblage> SSassemblages; std::map < int, cxxSSassemblage > SSassemblages;
std::map<int, cxxSurface> Surfaces; std::map < int, cxxSurface > Surfaces;
//bool b = exists (Solutions, 5); //bool b = exists (Solutions, 5);
// Initial classes // Initial classes
//std::map<int, cxxISolution> ISolutions; //std::map<int, cxxISolution> ISolutions;
// Reaction classes // Reaction classes
std::map<int, cxxMix> Mixes; std::map < int, cxxMix > Mixes;
std::map<int, cxxReaction> Reactions; std::map < int, cxxReaction > Reactions;
std::map<int, cxxTemperature> Temperatures; std::map < int, cxxTemperature > Temperatures;
cxxSystem system; cxxSystem system;
public: public:
//static std::map<int, cxxStorageBin>& map; //static std::map<int, cxxStorageBin>& map;
}; };

View File

@ -4,74 +4,75 @@
#include "NumKeyword.h" #include "NumKeyword.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
#include "SurfaceComp.h" #include "SurfaceComp.h"
#include "SurfaceCharge.h" #include "SurfaceCharge.h"
#include "cxxMix.h" #include "cxxMix.h"
class cxxSurface : public cxxNumKeyword class cxxSurface:public cxxNumKeyword
{ {
public: public:
cxxSurface(); cxxSurface();
cxxSurface(struct surface *); cxxSurface(struct surface *);
cxxSurface(const std::map<int, cxxSurface> &entity_map, cxxMix &mx, int n_user); cxxSurface(const std::map < int, cxxSurface > &entity_map, cxxMix & mx,
~cxxSurface(); int n_user);
~cxxSurface();
//enum SURFACE_STYPE { UNKNOWN_DL, NO_EDL, DDL, CD_MUSIC }; //enum SURFACE_STYPE { UNKNOWN_DL, NO_EDL, DDL, CD_MUSIC };
//enum SURFACE_DL_TYPE { NO_DL, BORKOVEC_DL, DONNAN_DL } ; //enum SURFACE_DL_TYPE { NO_DL, BORKOVEC_DL, DONNAN_DL } ;
//enum SURFACE_SITES_UNITS { SITES_ABSOLUTE, SITES_DENSITY } ; //enum SURFACE_SITES_UNITS { SITES_ABSOLUTE, SITES_DENSITY } ;
struct surface *cxxSurface2surface(); struct surface *cxxSurface2surface();
struct surf_comp *cxxSurfaceComp2surf_comp(); struct surf_comp *cxxSurfaceComp2surf_comp();
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
bool get_related_phases(void); bool get_related_phases(void);
bool get_related_rate(void);
bool get_related_rate(void);
void totalize(); void totalize();
const cxxNameDouble& get_totals()const const cxxNameDouble & get_totals() const
{ {
return this->totals; return this->totals;
}; };
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
private: private:
void add(const cxxSurface &addee, double extensive); void add(const cxxSurface & addee, double extensive);
protected: protected:
std::list<cxxSurfaceComp> surfaceComps; std::list < cxxSurfaceComp > surfaceComps;
std::list<cxxSurfaceCharge> surfaceCharges; std::list < cxxSurfaceCharge > surfaceCharges;
enum SURFACE_TYPE type; enum SURFACE_TYPE type;
enum DIFFUSE_LAYER_TYPE dl_type; enum DIFFUSE_LAYER_TYPE dl_type;
enum SITES_UNITS sites_units; enum SITES_UNITS sites_units;
bool only_counter_ions; bool only_counter_ions;
double thickness; double thickness;
double debye_lengths; double debye_lengths;
double DDL_viscosity; double DDL_viscosity;
double DDL_limit; double DDL_limit;
bool transport; bool transport;
cxxNameDouble totals; cxxNameDouble totals;
public: public:
//static std::map<int, cxxSurface>& map; //static std::map<int, cxxSurface>& map;
}; };
#endif // !defined(SURFACE_H_INCLUDED) #endif // !defined(SURFACE_H_INCLUDED)

View File

@ -4,57 +4,62 @@
#include "NameDouble.h" #include "NameDouble.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxSurfaceCharge class cxxSurfaceCharge
{ {
public: public:
cxxSurfaceCharge(); cxxSurfaceCharge();
cxxSurfaceCharge(struct surface_charge *); cxxSurfaceCharge(struct surface_charge *);
~cxxSurfaceCharge(); ~cxxSurfaceCharge();
struct master *get_psi_master(); struct master *get_psi_master();
static struct surface_charge *cxxSurfaceCharge2surface_charge(std::list<cxxSurfaceCharge>& el); static struct surface_charge *cxxSurfaceCharge2surface_charge(std::list <
cxxSurfaceCharge
> &el);
void dump_xml(std::ostream& os, unsigned int indent = 0)const; void dump_xml(std::ostream & os, unsigned int indent = 0) const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
char *get_name()const {return this->name;} char *get_name() const
{
return this->name;
}
void add(const cxxSurfaceCharge &comp, double extensive); void add(const cxxSurfaceCharge & comp, double extensive);
void multiply(double extensive); void multiply(double extensive);
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
protected: protected:
char * name; char *name;
double specific_area; double specific_area;
double grams; double grams;
double charge_balance; double charge_balance;
double mass_water; double mass_water;
double la_psi, la_psi1, la_psi2; double la_psi, la_psi1, la_psi2;
double capacitance[2]; double capacitance[2];
//std::map<double, cxxSurfDL> g; //std::map<double, cxxSurfDL> g;
//char * psi_master_name; //char * psi_master_name;
cxxNameDouble diffuse_layer_totals; cxxNameDouble diffuse_layer_totals;
public: public:
}; };

View File

@ -5,81 +5,102 @@
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include "phrqproto.h" #include "phrqproto.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxSurfaceComp class cxxSurfaceComp
{ {
public: public:
cxxSurfaceComp(); cxxSurfaceComp();
cxxSurfaceComp(struct surface_comp *); cxxSurfaceComp(struct surface_comp *);
~cxxSurfaceComp(); ~cxxSurfaceComp();
struct master *get_master(); struct master *get_master();
char *get_phase_name()const {return this->phase_name;} char *get_phase_name() const
char *get_rate_name()const {return this->rate_name;}
char *get_formula()const {return this->formula;}
double get_charge_balance()const { return this->charge_balance;}
void set_charge_balance(double d) { this->charge_balance = d;}
static struct surface_comp *cxxSurfaceComp2surface_comp(std::list<cxxSurfaceComp>& 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);
const cxxNameDouble &get_totals()const
{ {
return (this->totals); return this->phase_name;
}
char *get_rate_name() const
{
return this->rate_name;
}
char *get_formula() const
{
return this->formula;
}
double get_charge_balance() const
{
return this->charge_balance;
}
void set_charge_balance(double d)
{
this->charge_balance = d;
}
static struct surface_comp *cxxSurfaceComp2surface_comp(std::list <
cxxSurfaceComp >
&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);
const cxxNameDouble & get_totals() const
{
return (this->totals);
}; };
void add(const cxxSurfaceComp &comp, double extensive); void add(const cxxSurfaceComp & comp, double extensive);
void multiply(double extensive); void multiply(double extensive);
char *charge_name() {return(get_charge_name(this->formula));}; char *charge_name()
{
return (get_charge_name(this->formula));
};
static char *get_charge_name(char * token) { static char *get_charge_name(char *token)
char name[100]; {
int l; char name[100];
char *ptr1 = token; int l;
get_elt (&ptr1, name, &l); char *ptr1 = token;
ptr1 = strchr (name, '_'); get_elt(&ptr1, name, &l);
if (ptr1 != NULL) ptr1 = strchr(name, '_');
{ if (ptr1 != NULL)
ptr1[0] = '\0'; {
} ptr1[0] = '\0';
return(string_hsave(name)); }
return (string_hsave(name));
}; };
#ifdef USE_MPI #ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
#endif #endif
protected: protected:
char * formula; char *formula;
cxxNameDouble formula_totals; cxxNameDouble formula_totals;
double formula_z; double formula_z;
double moles; double moles;
cxxNameDouble totals; cxxNameDouble totals;
double la; double la;
//int charge_number; //int charge_number;
double charge_balance; double charge_balance;
char *phase_name; char *phase_name;
double phase_proportion; double phase_proportion;
char *rate_name; char *rate_name;
double Dw; double Dw;
public: public:
}; };

151
System.h
View File

@ -1,75 +1,76 @@
#if !defined(SYSTEM_H_INCLUDED) #if !defined(SYSTEM_H_INCLUDED)
#define SYSTEM_H_INCLUDED #define SYSTEM_H_INCLUDED
#include "Solution.h" #include "Solution.h"
#include "Exchange.h" #include "Exchange.h"
#include "GasPhase.h" #include "GasPhase.h"
#include "cxxKinetics.h" #include "cxxKinetics.h"
#include "PPassemblage.h" #include "PPassemblage.h"
#include "SSassemblage.h" #include "SSassemblage.h"
#include "Surface.h" #include "Surface.h"
#include "cxxMix.h" #include "cxxMix.h"
#include "Reaction.h" #include "Reaction.h"
#include "Temperature.h" #include "Temperature.h"
class cxxSystem class cxxSystem
{ {
public: public:cxxSystem(void);
cxxSystem(void); public: ~cxxSystem(void);
public: void Initialize(void);
~cxxSystem(void); void setSolution(cxxSolution * entity)
void Initialize(void); {
void setSolution(cxxSolution *entity) { this->solution = entity;
this->solution = entity; } void setExchange(cxxExchange * entity)
} {
void setExchange(cxxExchange *entity) { this->exchange = entity;
this->exchange = entity; } void setPPassemblage(cxxPPassemblage * entity)
} {
void setPPassemblage(cxxPPassemblage *entity) { this->ppassemblage = entity;
this->ppassemblage = entity; } void setGasPhase(cxxGasPhase * entity)
} {
void setGasPhase(cxxGasPhase *entity) { this->gasphase = entity;
this->gasphase = entity; } void setSSassemblage(cxxSSassemblage * entity)
} {
void setSSassemblage(cxxSSassemblage *entity) { this->ssassemblage = entity;
this->ssassemblage = entity; } void setKinetics(cxxKinetics * entity)
} {
void setKinetics(cxxKinetics *entity) { this->kinetics = entity;
this->kinetics = entity; } void setSurface(cxxSurface * entity)
} {
void setSurface(cxxSurface *entity) { this->surface = entity;
this->surface = entity; } void setMix(cxxMix * entity)
} {
void setMix(cxxMix *entity) { this->mix = entity;
this->mix = entity; } void setReaction(cxxReaction * entity)
} {
void setReaction(cxxReaction *entity) { this->reaction = entity;
this->reaction = entity; } void setTemperature(cxxTemperature * entity)
} {
void setTemperature(cxxTemperature *entity) { this->temperature = entity;
this->temperature = entity; } void totalize();
}
void totalize(); #ifdef ORCHESTRA
#ifdef ORCHESTRA void ORCH_components();
void ORCH_components(); void ORCH_write(std::ostream & chemistry_dat, std::ostream & input_dat,
void ORCH_write(std::ostream &chemistry_dat, std::ostream &input_dat, std::ostream &output_dat); std::ostream & output_dat);
void ORCH_write_chemistry_water(std::ostream &chemistry_dat); void ORCH_write_chemistry_water(std::ostream & chemistry_dat);
void ORCH_write_chemistry_primary(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_total_O_H(std::ostream & chemistry_dat);
void ORCH_write_output_vars(std::ostream &outstream); void ORCH_write_output_vars(std::ostream & outstream);
void ORCH_write_input(std::ostream &input_dat); void ORCH_write_input(std::ostream & input_dat);
#endif
#endif /* */
private: private:cxxSolution * solution;
cxxSolution *solution; cxxExchange * exchange;
cxxExchange *exchange; cxxPPassemblage * ppassemblage;
cxxPPassemblage *ppassemblage; cxxGasPhase * gasphase;
cxxGasPhase *gasphase; cxxSSassemblage * ssassemblage;
cxxSSassemblage *ssassemblage; cxxKinetics * kinetics;
cxxKinetics *kinetics; cxxSurface * surface;
cxxSurface *surface; cxxMix * mix;
cxxMix *mix; cxxReaction * reaction;
cxxReaction *reaction; cxxTemperature * temperature;
cxxTemperature *temperature; cxxNameDouble totals;
cxxNameDouble totals; cxxNameDouble orch_totals;
cxxNameDouble orch_totals; };
};
#endif // !defined(SYSTEM_H_INCLUDED)
#endif // !defined(SYSTEM_H_INCLUDED)

View File

@ -4,37 +4,37 @@
#include "NumKeyword.h" #include "NumKeyword.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxTemperature : public cxxNumKeyword class cxxTemperature:public cxxNumKeyword
{ {
public: public:
cxxTemperature(); cxxTemperature();
cxxTemperature(struct temperature *); cxxTemperature(struct temperature *);
~cxxTemperature(); ~cxxTemperature();
struct temperature *cxxTemperature2temperature(); struct temperature *cxxTemperature2temperature();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
protected: protected:
std::vector<double> temps; std::vector < double >temps;
int countTemps; int countTemps;
bool equalIncrements; bool equalIncrements;
public: public:
//static std::map<int, cxxTemperature>& map; //static std::map<int, cxxTemperature>& map;
}; };

83
Utils.h
View File

@ -2,65 +2,72 @@
#define UTILITIES_H_INCLUDED #define UTILITIES_H_INCLUDED
#include <string> #include <string>
#include <sstream> // std::istringstream std::ostringstream #include <sstream> // std::istringstream std::ostringstream
#include <ostream> // std::ostream #include <ostream> // std::ostream
#include <istream> // std::istream #include <istream> // std::istream
#include <map> // std::map #include <map> // std::map
#include "char_star.h" #include "char_star.h"
namespace Utilities { namespace Utilities
{
const char INDENT[] = " "; const char INDENT[] = " ";
enum STATUS_TYPE { enum STATUS_TYPE
OK = 0, {
ERROR = 1 OK = 0,
}; ERROR = 1
};
STATUS_TYPE parse_couple(std::string& token); STATUS_TYPE parse_couple(std::string & token);
int strcmp_nocase(const char *str1, const char *str2); int strcmp_nocase(const char *str1, const char *str2);
int strcmp_nocase_arg1(const char *str1, const char *str2); int strcmp_nocase_arg1(const char *str1, const char *str2);
void str_tolower(std::string& str); void str_tolower(std::string & str);
bool replace(const char* str1, const char* str2, std::string& str); bool replace(const char *str1, const char *str2, std::string & str);
void squeeze_white(std::string& s_l); void squeeze_white(std::string & s_l);
//void error_msg(const std::string&, const int stopflag); //void error_msg(const std::string&, const int stopflag);
// operations on maps of entities (Solution, Exchange, ...) // operations on maps of entities (Solution, Exchange, ...)
template<typename T> template < typename T >
void dump_raw (const T &b, std::ostream& s_oss, unsigned int indent) void dump_raw(const T & b, std::ostream & s_oss, unsigned int indent)
{
//std :: map < int, T > :: const_iterator it;
typename T::const_iterator it;
for (it = b.begin(); it != b.end(); ++it)
{ {
//std :: map < int, T > :: const_iterator it; it->second.dump_raw(s_oss, indent);
typename T::const_iterator it;
for (it = b.begin(); it != b.end(); ++it) {
it->second.dump_raw(s_oss, indent);
}
return;
} }
template<typename T> return;
bool exists (const T &b, int i){ }
return (b.find(i) != b.end());} template < typename T > bool exists(const T & b, int i)
{
return (b.find(i) != b.end());
}
template<typename T> template < typename T > T * get_entity(std::map < int, T > b, int i)
T *get_entity(std::map<int, T> b, int i) { {
if (b.find(i) != b.end()) { if (b.find(i) != b.end())
return(&(b.find(i)->second)); {
} else { return (&(b.find(i)->second));
}
else
{
return (NULL); return (NULL);
} }
} }
/* /*
template<class T> template<class T>
bool exists (std::map<int, T> b, int i){ bool exists (std::map<int, T> b, int i){
return (b.find(i) != b.end());} return (b.find(i) != b.end());}
*/ */
} }

View File

@ -1,11 +1,16 @@
#if !defined(CHARSTAR_H_INCLUDED) #if !defined(CHARSTAR_H_INCLUDED)
#define CHARSTAR_H_INCLUDED #define CHARSTAR_H_INCLUDED
struct CHARSTAR_LESS : std::binary_function<const char*, const char*, bool> { struct CHARSTAR_LESS:
bool operator()(const char* _X, const char* _Y) const std::binary_function < const char *, const char *,
bool >
{ {
return ::strcmp( _X, _Y) < 0;} bool
operator() (const char *_X, const char *_Y) const
{
return::strcmp(_X, _Y) <
0;
}
}; };
#endif #endif

View File

@ -4,58 +4,59 @@
#include "NumKeyword.h" #include "NumKeyword.h"
#define EXTERNAL extern #define EXTERNAL extern
#include "global.h" #include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
#include "KineticsComp.h" #include "KineticsComp.h"
#include "cxxMix.h" #include "cxxMix.h"
class cxxKinetics : public cxxNumKeyword class cxxKinetics:public cxxNumKeyword
{ {
public: public:
cxxKinetics(); cxxKinetics();
cxxKinetics(struct kinetics *); cxxKinetics(struct kinetics *);
cxxKinetics(const std::map<int, cxxKinetics> &entity_map, cxxMix &mx, int n_user); cxxKinetics(const std::map < int, cxxKinetics > &entity_map, cxxMix & mx,
~cxxKinetics(); int n_user);
~cxxKinetics();
struct kinetics *cxxKinetics2kinetics(); struct kinetics *cxxKinetics2kinetics();
struct kinetics_comp *cxxKineticsComp2kinetics_comp(); struct kinetics_comp *cxxKineticsComp2kinetics_comp();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
bool get_related_phases(void); bool get_related_phases(void);
bool get_related_rate(void); bool get_related_rate(void);
#ifdef USE_MPI #ifdef USE_MPI
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd); void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles); void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
#endif #endif
private: private:
void add(const cxxKinetics &addee, double extensive); void add(const cxxKinetics & addee, double extensive);
protected: protected:
std::list<cxxKineticsComp> kineticsComps; std::list < cxxKineticsComp > kineticsComps;
std::vector<double> steps; std::vector < double >steps;
cxxNameDouble totals; cxxNameDouble totals;
double step_divide; double step_divide;
int rk; int rk;
int bad_step_max; int bad_step_max;
bool use_cvode; bool use_cvode;
int cvode_steps; int cvode_steps;
int cvode_order; int cvode_order;
public: public:
//static std::map<int, cxxKinetics>& map; //static std::map<int, cxxKinetics>& map;
}; };

View File

@ -4,48 +4,53 @@
#include "NumKeyword.h" #include "NumKeyword.h"
//#define EXTERNAL extern //#define EXTERNAL extern
//#include "global.h" //#include "global.h"
#include <cassert> // assert #include <cassert> // assert
#include <map> // std::map #include <map> // std::map
#include <string> // std::string #include <string> // std::string
#include <list> // std::list #include <list> // std::list
#include <vector> // std::vector #include <vector> // std::vector
#include "char_star.h" #include "char_star.h"
class cxxMix : public cxxNumKeyword class cxxMix:public cxxNumKeyword
{ {
public: public:
cxxMix(); cxxMix();
cxxMix(struct mix *); cxxMix(struct mix *);
~cxxMix(); ~cxxMix();
struct mix *cxxMix2mix(); struct mix *cxxMix2mix();
//void dump_xml(std::ostream& os, unsigned int indent = 0)const; //void dump_xml(std::ostream& os, unsigned int indent = 0)const;
void dump_raw(std::ostream& s_oss, unsigned int indent)const; void dump_raw(std::ostream & s_oss, unsigned int indent) const;
void read_raw(CParser& parser); void read_raw(CParser & parser);
void add(int n, double f) { void add(int n, double f)
if (this->mixComps.find(n) != this->mixComps.end()) {
{ if (this->mixComps.find(n) != this->mixComps.end())
mixComps[n] += f; {
} else mixComps[n] += f;
{ }
mixComps[n] = f; else
} {
mixComps[n] = f;
}
}; };
std::map<int, double> *comps() {return &mixComps;} std::map < int, double >*comps()
{
return &mixComps;
}
protected: protected:
friend class cxxStorageBin; friend class cxxStorageBin;
std::map<int, double> mixComps; std::map < int, double >mixComps;
public: public:
//static std::map<int, cxxMix>& map; //static std::map<int, cxxMix>& map;
}; };