Commit 92578a09 authored by Dmitry Yu. Naumov's avatar Dmitry Yu. Naumov
Browse files

[PL] Rewrite update of deactivated subdomains.

The previous implementation was looking for one deactivated
subdomain, but there could be multiple subdomains inactive
at the same time. Now all deactivated subdomains are
searched for active/inactive elements.
parent 15a2ed9b
......@@ -286,34 +286,38 @@ void ProcessVariable::updateDeactivatedSubdomains(double const time)
{
_ids_of_active_elements.clear();
auto found_a_set =
std::find_if(_deactivated_subdomains.begin(),
_deactivated_subdomains.end(),
[&](auto& _deactivated_subdomain) {
return _deactivated_subdomain->includesTimeOf(time);
});
if (found_a_set == _deactivated_subdomains.end())
{
return;
}
auto const* const material_ids = MeshLib::materialIDs(_mesh);
auto const& deactivated_materialIDs = (*found_a_set)->materialIDs;
auto is_active_in_subdomain = [&](std::size_t const i,
DeactivatedSubdomain const& ds) -> bool {
if (!ds.includesTimeOf(time))
{
return true;
}
auto const* const material_ids = MeshLib::materialIDs(_mesh);
auto const number_of_elements = _mesh.getNumberOfElements();
auto const& deactivated_materialIDs =
ds.materialIDs;
for (std::size_t i = 0; i < number_of_elements; i++)
{
auto const& element_center = getCenterOfGravity(*_mesh.getElement(i));
if (std::binary_search(deactivated_materialIDs.begin(),
deactivated_materialIDs.end(),
(*material_ids)[i]) &&
(*found_a_set)->isDeactivated(element_center, time))
ds.isDeactivated(element_center, time))
{
continue;
return false;
}
return true;
};
auto const number_of_elements = _mesh.getNumberOfElements();
for (std::size_t i = 0; i < number_of_elements; i++)
{
if (std::all_of(
begin(_deactivated_subdomains), end(_deactivated_subdomains),
[&](auto const& ds) { return is_active_in_subdomain(i, *ds); }))
{
_ids_of_active_elements.push_back(_mesh.getElement(i)->getID());
}
_ids_of_active_elements.push_back(_mesh.getElement(i)->getID());
}
}
......
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