Primary process variables as they appear in the global component vector.
Temperature is optional.
83{
85 config.checkConfigParameter("type", "ComponentTransport");
86
87 DBUG(
"Create ComponentTransportProcess.");
88
89 auto const coupling_scheme =
91 config.getConfigParameter<std::string>("coupling_scheme",
92 "monolithic_scheme");
93 const bool use_monolithic_scheme = (coupling_scheme != "staggered");
94
96
98 auto const pv_config = config.getConfigSubtree("process_variables");
99
100 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
101 process_variables;
102
105 variables, pv_config,
106 {
107 "pressure",
109 "concentration"});
110
113 variables, pv_config,
115 "temperature", true );
116 bool const isothermal = temperature_variable.empty();
117 if (!isothermal)
118 {
119 assert(temperature_variable.size() == 1);
120 collected_process_variables.insert(
121 ++collected_process_variables.begin(), temperature_variable[0]);
122 }
123
124
125 auto it = std::find_if(
126 collected_process_variables.cbegin(),
127 collected_process_variables.cend(),
128 [](std::reference_wrapper<ProcessLib::ProcessVariable> const& pv)
129 { return pv.get().getNumberOfGlobalComponents() != 1; });
130
131 if (it != collected_process_variables.end())
132 {
134 "Number of components for process variable '{:s}' should be 1 "
135 "rather "
136 "than {:d}.",
137 it->get().getName(),
138 it->get().getNumberOfGlobalComponents());
139 }
140
141
142
143 if (use_monolithic_scheme)
144 {
145 if (!isothermal)
146 {
148 "Currently, non-isothermal component transport process can "
149 "only be simulated in staggered scheme.");
150 }
151
152 process_variables.push_back(std::move(collected_process_variables));
153 }
154 else
155 {
156 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>
157 per_process_variable;
158
159 if (!chemical_solver_interface)
160 {
161 for (auto& pv : collected_process_variables)
162 {
163 per_process_variable.emplace_back(pv);
164 process_variables.push_back(std::move(per_process_variable));
165 }
166 }
167 else
168 {
169 auto sort_by_component =
170 [&per_process_variable,
171 collected_process_variables](auto const& c_name)
172 {
173 auto pv = std::find_if(collected_process_variables.begin(),
174 collected_process_variables.end(),
175 [&c_name](auto const& v) -> bool
176 { return v.get().getName() == c_name; });
177
178 if (pv == collected_process_variables.end())
179 {
181 "Component {:s} given in "
182 "<chemical_system>/<solution>/"
183 "<components> is not found in specified "
184 "coupled processes (see "
185 "<process>/<process_variables>/"
186 "<concentration>).",
187 c_name);
188 }
189
190 per_process_variable.emplace_back(*pv);
191 return std::move(per_process_variable);
192 };
193
194 auto const components =
195 chemical_solver_interface->getComponentList();
196
197 per_process_variable.emplace_back(collected_process_variables[0]);
198 process_variables.push_back(std::move(per_process_variable));
199
200 if (!isothermal)
201 {
202 per_process_variable.emplace_back(
203 collected_process_variables[1]);
204 process_variables.push_back(std::move(per_process_variable));
205 }
206
207 assert(components.size() + (isothermal ? 1 : 2) ==
208 collected_process_variables.size());
209 std::transform(components.begin(), components.end(),
210 std::back_inserter(process_variables),
211 sort_by_component);
212 }
213 }
214
216 std::vector<double> const b =
218 config.getConfigParameter<std::vector<double>>("specific_body_force");
219 assert(!b.empty() && b.size() < 4);
220
221 Eigen::VectorXd specific_body_force(b.size());
222 int const mesh_space_dimension =
224 if (static_cast<int>(b.size()) != mesh_space_dimension)
225 {
227 "specific body force (gravity vector) has {:d} components, mesh "
228 "dimension is {:d}",
229 b.size(), mesh_space_dimension);
230 }
232 if (has_gravity)
233 {
234 std::copy_n(b.data(), b.size(), specific_body_force.data());
235 }
236
237 bool const non_advective_form =
239 config.getConfigParameter<bool>("non_advective_form", false);
240
241 bool chemically_induced_porosity_change =
243 config.getConfigParameter<bool>("chemically_induced_porosity_change",
244 false);
245
247 double>(
249 config, "temperature_field", parameters, 1, &mesh);
250 if (!isothermal && temperature_field != nullptr)
251 {
252 OGS_FATAL(
"Temperature field is set for non-isothermal setup.")
253 }
254
255 auto media_map =
257
260 config.getConfigParameterOptional<std::string>("tabular_file"),
261 config.projectDirectory(),
262 process_variables);
263
264 DBUG(
"Check the media properties of ComponentTransport process ...");
266 DBUG(
"Media properties verified.");
267
269
272 auto const aperture_config =
274 config.getConfigSubtreeOptional("aperture_size");
275 if (aperture_config)
276 {
279 *aperture_config, "parameter", parameters, 1);
280 }
281
282 auto const is_linear =
284 config.getConfigParameter("linear", false);
285
286 auto const ls_compute_only_upon_timestep_change =
288 config.getConfigParameter(
289 "linear_solver_compute_only_upon_timestep_change", false);
290
293 std::vector<Eigen::VectorXd> projected_specific_body_force_vectors;
294 projected_specific_body_force_vectors.reserve(rotation_matrices.size());
295
296 std::transform(rotation_matrices.begin(), rotation_matrices.end(),
297 std::back_inserter(projected_specific_body_force_vectors),
298 [&specific_body_force](const auto& R)
299 { return R * R.transpose() * specific_body_force; });
300
302 std::move(media_map),
303 has_gravity,
304 non_advective_form,
305 temperature_field,
306 chemically_induced_porosity_change,
307 chemical_solver_interface.get(),
308 std::move(lookup_table),
309 std::move(stabilizer),
310 projected_specific_body_force_vectors,
311 mesh_space_dimension,
312 *aperture_size_parameter,
313 isothermal,
314 NumLib::ShapeMatrixCache{integration_order}};
315
316 SecondaryVariableCollection secondary_variables;
317
319
320 std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
321 auto surfaceflux_config =
323 config.getConfigSubtreeOptional("calculatesurfaceflux");
324 if (surfaceflux_config)
325 {
327 *surfaceflux_config, meshes);
328 }
329
330 return std::make_unique<ComponentTransportProcess>(
331 std::move(name), mesh, std::move(jacobian_assembler), parameters,
332 integration_order, std::move(process_variables),
333 std::move(process_data), std::move(secondary_variables),
334 use_monolithic_scheme, std::move(surfaceflux),
335 std::move(chemical_solver_interface), is_linear,
336 ls_compute_only_upon_timestep_change);
337}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
std::vector< Node * > const & getNodes() const
Get the nodes-vector for the mesh.
std::vector< Element * > const & getElements() const
Get the element-vector for the mesh.
unsigned getDimension() const
Returns the dimension of the mesh (determined by the maximum dimension over all elements).
static PROCESSLIB_EXPORT const std::string constant_one_parameter_name
MaterialSpatialDistributionMap createMaterialSpatialDistributionMap(std::map< int, std::shared_ptr< Medium > > const &media, MeshLib::Mesh const &mesh)
Eigen::Map< const Vector > toVector(std::vector< double > const &data, Eigen::VectorXd::Index size)
Creates an Eigen mapped vector from the given data vector.
std::vector< Eigen::MatrixXd > getElementRotationMatrices(int const space_dimension, int const mesh_dimension, std::vector< Element * > const &elements)
Element rotation matrix computation.
int getSpaceDimension(std::vector< Node * > const &nodes)
Computes dimension of the embedding space containing the set of given points.
NumericalStabilization createNumericalStabilization(MeshLib::Mesh const &mesh, BaseLib::ConfigTree const &config)
Parameter< ParameterDataType > * findOptionalTagParameter(BaseLib::ConfigTree const &process_config, std::string const &tag, std::vector< std::unique_ptr< ParameterBase > > const ¶meters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
OGS_NO_DANGLING Parameter< ParameterDataType > & findParameter(std::string const ¶meter_name, std::vector< std::unique_ptr< ParameterBase > > const ¶meters, int const num_components, MeshLib::Mesh const *const mesh=nullptr)
std::unique_ptr< LookupTable > createLookupTable(std::optional< std::string > const tabular_file, std::filesystem::path const &project_directory, std::vector< std::vector< std::reference_wrapper< ProcessVariable > > > const &process_variables)
void checkMPLProperties(MeshLib::Mesh const &mesh, MaterialPropertyLib::MaterialSpatialDistributionMap const &media_map)
std::vector< std::reference_wrapper< ProcessVariable > > findProcessVariables(std::vector< ProcessVariable > const &variables, BaseLib::ConfigTree const &pv_config, std::initializer_list< std::string > tags)
void createSecondaryVariables(BaseLib::ConfigTree const &config, SecondaryVariableCollection &secondary_variables)
static std::unique_ptr< ProcessLib::SurfaceFluxData > createSurfaceFluxData(BaseLib::ConfigTree const &calculatesurfaceflux_config, std::vector< std::unique_ptr< MeshLib::Mesh > > const &meshes)