Skip to content
Snippets Groups Projects
Commit 363608c7 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[PL/ST] Make component id mandatory for source terms

parent 27546c0f
No related branches found
No related tags found
No related merge requests found
...@@ -33,13 +33,13 @@ std::unique_ptr<SourceTerm> createSourceTerm( ...@@ -33,13 +33,13 @@ std::unique_ptr<SourceTerm> createSourceTerm(
// check basic data consistency // check basic data consistency
if (variable_id >= if (variable_id >=
static_cast<int>(dof_table_bulk.getNumberOfVariables()) || static_cast<int>(dof_table_bulk.getNumberOfVariables()) ||
*config.component_id >= config.component_id >=
dof_table_bulk.getNumberOfVariableComponents(variable_id)) dof_table_bulk.getNumberOfVariableComponents(variable_id))
{ {
OGS_FATAL( OGS_FATAL(
"Variable id or component id too high. Actual values: ({:d}, " "Variable id or component id too high. Actual values: ({:d}, "
"{:d}), maximum values: ({:d}, {:d}).", "{:d}), maximum values: ({:d}, {:d}).",
variable_id, *config.component_id, variable_id, config.component_id,
dof_table_bulk.getNumberOfVariables(), dof_table_bulk.getNumberOfVariables(),
dof_table_bulk.getNumberOfVariableComponents(variable_id)); dof_table_bulk.getNumberOfVariableComponents(variable_id));
} }
...@@ -59,7 +59,7 @@ std::unique_ptr<SourceTerm> createSourceTerm( ...@@ -59,7 +59,7 @@ std::unique_ptr<SourceTerm> createSourceTerm(
"Found {:d} nodes for source term at mesh '{:s}' for the variable {:d} " "Found {:d} nodes for source term at mesh '{:s}' for the variable {:d} "
"and component {:d}", "and component {:d}",
source_term_nodes.size(), source_term_mesh.getName(), variable_id, source_term_nodes.size(), source_term_mesh.getName(), variable_id,
*config.component_id); config.component_id);
MeshLib::MeshSubset source_term_mesh_subset(source_term_mesh, MeshLib::MeshSubset source_term_mesh_subset(source_term_mesh,
source_term_nodes); source_term_nodes);
...@@ -68,11 +68,11 @@ std::unique_ptr<SourceTerm> createSourceTerm( ...@@ -68,11 +68,11 @@ std::unique_ptr<SourceTerm> createSourceTerm(
{ {
auto dof_table_source_term = auto dof_table_source_term =
dof_table_bulk.deriveBoundaryConstrainedMap( dof_table_bulk.deriveBoundaryConstrainedMap(
variable_id, {*config.component_id}, variable_id, {config.component_id},
std::move(source_term_mesh_subset)); std::move(source_term_mesh_subset));
return ProcessLib::createNodalSourceTerm( return ProcessLib::createNodalSourceTerm(
config.config, config.mesh, std::move(dof_table_source_term), config.config, config.mesh, std::move(dof_table_source_term),
source_term_mesh.getID(), variable_id, *config.component_id, source_term_mesh.getID(), variable_id, config.component_id,
parameters); parameters);
} }
...@@ -80,10 +80,10 @@ std::unique_ptr<SourceTerm> createSourceTerm( ...@@ -80,10 +80,10 @@ std::unique_ptr<SourceTerm> createSourceTerm(
{ {
auto dof_table_source_term = auto dof_table_source_term =
dof_table_bulk.deriveBoundaryConstrainedMap( dof_table_bulk.deriveBoundaryConstrainedMap(
variable_id, {*config.component_id}, variable_id, {config.component_id},
std::move(source_term_mesh_subset)); std::move(source_term_mesh_subset));
auto const& bulk_mesh_dimension = auto const& bulk_mesh_dimension =
dof_table_bulk.getMeshSubset(variable_id, *config.component_id) dof_table_bulk.getMeshSubset(variable_id, config.component_id)
.getMesh() .getMesh()
.getDimension(); .getDimension();
return ProcessLib::createVolumetricSourceTerm( return ProcessLib::createVolumetricSourceTerm(
...@@ -100,7 +100,7 @@ std::unique_ptr<SourceTerm> createSourceTerm( ...@@ -100,7 +100,7 @@ std::unique_ptr<SourceTerm> createSourceTerm(
return ProcessLib::createPythonSourceTerm( return ProcessLib::createPythonSourceTerm(
config.config, config.mesh, std::move(dof_table_source_term), config.config, config.mesh, std::move(dof_table_source_term),
variable_id, *config.component_id, integration_order, variable_id, config.component_id, integration_order,
shapefunction_order, source_term_mesh.getDimension(), shapefunction_order, source_term_mesh.getDimension(),
all_process_variables_for_this_process); all_process_variables_for_this_process);
} }
......
...@@ -19,7 +19,7 @@ struct SourceTermConfig final ...@@ -19,7 +19,7 @@ struct SourceTermConfig final
{ {
SourceTermConfig(BaseLib::ConfigTree&& config_, SourceTermConfig(BaseLib::ConfigTree&& config_,
MeshLib::Mesh const& mesh_, MeshLib::Mesh const& mesh_,
std::optional<int> const component_id_) int component_id_)
: config(std::move(config_)), mesh(mesh_), component_id(component_id_) : config(std::move(config_)), mesh(mesh_), component_id(component_id_)
{ {
} }
...@@ -33,7 +33,7 @@ struct SourceTermConfig final ...@@ -33,7 +33,7 @@ struct SourceTermConfig final
BaseLib::ConfigTree config; BaseLib::ConfigTree config;
MeshLib::Mesh const& mesh; MeshLib::Mesh const& mesh;
std::optional<int> const component_id; int component_id;
}; };
} // namespace ProcessLib } // namespace ProcessLib
...@@ -172,14 +172,24 @@ ProcessVariable::ProcessVariable( ...@@ -172,14 +172,24 @@ ProcessVariable::ProcessVariable(
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__component} //! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__component}
st_config.getConfigParameterOptional<int>("component"); st_config.getConfigParameterOptional<int>("component");
if (!component_id && _n_components == 1) if (!component_id)
{ {
// default value for single component vars. if (_n_components == 1)
component_id = 0; {
// default value for single component vars.
component_id = 0;
}
else
{
OGS_FATAL(
"Specifying the component id (<component>) for a "
"source term for a non-scalar process variable is "
"mandatory.");
}
} }
_source_term_configs.emplace_back(std::move(st_config), st_mesh, _source_term_configs.emplace_back(std::move(st_config), st_mesh,
component_id); *component_id);
} }
} }
else else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment