Commit f83fe630 authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov

Merge branch 'FixSolutionDependentDirichlet' into 'master'

[PL/BC] Bugfix solution dependent dirichlet boundary condition

See merge request !3123
parents d4af3a29 3e3b64ad
Pipeline #1485 failed with stages
in 91 minutes and 43 seconds
......@@ -24,6 +24,7 @@ namespace ProcessLib
{
SolutionDependentDirichletBoundaryCondition::
SolutionDependentDirichletBoundaryCondition(
std::string property_name,
ParameterLib::Parameter<double> const& parameter,
MeshLib::Mesh const& bc_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
......@@ -41,32 +42,33 @@ SolutionDependentDirichletBoundaryCondition::
_dof_table_boundary.reset(dof_table_bulk.deriveBoundaryConstrainedMap(
variable_id, {component_id}, std::move(bc_mesh_subset)));
std::string const property_name = "solution_dependent_bc";
if (bc_mesh.getProperties().existsPropertyVector<double>(property_name))
{
OGS_FATAL(
"Found mesh property '{:s}' which is the built-in property of the "
"Found mesh property '{:s}' in the mesh '{:s}' which is for "
"boundary assignment. This mesh property is the built-in property "
"of the "
"class SolutionDependentDirichletBoundaryCondition.",
property_name);
property_name, bc_mesh.getName());
}
auto& solution_dependent_bc = *MeshLib::getOrCreateMeshProperty<double>(
_solution_dependent_bc = MeshLib::getOrCreateMeshProperty<double>(
const_cast<MeshLib::Mesh&>(bc_mesh), property_name,
MeshLib::MeshItemType::Node, 1);
solution_dependent_bc.resize(bc_mesh.getNumberOfNodes());
_solution_dependent_bc->resize(bc_mesh.getNumberOfNodes());
ParameterLib::SpatialPosition pos;
auto const& nodes = bc_mesh.getNodes();
for (std::size_t i = 0; i < solution_dependent_bc.size(); ++i)
for (std::size_t i = 0; i < _solution_dependent_bc->size(); ++i)
{
auto const id = nodes[i]->getID();
pos.setNodeID(id);
solution_dependent_bc[i] = parameter(0, pos)[0];
(*_solution_dependent_bc)[i] = parameter(0, pos)[0];
}
_parameter = std::make_unique<ParameterLib::MeshNodeParameter<double>>(
property_name, bc_mesh, solution_dependent_bc);
property_name, bc_mesh, *_solution_dependent_bc);
}
void SolutionDependentDirichletBoundaryCondition::getEssentialBCValues(
......@@ -82,12 +84,8 @@ void SolutionDependentDirichletBoundaryCondition::postTimestep(
double const /*t*/, std::vector<GlobalVector*> const& x,
int const process_id)
{
auto& solution_dependent_bc =
*const_cast<MeshLib::Properties&>(_bc_mesh.getProperties())
.getPropertyVector<double>("solution_dependent_bc");
auto const& nodes = _bc_mesh.getNodes();
for (std::size_t i = 0; i < solution_dependent_bc.size(); ++i)
for (std::size_t i = 0; i < _solution_dependent_bc->size(); ++i)
{
auto const id = nodes[i]->getID();
auto const global_index = _dof_table_boundary->getGlobalIndex(
......@@ -95,7 +93,7 @@ void SolutionDependentDirichletBoundaryCondition::postTimestep(
_component_id);
assert(global_index >= 0);
solution_dependent_bc[i] = x[process_id]->get(global_index);
(*_solution_dependent_bc)[i] = x[process_id]->get(global_index);
}
}
......@@ -112,6 +110,10 @@ createSolutionDependentDirichletBoundaryCondition(
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__type}
config.checkConfigParameter("type", "SolutionDependentDirichlet");
auto property_name =
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__SolutionDependentDirichlet__property_name}
config.getConfigParameter<std::string>("property_name");
auto& initial_value_parameter = ParameterLib::findParameter<double>(
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__SolutionDependentDirichlet__initial_value_parameter}
config.getConfigParameter<std::string>("initial_value_parameter"),
......@@ -132,8 +134,8 @@ createSolutionDependentDirichletBoundaryCondition(
#endif // USE_PETSC
return std::make_unique<SolutionDependentDirichletBoundaryCondition>(
initial_value_parameter, bc_mesh, dof_table_bulk, variable_id,
component_id);
std::move(property_name), initial_value_parameter, bc_mesh,
dof_table_bulk, variable_id, component_id);
}
} // namespace ProcessLib
......@@ -28,6 +28,7 @@ class SolutionDependentDirichletBoundaryCondition final
{
public:
SolutionDependentDirichletBoundaryCondition(
std::string property_name,
ParameterLib::Parameter<double> const& parameter,
MeshLib::Mesh const& bc_mesh,
NumLib::LocalToGlobalIndexMap const& dof_table_bulk,
......@@ -58,6 +59,9 @@ private:
int const _component_id;
std::unique_ptr<NumLib::LocalToGlobalIndexMap const> _dof_table_boundary;
std::unique_ptr<ParameterLib::MeshNodeParameter<double>> _parameter;
// avoid repetitively retrieving the desired property from the boundary mesh
// over time steps
MeshLib::PropertyVector<double>* _solution_dependent_bc;
};
std::unique_ptr<SolutionDependentDirichletBoundaryCondition>
......
......@@ -439,6 +439,7 @@
<boundary_condition>
<mesh>1d_isofrac_upstream</mesh>
<type>SolutionDependentDirichlet</type>
<property_name>bc_Synthetica</property_name>
<initial_value_parameter>c_Synthetica</initial_value_parameter>
</boundary_condition>
</boundary_conditions>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment