mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
Working on phast driver to use classes for main storage
git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@859 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
3261c99891
commit
574da9a1ac
2
Makefile
2
Makefile
@ -156,7 +156,7 @@ COMMON_CXXOBJS = \
|
||||
ReadClass.o \
|
||||
Solution.o \
|
||||
SolutionIsotope.o \
|
||||
SolutionIsotopelist.o \
|
||||
SolutionIsotopeList.o \
|
||||
SSassemblage.o \
|
||||
SSassemblageSS.o \
|
||||
StorageBin.o \
|
||||
|
||||
23
Solution.cxx
23
Solution.cxx
@ -732,6 +732,26 @@ double cxxSolution::get_total(char *string)const
|
||||
}
|
||||
}
|
||||
|
||||
void cxxSolution::set_total(char *string, double d)
|
||||
{
|
||||
this->totals[string] = d;
|
||||
}
|
||||
|
||||
double cxxSolution::get_master_activity(char *string)const
|
||||
{
|
||||
cxxNameDouble::const_iterator it = this->master_activity.find(string);
|
||||
if (it == this->master_activity.end()) {
|
||||
return(0.0);
|
||||
} else {
|
||||
return(it->second);
|
||||
}
|
||||
}
|
||||
|
||||
void cxxSolution::set_master_activity(char *string, double d)
|
||||
{
|
||||
this->master_activity[string] = d;
|
||||
}
|
||||
|
||||
#ifdef SKIP
|
||||
cxxSolution& cxxSolution::read(CParser& parser)
|
||||
{
|
||||
@ -1245,7 +1265,8 @@ void test_classes(void)
|
||||
#endif
|
||||
{
|
||||
// get all c storage
|
||||
cxxStorageBin cstorage(cxxStorageBin::SB_GLOBAL);
|
||||
cxxStorageBin cstorage;
|
||||
cstorage.import_phreeqc();
|
||||
//std::ostringstream oss;
|
||||
//cstorage.dump_raw(oss, 0);
|
||||
//write it out
|
||||
|
||||
30
Solution.h
30
Solution.h
@ -41,29 +41,39 @@ public:
|
||||
void set_pe(double pe) {this->pe =pe;}
|
||||
|
||||
double get_mu()const {return this->mu;}
|
||||
void set_mu(double mu) {this->pe = mu;}
|
||||
void set_mu(double mu) {this->mu = mu;}
|
||||
|
||||
double get_ah2o()const {return this->ah2o;}
|
||||
void set_ah2o(double ah2o) {this->pe = 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->pe = 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->pe = 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_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->pe = total_alkalinity;}
|
||||
|
||||
double get_cb()const {return this->cb;}
|
||||
void set_cb(double cb) {this->cb = cb;}
|
||||
void set_total_alkalinity(double total_alkalinity) {this->total_alkalinity = total_alkalinity;}
|
||||
|
||||
double get_total(char *string)const;
|
||||
//char * get_pe_reaction()const {return this->pe_reaction;}
|
||||
//void set_pe_reaction(char * pe_reaction) {this->pe_reaction = pe_reaction;}
|
||||
void set_total(char *string, double value);
|
||||
|
||||
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_isotope(char *string)const;
|
||||
void set_isotope(char *string, double value);
|
||||
*/
|
||||
|
||||
struct solution *cxxSolution2solution();
|
||||
|
||||
|
||||
@ -14,6 +14,13 @@ cxxSolutionIsotopeList::cxxSolutionIsotopeList(void)
|
||||
{
|
||||
}
|
||||
|
||||
cxxSolutionIsotopeList::~cxxSolutionIsotopeList(void)
|
||||
//
|
||||
// default destructor for cxxSolution
|
||||
//
|
||||
{
|
||||
}
|
||||
|
||||
cxxSolutionIsotopeList::cxxSolutionIsotopeList(struct solution *solution_ptr)
|
||||
{
|
||||
int i;
|
||||
|
||||
144
StorageBin.cxx
144
StorageBin.cxx
@ -12,6 +12,7 @@
|
||||
#include "global.h"
|
||||
#include "phqalloc.h"
|
||||
#include "phrqproto.h"
|
||||
#include "output.h"
|
||||
#include <cassert> // assert
|
||||
#include <algorithm> // std::sort
|
||||
|
||||
@ -23,7 +24,11 @@ cxxStorageBin::cxxStorageBin()
|
||||
// default constructor for cxxStorageBin
|
||||
}
|
||||
|
||||
cxxStorageBin::cxxStorageBin(cxxStorageBin::SB_CONSTRUCTOR flag)
|
||||
cxxStorageBin::~cxxStorageBin()
|
||||
{
|
||||
}
|
||||
|
||||
void cxxStorageBin::import_phreeqc(void)
|
||||
//
|
||||
// pull data out of c storage
|
||||
//
|
||||
@ -81,11 +86,6 @@ cxxStorageBin::cxxStorageBin(cxxStorageBin::SB_CONSTRUCTOR flag)
|
||||
}
|
||||
}
|
||||
|
||||
cxxStorageBin::~cxxStorageBin()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef SKIP
|
||||
void cxxStorageBin::dump_xml(std::ostream& s_oss, unsigned int indent)const
|
||||
@ -274,3 +274,135 @@ void cxxStorageBin::add(struct system * system_ptr)
|
||||
this->Surfaces[system_ptr->surface->n_user] = cxxSurface(system_ptr->surface);
|
||||
}
|
||||
}
|
||||
|
||||
void cxxStorageBin::cxxStorageBin2phreeqc(int n)
|
||||
//
|
||||
// copy data fromphreeqc storage to storage bin
|
||||
//
|
||||
{
|
||||
|
||||
// Solutions
|
||||
{
|
||||
|
||||
std::map <int, cxxSolution>::iterator it = this->Solutions.find(n);
|
||||
if (it != this->Solutions.end()){
|
||||
solution[0] = (it->second).cxxSolution2solution();
|
||||
solution[0]->n_user = n;
|
||||
solution[0]->n_user_end = n;
|
||||
count_solution++;
|
||||
} else {
|
||||
error_msg("cxxSolution not found in system2phreeqc", STOP);
|
||||
}
|
||||
}
|
||||
|
||||
// Exchangers
|
||||
{
|
||||
std::map <int, cxxExchange>::iterator it = this->Exchangers.find(n);
|
||||
if ( it != this->Exchangers.end()) {
|
||||
struct exchange *exchange_ptr = (it->second).cxxExchange2exchange();
|
||||
exchange_copy(exchange_ptr, &exchange[0], n);
|
||||
count_exchange++;
|
||||
}
|
||||
}
|
||||
|
||||
// GasPhases
|
||||
{
|
||||
std::map <int, cxxGasPhase>::iterator it = this->GasPhases.find(n);
|
||||
if ( it != this->GasPhases.end()) {
|
||||
struct gas_phase *gas_phase_ptr = (it->second).cxxGasPhase2gas_phase();
|
||||
gas_phase_copy(gas_phase_ptr, &gas_phase[0], n);
|
||||
count_gas_phase++;
|
||||
}
|
||||
}
|
||||
|
||||
// Kinetics
|
||||
{
|
||||
std::map <int, cxxKinetics>::iterator it = this->Kinetics.find(n);
|
||||
if ( it != this->Kinetics.end()) {
|
||||
struct kinetics *kinetics_ptr = (it->second).cxxKinetics2kinetics();
|
||||
kinetics_copy(kinetics_ptr, &kinetics[0], n);
|
||||
count_kinetics++;
|
||||
}
|
||||
}
|
||||
|
||||
// PPassemblages
|
||||
{
|
||||
std::map <int, cxxPPassemblage>::iterator it = this->PPassemblages.find(n);
|
||||
if ( it != this->PPassemblages.end()) {
|
||||
struct pp_assemblage *pp_assemblage_ptr = (it->second).cxxPPassemblage2pp_assemblage();
|
||||
pp_assemblage_copy(pp_assemblage_ptr, &pp_assemblage[0], n);
|
||||
count_pp_assemblage++;
|
||||
}
|
||||
}
|
||||
|
||||
// SSassemblages
|
||||
{
|
||||
std::map <int, cxxSSassemblage>::iterator it = this->SSassemblages.find(n);
|
||||
if ( it != this->SSassemblages.end()) {
|
||||
struct s_s_assemblage *s_s_assemblage_ptr = (it->second).cxxSSassemblage2s_s_assemblage();
|
||||
s_s_assemblage_copy(s_s_assemblage_ptr, &s_s_assemblage[0], n);
|
||||
count_s_s_assemblage++;
|
||||
}
|
||||
}
|
||||
|
||||
// Surfaces
|
||||
{
|
||||
std::map <int, cxxSurface>::iterator it = this->Surfaces.find(n);
|
||||
if ( it != this->Surfaces.end()) {
|
||||
struct surface *surface_ptr = (it->second).cxxSurface2surface();
|
||||
surface_copy(surface_ptr, &surface[0], n);
|
||||
count_surface++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
void cxxStorageBin::phreeqc2cxxStorageBin(int n)
|
||||
//
|
||||
// copy data fromphreeqc storage to storage bin
|
||||
//
|
||||
{
|
||||
int pos;
|
||||
|
||||
// Solutions
|
||||
{
|
||||
solution_bsearch(n, &pos, TRUE);
|
||||
this->Solutions[n] = cxxSolution(solution[pos]);
|
||||
}
|
||||
|
||||
// Exchangers
|
||||
{
|
||||
exchange_bsearch(n, &pos);
|
||||
this->Exchangers[n] = cxxExchange(&(exchange[pos]));
|
||||
}
|
||||
|
||||
// GasPhases
|
||||
{
|
||||
gas_phase_bsearch(n, &pos);
|
||||
this->GasPhases[n] = cxxGasPhase(&(gas_phase[pos]));
|
||||
}
|
||||
|
||||
// Kinetics
|
||||
{
|
||||
kinetics_bsearch(n, &pos);
|
||||
this->Kinetics[n] = cxxKinetics(&(kinetics[pos]));
|
||||
}
|
||||
|
||||
// PPassemblages
|
||||
{
|
||||
pp_assemblage_bsearch(n, &pos);
|
||||
this->PPassemblages[n] = cxxPPassemblage(&(pp_assemblage[pos]));
|
||||
}
|
||||
|
||||
// SSassemblages
|
||||
{
|
||||
s_s_assemblage_bsearch(n, &pos);
|
||||
this->SSassemblages[n] = cxxSSassemblage(&(s_s_assemblage[pos]));
|
||||
}
|
||||
|
||||
// Surfaces
|
||||
{
|
||||
surface_bsearch(n, &pos);
|
||||
this->Surfaces[n] = cxxSurface(&(surface[pos]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
28
StorageBin.h
28
StorageBin.h
@ -24,24 +24,24 @@ class cxxStorageBin
|
||||
{
|
||||
|
||||
public:
|
||||
enum SB_CONSTRUCTOR {
|
||||
SB_GLOBAL = 1
|
||||
};
|
||||
|
||||
cxxStorageBin();
|
||||
cxxStorageBin(SB_CONSTRUCTOR flag);
|
||||
|
||||
~cxxStorageBin();
|
||||
|
||||
//void dump_xml(std::ostream& os, unsigned int indent = 0)const;
|
||||
void import_phreeqc(void);
|
||||
|
||||
struct cxxSolution *get_solution(int i) {
|
||||
//cxxSolution *solution_ptr = Utilities::get_entity(this->Solutions, i);
|
||||
return(Utilities::get_entity(this->Solutions, i));
|
||||
//if (this->Solutions.find(i) != this->Solutions.end()) {
|
||||
//return(&(this->Solutions.find(i)->second));
|
||||
//} else {
|
||||
//return(NULL);
|
||||
//}
|
||||
void cxxStorageBin2phreeqc(int n);
|
||||
|
||||
void phreeqc2cxxStorageBin(int n);
|
||||
|
||||
struct cxxSolution *get_solution(int n_user) {
|
||||
if (this->Solutions.find(n_user) != this->Solutions.end()) {
|
||||
return(&(this->Solutions.find(n_user)->second));
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
void set_solution(int n_user, cxxSolution soln) {
|
||||
Solutions[n_user] = soln;
|
||||
}
|
||||
|
||||
void dump_raw(std::ostream& s_oss, unsigned int indent)const;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user