classified struct use

finished rename of s_s_assemblage and SSassemblageSS

git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/branches/ErrorHandling@6032 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
David L Parkhurst 2012-01-11 16:15:48 +00:00
parent 4f0fb6c928
commit 568a2ab70a
8 changed files with 89 additions and 73 deletions

View File

@ -1983,7 +1983,7 @@ factor(struct LOC_exec * LINK)
break;
case toksim_time:
if (PhreeqcPtr->use.kinetics_in == FALSE)
if (!PhreeqcPtr->use.Get_kinetics_in())
{
if (PhreeqcPtr->state == PHAST)
{
@ -2016,7 +2016,7 @@ factor(struct LOC_exec * LINK)
break;
case toktotal_time:
if (PhreeqcPtr->use.kinetics_in == FALSE)
if (!PhreeqcPtr->use.Get_kinetics_in())
{
if (PhreeqcPtr->state == PHAST)
{
@ -2289,14 +2289,14 @@ factor(struct LOC_exec * LINK)
n.stringval = true;
if (PhreeqcPtr->state == REACTION)
{
if (PhreeqcPtr->use.mix_in == TRUE)
if (PhreeqcPtr->use.Get_mix_in())
{
sprintf(string, "Mix %d", PhreeqcPtr->use.n_mix_user);
sprintf(string, "Mix %d", PhreeqcPtr->use.Get_n_mix_user());
n.UU.sval = PhreeqcPtr->string_duplicate(string);
}
else
{
soln_ptr = PhreeqcPtr->solution_bsearch(PhreeqcPtr->use.n_solution_user, &nn, TRUE);
soln_ptr = PhreeqcPtr->solution_bsearch(PhreeqcPtr->use.Get_n_solution_user(), &nn, TRUE);
if (soln_ptr != NULL)
{
n.UU.sval = PhreeqcPtr->string_duplicate(soln_ptr->description);
@ -2314,9 +2314,9 @@ factor(struct LOC_exec * LINK)
}
else
{
if (PhreeqcPtr->use.solution_ptr != NULL)
if (PhreeqcPtr->use.Get_solution_ptr() != NULL)
{
n.UU.sval = PhreeqcPtr->string_duplicate(PhreeqcPtr->use.solution_ptr->description);
n.UU.sval = PhreeqcPtr->string_duplicate(PhreeqcPtr->use.Get_solution_ptr()->description);
}
else
{
@ -2757,7 +2757,7 @@ factor(struct LOC_exec * LINK)
}
else if (PhreeqcPtr->state == ADVECTION)
{
n.UU.val = (LDBLE) PhreeqcPtr->use.n_solution_user;
n.UU.val = (LDBLE) PhreeqcPtr->use.Get_n_solution_user();
}
else
{
@ -2831,17 +2831,17 @@ factor(struct LOC_exec * LINK)
}
else if (PhreeqcPtr->state < REACTION)
{
n.UU.val = PhreeqcPtr->use.solution_ptr->n_user;
n.UU.val = PhreeqcPtr->use.Get_solution_ptr()->n_user;
}
else
{
if (PhreeqcPtr->use.mix_in == TRUE)
if (PhreeqcPtr->use.Get_mix_in())
{
n.UU.val = PhreeqcPtr->use.n_mix_user;
n.UU.val = PhreeqcPtr->use.Get_n_mix_user();
}
else
{
n.UU.val = PhreeqcPtr->use.n_solution_user;
n.UU.val = PhreeqcPtr->use.Get_n_solution_user();
}
}
if (parse_all) n.UU.val = 1;

View File

@ -479,10 +479,10 @@ void Phreeqc::init(void)
/*
* Initialize use pointers
*/
use.solution_in = FALSE;
use.pp_assemblage_in = FALSE;
use.mix_in = FALSE;
use.reaction_in = FALSE;
//use.Get_solution_in() = FALSE;
//use.Get_pp_assemblage_in() = FALSE;
//use.Get_mix_in() = FALSE;
//use.Get_reaction_in() = FALSE;
/*
* Initialize punch
*/
@ -718,7 +718,7 @@ void Phreeqc::init(void)
/*
* to facilitate debuging
*/
dbg_use = &use;
//dbg_use = &use;
dbg_solution = solution;
//dbg_exchange = exchange;
dbg_surface = surface;

View File

@ -31,6 +31,7 @@
#include "Keywords.h"
#include "Pressure.h"
#include "cxxMix.h"
#include "Use.h"
class cxxNameDouble;
class cxxKinetics;
@ -422,7 +423,7 @@ public:
int do_initialize(void);
int do_status(void);
void save_init(int i);
void use_init(void);
//void use_init(void);
int copy_use(int i);
int set_use(void);
@ -1360,9 +1361,9 @@ protected:
/*----------------------------------------------------------------------
* Use
*---------------------------------------------------------------------- */
struct Use use;
struct Use *dbg_use;
cxxUse use;
//struct Use use;
//struct Use *dbg_use;
/*----------------------------------------------------------------------
* Copy
*---------------------------------------------------------------------- */

View File

@ -1471,28 +1471,28 @@ run_as_cells(void)
*/
dup_print("Beginning of batch-reaction calculations.", TRUE);
count_steps = 1;
if (use.reaction_in == TRUE && use.reaction_ptr != NULL)
if (use.Get_reaction_in() == TRUE && use.Get_reaction_ptr() != NULL)
{
int count = ((cxxReaction *) use.reaction_ptr)->Get_actualSteps();
int count = ((cxxReaction *) use.Get_reaction_ptr())->Get_actualSteps();
if (count > count_steps)
count_steps = count;
}
if (use.kinetics_in == TRUE && use.kinetics_ptr != NULL)
if (use.Get_kinetics_in() == TRUE && use.Get_kinetics_ptr() != NULL)
{
if (abs(use.kinetics_ptr->count_steps) > count_steps)
count_steps = abs(use.kinetics_ptr->count_steps);
if (abs(use.Get_kinetics_ptr()->count_steps) > count_steps)
count_steps = abs(use.Get_kinetics_ptr()->count_steps);
}
if (use.temperature_in == TRUE && use.temperature_ptr != NULL)
if (use.Get_temperature_in() == TRUE && use.Get_temperature_ptr() != NULL)
{
int count = ((cxxTemperature *) use.temperature_ptr)->Get_countTemps();
int count = ((cxxTemperature *) use.Get_temperature_ptr())->Get_countTemps();
if (count > count_steps)
{
count_steps = count;
}
}
if (use.pressure_in == TRUE && use.pressure_ptr != NULL)
if (use.Get_pressure_in() == TRUE && use.Get_pressure_ptr() != NULL)
{
int count = ((cxxPressure *) use.pressure_ptr)->Get_count();
int count = ((cxxPressure *) use.Get_pressure_ptr())->Get_count();
if (count > count_steps)
{
count_steps = count;
@ -1522,7 +1522,7 @@ run_as_cells(void)
* Determine time step for kinetics
*/
kin_time = 0.0;
if (use.kinetics_in == TRUE)
if (use.Get_kinetics_in() == TRUE)
{
// runner kin_time
// equivalent to kin_time in count_steps
@ -1634,9 +1634,9 @@ run_as_cells(void)
* save end of reaction
*/
memcpy(&save, &save_data, sizeof(struct save));
if (use.kinetics_in == TRUE)
if (use.Get_kinetics_in() == TRUE)
{
kinetics_duplicate(-2, use.n_kinetics_user);
kinetics_duplicate(-2, use.Get_n_kinetics_user());
}
saver();
}

View File

@ -30,6 +30,7 @@
#include "Reaction.h"
#include "Temperature.h"
#include "phqalloc.h"
#include "Use.h"
//////////////////////////////////////////////////////////////////////
@ -1418,114 +1419,114 @@ cxxStorageBin::Get_System(void)
}
void
cxxStorageBin::Set_System(struct Use *use_ptr)
cxxStorageBin::Set_System(cxxUse *use_ptr)
{
// Initialize
this->system.Initialize();
// Solution
if (use_ptr->solution_ptr != NULL)
if (use_ptr->Get_solution_ptr() != NULL)
{
std::map < int, cxxSolution >::iterator it =
this->Solutions.find(use_ptr->n_solution_user);
this->Solutions.find(use_ptr->Get_n_solution_user());
if (it != this->Solutions.end())
{
this->system.Set_Solution(&(it->second));
}
}
// Exchange
if (use_ptr->exchange_ptr != NULL)
if (use_ptr->Get_exchange_ptr() != NULL)
{
std::map < int, cxxExchange >::iterator it =
this->Exchangers.find(use_ptr->n_exchange_user);
this->Exchangers.find(use_ptr->Get_n_exchange_user());
if (it != this->Exchangers.end())
{
this->system.Set_Exchange(&(it->second));
}
}
// gas_phase
if (use_ptr->gas_phase_ptr != NULL)
if (use_ptr->Get_gas_phase_ptr() != NULL)
{
std::map < int, cxxGasPhase >::iterator it =
this->GasPhases.find(use_ptr->n_gas_phase_user);
this->GasPhases.find(use_ptr->Get_n_gas_phase_user());
if (it != this->GasPhases.end())
{
this->system.Set_GasPhase(&(it->second));
}
}
// kinetics
if (use_ptr->kinetics_ptr != NULL)
if (use_ptr->Get_kinetics_ptr() != NULL)
{
std::map < int, cxxKinetics >::iterator it =
this->Kinetics.find(use_ptr->n_kinetics_user);
this->Kinetics.find(use_ptr->Get_n_kinetics_user());
if (it != this->Kinetics.end())
{
this->system.Set_Kinetics(&(it->second));
}
}
// pp_assemblage
if (use_ptr->pp_assemblage_ptr != NULL)
if (use_ptr->Get_pp_assemblage_ptr() != NULL)
{
std::map < int, cxxPPassemblage >::iterator it =
this->PPassemblages.find(use_ptr->n_pp_assemblage_user);
this->PPassemblages.find(use_ptr->Get_n_pp_assemblage_user());
if (it != this->PPassemblages.end())
{
this->system.Set_PPassemblage(&(it->second));
}
}
// ss_assemblage
if (use_ptr->ss_assemblage_ptr != NULL)
if (use_ptr->Get_ss_assemblage_ptr() != NULL)
{
std::map < int, cxxSSassemblage >::iterator it =
this->SSassemblages.find(use_ptr->n_ss_assemblage_user);
this->SSassemblages.find(use_ptr->Get_n_ss_assemblage_user());
if (it != this->SSassemblages.end())
{
this->system.Set_SSassemblage(&(it->second));
}
}
// surface
if (use_ptr->surface_ptr != NULL)
if (use_ptr->Get_surface_ptr() != NULL)
{
std::map < int, cxxSurface >::iterator it =
this->Surfaces.find(use_ptr->n_surface_user);
this->Surfaces.find(use_ptr->Get_n_surface_user());
if (it != this->Surfaces.end())
{
this->system.Set_Surface(&(it->second));
}
}
// mix
if (use_ptr->mix_ptr != NULL)
if (use_ptr->Get_mix_ptr() != NULL)
{
std::map < int, cxxMix >::iterator it =
this->Mixes.find(use_ptr->n_mix_user);
this->Mixes.find(use_ptr->Get_n_mix_user());
if (it != this->Mixes.end())
{
this->system.Set_Mix(&(it->second));
}
}
// reaction
if (use_ptr->reaction_ptr != NULL)
if (use_ptr->Get_reaction_ptr() != NULL)
{
std::map < int, cxxReaction >::iterator it =
this->Reactions.find(use_ptr->n_reaction_user);
this->Reactions.find(use_ptr->Get_n_reaction_user());
if (it != this->Reactions.end())
{
this->system.Set_Reaction(&(it->second));
}
}
// reaction temperature
if (use_ptr->temperature_ptr != NULL)
if (use_ptr->Get_temperature_ptr() != NULL)
{
std::map < int, cxxTemperature >::iterator it =
this->Temperatures.find(use_ptr->n_temperature_user);
this->Temperatures.find(use_ptr->Get_n_temperature_user());
if (it != this->Temperatures.end())
{
this->system.Set_Temperature(&(it->second));
}
}
// reaction pressure
if (use_ptr->pressure_ptr != NULL)
if (use_ptr->Get_pressure_ptr() != NULL)
{
cxxPressure * p = Utilities::Rxn_find(this->Pressures, use_ptr->n_pressure_user);
cxxPressure * p = Utilities::Rxn_find(this->Pressures, use_ptr->Get_n_pressure_user());
if (p != NULL)
{
this->system.Set_Pressure(p);

View File

@ -18,6 +18,7 @@ class cxxSSassemblage;
class cxxSurface;
class cxxReaction;
class cxxTemperature;
class cxxUse;
class cxxStorageBin: public PHRQ_base
{
@ -77,7 +78,7 @@ class cxxStorageBin: public PHRQ_base
void Remove_Pressure(int n_user);
cxxSystem &Get_System(void);
void Set_System(struct Use *use_ptr);
void Set_System(cxxUse *use_ptr);
void Set_System(int i);
void dump_raw(std::ostream & s_oss, unsigned int indent) const;

18
Use.cpp
View File

@ -1,7 +1,18 @@
#include <stdio.h>
#include "Use.h"
Use::Use()
cxxUse::cxxUse()
{
this->init();
}
cxxUse::~cxxUse(void)
{
}
void cxxUse::
init(void)
{
solution_in = false;
n_solution_user = -999;
@ -59,11 +70,6 @@ Use::Use()
trans_in = false;
advect_in = false;
}
Use::~Use(void)
{
}

27
Use.h
View File

@ -8,11 +8,12 @@ class cxxGasPhase;
class cxxPressure;
class cxxTemperature;
class Use
class cxxUse
{
public:
Use();
virtual ~Use(void);
cxxUse();
virtual ~cxxUse(void);
void init(void);
bool Get_solution_in(void) const {return this->solution_in;}
bool Get_pp_assemblage_in(void) const {return this->pp_assemblage_in;}
@ -26,6 +27,8 @@ public:
bool Get_gas_phase_in(void) const {return this->gas_phase_in;}
bool Get_inverse_in(void) const {return this->inverse_in;}
bool Get_ss_assemblage_in(void) const {return this->ss_assemblage_in;}
bool Get_advect_in(void) const {return this->advect_in;}
bool Get_trans_in(void) const {return this->trans_in;}
void Set_solution_in(bool tf) {solution_in = tf;}
void Set_pp_assemblage_in(bool tf) {pp_assemblage_in = tf;}
@ -39,10 +42,13 @@ public:
void Set_gas_phase_in(bool tf) {gas_phase_in = tf;}
void Set_inverse_in(bool tf) {inverse_in = tf;}
void Set_ss_assemblage_in(bool tf) {ss_assemblage_in = tf;}
void Set_advect_in(bool tf) {advect_in = tf;}
void Set_trans_in(bool tf) {trans_in = tf;}
int Get_n_solution_user(void) const {return n_solution_user;}
int Get_n_pp_assemblage_user(void) const {return n_pp_assemblage_user;}
int Get_n_mix_user(void) const {return n_mix_user;}
int Get_n_mix_user_orig(void) const {return n_mix_user_orig;}
int Get_n_reaction_user(void) const {return n_reaction_user;}
int Get_n_exchange_user(void) const {return n_exchange_user;}
int Get_n_kinetics_user(void) const {return n_kinetics_user;}
@ -56,6 +62,7 @@ public:
void Set_n_solution_user(int i) {n_solution_user = i;}
void Set_n_pp_assemblage_user(int i) {n_pp_assemblage_user = i;}
void Set_n_mix_user(int i) {n_mix_user = i;}
void Set_n_mix_user_orig(int i) {n_mix_user = i;}
void Set_n_reaction_user(int i) {n_reaction_user = i;}
void Set_n_exchange_user(int i) {n_exchange_user = i;}
void Set_n_kinetics_user(int i) {n_kinetics_user = i;}
@ -65,7 +72,7 @@ public:
void Set_n_gas_phase_user(int i) {n_gas_phase_user = i;}
void Set_n_inverse_user(int i) {n_inverse_user = i;}
void Set_n_ss_assemblage_user(int i) {n_ss_assemblage_user = i;}
#ifdef SKIP
int Get_n_solution(void) const {return n_solution;}
//int Get_n_mix(void) const {return n_mix;}
int Get_n_kinetics(void) const {return n_kinetics;}
@ -79,7 +86,7 @@ public:
void Set_n_surface(int i) {n_surface = i;}
void Set_n_inverse(int i) {n_inverse = i;}
void Set_n_ss_assemblage(int i) {n_ss_assemblage = i;}
#endif
struct solution * Get_solution_ptr(void) const {return this->solution_ptr;}
cxxPPassemblage * Get_pp_assemblage_ptr(void) const {return this->pp_assemblage_ptr;}
cxxMix * Get_mix_ptr(void) const {return this->mix_ptr;}
@ -109,7 +116,7 @@ public:
protected:
bool solution_in;
int n_solution_user;
int n_solution;
//int n_solution;
struct solution *solution_ptr;
bool pp_assemblage_in;
@ -132,12 +139,12 @@ protected:
bool kinetics_in;
int n_kinetics_user;
int n_kinetics;
//int n_kinetics;
struct kinetics *kinetics_ptr;
bool surface_in;
int n_surface_user;
int n_surface;
//int n_surface;
struct surface *surface_ptr;
bool pressure_in;
@ -150,7 +157,7 @@ protected:
bool inverse_in;
int n_inverse_user;
int n_inverse;
//int n_inverse;
struct inverse *inverse_ptr;
bool gas_phase_in;
@ -159,7 +166,7 @@ protected:
bool ss_assemblage_in;
int n_ss_assemblage_user;
int n_ss_assemblage;
//int n_ss_assemblage;
struct ss_assemblage *ss_assemblage_ptr;
bool trans_in;