ComputeTags.hpp
1 // 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"
15 #include "Domain/Tags.hpp"
17 #include "ParallelAlgorithms/LinearSolver/Schwarz/OverlapHelpers.hpp"
18 #include "ParallelAlgorithms/LinearSolver/Schwarz/Tags.hpp"
19 #include "Utilities/Gsl.hpp"
20 #include "Utilities/TMPL.hpp"
21 
23 
24 /*!
25  * \brief A diagnostic quantity to check that weights are conserved
26  *
27  * \see `LinearSolver::Schwarz::Tags::SummedIntrudingOverlapWeights`
28  */
29 template <size_t Dim, typename OptionsGroup>
32  SummedIntrudingOverlapWeights<OptionsGroup> {
34  using return_type = typename base::type;
35  using argument_tags =
36  tmpl::list<domain::Tags::Interface<domain::Tags::InternalDirections<Dim>,
39  static void function(
40  const gsl::not_null<return_type*> summed_intruding_overlap_weights,
42  all_intruding_weights,
43  const Mesh<Dim>& mesh,
44  const std::array<size_t, Dim>& all_intruding_extents) noexcept {
45  destructive_resize_components(summed_intruding_overlap_weights,
46  mesh.number_of_grid_points());
47  get(*summed_intruding_overlap_weights) = 0.;
48  for (const auto& [direction, intruding_weight] : all_intruding_weights) {
49  // Extend intruding weight to full extents
50  // There's not function to extend a single tensor, so we create a
51  // temporary Variables. This is only a diagnostic quantity that won't be
52  // used in production code, so it doesn't need to be particularly
53  // efficient and we don't need to add an overload of
54  // `LinearSolver::Schwarz::extended_overlap_data` just for this purpose.
55  using temp_tag = ::Tags::TempScalar<0>;
56  Variables<tmpl::list<temp_tag>> temp_vars{get(intruding_weight).size()};
57  get<temp_tag>(temp_vars) = intruding_weight;
59  temp_vars, mesh.extents(),
60  gsl::at(all_intruding_extents, direction.dimension()), direction);
61  // Contribute to conserved weight
62  get(*summed_intruding_overlap_weights) += get(get<temp_tag>(temp_vars));
63  }
64  }
65 };
66 
67 } // namespace LinearSolver::Schwarz::Tags
LinearSolver::Schwarz::intruding_weight
DataVector intruding_weight(const DataVector &logical_coords, double width, const Side &side) noexcept
Weights for the intruding solution of a neighboring element-centered subdomain, increasing from 0 to ...
gsl::at
constexpr T & at(std::array< T, N > &arr, Size index)
Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid.
Definition: Gsl.hpp:125
db::ComputeTag
Mark a struct as a compute tag by inheriting from this.
Definition: Tag.hpp:157
LinearSolver::Schwarz::Tags::SummedIntrudingOverlapWeightsCompute
A diagnostic quantity to check that weights are conserved.
Definition: ComputeTags.hpp:30
Tags.hpp
domain::Tags::Mesh
The computational grid of the Element in the DataBox.
Definition: Tags.hpp:107
LinearSolver::Schwarz::Tags::IntrudingExtents
The number of points a neighbor's subdomain extends into the element.
Definition: Tags.hpp:126
db::get
const auto & get(const DataBox< TagList > &box) noexcept
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:791
cstddef
array
LinearSolver::Schwarz::Tags::Weight
Weighting field for combining data from multiple overlapping subdomains.
Definition: Tags.hpp:145
LinearSolver::Schwarz::extended_overlap_data
void extended_overlap_data(const gsl::not_null< Variables< ExtendedTagsList > * > extended_data, const Variables< OverlapTagsList > &overlap_data, const Index< Dim > &volume_extents, const size_t overlap_extent, const Direction< Dim > &direction) noexcept
Extend the overlap data to the full mesh by filling it with zeros outside the overlap region.
Definition: OverlapHelpers.hpp:253
Variables.hpp
Mesh
Holds the number of grid points, basis, and quadrature in each direction of the computational grid.
Definition: Mesh.hpp:49
LinearSolver::Schwarz::Tags::SummedIntrudingOverlapWeights
A diagnostic quantity to check that weights are conserved.
Definition: Tags.hpp:160
Scalar
Tensor< T, Symmetry<>, index_list<> > Scalar
Definition: TypeAliases.hpp:21
Tags::TempTensor
Definition: TempTensor.hpp:21
Gsl.hpp
LinearSolver::Schwarz::Tags
Tags related to the Schwarz solver.
Definition: ComputeTags.hpp:22
Tensor.hpp
Direction.hpp
unordered_map
TMPL.hpp
Mesh.hpp
gsl::not_null
Require a pointer to not be a nullptr
Definition: ReadSpecPiecewisePolynomial.hpp:13
destructive_resize_components
void destructive_resize_components(const gsl::not_null< Container * > container, const size_t new_size, DestructiveResizeFunction destructive_resize=ContainerDestructiveResize{}) noexcept
Checks the size of each component of the container, and resizes if necessary.
Definition: ContainerHelpers.hpp:177