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)
#define DICTIONARY_H_INCLUDED
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "Solution.h"
#include "NameDouble.h"
class cxxDictionary
{
public:
cxxDictionary();
public:
cxxDictionary();
~cxxDictionary();
~cxxDictionary();
void add_phreeqc();
void add_phreeqc();
int size() {
int size()
{
return (int) stringkey.size();
}
int putString(std::string str);
int putString(char * str);
int putString(char *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);
protected:
std::map<std::string, int> stringkey;
std::map<int, std::string> intkey;
protected:
std::map < std::string, int >stringkey;
std::map < int, std::string > intkey;
public:
public:
};

View File

@ -4,88 +4,149 @@
#include "NameDouble.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
class cxxExchComp
{
public:
cxxExchComp();
cxxExchComp(struct exch_comp *);
~cxxExchComp();
public:
cxxExchComp();
cxxExchComp(struct exch_comp *);
~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;}
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
char *get_formula() 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);
#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);
#endif
protected:
char * formula;
double moles;
cxxNameDouble formula_totals;
cxxNameDouble totals;
double la;
double charge_balance;
char *phase_name;
double phase_proportion;
char *rate_name;
double formula_z; // charge on formula
protected:
char *formula;
double moles;
cxxNameDouble formula_totals;
cxxNameDouble totals;
double la;
double charge_balance;
char *phase_name;
double phase_proportion;
char *rate_name;
double formula_z; // charge on formula
public:
public:
};

View File

