68{
69 auto mesh_name =
71 config.getConfigParameter<std::string>("mesh");
72
73
75
76 assert(mesh.getID() != 0);
77 DBUG(
"Found mesh '{:s}' with id {:d}.", mesh.getName(), mesh.getID());
78
79 auto const ls_name =
81 config.getConfigParameter<std::string>("linear_solver");
83 linear_solvers, ls_name,
84 "A linear solver with the given name does not exist.");
85
86 auto path_to_database = parseDatabasePath(config);
87
88
89 auto chemical_system =
91
92
95 config.getConfigSubtreeOptional("rates"));
96
97
98 auto const& surface = chemical_system->surface;
99
100
101 auto const& exchangers = chemical_system->exchangers;
102
103
104 auto use_stream_for_data_exchange =
106 config.getConfigParameter<bool>("use_stream_for_data_exchange", true);
107
108
109 auto const num_chemistry_threads_opt =
111 config.getConfigParameterOptional<int>("chemistry_threads");
112 if (num_chemistry_threads_opt && *num_chemistry_threads_opt <= 0)
113 {
115 "<chemistry_threads> must be a positive integer, but got {:d}.",
116 *num_chemistry_threads_opt);
117 }
118 int const num_chemistry_threads =
119 num_chemistry_threads_opt ? *num_chemistry_threads_opt
121
122
123
124
125
126 auto const concentration_warning_threshold =
128 config.getConfigParameter<double>("concentration_warning_threshold",
129 -1e-12);
130 if (concentration_warning_threshold > 0.0)
131 {
133 "<concentration_warning_threshold> must not be positive (it is a "
134 "threshold for negative concentrations), but got {:g}.",
135 concentration_warning_threshold);
136 }
137
138
139 auto const project_file_name =
142 config.projectFilePath().string()));
143
144 auto dump = surface.empty() && exchangers.empty()
145 ? nullptr
146 : std::make_unique<PhreeqcIOData::Dump>(project_file_name);
147
148
151 config.getConfigSubtree("knobs"));
152
153
156 config.getConfigSubtreeOptional("user_punch"), *meshes[0]);
157
158
159 auto const use_high_precision =
161 config.getConfigParameter<bool>("use_high_precision", true);
163 *chemical_system, user_punch, use_high_precision, project_file_name);
164
165 if (use_stream_for_data_exchange)
166 {
167 INFO(
"PhreeqcIO will use stringstream for data exchange.");
168 }
169 else
170 {
171 INFO(
"PhreeqcIO will use file for data exchange.");
172 }
173
174 return std::make_unique<PhreeqcIOData::PhreeqcIO>(
175 mesh, *linear_solver, std::move(project_file_name),
176 std::move(path_to_database), std::move(chemical_system),
177 std::move(reaction_rates), std::move(user_punch), std::move(output),
178 std::move(dump), std::move(knobs), use_stream_for_data_exchange,
179 num_chemistry_threads, concentration_warning_threshold);
180}
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)
int getNumberOfChemistryThreads()
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)