From ee48514cf06abab48e4bc3ab1345fb29a4d5b159 Mon Sep 17 00:00:00 2001 From: Nils Leif Fischer Date: Mon, 1 Feb 2021 12:19:01 +0100 Subject: [PATCH] Loosen restrictions on divergence return buffer tags Allow the divergence function to write the result into any Variables that holds compatible tags, not only ::Tags::div. --- .../LinearOperators/Divergence.hpp | 16 +++++++------- .../LinearOperators/Divergence.tpp | 21 ++++++++++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/NumericalAlgorithms/LinearOperators/Divergence.hpp b/src/NumericalAlgorithms/LinearOperators/Divergence.hpp index 43610a23cfeb..be9cd8e3230b 100644 --- a/src/NumericalAlgorithms/LinearOperators/Divergence.hpp +++ b/src/NumericalAlgorithms/LinearOperators/Divergence.hpp @@ -63,11 +63,11 @@ auto divergence( inverse_jacobian) noexcept -> Variables>; -template +template void divergence( - gsl::not_null>*> - divergence_of_F, - const Variables& F, const Mesh& mesh, + gsl::not_null>*> divergence_of_F, + const Variables>& F, const Mesh& mesh, const InverseJacobian& inverse_jacobian) noexcept; // @} @@ -127,11 +127,9 @@ struct DivVariablesCompute : db::add_tag_prefix, db::ComputeTag { public: using base = db::add_tag_prefix; using return_type = typename base::type; - static constexpr void (*function)(const gsl::not_null, - const typename Tag::type&, const Mesh&, - const typename InverseJacobianTag::type&) = - divergence::Frame>; + static constexpr void (*function)( + const gsl::not_null, const typename Tag::type&, + const Mesh&, const typename InverseJacobianTag::type&) = divergence; using argument_tags = tmpl::list, InverseJacobianTag>; }; diff --git a/src/NumericalAlgorithms/LinearOperators/Divergence.tpp b/src/NumericalAlgorithms/LinearOperators/Divergence.tpp index 684cd2c1c5e1..b66e451fd74d 100644 --- a/src/NumericalAlgorithms/LinearOperators/Divergence.tpp +++ b/src/NumericalAlgorithms/LinearOperators/Divergence.tpp @@ -22,11 +22,11 @@ Variables> divergence( return divergence_of_F; } -template +template void divergence( - const gsl::not_null>*> - divergence_of_F, - const Variables& F, const Mesh& mesh, + const gsl::not_null>*> divergence_of_F, + const Variables>& F, const Mesh& mesh, const InverseJacobian& inverse_jacobian) noexcept { if (UNLIKELY(divergence_of_F->number_of_grid_points() != @@ -35,13 +35,13 @@ void divergence( } const auto logical_partial_derivatives_of_F = - logical_partial_derivatives(F, mesh); + logical_partial_derivatives>(F, mesh); - tmpl::for_each([ + const auto apply_div = [ &divergence_of_F, &inverse_jacobian, &logical_partial_derivatives_of_F - ](auto tag) noexcept { - using FluxTag = tmpl::type_from; - using DivFluxTag = Tags::div; + ](auto flux_tag_v, auto div_tag_v) noexcept { + using FluxTag = std::decay_t; + using DivFluxTag = std::decay_t; using first_index = tmpl::front; @@ -66,5 +66,6 @@ void divergence( } } } - }); + }; + EXPAND_PACK_LEFT_TO_RIGHT(apply_div(FluxTags{}, DivTags{})); }