mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
list_components method to extract complete list of elements in all solutions, equilibrium_phases, etc that are currently defined within the object.
git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@4171 1feff8c3-07ed-0310-ac33-dd36852eb9cd
This commit is contained in:
parent
a22a6db097
commit
4eb0dbc99b
@ -33,6 +33,10 @@ class cxxPPassemblage:public cxxNumKeyword
|
||||
{
|
||||
return this->totals;
|
||||
};
|
||||
const cxxNameDouble & get_eltList() const
|
||||
{
|
||||
return this->eltList;
|
||||
};
|
||||
|
||||
#ifdef USE_MPI
|
||||
void mpi_pack(std::vector < int >&ints, std::vector < double >&doubles);
|
||||
|
||||
@ -1423,7 +1423,7 @@ virtual int EndRow(void);
|
||||
public: // public methods for PHREEQC_CLASS
|
||||
int main_method(int argc, char *argv[]);
|
||||
void set_phast(int);
|
||||
|
||||
size_t list_components(std::list<std::string> &list_c);
|
||||
};
|
||||
#endif /* _INC_PHREEQC_H */
|
||||
|
||||
|
||||
@ -25,6 +25,10 @@ class cxxReaction:public cxxNumKeyword
|
||||
void dump_raw(std::ostream & s_oss, unsigned int indent) const;
|
||||
|
||||
void read_raw(PHREEQC_PTR_ARG_COMMA CParser & parser);
|
||||
cxxNameDouble &get_elementList(void)
|
||||
{
|
||||
return this->elementList;
|
||||
}
|
||||
|
||||
void set_units(const char * s)
|
||||
{
|
||||
|
||||
105
class_main.cpp
105
class_main.cpp
@ -2,6 +2,15 @@
|
||||
#include "output.h"
|
||||
#include "phrqproto.h"
|
||||
#include "input.h"
|
||||
#include "NameDouble.h"
|
||||
#include "Solution.h"
|
||||
#include "Reaction.h"
|
||||
#include "PPassemblage.h"
|
||||
#include "Exchange.h"
|
||||
#include "Surface.h"
|
||||
#include "GasPhase.h"
|
||||
#include "SSassemblage.h"
|
||||
#include "cxxKinetics.h"
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -37,7 +46,14 @@ main(int argc, char *argv[])
|
||||
|
||||
Phreeqc phreeqc_instance;
|
||||
phreeqc_instance.main_method(argc, argv);
|
||||
|
||||
std::list<std::string> components;
|
||||
phreeqc_instance.list_components(components);
|
||||
std::list<std::string>::iterator it;
|
||||
std::cout << "Number of components: " << components.size() << std::endl;
|
||||
for (it = components.begin(); it != components.end(); it++)
|
||||
{
|
||||
std::cout << " " << *it << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -188,3 +204,90 @@ write_banner(void)
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
size_t CLASS_QUALIFIER
|
||||
list_components(std::list<std::string> &list_c)
|
||||
/*
|
||||
* Find all elements in any class definition
|
||||
*/
|
||||
{
|
||||
cxxNameDouble accumulator;
|
||||
accumulator.add("H", 1);
|
||||
accumulator.add("O", 1);
|
||||
|
||||
int i;
|
||||
|
||||
// solutions
|
||||
for (i = 0; i < count_solution; i++)
|
||||
{
|
||||
cxxSolution entity(solution[i]);
|
||||
accumulator.add_extensive(entity.get_totals(), 1.0);
|
||||
}
|
||||
|
||||
// irreversible reactions
|
||||
for (i = 0; i < count_irrev; i++)
|
||||
{
|
||||
reaction_calc(&irrev[i]);
|
||||
cxxReaction entity(&irrev[i]);
|
||||
accumulator.add_extensive(entity.get_elementList(), 1.0);
|
||||
}
|
||||
|
||||
// pure phases
|
||||
for (i = 0; i < count_pp_assemblage; i++)
|
||||
{
|
||||
cxxPPassemblage entity(&pp_assemblage[i]);
|
||||
entity.totalize(this);
|
||||
accumulator.add_extensive(entity.get_totals(), 1.0);
|
||||
}
|
||||
|
||||
// exchangers
|
||||
for (i = 0; i < count_exchange; i++)
|
||||
{
|
||||
cxxExchange entity(&exchange[i]);
|
||||
entity.totalize();
|
||||
accumulator.add_extensive(entity.get_totals(), 1.0);
|
||||
}
|
||||
|
||||
// surfaces
|
||||
for (i = 0; i < count_surface; i++)
|
||||
{
|
||||
cxxSurface entity(&surface[i]);
|
||||
entity.totalize();
|
||||
accumulator.add_extensive(entity.get_totals(), 1.0);
|
||||
}
|
||||
|
||||
// gas phases
|
||||
for (i = 0; i < count_gas_phase; i++)
|
||||
{
|
||||
cxxGasPhase entity(&gas_phase[i]);
|
||||
entity.totalize(this);
|
||||
accumulator.add_extensive(entity.get_totals(), 1.0);
|
||||
}
|
||||
|
||||
// solid-solutions
|
||||
for (i = 0; i < count_s_s_assemblage; i++)
|
||||
{
|
||||
cxxSSassemblage entity(&s_s_assemblage[i]);
|
||||
entity.totalize(this);
|
||||
accumulator.add_extensive(entity.get_totals(), 1.0);
|
||||
}
|
||||
|
||||
// kinetics
|
||||
for (i = 0; i < count_kinetics; i++)
|
||||
{
|
||||
calc_dummy_kinetic_reaction_tally(&kinetics[i]);
|
||||
cxxKinetics entity(&kinetics[i]);
|
||||
accumulator.add_extensive(entity.get_totals(), 1.0);
|
||||
}
|
||||
|
||||
// print list
|
||||
cxxNameDouble::iterator it;
|
||||
for (it = accumulator.begin(); it != accumulator.end(); it++)
|
||||
{
|
||||
struct master *master_ptr = master_bsearch(it->first.c_str());
|
||||
if (master_ptr == NULL) continue;
|
||||
if (master_ptr->type != AQ) continue;
|
||||
if (master_ptr->primary == 0) continue;
|
||||
list_c.push_back(it->first);
|
||||
}
|
||||
return(accumulator.size());
|
||||
}
|
||||
@ -737,3 +737,7 @@ cxxKinetics::add(const cxxKinetics & addee, double extensive)
|
||||
this->cvode_steps = addee.cvode_steps;
|
||||
this->cvode_order = addee.cvode_order;
|
||||
}
|
||||
//cxxNameDouble & cxxKinetics::get_totals(void)
|
||||
//{
|
||||
// return this->totals;
|
||||
//}
|
||||
@ -35,6 +35,10 @@ class cxxKinetics:public cxxNumKeyword
|
||||
|
||||
bool get_related_rate(void);
|
||||
|
||||
cxxNameDouble & get_totals(void)
|
||||
{
|
||||
return this->totals;
|
||||
}
|
||||
#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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user