@ -3,67 +3,71 @@
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include "ExchComp.h"
#include "cxxMix.h"
class cxxExchange : public cxxNumKeyword
class cxxExchange:public cxxNumKeyword
{
public:
cxxExchange();
public:
cxxExchange();
cxxExchange(int n_user);
cxxExchange(struct exchange *);
cxxExchange(const std::map<int, cxxExchange> &exchange_map, cxxMix &mx, int n_user);
~cxxExchange();
cxxExchange(struct exchange *);
cxxExchange(const std::map < int, cxxExchange > &exchange_map,
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;
}
void set_pitzer_exchange_gammas(bool b) {
void set_pitzer_exchange_gammas(bool b)
{
this->pitzer_exchange_gammas = b;
}
std::list<cxxExchComp> &get_exchComps(void) {
return(this->exchComps);
std::list < cxxExchComp > &get_exchComps(void)
{
return (this->exchComps);
}
void totalize();
const cxxNameDouble& get_totals()const
const cxxNameDouble & get_totals() const
{
return totals;
return totals;
};
#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);
#endif
private:
void add(const cxxExchange &addee, double extensive);
private:
void add(const cxxExchange & addee, double extensive);
// 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:
std::list<cxxExchComp> exchComps;
bool pitzer_exchange_gammas;
protected:
std::list < cxxExchComp > exchComps;
bool pitzer_exchange_gammas;
cxxNameDouble totals;
public:
public:
};

View File

@ -5,63 +5,65 @@
#include "NameDouble.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
#include "cxxMix.h"
class cxxGasPhase : public cxxNumKeyword
class cxxGasPhase:public cxxNumKeyword
{
public:
cxxGasPhase();
cxxGasPhase(struct gas_phase *);
cxxGasPhase(const std::map<int, cxxGasPhase> &entity_map, cxxMix &mx, int n_user);
~cxxGasPhase();
public:
cxxGasPhase();
cxxGasPhase(struct gas_phase *);
cxxGasPhase(const std::map < int, cxxGasPhase > &entity_map,
cxxMix & mx, int n_user);
~cxxGasPhase();
enum GP_TYPE {
GP_PRESSURE = 0,
GP_VOLUME = 1
};
enum GP_TYPE
{
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
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);
#endif
void totalize();
const cxxNameDouble& get_totals()const
const cxxNameDouble & get_totals() const
{
return this->totals;
return this->totals;
};
private:
void add(const cxxGasPhase &addee, double extensive);
private:
void add(const cxxGasPhase & addee, double extensive);
protected:
cxxNameDouble gasPhaseComps;
protected:
cxxNameDouble gasPhaseComps;
GP_TYPE type;
double total_p;
double volume;
double total_p;
double volume;
cxxNameDouble totals;
public:
//static std::map<int, cxxGasPhase>& map;
public:
//static std::map<int, cxxGasPhase>& map;
};

View File

@ -6,65 +6,78 @@
#include "NumKeyword.h"
#include "Solution.h"
//#include "Isotope.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <set> // std::set
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <set> // std::set
#include <iostream>
#include <sstream>
#include <fstream>
class cxxISolution : public cxxSolution
class cxxISolution:public cxxSolution
{
public:
cxxISolution();
cxxISolution(struct solution *);
//cxxISolution(const cxxISolution&);
~cxxISolution();
public:
cxxISolution();
cxxISolution(struct solution *);
//cxxISolution(const 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;}
void set_density(double density) {this->density = density;}
double get_density() const
{
return this->density;
}
void set_density(double density)
{
this->density = density;
}
std::string get_units()const {return units;}
void set_units(std::string units) {units = units;}
std::string get_units() const
{
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();
#ifdef ORCHESTRA
void ORCH_write(std::ostream &chemistry_dat, std::ostream &input_dat, std::ostream &output_dat);
void ORCH_write_chemistry(std::ostream &chemistry_dat);
void ORCH_write_input(std::ostream &input_dat);
void ORCH_write_output_vars(std::ostream &input_dat);
private:
void ORCH_write_chemistry_water(std::ostream &chemistry_dat);
void ORCH_write_chemistry_primary(std::ostream &chemistry_dat);
void ORCH_write_chemistry_total_O_H(std::ostream &chemistry_dat);
void ORCH_write_chemistry_alkalinity(std::ostream &chemistry_dat);
void ORCH_write_chemistry_minerals(std::ostream &chemistry_dat);
void ORCH_write(std::ostream & chemistry_dat, std::ostream & input_dat,
std::ostream & output_dat);
void ORCH_write_chemistry(std::ostream & chemistry_dat);
void ORCH_write_input(std::ostream & input_dat);
void ORCH_write_output_vars(std::ostream & input_dat);
private:
void ORCH_write_chemistry_water(std::ostream & chemistry_dat);
void ORCH_write_chemistry_primary(std::ostream & chemistry_dat);
void ORCH_write_chemistry_total_O_H(std::ostream & chemistry_dat);
void ORCH_write_chemistry_alkalinity(std::ostream & chemistry_dat);
void ORCH_write_chemistry_minerals(std::ostream & chemistry_dat);
#endif
protected:
friend class cxxISolutionComp; // for this->pe access
double density;
std::string units;
std::map<char *, cxxISolutionComp, CHARSTAR_LESS> comps;
struct pe_data *pes;
int default_pe;
protected:
friend class cxxISolutionComp; // for this->pe access
double density;
std::string units;
std::map < char *, cxxISolutionComp, CHARSTAR_LESS > comps;
struct pe_data *pes;
int default_pe;
public:
//static std::map<int, cxxISolution>& map;
public:
//static std::map<int, cxxISolution>& map;
};

View File

@ -9,70 +9,129 @@
#include "phrqproto.h"
#include <string>
#include <map> // std::map
#include <map> // std::map
#include <vector>
#include <set>
#include "char_star.h"
// forward declarations
class cxxISolution; // reqd for read and dump_xml
class cxxISolution; // reqd for read and dump_xml
class cxxISolutionComp
{
public:
cxxISolutionComp(void);
cxxISolutionComp(struct conc *conc_ptr);
~cxxISolutionComp(void);
public:
cxxISolutionComp(void);
cxxISolutionComp(struct conc *conc_ptr);
~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;}
void set_description(char * description) {this->description = description;}
char *get_description() const
{
return this->description;
}
void set_description(char *description)
{
this->description = description;
}
double get_moles()const {return this->moles;}
void set_moles(double moles) {this->moles = moles;}
double get_moles() const
{
return this->moles;
}
void set_moles(double moles)
{
this->moles = moles;
}
double get_input_conc()const {return this->input_conc;}
void set_input_conc(double input_conc) {this->input_conc = input_conc;}
double get_input_conc() const
{
return this->input_conc;
}
void set_input_conc(double input_conc)
{
this->input_conc = input_conc;
}
std::string get_units()const {return this->units;}
void set_units(char * units) {this->units = units;}
std::string get_units()const
{
return this->units;
}
void set_units(char *units)
{
this->units = units;
}
char * get_equation_name()const {return this->equation_name;}
void set_equation_name(char * equation_name) {this->equation_name = equation_name;}
char *get_equation_name() const
{
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;}
void set_phase_si(int phase_si) {this->phase_si = phase_si;}
double get_phase_si() const
{
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;}
void set_n_pe(int n_pe) {this->n_pe = n_pe;}
int get_n_pe() const
{
return this->n_pe;
}
void set_n_pe(int n_pe)
{
this->n_pe = n_pe;
}
char *get_as()const {return this->as;}
void set_as(char *as) {this->as = as;}
char *get_as() const
{
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;};
void set_gfw(double gfw) {this->gfw = gfw;}
//double get_gfw()const {return this->gfw;}
double get_gfw() const
{
return this->gfw;
};
void set_gfw(double gfw)
{
this->gfw = 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:
char * description;
double moles;
double input_conc;
char * units;
char * equation_name;
double phase_si;
int n_pe;
char * as;
double gfw;
private:
char *description;
double moles;
double input_conc;
char *units;
char *equation_name;
double phase_si;
int n_pe;
char *as;
double gfw;
};
#endif // ISOLUTIONCOMP_H_INCLUDED

View File

@ -4,49 +4,54 @@
#include "NameDouble.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
class cxxKineticsComp
class cxxKineticsComp
{
public:
cxxKineticsComp();
cxxKineticsComp(struct kinetics_comp *);
~cxxKineticsComp();
public:
cxxKineticsComp();
cxxKineticsComp(struct kinetics_comp *);
~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);
char *get_rate_name()const {return this->rate_name;}
void read_raw(CParser & parser);
char *get_rate_name() const
{
return this->rate_name;
}
#ifdef USE_MPI
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
void add(const cxxKineticsComp &comp, double extensive);
void add(const cxxKineticsComp & comp, double extensive);
void multiply(double extensive);
protected:
char * rate_name;
cxxNameDouble namecoef; //stoichiometry of reaction
double tol;
double m;
double m0;
double moles;
std::vector<double> d_params;
protected:
char *rate_name;
cxxNameDouble namecoef; //stoichiometry of reaction
double tol;
double m;
double m0;
double moles;
std::vector < double >d_params;
public:
public:
};

View File

@ -2,73 +2,95 @@
#define NAMEDOUBLE_H_INCLUDED
//#define EXTERNAL extern
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
//#include "global.h"
#include "char_star.h"
#include "Parser.h"
class cxxNameDouble : public std::map <char *, double, CHARSTAR_LESS>
class cxxNameDouble:public
std::map < char *, double,
CHARSTAR_LESS >
{
public:
enum ND_TYPE {
ND_ELT_MOLES = 1,
ND_SPECIES_LA = 2,
ND_SPECIES_GAMMA = 3,
ND_NAME_COEF = 4
};
public:
enum ND_TYPE
{
ND_ELT_MOLES = 1,
ND_SPECIES_LA = 2,
ND_SPECIES_GAMMA = 3,
ND_NAME_COEF = 4
};
cxxNameDouble();
cxxNameDouble(struct elt_list *);
cxxNameDouble(struct elt_list *, int count);
cxxNameDouble(struct conc *);
cxxNameDouble(struct master_activity *ma, int count, ND_TYPE);
cxxNameDouble(struct name_coef *nc, int count);
cxxNameDouble(const cxxNameDouble &old, double factor);
~cxxNameDouble();
cxxNameDouble();
cxxNameDouble(struct elt_list *);
cxxNameDouble(struct elt_list *, int count);
cxxNameDouble(struct conc *);
cxxNameDouble(struct master_activity *ma, int count, ND_TYPE);
cxxNameDouble(struct name_coef *nc, int count);
cxxNameDouble(const cxxNameDouble & old, double factor);
~
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 add_intensive(const cxxNameDouble &addee, double fthis, double f2);
void add_log_activities(const cxxNameDouble &addee, double fthis, double f2);
void add(const char * key, double total);
void multiply(double factor);
void
add_extensive(const cxxNameDouble & old, double factor);
void
add_intensive(const cxxNameDouble & addee, double fthis, double f2);
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;
}
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles);
void mpi_pack(int *ints, int *ii, double *doubles, int *dd);
void
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;
protected:
enum ND_TYPE
type;
//std::map <char *, double, CHARSTAR_LESS> totals;
protected:
//std::map <char *, double, CHARSTAR_LESS> totals;
public:
//static std::map<int, cxxNameDouble>& map;
public:
//static std::map<int, cxxNameDouble>& map;
};

