Skip to content
Snippets Groups Projects
Commit 6c329b10 authored by renchao.lu's avatar renchao.lu
Browse files

[PL] Pass chemical solver interface.

parent 8dec1460
No related branches found
No related tags found
No related merge requests found
...@@ -328,14 +328,15 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, ...@@ -328,14 +328,15 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config,
//! \ogs_file_param{prj__media} //! \ogs_file_param{prj__media}
parseMedia(project_config.getConfigSubtreeOptional("media")); parseMedia(project_config.getConfigSubtreeOptional("media"));
parseChemicalSolverInterface( auto chemical_solver_interface = parseChemicalSolverInterface(
//! \ogs_file_param{prj__chemical_system} //! \ogs_file_param{prj__chemical_system}
project_config.getConfigSubtreeOptional("chemical_system"), project_config.getConfigSubtreeOptional("chemical_system"),
output_directory); output_directory);
//! \ogs_file_param{prj__processes} //! \ogs_file_param{prj__processes}
parseProcesses(project_config.getConfigSubtree("processes"), parseProcesses(project_config.getConfigSubtree("processes"),
project_directory, output_directory); project_directory, output_directory,
chemical_solver_interface.get());
//! \ogs_file_param{prj__linear_solvers} //! \ogs_file_param{prj__linear_solvers}
parseLinearSolvers(project_config.getConfigSubtree("linear_solvers")); parseLinearSolvers(project_config.getConfigSubtree("linear_solvers"));
...@@ -345,7 +346,7 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, ...@@ -345,7 +346,7 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config,
//! \ogs_file_param{prj__time_loop} //! \ogs_file_param{prj__time_loop}
parseTimeLoop(project_config.getConfigSubtree("time_loop"), parseTimeLoop(project_config.getConfigSubtree("time_loop"),
output_directory); output_directory, std::move(chemical_solver_interface));
} }
void ProjectData::parseProcessVariables( void ProjectData::parseProcessVariables(
...@@ -501,15 +502,18 @@ void ProjectData::parseMedia( ...@@ -501,15 +502,18 @@ void ProjectData::parseMedia(
} }
} }
void ProjectData::parseChemicalSolverInterface( std::unique_ptr<ChemistryLib::ChemicalSolverInterface>
ProjectData::parseChemicalSolverInterface(
boost::optional<BaseLib::ConfigTree> const& config, boost::optional<BaseLib::ConfigTree> const& config,
std::string const& output_directory) std::string const& output_directory)
{ {
if (!config) if (!config)
{ {
return; return nullptr;
} }
std::unique_ptr<ChemistryLib::ChemicalSolverInterface>
chemical_solver_interface;
#ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT #ifdef OGS_BUILD_PROCESS_COMPONENTTRANSPORT
INFO( INFO(
"Ready for initializing interface to a chemical solver for water " "Ready for initializing interface to a chemical solver for water "
...@@ -525,10 +529,9 @@ void ProjectData::parseChemicalSolverInterface( ...@@ -525,10 +529,9 @@ void ProjectData::parseChemicalSolverInterface(
"Configuring phreeqc interface for water chemistry " "Configuring phreeqc interface for water chemistry "
"calculation using file-based approach."); "calculation using file-based approach.");
_chemical_solver_interface = chemical_solver_interface = ChemistryLib::createChemicalSolverInterface<
ChemistryLib::createChemicalSolverInterface< ChemistryLib::ChemicalSolver::Phreeqc>(_mesh_vec, *config,
ChemistryLib::ChemicalSolver::Phreeqc>(_mesh_vec, *config, output_directory);
output_directory);
} }
else if (boost::iequals(chemical_solver, "PhreeqcKernel")) else if (boost::iequals(chemical_solver, "PhreeqcKernel"))
{ {
...@@ -553,11 +556,14 @@ void ProjectData::parseChemicalSolverInterface( ...@@ -553,11 +556,14 @@ void ProjectData::parseChemicalSolverInterface(
"the present, water chemistry calculation is only available for " "the present, water chemistry calculation is only available for "
"component transport process."); "component transport process.");
#endif #endif
return chemical_solver_interface;
} }
void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config, void ProjectData::parseProcesses(
std::string const& project_directory, BaseLib::ConfigTree const& processes_config,
std::string const& output_directory) std::string const& project_directory,
std::string const& output_directory,
ChemistryLib::ChemicalSolverInterface* const chemical_solver_interface)
{ {
(void)project_directory; // to avoid compilation warning (void)project_directory; // to avoid compilation warning
(void)output_directory; // to avoid compilation warning (void)output_directory; // to avoid compilation warning
...@@ -728,7 +734,7 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config, ...@@ -728,7 +734,7 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config,
name, *_mesh_vec[0], std::move(jacobian_assembler), name, *_mesh_vec[0], std::move(jacobian_assembler),
_process_variables, _parameters, integration_order, _process_variables, _parameters, integration_order,
process_config, _mesh_vec, output_directory, _media, process_config, _mesh_vec, output_directory, _media,
_chemical_solver_interface); chemical_solver_interface);
} }
else else
#endif #endif
...@@ -1022,14 +1028,17 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config, ...@@ -1022,14 +1028,17 @@ void ProjectData::parseProcesses(BaseLib::ConfigTree const& processes_config,
} }
} }
void ProjectData::parseTimeLoop(BaseLib::ConfigTree const& config, void ProjectData::parseTimeLoop(
std::string const& output_directory) BaseLib::ConfigTree const& config,
std::string const& output_directory,
std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
chemical_solver_interface)
{ {
DBUG("Reading time loop configuration."); DBUG("Reading time loop configuration.");
_time_loop = ProcessLib::createTimeLoop( _time_loop = ProcessLib::createTimeLoop(
config, output_directory, _processes, _nonlinear_solvers, _mesh_vec, config, output_directory, _processes, _nonlinear_solvers, _mesh_vec,
_chemical_solver_interface); std::move(chemical_solver_interface));
if (!_time_loop) if (!_time_loop)
{ {
......
...@@ -99,13 +99,17 @@ private: ...@@ -99,13 +99,17 @@ private:
/// Parses the processes configuration and creates new processes for each /// Parses the processes configuration and creates new processes for each
/// process entry passing the corresponding subtree to the process /// process entry passing the corresponding subtree to the process
/// constructor. /// constructor.
void parseProcesses(BaseLib::ConfigTree const& processes_config, void parseProcesses(
std::string const& project_directory, BaseLib::ConfigTree const& processes_config,
std::string const& output_directory); std::string const& project_directory,
std::string const& output_directory,
ChemistryLib::ChemicalSolverInterface* chemical_solver_interface);
/// Parses the time loop configuration. /// Parses the time loop configuration.
void parseTimeLoop(BaseLib::ConfigTree const& config, void parseTimeLoop(BaseLib::ConfigTree const& config,
const std::string& output_directory); const std::string& output_directory,
std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
chemical_solver_interface);
void parseLinearSolvers(BaseLib::ConfigTree const& config); void parseLinearSolvers(BaseLib::ConfigTree const& config);
...@@ -113,7 +117,8 @@ private: ...@@ -113,7 +117,8 @@ private:
void parseCurves(boost::optional<BaseLib::ConfigTree> const& config); void parseCurves(boost::optional<BaseLib::ConfigTree> const& config);
void parseChemicalSolverInterface( std::unique_ptr<ChemistryLib::ChemicalSolverInterface>
parseChemicalSolverInterface(
boost::optional<BaseLib::ConfigTree> const& config, boost::optional<BaseLib::ConfigTree> const& config,
const std::string& output_directory); const std::string& output_directory);
...@@ -138,7 +143,4 @@ private: ...@@ -138,7 +143,4 @@ private:
std::map<std::string, std::map<std::string,
std::unique_ptr<MathLib::PiecewiseLinearInterpolation>> std::unique_ptr<MathLib::PiecewiseLinearInterpolation>>
_curves; _curves;
std::unique_ptr<ChemistryLib::ChemicalSolverInterface>
_chemical_solver_interface;
}; };
...@@ -85,8 +85,7 @@ std::unique_ptr<Process> createComponentTransportProcess( ...@@ -85,8 +85,7 @@ std::unique_ptr<Process> createComponentTransportProcess(
std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
std::string const& output_directory, std::string const& output_directory,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media, std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
std::unique_ptr<ChemistryLib::ChemicalSolverInterface> const& ChemistryLib::ChemicalSolverInterface* const chemical_solver_interface)
chemical_solver_interface)
{ {
//! \ogs_file_param{prj__processes__process__type} //! \ogs_file_param{prj__processes__process__type}
config.checkConfigParameter("type", "ComponentTransport"); config.checkConfigParameter("type", "ComponentTransport");
......
...@@ -38,7 +38,6 @@ std::unique_ptr<Process> createComponentTransportProcess( ...@@ -38,7 +38,6 @@ std::unique_ptr<Process> createComponentTransportProcess(
std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
std::string const& output_directory, std::string const& output_directory,
std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media, std::map<int, std::shared_ptr<MaterialPropertyLib::Medium>> const& media,
std::unique_ptr<ChemistryLib::ChemicalSolverInterface> const& ChemistryLib::ChemicalSolverInterface* chemical_solver_interface);
chemical_solver_interface);
} // namespace ComponentTransport } // namespace ComponentTransport
} // namespace ProcessLib } // namespace ProcessLib
...@@ -25,7 +25,7 @@ std::unique_ptr<TimeLoop> createTimeLoop( ...@@ -25,7 +25,7 @@ std::unique_ptr<TimeLoop> createTimeLoop(
const std::map<std::string, std::unique_ptr<NumLib::NonlinearSolverBase>>& const std::map<std::string, std::unique_ptr<NumLib::NonlinearSolverBase>>&
nonlinear_solvers, nonlinear_solvers,
std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
std::unique_ptr<ChemistryLib::ChemicalSolverInterface>& std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
chemical_solver_interface) chemical_solver_interface)
{ {
auto const& coupling_config auto const& coupling_config
......
...@@ -50,7 +50,7 @@ std::unique_ptr<TimeLoop> createTimeLoop( ...@@ -50,7 +50,7 @@ std::unique_ptr<TimeLoop> createTimeLoop(
std::map<std::string, std::unique_ptr<NumLib::NonlinearSolverBase>> const& std::map<std::string, std::unique_ptr<NumLib::NonlinearSolverBase>> const&
nonlinear_solvers, nonlinear_solvers,
std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes, std::vector<std::unique_ptr<MeshLib::Mesh>> const& meshes,
std::unique_ptr<ChemistryLib::ChemicalSolverInterface>& std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
chemical_solver_interface); chemical_solver_interface);
} // namespace ProcessLib } // namespace ProcessLib
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment