66{
67 auto mesh_name =
69 config.getConfigParameter<std::string>("mesh");
70
71
73
74 assert(mesh.getID() != 0);
75 DBUG(
"Found mesh '{:s}' with id {:d}.", mesh.getName(), mesh.getID());
76
77 auto const ls_name =
79 config.getConfigParameter<std::string>("linear_solver");
81 linear_solvers, ls_name,
82 "A linear solver with the given name does not exist.");
83
84 auto path_to_database = parseDatabasePath(config);
85
86
87 auto chemical_system =
89
90
93 config.getConfigSubtreeOptional("rates"));
94
95
96 auto const& surface = chemical_system->surface;
97
98
99 auto const& exchangers = chemical_system->exchangers;
100
101
102 auto use_stream_for_data_exchange =
104 config.getConfigParameter<bool>("use_stream_for_data_exchange", true);
105
106
107 auto const project_file_name =
110 config.projectFilePath().string()));
111
112 auto dump = surface.empty() && exchangers.empty()
113 ? nullptr
114 : std::make_unique<PhreeqcIOData::Dump>(project_file_name);
115
116
119 config.getConfigSubtree("knobs"));
120
121
124 config.getConfigSubtreeOptional("user_punch"), *meshes[0]);
125
126
127 auto const use_high_precision =
129 config.getConfigParameter<bool>("use_high_precision", true);
131 *chemical_system, user_punch, use_high_precision, project_file_name);
132
133 if (use_stream_for_data_exchange)
134 {
135 INFO(
"PhreeqcIO will use stringstream for data exchange.");
136 }
137 else
138 {
139 INFO(
"PhreeqcIO will use file for data exchange.");
140 }
141
142 return std::make_unique<PhreeqcIOData::PhreeqcIO>(
143 mesh, *linear_solver, std::move(project_file_name),
144 std::move(path_to_database), std::move(chemical_system),
145 std::move(reaction_rates), std::move(user_punch), std::move(output),
146 std::move(dump), std::move(knobs), use_stream_for_data_exchange);
147}
void INFO(fmt::format_string< Args... > fmt, Args &&... args)
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
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)
template std::vector< PhreeqcIOData::ReactionRate > createReactionRates< PhreeqcIOData::ReactionRate >(std::optional< BaseLib::ConfigTree > const &config)
Mesh & findMeshByName(std::vector< std::unique_ptr< Mesh > > const &meshes, std::string_view const name)