View File

@ -2,8 +2,8 @@
#define NUMKEYWORD_H_INCLUDED
#include "Parser.h"
#include <ostream> // std::ostream
#include <string> // std::string
#include <ostream> // std::ostream
#include <string> // std::string
//#define EXTERNAL extern
//#include "global.h"
//#include "phrqproto.h"
@ -11,33 +11,58 @@ extern char *string_duplicate(const char *);
class cxxNumKeyword
{
public:
cxxNumKeyword();
virtual ~cxxNumKeyword();
public:
cxxNumKeyword();
virtual ~ cxxNumKeyword();
char * get_description()const { 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; }
char *get_description() const
{
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; }
void set_n_user(int user) { this->n_user = user; }
int get_n_user() const
{
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; }
void set_n_user_end(int user_end) { this->n_user_end = user_end; }
int get_n_user_end() const
{
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:
int n_user;
int n_user_end;
std::string description;
protected:
int n_user;
int n_user_end;
std::string description;
private:
void read_number_description(std::istream& is);
private:
void read_number_description(std::istream & is);
};
#endif // !defined(NUMKEYWORD_H_INCLUDED)

View File

@ -4,63 +4,67 @@
#include "NumKeyword.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
#include "PPassemblageComp.h"
#include "cxxMix.h"
class cxxPPassemblage : public cxxNumKeyword
class cxxPPassemblage:public cxxNumKeyword
{
public:
cxxPPassemblage();
cxxPPassemblage(struct pp_assemblage *);
cxxPPassemblage(const std::map<int, cxxPPassemblage> &entity_map, cxxMix &mx, int n_user);
~cxxPPassemblage();
public:
cxxPPassemblage();
cxxPPassemblage(struct pp_assemblage *);
cxxPPassemblage(const std::map < int, cxxPPassemblage > &entity_map,
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
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);
#endif
void totalize();
#ifdef ORCHESTRA
void ORCH_write_chemistry(std::ostream &chemistry_dat);
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_store_global(std::map < std::string, double > output_map);
void ORCH_write_chemistry(std::ostream & chemistry_dat);
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_store_global(std::map < std::string, double >output_map);
#endif
private:
void add(const cxxPPassemblage &addee, double extensive);
private:
void add(const cxxPPassemblage & addee, double extensive);
// 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:
std::list<cxxPPassemblageComp> ppAssemblageComps;
cxxNameDouble eltList;
protected:
std::list < cxxPPassemblageComp > ppAssemblageComps;
cxxNameDouble eltList;
cxxNameDouble totals;
public:
//static std::map<int, cxxPPassemblage>& map;
public:
//static std::map<int, cxxPPassemblage>& map;
};

View File

@ -4,60 +4,65 @@
#include "NameDouble.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
class cxxPPassemblageComp
{
public:
cxxPPassemblageComp();
cxxPPassemblageComp(struct pure_phase *);
~cxxPPassemblageComp();
public:
cxxPPassemblageComp();
cxxPPassemblageComp(struct pure_phase *);
~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();
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);
#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);
#endif
protected:
char *name;
char *add_formula;
double si;
double moles;
double delta;
double initial_moles;
protected:
char *name;
char *add_formula;
double si;
double moles;
double delta;
double initial_moles;
bool force_equality;
bool dissolve_only;
bool dissolve_only;
cxxNameDouble totals;
public:
public:
};

