SpECTRE Documentation Coverage Report
Current view: top level - Evolution/DgSubcell - SliceVariable.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 2 3 66.7 %
Date: 2024-04-23 20:50:18
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <algorithm>
       7             : #include <cstddef>
       8             : #include <unordered_set>
       9             : 
      10             : #include "DataStructures/DataVector.hpp"
      11             : #include "DataStructures/Index.hpp"
      12             : #include "DataStructures/Variables.hpp"
      13             : #include "Domain/Structure/Direction.hpp"
      14             : #include "Domain/Structure/DirectionMap.hpp"
      15             : #include "Domain/Structure/DirectionalId.hpp"
      16             : #include "Domain/Structure/DirectionalIdMap.hpp"
      17             : #include "Evolution/DgSubcell/SliceData.hpp"
      18             : #include "Utilities/Gsl.hpp"
      19             : 
      20             : namespace evolution::dg::subcell {
      21             : /// @{
      22             : /*!
      23             :  * \brief Slice a Variables object on subcell mesh for a given direction and
      24             :  * slicing depth (number of ghost points).
      25             :  */
      26             : template <size_t Dim, typename TagList>
      27           1 : void slice_variable(
      28             :     const gsl::not_null<Variables<TagList>*>& sliced_subcell_vars,
      29             :     const Variables<TagList>& volume_subcell_vars,
      30             :     const Index<Dim>& subcell_extents, const size_t ghost_zone_size,
      31             :     const Direction<Dim>& direction,
      32             :     const DirectionalIdMap<Dim, std::optional<intrp::Irregular<Dim>>>&
      33             :         fd_to_neighbor_fd_interpolants) {
      34             :   // check the size of sliced_subcell_vars (output)
      35             :   const size_t num_sliced_pts =
      36             :       subcell_extents.slice_away(direction.dimension()).product() *
      37             :       ghost_zone_size;
      38             :   if (sliced_subcell_vars->size() != num_sliced_pts) {
      39             :     sliced_subcell_vars->initialize(num_sliced_pts);
      40             :   }
      41             : 
      42             :   // Slice volume variables. Note that the return type of the
      43             :   // `slice_data_impl()` function is DataVector.
      44             :   std::unordered_set directions_to_slice{direction};
      45             : 
      46             :   const DataVector sliced_data{detail::slice_data_impl(
      47             :       gsl::make_span(volume_subcell_vars.data(), volume_subcell_vars.size()),
      48             :       subcell_extents, ghost_zone_size, directions_to_slice, 0,
      49             :       fd_to_neighbor_fd_interpolants)[direction]};
      50             : 
      51             :   // copy the returned DataVector data into sliced variables
      52             :   std::copy(sliced_data.begin(), sliced_data.end(),
      53             :             sliced_subcell_vars->data());
      54             : }
      55             : 
      56             : template <size_t Dim, typename TagList>
      57           1 : Variables<TagList> slice_variable(
      58             :     const Variables<TagList>& volume_subcell_vars,
      59             :     const Index<Dim>& subcell_extents, const size_t ghost_zone_size,
      60             :     const Direction<Dim>& direction,
      61             :     const DirectionalIdMap<Dim, std::optional<intrp::Irregular<Dim>>>&
      62             :         fd_to_neighbor_fd_interpolants) {
      63             :   Variables<TagList> sliced_subcell_vars{
      64             :       subcell_extents.slice_away(direction.dimension()).product() *
      65             :       ghost_zone_size};
      66             :   slice_variable(make_not_null(&sliced_subcell_vars), volume_subcell_vars,
      67             :                  subcell_extents, ghost_zone_size, direction,
      68             :                  fd_to_neighbor_fd_interpolants);
      69             :   return sliced_subcell_vars;
      70             : }
      71             : /// @}
      72             : }  // namespace evolution::dg::subcell

Generated by: LCOV version 1.14