13 #include <phreeqcpp/cxxKinetics.h>
46 auto path_to_database =
51 OGS_FATAL(
"Not found the specified thermodynamicdatabase: {:s}",
55 INFO(
"Found the specified thermodynamic database: {:s}", path_to_database);
57 return path_to_database;
64 std::unique_ptr<ChemicalSolverInterface>
65 createChemicalSolverInterface<ChemicalSolver::Phreeqc>(
66 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes,
67 std::map<std::string, std::unique_ptr<GlobalLinearSolver>>
const&
77 std::begin(meshes), std::end(meshes),
78 [&mesh_name](
auto const& mesh)
80 assert(mesh !=
nullptr);
81 return mesh->getName() == mesh_name;
83 "Required mesh with name '" + mesh_name +
"' not found.");
85 assert(mesh.getID() != 0);
86 DBUG(
"Found mesh '{:s}' with id {:d}.", mesh.getName(), mesh.getID());
92 linear_solvers, ls_name,
93 "A linear solver with the given name does not exist.");
98 auto chemical_system =
102 auto reaction_rates = createReactionRates<PhreeqcIOData::ReactionRate>(
112 auto const& exchangers = chemical_system->exchangers;
119 if (!surface.empty() && !exchangers.empty())
122 "Using surface and exchange reactions simultaneously is not "
123 "supported at the moment");
126 auto dump = surface.empty() && exchangers.empty()
128 : std::make_unique<PhreeqcIOData::Dump>(project_file_name);
141 auto const use_high_precision =
145 *chemical_system, user_punch, use_high_precision, project_file_name);
147 return std::make_unique<PhreeqcIOData::PhreeqcIO>(
148 *linear_solver, std::move(project_file_name),
149 std::move(path_to_database), std::move(chemical_system),
150 std::move(reaction_rates), std::move(surface), std::move(user_punch),
151 std::move(output), std::move(dump), std::move(knobs));
155 std::unique_ptr<ChemicalSolverInterface>
156 createChemicalSolverInterface<ChemicalSolver::PhreeqcKernel>(
157 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes,
158 std::map<std::string, std::unique_ptr<GlobalLinearSolver>>
const&
162 auto mesh = *meshes[0];
168 linear_solvers, ls_name,
169 "A linear solver with the given name does not exist.");
174 std::vector<std::pair<int, std::string>> process_id_to_component_name_map;
179 process_id_to_component_name_map);
187 auto reaction_rates = createReactionRates<PhreeqcKernelData::ReactionRate>(
196 return std::make_unique<PhreeqcKernelData::PhreeqcKernel>(
197 *linear_solver, mesh.getNumberOfBaseNodes(),
198 process_id_to_component_name_map, std::move(path_to_database),
199 std::move(aqueous_solution), std::move(equilibrium_reactants),
200 std::move(kinetic_reactants), std::move(reaction_rates));
void INFO(char const *fmt, Args const &... args)
void DBUG(char const *fmt, Args const &... args)
Definition of the Mesh class.
std::optional< ConfigTree > getConfigSubtreeOptional(std::string const &root) const
T getConfigParameter(std::string const ¶m) const
ConfigTree getConfigSubtree(std::string const &root) const
std::string const & getProjectFileName() const
Used to get the project file name.
Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
std::string const & getProjectDirectory()
Returns the directory where the prj file resides.
bool IsFileExisting(const std::string &strFilename)
Returns true if given file exists.
std::string extractBaseNameWithoutExtension(std::string const &pathname)
std::string joinPaths(std::string const &pathA, std::string const &pathB)
std::iterator_traits< InputIt >::reference findElementOrError(InputIt begin, InputIt end, Predicate predicate, std::string const &error="")
std::unique_ptr< UserPunch > createUserPunch(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)
std::unique_ptr< Output > createOutput(ChemicalSystem const &chemical_system, std::unique_ptr< UserPunch > const &user_punch, bool const use_high_precision, std::string const &project_file_name)
std::unique_ptr< ChemicalSystem > createChemicalSystem(BaseLib::ConfigTree const &config, MeshLib::Mesh &mesh)
Knobs createKnobs(BaseLib::ConfigTree const &config)
std::vector< SurfaceSite > createSurface(std::optional< BaseLib::ConfigTree > const &config)
std::unique_ptr< EquilibriumReactants > createEquilibriumReactants(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)
std::unique_ptr< Kinetics > createKineticReactants(std::optional< BaseLib::ConfigTree > const &config, MeshLib::Mesh const &mesh)
AqueousSolution createAqueousSolution(BaseLib::ConfigTree const &config, std::vector< std::pair< int, std::string >> const &process_id_to_component_name_map)
std::string parseDatabasePath(BaseLib::ConfigTree const &config)