286
Parser.h
View File

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

View File

@ -5,40 +5,40 @@
#include "NameDouble.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
class cxxReaction : public cxxNumKeyword
class cxxReaction:public cxxNumKeyword
{
public:
cxxReaction();
cxxReaction(struct irrev *);
~cxxReaction();
public:
cxxReaction();
cxxReaction(struct irrev *);
~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:
cxxNameDouble reactantList;
cxxNameDouble elementList;
std::vector<double> steps;
protected:
cxxNameDouble reactantList;
cxxNameDouble elementList;
std::vector < double >steps;
int countSteps;
bool equalIncrements;
char *units;
public:
//static std::map<int, cxxReaction>& map;
public:
//static std::map<int, cxxReaction>& map;
};

View File

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

View File

@ -4,56 +4,57 @@
#include "NumKeyword.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
#include "SSassemblageSS.h"
#include "cxxMix.h"
class cxxSSassemblage : public cxxNumKeyword
class cxxSSassemblage:public cxxNumKeyword
{
public:
cxxSSassemblage();
cxxSSassemblage(struct s_s_assemblage *);
cxxSSassemblage(const std::map<int, cxxSSassemblage> &entity_map, cxxMix &mx, int n_user);
~cxxSSassemblage();
public:
cxxSSassemblage();
cxxSSassemblage(struct s_s_assemblage *);
cxxSSassemblage(const std::map < int, cxxSSassemblage > &entity_map,
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
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);
#endif
void totalize();
const cxxNameDouble& get_totals()const
const cxxNameDouble & get_totals() const
{
return this->totals;
return this->totals;
};
private:
void add(const cxxSSassemblage &addee, double extensive);
private:
void add(const cxxSSassemblage & addee, double extensive);
protected:
std::list<cxxSSassemblageSS> ssAssemblageSSs;
protected:
std::list < cxxSSassemblageSS > ssAssemblageSSs;
cxxNameDouble totals;
public:
//static std::map<int, cxxSSassemblage>& map;
public:
//static std::map<int, cxxSSassemblage>& map;
};

View File

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

View File

