mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
Working through using C++ structures in transport git-svn-id: svn://136.177.114.72/svn_GW/phreeqcpp/trunk@855 1feff8c3-07ed-0310-ac33-dd36852eb9cd
79 lines
3.1 KiB
C++
79 lines
3.1 KiB
C++
#include "Utils.h" // define first
|
|
#include "SolutionIsotopeList.h"
|
|
#define EXTERNAL extern
|
|
#include "global.h"
|
|
#include "phqalloc.h"
|
|
#include "phrqproto.h"
|
|
#include <cassert> // assert
|
|
#include <algorithm> // std::sort
|
|
|
|
cxxSolutionIsotopeList::cxxSolutionIsotopeList(void)
|
|
//
|
|
// default constructor for cxxSolution
|
|
//
|
|
{
|
|
}
|
|
|
|
cxxSolutionIsotopeList::cxxSolutionIsotopeList(struct solution *solution_ptr)
|
|
{
|
|
int i;
|
|
// Isotopes
|
|
for (i = 0; i < solution_ptr->count_isotopes; i++) {
|
|
//cxxSolutionIsotope iso(&solution_ptr->isotopes[i]);
|
|
(*this).push_back(&solution_ptr->isotopes[i]);
|
|
}
|
|
}
|
|
void cxxSolutionIsotopeList::add(cxxSolutionIsotopeList old, double intensive, double extensive)
|
|
{
|
|
|
|
for (cxxSolutionIsotopeList::const_iterator itold = old.begin(); itold != old.end(); ++itold) {
|
|
|
|
//for (std::list <cxxSolutionIsotope>::const_iterator itold = old.isotopes.begin(); itold != old.isotopes.end(); ++itold) {
|
|
bool found = false;
|
|
for (cxxSolutionIsotopeList::iterator it = this->begin(); it != this->end(); ++it) {
|
|
//for (std::list <cxxSolutionIsotope>::iterator it = this->isotopes.begin(); it != this->isotopes.end(); ++it) {
|
|
if ((it->isotope_number == itold->isotope_number) &&
|
|
(it->elt_name == itold->elt_name) &&
|
|
(it->isotope_name == itold->isotope_name)) {
|
|
it->total += itold->total * extensive;
|
|
it->ratio += itold->ratio * intensive;
|
|
it->ratio_uncertainty += itold->ratio_uncertainty * intensive;
|
|
it->ratio_uncertainty_defined = (it->ratio_uncertainty_defined || itold->ratio_uncertainty_defined);
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!found) {
|
|
cxxSolutionIsotope iso;
|
|
iso.total = itold->total * extensive;
|
|
iso.ratio = itold->ratio * intensive;
|
|
iso.ratio_uncertainty = itold->ratio_uncertainty * intensive;
|
|
iso.ratio_uncertainty_defined = itold->ratio_uncertainty_defined;
|
|
this->push_back(iso);
|
|
}
|
|
}
|
|
}
|
|
struct isotope * cxxSolutionIsotopeList::cxxSolutionIsotopeList2isotope()
|
|
{
|
|
struct isotope *iso;
|
|
if (this->size() <= 0) {
|
|
return NULL;
|
|
} else {
|
|
iso = (struct isotope *) PHRQ_malloc((size_t) ((this->size()) * sizeof(struct isotope)));
|
|
if (iso == NULL) malloc_error();
|
|
int i = 0;
|
|
for (cxxSolutionIsotopeList::iterator it = this->begin(); it != this->end(); ++it) {
|
|
iso[i].isotope_number = it->isotope_number;
|
|
iso[i].elt_name = it->elt_name;
|
|
iso[i].total = it->total;
|
|
iso[i].ratio = it->ratio;
|
|
iso[i].ratio_uncertainty = it->ratio_uncertainty;
|
|
iso[i].master = it->master();
|
|
iso[i].primary = it->primary();
|
|
i++;
|
|
}
|
|
}
|
|
return(iso);
|
|
}
|
|
|