Line data Source code
1 0 : // Distributed under the MIT License. 2 : // See LICENSE.txt for details. 3 : 4 : #pragma once 5 : 6 : #include <array> 7 : #include <cstddef> 8 : #include <unordered_map> 9 : 10 : #include "DataStructures/DataBox/Tag.hpp" 11 : #include "DataStructures/Tags/TempTensor.hpp" 12 : #include "DataStructures/Tensor/Tensor.hpp" 13 : #include "DataStructures/Variables.hpp" 14 : #include "Domain/Structure/Direction.hpp" 15 : #include "Domain/Tags.hpp" 16 : #include "NumericalAlgorithms/Spectral/Mesh.hpp" 17 : #include "ParallelAlgorithms/LinearSolver/Schwarz/OverlapHelpers.hpp" 18 : #include "ParallelAlgorithms/LinearSolver/Schwarz/Tags.hpp" 19 : #include "Utilities/Gsl.hpp" 20 : #include "Utilities/SetNumberOfGridPoints.hpp" 21 : #include "Utilities/TMPL.hpp" 22 : 23 1 : namespace LinearSolver::Schwarz::Tags { 24 : 25 : /*! 26 : * \brief A diagnostic quantity to check that weights are conserved 27 : * 28 : * \see `LinearSolver::Schwarz::Tags::SummedIntrudingOverlapWeights` 29 : */ 30 : template <size_t Dim, typename OptionsGroup> 31 1 : struct SummedIntrudingOverlapWeightsCompute 32 : : db::ComputeTag, 33 : SummedIntrudingOverlapWeights<OptionsGroup> { 34 0 : using base = SummedIntrudingOverlapWeights<OptionsGroup>; 35 0 : using return_type = typename base::type; 36 0 : using argument_tags = 37 : tmpl::list<domain::Tags::Interface<domain::Tags::InternalDirections<Dim>, 38 : Weight<OptionsGroup>>, 39 : domain::Tags::Mesh<Dim>, IntrudingExtents<Dim, OptionsGroup>>; 40 0 : static void function( 41 : const gsl::not_null<return_type*> summed_intruding_overlap_weights, 42 : const std::unordered_map<Direction<Dim>, Scalar<DataVector>>& 43 : all_intruding_weights, 44 : const Mesh<Dim>& mesh, 45 : const std::array<size_t, Dim>& all_intruding_extents) { 46 : set_number_of_grid_points(summed_intruding_overlap_weights, 47 : mesh.number_of_grid_points()); 48 : get(*summed_intruding_overlap_weights) = 0.; 49 : for (const auto& [direction, intruding_weight] : all_intruding_weights) { 50 : // Extend intruding weight to full extents 51 : // There's not function to extend a single tensor, so we create a 52 : // temporary Variables. This is only a diagnostic quantity that won't be 53 : // used in production code, so it doesn't need to be particularly 54 : // efficient and we don't need to add an overload of 55 : // `LinearSolver::Schwarz::extended_overlap_data` just for this purpose. 56 : using temp_tag = ::Tags::TempScalar<0>; 57 : Variables<tmpl::list<temp_tag>> temp_vars{get(intruding_weight).size()}; 58 : get<temp_tag>(temp_vars) = intruding_weight; 59 : temp_vars = LinearSolver::Schwarz::extended_overlap_data( 60 : temp_vars, mesh.extents(), 61 : gsl::at(all_intruding_extents, direction.dimension()), direction); 62 : // Contribute to conserved weight 63 : get(*summed_intruding_overlap_weights) += get(get<temp_tag>(temp_vars)); 64 : } 65 : } 66 : }; 67 : 68 : } // namespace LinearSolver::Schwarz::Tags