@ -9,8 +9,8 @@
#pragma once
#endif // _MSC_VER > 1000
#include <wchar.h> // iswspace sprintf
#include <xercesc/sax2/DefaultHandler.hpp> // SAX2XMLReader
#include <wchar.h> // iswspace sprintf
#include <xercesc/sax2/DefaultHandler.hpp> // SAX2XMLReader
/**
#include <hash_map>
**/
@ -25,10 +25,17 @@
#define LDBLE double
#endif
struct XMLCH_LESS : std::binary_function<const XMLCh*, const XMLCh*, bool> {
bool operator()(const XMLCh* _X, const XMLCh* _Y) const
struct XMLCH_LESS:
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>
@ -41,114 +48,159 @@ bool operator()(const XMLCh* _X, const XMLCh* _Y) const
//}
class Cconc : public conc
class
Cconc:
public
conc
{
public:
Cconc() { conc_init(this); }
~Cconc() { ; }
public:
Cconc()
{
conc_init(this);
}
~
Cconc()
{;
}
};
class SaxPhreeqcHandlers : public xns::DefaultHandler
class
SaxPhreeqcHandlers:
public
xns::DefaultHandler
{
public:
SaxPhreeqcHandlers();
virtual ~SaxPhreeqcHandlers();
public:
SaxPhreeqcHandlers();
virtual ~
SaxPhreeqcHandlers();
// -----------------------------------------------------------------------
// Implementations of the SAX DocumentHandler interface
// -----------------------------------------------------------------------
void endDocument();
// -----------------------------------------------------------------------
// Implementations of the SAX DocumentHandler interface
// -----------------------------------------------------------------------
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
enum elementType
{
typeNULL,
typePHAST_STATE,
typeSYSTEM,
typeSOLUTION,
typeSOLN_PE,
typeSOLN_TOTAL,
typeSOLN_MASTER_ACTIVITY,
typeSOLN_ISOTOPE,
typeSOLN_SPECIES_GAMMA
} eltType;
// attribute types
enum attributeType
{
attNULL,
attSOLN_new_def,
attSOLN_n_user,
attSOLN_n_user_end,
attSOLN_description,
attSOLN_tc,
attSOLN_ph,
attSOLN_solution_pe,
attSOLN_mu,
attSOLN_ah2o,
attSOLN_density,
attSOLN_total_h,
attSOLN_total_o,
attSOLN_cb,
attSOLN_mass_water,
attSOLN_total_alkalinity,
attSOLN_total_co2,
attSOLN_units,
attSOLN_default_pe,
attSOLN_count_master_activity,
attSOLN_count_isotopes,
attSOLN_count_species_gamma,
attSOLN_PE_name,
attM_A_description,
attM_A_la,
attM_A_list,
attISO_isotope_number,
attISO_elt_name,
attISO_isotope_name,
attISO_total,
attISO_ratio,
attISO_ratio_uncertainty,
attISO_x_ratio_uncertainty,
attISO_coef,
attCONC_description,
attCONC_moles,
attCONC_input_conc,
attCONC_units,
attCONC_equation_name,
attCONC_phase_si,
attCONC_n_pe,
attCONC_as,
attCONC_gfw,
} attType;
// element types
enum elementType
{
typeNULL,
typePHAST_STATE,
typeSYSTEM,
typeSOLUTION,
typeSOLN_PE,
typeSOLN_TOTAL,
typeSOLN_MASTER_ACTIVITY,
typeSOLN_ISOTOPE,
typeSOLN_SPECIES_GAMMA
} eltType;
// attribute types
enum attributeType
{
attNULL,
attSOLN_new_def,
attSOLN_n_user,
attSOLN_n_user_end,
attSOLN_description,
attSOLN_tc,
attSOLN_ph,
attSOLN_solution_pe,
attSOLN_mu,
attSOLN_ah2o,
attSOLN_density,
attSOLN_total_h,
attSOLN_total_o,
attSOLN_cb,
attSOLN_mass_water,
attSOLN_total_alkalinity,
attSOLN_total_co2,
attSOLN_units,
attSOLN_default_pe,
attSOLN_count_master_activity,
attSOLN_count_isotopes,
attSOLN_count_species_gamma,
attSOLN_PE_name,
attM_A_description,
attM_A_la,
attM_A_list,
attISO_isotope_number,
attISO_elt_name,
attISO_isotope_name,
attISO_total,
attISO_ratio,
attISO_ratio_uncertainty,
attISO_x_ratio_uncertainty,
attISO_coef,
attCONC_description,
attCONC_moles,
attCONC_input_conc,
attCONC_units,
attCONC_equation_name,
attCONC_phase_si,
attCONC_n_pe,
attCONC_as,
attCONC_gfw,
} attType;
int processSolutionAttributes(const xns::Attributes& attributes);
int processSolutionTotalAttributes(const xns::Attributes& attributes, 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);
int
processSolutionAttributes(const xns::Attributes & attributes);
int
processSolutionTotalAttributes(const xns::Attributes & attributes,
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:
std::vector<conc> totals;
std::vector<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;
/**
protected:
std::vector <
conc >
totals;
std::vector <
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;
**/
struct solution* solution_ptr;
struct solution *
solution_ptr;
};
#endif // !defined(AFX_SAXPHREEQCHANDLERS_H__4A69D5F5_2E57_4001_911D_4ABF6F2C0A0B__INCLUDED_)

View File

@ -8,116 +8,193 @@
//#define EXTERNAL extern
//#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <vector> // std::vector
#include <iostream>
#include "char_star.h"
class cxxSolution : public cxxNumKeyword
class cxxSolution:public cxxNumKeyword
{
public:
cxxSolution();
cxxSolution(struct solution *);
cxxSolution(int n_user);
cxxSolution(const std::map<int, cxxSolution> &solution_map, cxxMix &mx, int n_user);
~cxxSolution();
public:
cxxSolution();
cxxSolution(struct solution *);
cxxSolution(int n_user);
cxxSolution(const std::map < int, cxxSolution > &solution_map,
cxxMix & mx, int n_user);
~cxxSolution();
//static cxxSolution& read(CParser& parser);
//static cxxSolution& read(CParser& parser);
double get_tc()const {return this->tc;}
void set_tc(double tc) {this->tc = tc;}
double get_tc() const
{
return this->tc;
}
void set_tc(double tc)
{
this->tc = tc;
}
double get_ph()const {return this->ph;}
void set_ph(double pH) {this->ph = pH;}
double get_ph() const
{
return this->ph;
}
void set_ph(double pH)
{
this->ph = pH;
}
double get_pe()const {return this->pe;}
void set_pe(double pe) {this->pe =pe;}
double get_pe() const
{
return this->pe;
}
void set_pe(double pe)
{
this->pe = pe;
}
double get_mu()const {return this->mu;}
void set_mu(double mu) {this->mu = mu;}
double get_mu() const
{
return this->mu;
}
void set_mu(double mu)
{
this->mu = mu;
}
double get_ah2o()const {return this->ah2o;}
void set_ah2o(double ah2o) {this->ah2o = ah2o;}
double get_ah2o() const
{
return this->ah2o;
}
void set_ah2o(double ah2o)
{
this->ah2o = ah2o;
}
double get_total_h()const {return this->total_h;}
void set_total_h(double total_h) {this->total_h = total_h;}
double get_total_h() const
{
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;}
void set_total_o(double total_o) {this->total_o = total_o;}
double get_total_o() const
{
return this->total_o;
}
void set_total_o(double total_o)
{
this->total_o = total_o;
}
double get_cb()const {return this->cb;}
void set_cb(double cb) {this->cb = cb;}
double get_cb() const
{
return this->cb;
}
void set_cb(double cb)
{
this->cb = cb;
}
double get_mass_water()const {return this->mass_water;}
void set_mass_water(long double mass_water) {this->mass_water = mass_water;}
double get_mass_water() const
{
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;}
void set_total_alkalinity(double total_alkalinity) {this->total_alkalinity = total_alkalinity;}
double get_total_alkalinity() const
{
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_element(char *string)const;
double get_total(char *string) const;
double get_total_element(char *string) const;
void set_total(char *string, double value);
const cxxNameDouble& get_totals(void)const {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_totals(void) const
{
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;}
double get_master_activity(char *string)const;
const cxxNameDouble & get_master_activity(void) const
{
return this->master_activity;
}
double get_master_activity(char *string) const;
void set_master_activity(char *string, double value);
/*
double get_species_gamma(char *string)const;
void set_species_gamma(char *string, double value);
double get_species_gamma(char *string)const;
void set_species_gamma(char *string, double value);
double get_isotope(char *string)const;
void set_isotope(char *string, double value);
*/
double get_isotope(char *string)const;
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);
#ifdef ORCHESTRA
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_store_global(std::map < std::string, double > output_map);
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_store_global(std::map < std::string, double >output_map);
#endif
#ifdef USE_MPI
void mpi_pack(std::vector<int>& ints, std::vector<double>& doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
void mpi_send(int task_number);
void mpi_recv(int task_number);
void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
void mpi_unpack(int *ints, int *ii, double *doubles, int *dd);
void mpi_send(int task_number);
void mpi_recv(int task_number);
#endif
private:
void zero();
void add(const cxxSolution &addee, double extensive);
private:
void zero();
void add(const cxxSolution & addee, double extensive);
// 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:
double tc;
double ph;
double pe;
double mu;
double ah2o;
double total_h;
double total_o;
double cb;
double mass_water;
double total_alkalinity;
cxxNameDouble totals;
//std::list<cxxSolutionIsotope> isotopes;
cxxNameDouble master_activity;
cxxNameDouble species_gamma;
protected:
double tc;
double ph;
double pe;
double mu;
double ah2o;
double total_h;
double total_o;
double cb;
double mass_water;
double total_alkalinity;
cxxNameDouble totals;
//std::list<cxxSolutionIsotope> isotopes;
cxxNameDouble master_activity;
cxxNameDouble species_gamma;
cxxSolutionIsotopeList isotopes;
};

View File

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

View File

@ -4,32 +4,38 @@
//#define EXTERNAL extern
#include "SolutionIsotope.h"
//#include "global.h"
#include <cassert> // assert
#include <string> // std::string
#include <list> // std::list
#include <cassert> // assert
#include <string> // std::string
#include <list> // std::list
#include "char_star.h"
#include "Parser.h"
class cxxSolutionIsotopeList : public std::list <cxxSolutionIsotope>
class cxxSolutionIsotopeList:public
std::list <
cxxSolutionIsotope >
{
public:
cxxSolutionIsotopeList();
public:
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 multiply(double extensive);
protected:
void
add(cxxSolutionIsotopeList oldlist, double intensive, double extensive);
void
multiply(double extensive);
protected:
public:
public:
};

View File

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

View File

@ -4,74 +4,75 @@
#include "NumKeyword.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
#include "SurfaceComp.h"
#include "SurfaceCharge.h"
#include "cxxMix.h"
class cxxSurface : public cxxNumKeyword
class cxxSurface:public cxxNumKeyword
{
public:
cxxSurface();
cxxSurface(struct surface *);
cxxSurface(const std::map<int, cxxSurface> &entity_map, cxxMix &mx, int n_user);
~cxxSurface();
public:
cxxSurface();
cxxSurface(struct surface *);
cxxSurface(const std::map < int, cxxSurface > &entity_map, cxxMix & mx,
int n_user);
~cxxSurface();
//enum SURFACE_STYPE { UNKNOWN_DL, NO_EDL, DDL, CD_MUSIC };
//enum SURFACE_DL_TYPE { NO_DL, BORKOVEC_DL, DONNAN_DL } ;
//enum SURFACE_SITES_UNITS { SITES_ABSOLUTE, SITES_DENSITY } ;
//enum SURFACE_STYPE { UNKNOWN_DL, NO_EDL, DDL, CD_MUSIC };
//enum SURFACE_DL_TYPE { NO_DL, BORKOVEC_DL, DONNAN_DL } ;
//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();
const cxxNameDouble& get_totals()const
const cxxNameDouble & get_totals() const
{
return this->totals;
return this->totals;
};
#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);
#endif
private:
void add(const cxxSurface &addee, double extensive);
private:
void add(const cxxSurface & addee, double extensive);
protected:
std::list<cxxSurfaceComp> surfaceComps;
std::list<cxxSurfaceCharge> surfaceCharges;
protected:
std::list < cxxSurfaceComp > surfaceComps;
std::list < cxxSurfaceCharge > surfaceCharges;
enum SURFACE_TYPE type;
enum DIFFUSE_LAYER_TYPE dl_type;
enum SITES_UNITS sites_units;
bool only_counter_ions;
double thickness;
double debye_lengths;
bool only_counter_ions;
double thickness;
double debye_lengths;
double DDL_viscosity;
double DDL_limit;
bool transport;
bool transport;
cxxNameDouble totals;
public:
//static std::map<int, cxxSurface>& map;
public:
//static std::map<int, cxxSurface>& map;
};
#endif // !defined(SURFACE_H_INCLUDED)

View File

@ -4,57 +4,62 @@
#include "NameDouble.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
class cxxSurfaceCharge
class cxxSurfaceCharge
{
public:
public:
cxxSurfaceCharge();
cxxSurfaceCharge(struct surface_charge *);
~cxxSurfaceCharge();
cxxSurfaceCharge();
cxxSurfaceCharge(struct surface_charge *);
~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);
#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);
#endif
protected:
char * name;
double specific_area;
double grams;
double charge_balance;
double mass_water;
double la_psi, la_psi1, la_psi2;
protected:
char *name;
double specific_area;
double grams;
double charge_balance;
double mass_water;
double la_psi, la_psi1, la_psi2;
double capacitance[2];
//std::map<double, cxxSurfDL> g;
//char * psi_master_name;
cxxNameDouble diffuse_layer_totals;
//std::map<double, cxxSurfDL> g;
//char * psi_master_name;
cxxNameDouble diffuse_layer_totals;
public:
public:
};

View File

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

151
System.h
View File

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

View File

@ -4,37 +4,37 @@
#include "NumKeyword.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
class cxxTemperature : public cxxNumKeyword
class cxxTemperature:public cxxNumKeyword
{
public:
cxxTemperature();
cxxTemperature(struct temperature *);
~cxxTemperature();
public:
cxxTemperature();
cxxTemperature(struct temperature *);
~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:
std::vector<double> temps;
protected:
std::vector < double >temps;
int countTemps;
bool equalIncrements;
public:
//static std::map<int, cxxTemperature>& map;
public:
//static std::map<int, cxxTemperature>& map;
};

83
Utils.h
View File

@ -2,65 +2,72 @@
#define UTILITIES_H_INCLUDED
#include <string>
#include <sstream> // std::istringstream std::ostringstream
#include <ostream> // std::ostream
#include <istream> // std::istream
#include <map> // std::map
#include <sstream> // std::istringstream std::ostringstream
#include <ostream> // std::ostream
#include <istream> // std::istream
#include <map> // std::map
#include "char_star.h"
namespace Utilities {
namespace Utilities
{
const char INDENT[] = " ";
const char INDENT[] = " ";
enum STATUS_TYPE {
OK = 0,
ERROR = 1
};
enum STATUS_TYPE
{
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, ...)
template<typename T>
void dump_raw (const T &b, std::ostream& s_oss, unsigned int indent)
template < typename T >
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;
typename T::const_iterator it;
for (it = b.begin(); it != b.end(); ++it) {
it->second.dump_raw(s_oss, indent);
}
return;
it->second.dump_raw(s_oss, indent);
}
template<typename T>
bool exists (const T &b, int i){
return (b.find(i) != b.end());}
return;
}
template < typename T > bool exists(const T & b, int i)
{
return (b.find(i) != b.end());
}
template<typename T>
T *get_entity(std::map<int, T> b, int i) {
if (b.find(i) != b.end()) {
return(&(b.find(i)->second));
} else {
template < typename T > T * get_entity(std::map < int, T > b, int i)
{
if (b.find(i) != b.end())
{
return (&(b.find(i)->second));
}
else
{
return (NULL);
}
}
/*
template<class T>
bool exists (std::map<int, T> b, int i){
return (b.find(i) != b.end());}
*/
template<class T>
bool exists (std::map<int, T> b, int i){
return (b.find(i) != b.end());}
*/
}

View File

@ -1,11 +1,16 @@
#if !defined(CHARSTAR_H_INCLUDED)
#define CHARSTAR_H_INCLUDED
struct CHARSTAR_LESS : std::binary_function<const char*, const char*, bool> {
bool operator()(const char* _X, const char* _Y) const
struct CHARSTAR_LESS:
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

View File

@ -4,58 +4,59 @@
#include "NumKeyword.h"
#define EXTERNAL extern
#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
#include "KineticsComp.h"
#include "cxxMix.h"
class cxxKinetics : public cxxNumKeyword
class cxxKinetics:public cxxNumKeyword
{
public:
cxxKinetics();
cxxKinetics(struct kinetics *);
cxxKinetics(const std::map<int, cxxKinetics> &entity_map, cxxMix &mx, int n_user);
~cxxKinetics();
public:
cxxKinetics();
cxxKinetics(struct kinetics *);
cxxKinetics(const std::map < int, cxxKinetics > &entity_map, cxxMix & mx,
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
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
private:
void add(const cxxKinetics &addee, double extensive);
private:
void add(const cxxKinetics & addee, double extensive);
protected:
std::list<cxxKineticsComp> kineticsComps;
std::vector<double> steps;
cxxNameDouble totals;
double step_divide;
int rk;
int bad_step_max;
bool use_cvode;
protected:
std::list < cxxKineticsComp > kineticsComps;
std::vector < double >steps;
cxxNameDouble totals;
double step_divide;
int rk;
int bad_step_max;
bool use_cvode;
int cvode_steps;
int cvode_order;
public:
//static std::map<int, cxxKinetics>& map;
public:
//static std::map<int, cxxKinetics>& map;
};

View File

@ -4,48 +4,53 @@
#include "NumKeyword.h"
//#define EXTERNAL extern
//#include "global.h"
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include <cassert> // assert
#include <map> // std::map
#include <string> // std::string
#include <list> // std::list
#include <vector> // std::vector
#include "char_star.h"
class cxxMix : public cxxNumKeyword
class cxxMix:public cxxNumKeyword
{
public:
cxxMix();
cxxMix(struct mix *);
~cxxMix();
public:
cxxMix();
cxxMix(struct mix *);
~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) {
if (this->mixComps.find(n) != this->mixComps.end())
{
mixComps[n] += f;
} else
{
mixComps[n] = f;
}
void add(int n, double f)
{
if (this->mixComps.find(n) != this->mixComps.end())
{
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;
std::map<int, double> mixComps;
std::map < int, double >mixComps;
public:
//static std::map<int, cxxMix>& map;
public:
//static std::map<int, cxxMix>& map;
};