13#include <phreeqcpp/cxxKinetics.h>
49 auto path_to_database =
54 OGS_FATAL(
"Not found the specified thermodynamicdatabase: {:s}",
58 INFO(
"Found the specified thermodynamic database: {:s}", path_to_database);
60 return path_to_database;
67std::unique_ptr<ChemicalSolverInterface>
69 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes,
70 std::map<std::string, std::unique_ptr<GlobalLinearSolver>>
const&
81 assert(mesh.getID() != 0);
82 DBUG(
"Found mesh '{:s}' with id {:d}.", mesh.getName(), mesh.getID());
88 linear_solvers, ls_name,
89 "A linear solver with the given name does not exist.");
94 auto chemical_system =
103 auto const& surface = chemical_system->surface;
106 auto const& exchangers = chemical_system->exchangers;
113 auto dump = surface.empty() && exchangers.empty()
115 : std::make_unique<PhreeqcIOData::Dump>(project_file_name);
128 auto const use_high_precision =
132 *chemical_system, user_punch, use_high_precision, project_file_name);
134 return std::make_unique<PhreeqcIOData::PhreeqcIO>(
135 mesh, *linear_solver, std::move(project_file_name),
136 std::move(path_to_database), std::move(chemical_system),
137 std::move(reaction_rates), std::move(user_punch), std::move(output),
138 std::move(dump), std::move(knobs));
142std::unique_ptr<ChemicalSolverInterface>
144 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes,
145 std::map<std::string, std::unique_ptr<GlobalLinearSolver>>
const&
149 auto mesh = *meshes[0];
155 linear_solvers, ls_name,
156 "A linear solver with the given name does not exist.");
161 std::vector<std::pair<int, std::string>> process_id_to_component_name_map;
166 process_id_to_component_name_map);
183 return std::make_unique<PhreeqcKernelData::PhreeqcKernel>(
184 mesh, *linear_solver, mesh.computeNumberOfBaseNodes(),
185 process_id_to_component_name_map, std::move(path_to_database),
186 std::move(aqueous_solution), std::move(equilibrium_reactants),
187 std::move(kinetic_reactants), std::move(reaction_rates));
191std::unique_ptr<ChemicalSolverInterface>
193 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes,
194 std::map<std::string, std::unique_ptr<GlobalLinearSolver>>
const&
205 assert(mesh.getID() != 0);
206 DBUG(
"Found mesh '{:s}' with id {:d}.", mesh.getName(), mesh.getID());
212 linear_solvers, ls_name,
213 "A linear solver with the given name does not exist.");
215 auto chemical_reaction_data =
221 std::vector<double> stoichiometric_matrix_vec;
222 for (
auto const& per_chemical_reaction_data : chemical_reaction_data)
224 stoichiometric_matrix_vec.insert(
225 stoichiometric_matrix_vec.end(),
226 per_chemical_reaction_data->stoichiometric_vector.begin(),
227 per_chemical_reaction_data->stoichiometric_vector.end());
230 auto const num_components =
235 stoichiometric_matrix_vec, num_components, num_components);
237 Eigen::SparseMatrix<double> sparse_stoichiometric_matrix;
238 sparse_stoichiometric_matrix = stoichiometric_matrix.sparseView();
240 return std::make_unique<SelfContainedSolverData::SelfContainedSolver>(
241 mesh, *linear_solver, sparse_stoichiometric_matrix,
242 std::move(chemical_reaction_data));
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition of the Mesh class.
std::string const & getProjectFileName() const
Used to get the project file name.
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 & 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)
OGS_NO_DANGLING Map::mapped_type & getOrError(Map &map, Key const &key, std::string const &error_message)
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::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::vector< std::unique_ptr< ChemicalReaction > > createChemicalReactionData(BaseLib::ConfigTree const &config)
template std::vector< PhreeqcKernelData::ReactionRate > createReactionRates< PhreeqcKernelData::ReactionRate >(std::optional< BaseLib::ConfigTree > const &config)
std::unique_ptr< ChemicalSolverInterface > createChemicalSolverInterface< ChemicalSolver::SelfContained >(std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< std::string, std::unique_ptr< GlobalLinearSolver > > const &linear_solvers, BaseLib::ConfigTree const &config, std::string const &)
std::unique_ptr< ChemicalSolverInterface > createChemicalSolverInterface< ChemicalSolver::PhreeqcKernel >(std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< std::string, std::unique_ptr< GlobalLinearSolver > > const &linear_solvers, BaseLib::ConfigTree const &config, std::string const &)
std::unique_ptr< ChemicalSolverInterface > createChemicalSolverInterface< ChemicalSolver::Phreeqc >(std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes, std::map< std::string, std::unique_ptr< GlobalLinearSolver > > const &linear_solvers, BaseLib::ConfigTree const &config, std::string const &output_directory)
template std::vector< PhreeqcIOData::ReactionRate > createReactionRates< PhreeqcIOData::ReactionRate >(std::optional< BaseLib::ConfigTree > const &config)
Eigen::Map< const Matrix > toMatrix(std::vector< double > const &data, Eigen::MatrixXd::Index rows, Eigen::MatrixXd::Index cols)
Mesh & findMeshByName(std::vector< std::unique_ptr< Mesh > > const &meshes, std::string_view const name)
std::string parseDatabasePath(BaseLib::ConfigTree const &config)