Primary process variables as they appear in the global component vector.
Temperature is optional.
90{
92 config.checkConfigParameter("type", "ComponentTransport");
93
94 DBUG(
"Create ComponentTransportProcess.");
95
96 auto const coupling_scheme =
98 config.getConfigParameter<std::string>("coupling_scheme",
99 "monolithic_scheme");
100 const bool use_monolithic_scheme = (coupling_scheme != "staggered");
101
103
105 auto const pv_config = config.getConfigSubtree("process_variables");
106
107 std::vector<std::vector<std::reference_wrapper<ProcessVariable>>>
108 process_variables;
109
112 variables, pv_config,
113 {
114 "pressure",
116 "concentration"});
117
120 variables, pv_config,
122 "temperature", true );
123 bool const isothermal = temperature_variable.empty();
124 if (!isothermal)
125 {
126 assert(temperature_variable.size() == 1);
127 collected_process_variables.insert(
128 ++collected_process_variables.begin(), temperature_variable[0]);
129 }
130
131
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; });
137
138 if (it != collected_process_variables.end())
139 {
141 "Number of components for process variable '{:s}' should be 1 "
142 "rather "
143 "than {:d}.",
144 it->get().getName(),
145 it->get().getNumberOfGlobalComponents());
146 }
147
148
149
150 if (use_monolithic_scheme)
151 {
152 if (!isothermal)
153 {
155 "Currently, non-isothermal component transport process can "
156 "only be simulated in staggered scheme.");
157 }
158
159 process_variables.push_back(std::move(collected_process_variables));
160 }
161 else
162 {
163 std::vector<std::reference_wrapper<ProcessLib::ProcessVariable>>
164 per_process_variable;
165
166 if (!chemical_solver_interface)
167 {
168 for (auto& pv : collected_process_variables)
169 {
170 per_process_variable.emplace_back(pv);
171 process_variables.push_back(std::move(per_process_variable));
172 }
173 }
174 else
175 {
176 auto sort_by_component =
177 [&per_process_variable,
178 collected_process_variables](auto const& c_name)
179 {
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; });
184
185 if (pv == collected_process_variables.end())
186 {
188 "Component {:s} given in "
189 "<chemical_system>/<solution>/"
190 "<components> is not found in specified "
191 "coupled processes (see "
192 "<process>/<process_variables>/"
193 "<concentration>).",
194 c_name);
195 }
196
197 per_process_variable.emplace_back(*pv);
198 return std::move(per_process_variable);
199 };
200
201 auto const components =
202 chemical_solver_interface->getComponentList();
203
204 per_process_variable.emplace_back(collected_process_variables[0]);
205 process_variables.push_back(std::move(per_process_variable));
206
207 if (!isothermal)
208 {
209 per_process_variable.emplace_back(
210 collected_process_variables[1]);
211 process_variables.push_back(std::move(per_process_variable));
212 }
213
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),
218 sort_by_component);
219 }
220 }
221
223 std::vector<double> const b =
225 config.getConfigParameter<std::vector<double>>("specific_body_force");
226 assert(!b.empty() && b.size() < 4);
227
228 Eigen::VectorXd specific_body_force(b.size());
229 int const mesh_space_dimension =
231 if (static_cast<int>(b.size()) != mesh_space_dimension)
232 {
234 "specific body force (gravity vector) has {:d} components, mesh "
235 "dimension is {:d}",
236 b.size(), mesh_space_dimension);
237 }
239 if (has_gravity)
240 {
241 std::copy_n(b.data(), b.size(), specific_body_force.data());
242 }
243
244 bool const non_advective_form =
246 config.getConfigParameter<bool>("non_advective_form", false);
247
248 bool chemically_induced_porosity_change =
250 config.getConfigParameter<bool>("chemically_induced_porosity_change",
251 false);
252
254 double>(
256 config, "temperature_field", parameters, 1, &mesh);
257 if (!isothermal && temperature_field != nullptr)
258 {
259 OGS_FATAL(
"Temperature field is set for non-isothermal setup.")
260 }
261
262 auto media_map =
264
265 auto lookup_table = ComponentTransport::createLookupTable(
267 config.getConfigParameterOptional<std::string>("tabular_file"),
268 process_variables);
269
270 DBUG(
"Check the media properties of ComponentTransport process ...");
272 DBUG(
"Media properties verified.");
273
275
278 auto const aperture_config =
280 config.getConfigSubtreeOptional("aperture_size");
281 if (aperture_config)
282 {
285 *aperture_config, "parameter", parameters, 1);
286 }
287
288 auto const is_linear =
290 config.getConfigParameter("linear", false);
291
292 auto const ls_compute_only_upon_timestep_change =
294 config.getConfigParameter(
295 "linear_solver_compute_only_upon_timestep_change", false);
296
299 std::vector<Eigen::VectorXd> projected_specific_body_force_vectors;
300 projected_specific_body_force_vectors.reserve(rotation_matrices.size());
301
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; });
306
307 ComponentTransportProcessData process_data{
308 std::move(media_map),
309 has_gravity,
310 non_advective_form,
311 temperature_field,
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,
319 isothermal,
321
322 SecondaryVariableCollection secondary_variables;
323
325
326 std::unique_ptr<ProcessLib::SurfaceFluxData> surfaceflux;
327 auto surfaceflux_config =
329 config.getConfigSubtreeOptional("calculatesurfaceflux");
330 if (surfaceflux_config)
331 {
333 *surfaceflux_config, meshes);
334 }
335
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);
343}
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)
constexpr int size(int const displacement_dim)
Vectorized tensor size for given displacement dimension.
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)
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)