From c4180b0be8ecc78d9a40bdbde43ed7561834f450 Mon Sep 17 00:00:00 2001 From: FZill <florian.zill@ufz.de> Date: Tue, 16 Jan 2024 14:31:58 +0100 Subject: [PATCH] [PL] added ids of active elements to process --- ProcessLib/Process.cpp | 20 ++++++++++++++++++++ ProcessLib/Process.h | 8 ++++++++ 2 files changed, 28 insertions(+) diff --git a/ProcessLib/Process.cpp b/ProcessLib/Process.cpp index 9004b0840cc..e45d6511274 100644 --- a/ProcessLib/Process.cpp +++ b/ProcessLib/Process.cpp @@ -202,6 +202,26 @@ void Process::updateDeactivatedSubdomains(double const time, { variable.get().updateDeactivatedSubdomains(time); } + _ids_of_active_elements.clear(); + for (ProcessLib::ProcessVariable const& pv : + getProcessVariables(process_id)) + { + auto const pv_active_element_ids = pv.getActiveElementIDs(); + // empty if no deactivated_subdomains exist in process variable + // executeSelectedMemberDereferenced with empty active_element_ids + // will run executeMemberDereferenced (i.e. on all elements) + if (pv_active_element_ids.empty()) + { + _ids_of_active_elements.clear(); + return; + } + std::vector<std::size_t> tempResult; + std::set_union( + _ids_of_active_elements.begin(), _ids_of_active_elements.end(), + pv_active_element_ids.begin(), pv_active_element_ids.end(), + std::back_inserter(tempResult)); + _ids_of_active_elements = std::move(tempResult); + } } void Process::preAssemble(const double t, double const dt, diff --git a/ProcessLib/Process.h b/ProcessLib/Process.h index ad90e756c2b..5bec907edaa 100644 --- a/ProcessLib/Process.h +++ b/ProcessLib/Process.h @@ -157,6 +157,11 @@ public: return _process_variables[process_id]; } + std::vector<std::size_t> const& getActiveElementIDs() const + { + return _ids_of_active_elements; + } + SecondaryVariableCollection const& getSecondaryVariables() const { return _secondary_variables; @@ -393,6 +398,9 @@ private: std::vector<SourceTermCollection> _source_term_collections; ExtrapolatorData _extrapolator_data; + + /// Union of active element ids per process variable + mutable std::vector<std::size_t> _ids_of_active_elements; }; } // namespace ProcessLib -- GitLab