From: Marco Feder Date: Tue, 19 Sep 2023 11:10:56 +0000 (+0000) Subject: Add signals for non nested mg X-Git-Tag: relicensing~471^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a37afd91ce341a333103e0b224130c4e7e9339a3;p=dealii.git Add signals for non nested mg --- diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.h index 222cb12923..3b569ce551 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.h @@ -52,6 +52,49 @@ namespace RepartitioningPolicyTools #endif +namespace mg +{ + /** + * A structure with boost::signal objects for optional processing in a + * non-nested multigrid solver. + * + * Similarly to mg::Signals, each signal is called twice: once before and once + * after the action is performed. The two calls only differ in the boolean argument @p before, which is true the first time and false the second. + * + */ + struct SignalsNonNested + { + /** + * This signal is triggered before and after the call to actual evaluation + * function inside RemotePointEvaluation::evaluate_and_process() during + * prolongation. + */ + boost::signals2::signal evaluation_prolongation; + + /** + * This signal is triggered before and after the call to actual evaluation + * function inside RemotePointEvaluation::process_and_evaluate() during + * restriction. + */ + boost::signals2::signal evaluation_restriction; + + /** + * This signal is triggered before and after the call to + * RemotePointEvaluation::evaluate_and_process() used in + * MGTwoLevelTransferNonNested::prolongate_and_add(). The difference with the @p evaluation + * signal is that also the communication phase is included. + */ + boost::signals2::signal evaluate_and_process; + + /** + * This signal is triggered before and after the call to + * RemotePointEvaluation::process_and_evaluate() used in + * MGTwoLevelTransferNonNested::restrict_and_add(). Similarly to the @p evaluate_and_process signal, + * also the communication phase is included. + */ + boost::signals2::signal process_and_evaluate; + }; +} // namespace mg /** * Global coarsening utility functions. @@ -705,6 +748,8 @@ class MGTwoLevelTransferNonNested; + mg::SignalsNonNested signals_non_nested; + public: /** * AdditionalData structure that can be used to tweak parameters @@ -798,6 +843,34 @@ public: std::size_t memory_consumption() const override; + /** + * Connect a function to mg::SignalsNonNested::evaluation_restriction. + * + */ + boost::signals2::connection + connect_evaluation_prolongation(const std::function &slot); + + /** + * Connect a function to mg::SignalsNonNested::evaluation_restriction. + * + */ + boost::signals2::connection + connect_evaluation_restriction(const std::function &slot); + + /** + * Connect a function to mg::SignalsNonNested::evaluate_and_process. + * + */ + boost::signals2::connection + connect_evaluate_and_process(const std::function &slot); + + /** + * Connect a function to mg::SignalsNonNested::process_and_evaluate. + * + */ + boost::signals2::connection + connect_process_and_evaluate(const std::function &slot); + protected: AdditionalData additional_data; /** diff --git a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h index 55d81d247c..b00bcfeea8 100644 --- a/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h +++ b/include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h @@ -4942,6 +4942,7 @@ MGTwoLevelTransferNonNested>:: std::vector buffer; const auto evaluation_function = [&](auto &values, const auto &cell_data) { + this->signals_non_nested.evaluation_prolongation(true); std::vector solution_values; FEPointEvaluation evaluator(*mapping_info, @@ -4971,11 +4972,14 @@ MGTwoLevelTransferNonNested>:: values[q + cell_data.reference_point_ptrs[cell]] = evaluator.get_value(q); } + this->signals_non_nested.evaluation_prolongation(false); }; + this->signals_non_nested.evaluate_and_process(true); rpe.template evaluate_and_process(evaluation_point_results, buffer, evaluation_function); + this->signals_non_nested.evaluate_and_process(false); // Weight operator in case some points are owned by multiple cells. if (rpe.is_map_unique() == false) @@ -5117,6 +5121,7 @@ MGTwoLevelTransferNonNested>:: const auto evaluation_function = [&](const auto &values, const auto &cell_data) { + this->signals_non_nested.evaluation_restriction(true); std::vector solution_values; FEPointEvaluation evaluator(*mapping_info, *fe_coarse); @@ -5146,11 +5151,14 @@ MGTwoLevelTransferNonNested>:: solution_values.size(), true); } + this->signals_non_nested.evaluation_restriction(false); }; + this->signals_non_nested.process_and_evaluate(true); rpe.template process_and_evaluate(evaluation_point_results, buffer, evaluation_function); + this->signals_non_nested.process_and_evaluate(false); } @@ -5219,6 +5227,46 @@ MGTwoLevelTransferNonNested>:: } + +template +boost::signals2::connection +MGTwoLevelTransferNonNested>:: + connect_evaluation_prolongation(const std::function &slot) +{ + return signals_non_nested.evaluation_prolongation.connect(slot); +} + + + +template +boost::signals2::connection +MGTwoLevelTransferNonNested>:: + connect_evaluation_restriction(const std::function &slot) +{ + return signals_non_nested.evaluation_restriction.connect(slot); +} + + + +template +boost::signals2::connection +MGTwoLevelTransferNonNested>:: + connect_evaluate_and_process(const std::function &slot) +{ + return signals_non_nested.evaluate_and_process.connect(slot); +} + + + +template +boost::signals2::connection +MGTwoLevelTransferNonNested>:: + connect_process_and_evaluate(const std::function &slot) +{ + return signals_non_nested.process_and_evaluate.connect(slot); +} + + DEAL_II_NAMESPACE_CLOSE #endif