diff --git a/ChemistryLib/PhreeqcIO.cpp b/ChemistryLib/PhreeqcIO.cpp index 8fc0d98c4436706f76da3ddbf6fb84515b9023bd..349820eeabcd8745cdafd10c4927014fd2adea6a 100644 --- a/ChemistryLib/PhreeqcIO.cpp +++ b/ChemistryLib/PhreeqcIO.cpp @@ -262,6 +262,9 @@ static double averageReactantMolality( } } // namespace +extern std::string specifyFileName(std::string const& project_file_name, + std::string const& file_extension); + PhreeqcIO::PhreeqcIO(MeshLib::Mesh const& mesh, GlobalLinearSolver& linear_solver, std::string const& project_file_name, @@ -273,7 +276,7 @@ PhreeqcIO::PhreeqcIO(MeshLib::Mesh const& mesh, std::unique_ptr<Dump>&& dump, Knobs&& knobs) : ChemicalSolverInterface(mesh, linear_solver), - _phreeqc_input_file(project_file_name + "_phreeqc.inp"), + _phreeqc_input_file(specifyFileName(project_file_name, ".inp")), _database(std::move(database)), _chemical_system(std::move(chemical_system)), _reaction_rates(std::move(reaction_rates)), diff --git a/ChemistryLib/PhreeqcIOData/Dump.h b/ChemistryLib/PhreeqcIOData/Dump.h index 55e3b60aede98785ce7564f775ba4e3853ec5907..d79a89bb759a585ec81f4d9f1307854d670b03f2 100644 --- a/ChemistryLib/PhreeqcIOData/Dump.h +++ b/ChemistryLib/PhreeqcIOData/Dump.h @@ -21,10 +21,13 @@ namespace ChemistryLib { namespace PhreeqcIOData { +extern std::string specifyFileName(std::string const& project_file_name, + std::string const& file_extension); + struct Dump { explicit Dump(std::string const& project_file_name) - : dump_file(project_file_name + ".dmp") + : dump_file(specifyFileName(project_file_name, ".dmp")) { try { diff --git a/ChemistryLib/PhreeqcIOData/Output.cpp b/ChemistryLib/PhreeqcIOData/Output.cpp index 4e2928c41ebaf0a3669199f237e915936f77999a..59d5bc96a22bafe6dc90d677c54d4b7a6611c9a0 100644 --- a/ChemistryLib/PhreeqcIOData/Output.cpp +++ b/ChemistryLib/PhreeqcIOData/Output.cpp @@ -12,10 +12,35 @@ #include <ostream> +#ifdef USE_PETSC +#include <mpi.h> +#endif + namespace ChemistryLib { namespace PhreeqcIOData { +std::string specifyFileName(std::string const& project_file_name, + std::string const& file_extension) +{ +#ifdef USE_PETSC + int mpi_rank; + + MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank); + return project_file_name + "_phreeqc_pid_" + std::to_string(mpi_rank) + + file_extension; +#endif + + return project_file_name + "_phreeqc" + file_extension; +} + +BasicOutputSetups::BasicOutputSetups(std::string const& project_file_name, + bool const use_high_precision_) + : output_file(specifyFileName(project_file_name, ".out")), + use_high_precision(use_high_precision_) +{ +} + std::ostream& operator<<(std::ostream& os, BasicOutputSetups const& basic_output_setups) { diff --git a/ChemistryLib/PhreeqcIOData/Output.h b/ChemistryLib/PhreeqcIOData/Output.h index 1f270a943eb3c16e3d83a3401be772535453cf06..99a264511b1c39fa8a7a23088b63bbc2519e9a07 100644 --- a/ChemistryLib/PhreeqcIOData/Output.h +++ b/ChemistryLib/PhreeqcIOData/Output.h @@ -24,11 +24,7 @@ class BasicOutputSetups { public: explicit BasicOutputSetups(std::string const& project_file_name, - bool const use_high_precision_) - : output_file(project_file_name + "_phreeqc.out"), - use_high_precision(use_high_precision_) - { - } + bool const use_high_precision_); static int getNumberOfItemsInDisplay() {