79 std::string
const& name,
81 std::unique_ptr<ProcessLib::AbstractJacobianAssembler>&& jacobian_assembler,
82 std::vector<ProcessVariable>
const& variables,
83 std::vector<std::unique_ptr<ParameterLib::ParameterBase>>
const& parameters,
84 unsigned const integration_order,
86 std::vector<std::unique_ptr<MeshLib::Mesh>>
const& meshes,
87 std::map<
int, std::shared_ptr<MaterialPropertyLib::Medium>>
const& media,
88 std::unique_ptr<ChemistryLib::ChemicalSolverInterface>&&
89 chemical_solver_interface)
94 DBUG(
"Create ComponentTransportProcess.");
96 auto const coupling_scheme =
100 const bool use_monolithic_scheme = (coupling_scheme !=
"staggered");
107 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
112 variables, pv_config,
120 variables, pv_config,
122 "temperature",
true );
123 bool const isothermal = temperature_variable.empty();
126 assert(temperature_variable.size() == 1);
127 collected_process_variables.insert(
128 ++collected_process_variables.begin(), temperature_variable[0]);
132 auto it = std::find_if(
133 collected_process_variables.cbegin(),
134 collected_process_variables.cend(),
135 [](std::reference_wrapper<ProcessLib::ProcessVariable>
const& pv)
136 { return pv.get().getNumberOfGlobalComponents() != 1; });
138 if (it != collected_process_variables.end())
141 "Number of components for process variable '{:s}' should be 1 "
145 it->get().getNumberOfGlobalComponents());
150 if (use_monolithic_scheme)
155 "Currently, non-isothermal component transport process can "
156 "only be simulated in staggered scheme.");
159 process_variables.push_back(std::move(collected_process_variables));
163 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>
164 per_process_variable;
166 if (!chemical_solver_interface)
168 for (
auto& pv : collected_process_variables)
170 per_process_variable.emplace_back(pv);
171 process_variables.push_back(std::move(per_process_variable));
176 auto sort_by_component =
177 [&per_process_variable,
178 collected_process_variables](
auto const& c_name)
180 auto pv = std::find_if(collected_process_variables.begin(),
181 collected_process_variables.end(),
182 [&c_name](
auto const& v) ->
bool
183 { return v.get().getName() == c_name; });
185 if (pv == collected_process_variables.end())
188 "Component {:s} given in "
189 "<chemical_system>/<solution>/"
190 "<components> is not found in specified "
191 "coupled processes (see "
192 "<process>/<process_variables>/"
197 per_process_variable.emplace_back(*pv);
198 return std::move(per_process_variable);
201 auto const components =
202 chemical_solver_interface->getComponentList();
204 per_process_variable.emplace_back(collected_process_variables[0]);
205 process_variables.push_back(std::move(per_process_variable));
209 per_process_variable.emplace_back(
210 collected_process_variables[1]);
211 process_variables.push_back(std::move(per_process_variable));
214 assert(components.size() + (isothermal ? 1 : 2) ==
215 collected_process_variables.size());
216 std::transform(components.begin(), components.end(),
217 std::back_inserter(process_variables),
223 std::vector<double>
const b =
226 assert(!b.empty() && b.size() < 4);
228 Eigen::VectorXd specific_body_force(b.size());
229 int const mesh_space_dimension =
231 if (
static_cast<int>(b.size()) != mesh_space_dimension)
234 "specific body force (gravity vector) has {:d} components, mesh "
236 b.size(), mesh_space_dimension);
241 std::copy_n(b.data(), b.size(), specific_body_force.data());
244 bool const non_advective_form =
248 bool chemically_induced_porosity_change =
256 config,
"temperature_field", parameters, 1, &mesh);
257 if (!isothermal && temperature_field !=
nullptr)
259 OGS_FATAL(
"Temperature field is set for non-isothermal setup.")
270 DBUG(
"Check the media properties of ComponentTransport process ...");
272 DBUG(
"Media properties verified.");
276 auto const* aperture_size_parameter = &ParameterLib::findParameter<double>(
278 auto const aperture_config =
283 aperture_size_parameter = &ParameterLib::findParameter<double>(
285 *aperture_config,
"parameter", parameters, 1);
288 auto const is_linear =
292 auto const ls_compute_only_upon_timestep_change =
295 "linear_solver_compute_only_upon_timestep_change",
false);
299 std::vector<Eigen::VectorXd> projected_specific_body_force_vectors;
300 projected_specific_body_force_vectors.reserve(rotation_matrices.size());
302 std::transform(rotation_matrices.begin(), rotation_matrices.end(),
303 std::back_inserter(projected_specific_body_force_vectors),
304 [&specific_body_force](
const auto& R)
305 { return R * R.transpose() * specific_body_force; });
308 std::move(media_map),
312 chemically_induced_porosity_change,
313 chemical_solver_interface.get(),
314 std::move(lookup_table),
315 std::move(stabilizer),
316 projected_specific_body_force_vectors,
317 mesh_space_dimension,
318 *aperture_size_parameter,
326 std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
327 auto surfaceflux_config =
330 if (surfaceflux_config)
333 *surfaceflux_config, meshes);
336 return std::make_unique<ComponentTransportProcess>(
337 std::move(name), mesh, std::move(jacobian_assembler), parameters,
338 integration_order, std::move(process_variables),
339 std::move(process_data), std::move(secondary_variables),
340 use_monolithic_scheme, std::move(surfaceflux),
341 std::move(chemical_solver_interface), is_linear,
342 ls_compute_only_upon_timestep_change);