4 #if !defined(PHREEQCRM_H_INCLUDED)
5 #define PHREEQCRM_H_INCLUDED
8 #define MP_TYPE MPI_Comm
16 #include "NameDouble.h"
26 #define IRM_DLL_EXPORT __declspec(dllexport)
28 #define IRM_DLL_EXPORT
42 const char *what()
const throw () {
return "Failure in PhreeqcRM\n";}
51 METHOD_FINDCOMPONENTS,
52 METHOD_GETCONCENTRATIONS,
54 METHOD_GETERRORSTRING,
57 METHOD_GETSELECTEDOUTPUT,
58 METHOD_GETSOLUTIONVOLUME,
59 METHOD_GETSPECIESCONCENTRATIONS,
60 METHOD_GETTEMPERATURE,
61 METHOD_INITIALPHREEQC2MODULE,
62 METHOD_INITIALPHREEQCCELL2MODULE,
64 METHOD_MPIWORKERBREAK,
68 METHOD_SETCOMPONENTH2O,
69 METHOD_SETCONCENTRATIONS,
71 METHOD_SETERRORHANDLERMODE,
73 METHOD_SETPARTITIONUZSOLIDS,
76 METHOD_SETPRINTCHEMISTRYON,
77 METHOD_SETPRINTCHEMISTRYMASK,
78 METHOD_SETREBALANCEBYCELL,
79 METHOD_SETREBALANCEFRACTION,
80 METHOD_SETREPRESENTATIVEVOLUME,
82 METHOD_SETSELECTEDOUTPUTON,
83 METHOD_SETSPECIESSAVEON,
84 METHOD_SETTEMPERATURE,
86 METHOD_SETTIMECONVERSION,
88 METHOD_SETUNITSEXCHANGE,
89 METHOD_SETUNITSGASPHASE,
90 METHOD_SETUNITSKINETICS,
91 METHOD_SETUNITSPPASSEMBLAGE,
92 METHOD_SETUNITSSOLUTION,
93 METHOD_SETUNITSSSASSEMBLAGE,
94 METHOD_SETUNITSSURFACE,
95 METHOD_SPECIESCONCENTRATIONS2MODULE,
96 METHOD_USESOLUTIONDENSITYVOLUME
122 static void CleanupReactionModuleInstances(
void);
123 static int CreateReactionModule(
int nxyz, MP_TYPE nthreads);
124 static IRM_RESULT DestroyReactionModule(
int n);
167 PhreeqcRM(
int nxyz, MP_TYPE thread_count_or_communicator, PHRQ_io * io=NULL);
231 IPhreeqc * Concentrations2Utility(std::vector<double> &c,
232 std::vector<double> tc, std::vector<double> p_atm);
268 IRM_RESULT CreateMapping(std::vector<int> &grid2chem);
302 void DecodeError(
int result);
324 IRM_RESULT DumpModule(
bool dump_on,
bool append =
false);
347 void ErrorHandler(
int result,
const std::string &e_string);
364 void ErrorMessage(
const std::string &error_string,
bool prepend =
true);
415 int FindComponents();
509 const std::vector<std::string> &
GetComponents(
void)
const {
return this->components;}
548 IRM_RESULT GetConcentrations(std::vector<double> &c);
591 IRM_RESULT GetDensity(std::vector<double> & density);
627 const std::vector < int> &
GetEndCell(
void)
const {
return this->end_cell;}
667 std::string GetErrorString(
void);
733 const std::vector < double > &
GetGfw(
void) {
return this->gfw;}
782 IPhreeqc * GetIPhreeqcPointer(
int i);
871 int GetNthSelectedOutputUserNumber(
int n);
926 std::vector<double> & GetPoreVolume(
void) {
return this->pore_volume;}
949 const std::vector<double> & GetPressure(
void);
1079 IRM_RESULT GetSaturation(std::vector<double> & sat);
1111 IRM_RESULT GetSelectedOutput(std::vector<double> &so);
1150 int GetSelectedOutputColumnCount(
void);
1177 int GetSelectedOutputCount(
void);
1214 IRM_RESULT GetSelectedOutputHeading(
int icol, std::string &heading);
1273 int GetSelectedOutputRowCount(
void);
1294 const std::vector<double> & GetSolutionVolume(
void);
1338 IRM_RESULT GetSpeciesConcentrations(std::vector<double> & species_conc);
1548 const std::vector<double> &
GetSpeciesZ(
void) {
return this->species_z;}
1583 const std::vector < int> &
GetStartCell(
void)
const {
return this->start_cell;}
1605 const std::vector<double> & GetTemperature(
void);
1925 const std::vector<IPhreeqcPhast *> &
GetWorkers() {
return this->workers;}
1954 std::vector < double > & destination_c,
1955 std::vector < int > & boundary_solution1);
1995 std::vector < double > & destination_c,
1996 std::vector < int > & boundary_solution1,
1997 std::vector < int > & boundary_solution2,
1998 std::vector < double > & fraction1);
2039 IRM_RESULT InitialPhreeqc2Module(std::vector < int > & initial_conditions1);
2103 std::vector < int > & initial_conditions1,
2104 std::vector < int > & initial_conditions2,
2105 std::vector < double > & fraction1);
2135 IRM_RESULT InitialPhreeqc2SpeciesConcentrations(
2136 std::vector < double > & destination_c,
2137 std::vector < int > & boundary_solution1);
2177 IRM_RESULT InitialPhreeqc2SpeciesConcentrations(
2178 std::vector < double > & destination_c,
2179 std::vector < int > & boundary_solution1,
2180 std::vector < int > & boundary_solution2,
2181 std::vector < double > & fraction1);
2208 IRM_RESULT InitialPhreeqcCell2Module(
int n,
const std::vector<int> &cell_numbers);
2225 IRM_RESULT LoadDatabase(
const std::string &database);
2244 void LogMessage(
const std::string &str);
2372 void OutputMessage(
const std::string &str);
2451 IRM_RESULT RunFile(
bool workers,
bool initial_phreeqc,
bool utility,
const std::string & chemistry_name);
2478 IRM_RESULT RunString(
bool workers,
bool initial_phreeqc,
bool utility,
const std::string & input_string);
2501 void ScreenMessage(
const std::string &str);
2568 IRM_RESULT SetConcentrations(
const std::vector<double> &c);
2600 IRM_RESULT SetCurrentSelectedOutputUserNumber(
int n_user);
2625 IRM_RESULT SetDensity(
const std::vector<double> &density);
2645 IRM_RESULT SetDumpFileName(
const std::string & dump_name);
2685 IRM_RESULT SetFilePrefix(
const std::string & prefix);
2781 IRM_RESULT SetMpiWorkerCallbackC(
int (*fcn)(
int *method,
void * cookie));
2852 IRM_RESULT SetMpiWorkerCallbackCookie(
void * cookie);
2857 IRM_RESULT SetMpiWorkerCallbackFortran(
int (*fcn)(
int *method));
2916 IRM_RESULT SetPorosity(
const std::vector<double> &por);
2938 IRM_RESULT SetPressure(
const std::vector<double> &p);
2965 IRM_RESULT SetPrintChemistryMask(std::vector<int> & cell_mask);
3000 IRM_RESULT SetPrintChemistryOn(
bool workers,
bool initial_phreeqc,
bool utility);
3086 IRM_RESULT SetRepresentativeVolume(
const std::vector<double> &rv);
3115 IRM_RESULT SetSaturation(
const std::vector<double> &sat);
3217 IRM_RESULT SetTemperature(
const std::vector<double> &t);
3254 IRM_RESULT SetTimeConversion(
double conv_factor);
3586 IRM_RESULT SpeciesConcentrations2Module(std::vector<double> & species_conc);
3622 void UseSolutionDensityVolume(
bool tf);
3639 void WarningMessage(
const std::string &warnstr);
3642 static std::string Char2TrimString(
const char * str,
size_t l = 0);
3643 static bool FileExists(
const std::string &name);
3644 static void FileRename(
const std::string &temp_name,
const std::string &name,
3645 const std::string &backup_name);
3646 static IRM_RESULT Int2IrmResult(
int r,
bool positive_ok);
3651 int *initial_conditions1,
3652 int *initial_conditions2,
3654 std::set<std::string> &error_set);
3656 int CheckSelectedOutput();
3659 IPhreeqc * Concentrations2UtilityH2O(std::vector<double> &c_in,
3660 std::vector<double> &t_in, std::vector<double> &p_in);
3661 IPhreeqc * Concentrations2UtilityNoH2O(std::vector<double> &c_in,
3662 std::vector<double> &t_in, std::vector<double> &p_in);
3663 void Concentrations2Solutions(
int n, std::vector<double> &c);
3664 void Concentrations2SolutionsH2O(
int n, std::vector<double> &c);
3665 void Concentrations2SolutionsNoH2O(
int n, std::vector<double> &c);
3666 void cxxSolution2concentration(cxxSolution * cxxsoln_ptr, std::vector<double> & d,
double v,
double dens);
3667 void cxxSolution2concentrationH2O(cxxSolution * cxxsoln_ptr, std::vector<double> & d,
double v,
double dens);
3668 void cxxSolution2concentrationNoH2O(cxxSolution * cxxsoln_ptr, std::vector<double> & d,
double v,
double dens);
3669 void GatherNchem(std::vector<double> &source, std::vector<double> &destination);
3670 cxxStorageBin & Get_phreeqc_bin(
void) {
return *this->phreeqc_bin;}
3671 IRM_RESULT HandleErrorsInternal(std::vector< int > & r);
3672 void PartitionUZ(
int n,
int iphrq,
int ihst,
double new_frac);
3673 void RebalanceLoad(
void);
3674 void RebalanceLoadPerCell(
void);
3677 IRM_RESULT RunStringThread(
int n, std::string & input);
3679 void Scale_solids(
int n,
int iphrq,
double frac);
3680 void ScatterNchem(
double *d_array);
3681 void ScatterNchem(
int *i_array);
3682 void ScatterNchem(std::vector<double> &source, std::vector<double> &destination);
3683 void ScatterNchem(std::vector<int> &source, std::vector<int> &destination);
3684 IRM_RESULT SetChemistryFileName(
const char * prefix = NULL);
3685 IRM_RESULT SetDatabaseFileName(
const char * db = NULL);
3686 void SetEndCells(
void);
3687 void SetEndCellsHeterogeneous(
void);
3688 double TimeStandardTask(
void);
3689 IRM_RESULT TransferCells(cxxStorageBin &t_bin,
int old,
int nnew);
3690 IRM_RESULT TransferCellsUZ(std::ostringstream &raw_stream,
int old,
int nnew);
3694 IRM_RESULT SetGeneric(
const std::vector<double> &source, std::vector<double> &destination_root, std::vector<double> &destination_worker,
int mpiMethod,
const std::string &name);
3697 #if defined(_MSC_VER)
3699 #pragma warning(disable:4251)
3704 std::string database_file_name;
3705 std::string chemistry_file_name;
3706 std::string dump_file_name;
3707 std::string file_prefix;
3708 cxxStorageBin * phreeqc_bin;
3711 std::vector <std::string> components;
3712 std::vector <double> gfw;
3714 bool partition_uz_solids;
3716 int count_chemistry;
3719 double time_conversion;
3720 std::vector <double> old_saturation_root;
3721 std::vector <double> old_saturation_worker;
3722 std::vector<double> saturation_root;
3723 std::vector<double> saturation_worker;
3724 std::vector<double> pressure_root;
3725 std::vector<double> pressure_worker;
3726 std::vector<double> rv_root;
3727 std::vector<double> rv_worker;
3728 std::vector<double> porosity_root;
3729 std::vector<double> porosity_worker;
3730 std::vector<double> tempc_root;
3731 std::vector<double> tempc_worker;
3732 std::vector<double> density_root;
3733 std::vector<double> density_worker;
3734 std::vector<double> solution_volume_root;
3735 std::vector<double> solution_volume_worker;
3736 std::vector<int> print_chem_mask_root;
3737 std::vector<int> print_chem_mask_worker;
3738 bool rebalance_by_cell;
3739 double rebalance_fraction;
3741 int units_PPassemblage;
3745 int units_SSassemblage;
3747 std::vector <int> forward_mapping_root;
3748 std::vector <std::vector <int> > backward_mapping;
3749 bool use_solution_density_volume;
3752 std::vector<bool> print_chemistry_on;
3753 bool selected_output_on;
3756 int error_handler_mode;
3757 bool need_error_check;
3758 std::string phreeqcrm_error_string;
3762 std::vector<IPhreeqcPhast *> workers;
3763 std::vector<int> start_cell;
3764 std::vector<int> end_cell;
3765 PHRQ_io *phreeqcrm_io;
3766 bool delete_phreeqcrm_io;
3770 MPI_Comm phreeqcrm_comm;
3772 int (*mpi_worker_callback_fortran) (
int *method);
3773 int (*mpi_worker_callback_c) (
int *method,
void *cookie);
3774 void *mpi_worker_callback_cookie;
3777 bool species_save_on;
3778 std::vector <std::string> species_names;
3779 std::vector <double> species_z;
3780 std::vector <double> species_d_25;
3781 std::vector <cxxNameDouble> species_stoichiometry;
3782 std::map<int, int> s_num2rm_species_num;
3783 std::vector<double> standard_task_vector;
3787 static std::map<size_t, PhreeqcRM*> Instances;
3788 static size_t InstancesIndex;
3790 #if defined(_MSC_VER)
3792 #pragma warning(default:4251)
3796 #endif // !defined(PHREEQCRM_H_INCLUDED)
int GetUnitsExchange(void)
Definition: PhreeqcRM.h:1723
const std::vector< std::vector< int > > & GetBackwardMapping(void)
Definition: PhreeqcRM.h:441
int GetUnitsGasPhase(void)
Definition: PhreeqcRM.h:1748
int GetUnitsSurface(void)
Definition: PhreeqcRM.h:1902
int GetGridCellCount(void)
Definition: PhreeqcRM.h:755
std::string GetFilePrefix(void)
Definition: PhreeqcRM.h:685
int GetChemistryCellCount(void) const
Definition: PhreeqcRM.h:464
int GetUnitsSolution(void)
Definition: PhreeqcRM.h:1852
const std::vector< double > & GetSpeciesZ(void)
Definition: PhreeqcRM.h:1548
bool GetSelectedOutputOn(void)
Definition: PhreeqcRM.h:1233
const std::vector< std::string > & GetSpeciesNames(void)
Definition: PhreeqcRM.h:1433
Geochemical reaction module.
Definition: PhreeqcRM.h:119
std::string GetDatabaseFileName(void)
Definition: PhreeqcRM.h:566
int GetUnitsSSassemblage(void)
Definition: PhreeqcRM.h:1877
double GetTimeStep(void)
Definition: PhreeqcRM.h:1698
int GetErrorHandlerMode(void)
Definition: PhreeqcRM.h:648
int GetSpeciesCount(void)
Definition: PhreeqcRM.h:1368
const std::vector< int > & GetForwardMapping(void)
Definition: PhreeqcRM.h:706
const std::vector< int > & GetStartCell(void) const
Definition: PhreeqcRM.h:1583
double GetRebalanceFraction(void) const
Definition: PhreeqcRM.h:1048
This class is derived from std::exception and is thrown when an unrecoverable error has occured...
Definition: PhreeqcRM.h:39
const std::vector< double > & GetSpeciesD25(void)
Definition: PhreeqcRM.h:1401
const std::vector< int > & GetPrintChemistryMask(void)
Definition: PhreeqcRM.h:970
int GetMpiMyself(void) const
Definition: PhreeqcRM.h:807
bool GetSpeciesSaveOn(void)
Definition: PhreeqcRM.h:1469
const std::vector< double > & GetGfw(void)
Definition: PhreeqcRM.h:733
double GetTime(void) const
Definition: PhreeqcRM.h:1649
IRM_RESULT
Enumeration for PhreeqcRM function return codes.
Definition: IrmResult.h:8
const std::vector< int > & GetEndCell(void) const
Definition: PhreeqcRM.h:627
const std::vector< std::string > & GetComponents(void) const
Definition: PhreeqcRM.h:509
int GetComponentCount(void) const
Definition: PhreeqcRM.h:484
int GetUnitsPPassemblage(void)
Definition: PhreeqcRM.h:1798
double GetTimeConversion(void)
Definition: PhreeqcRM.h:1674
Enumeration used to return error codes.
bool GetRebalanceByCell(void) const
Definition: PhreeqcRM.h:1023
const std::vector< bool > & GetPrintChemistryOn(void) const
Definition: PhreeqcRM.h:999
const std::vector< IPhreeqcPhast * > & GetWorkers()
Definition: PhreeqcRM.h:1925
int GetThreadCount()
Definition: PhreeqcRM.h:1626
const std::vector< cxxNameDouble > & GetSpeciesStoichiometry(void)
Definition: PhreeqcRM.h:1518
int GetMpiTasks(void) const
Definition: PhreeqcRM.h:833
int GetUnitsKinetics(void)
Definition: PhreeqcRM.h:1773
bool GetPartitionUZSolids(void) const
Definition: PhreeqcRM.h:904