SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Amr/Actions - RunAmrDiagnostics.hpp Hit Total Coverage
Commit: aabde07399ba7837e5db64eedfd0a21f31f96922 Lines: 1 4 25.0 %
Date: 2024-04-26 02:38:13
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 <boost/rational.hpp>
       7             : #include <cstddef>
       8             : #include <string>
       9             : #include <vector>
      10             : 
      11             : #include "DataStructures/DataBox/DataBox.hpp"
      12             : #include "IO/Logging/Tags.hpp"
      13             : #include "IO/Logging/Verbosity.hpp"
      14             : #include "Parallel/Printf/Printf.hpp"
      15             : #include "ParallelAlgorithms/Amr/Tags.hpp"
      16             : #include "Utilities/MakeString.hpp"
      17             : #include "Utilities/StdHelpers.hpp"
      18             : #include "Utilities/System/Abort.hpp"
      19             : #include "Utilities/TMPL.hpp"
      20             : 
      21             : /// \cond
      22             : namespace Parallel {
      23             : template <typename Metavariables>
      24             : class GlobalCache;
      25             : }  // namespace Parallel
      26             : namespace domain::Tags {
      27             : template <size_t VolumeDim>
      28             : struct Domain;
      29             : }  // namespace domain::Tags
      30             : /// \endcond
      31             : 
      32             : namespace amr::Actions {
      33             : 
      34             : /// \brief Use the AMR diagnostics gathered from all of the Element%s
      35             : ///
      36             : /// Checks the following:
      37             : /// - That the fraction of Block volume (in the logical coordinate frame)
      38             : /// covered by all Element%s is equal to the number of Block%s in the Domain
      39             : ///
      40             : /// Prints the following (as integers):
      41             : /// - The number of elements
      42             : /// - The number of grid points
      43             : /// - The average refinement level by logical dimension (i.e. not by the
      44             : ///   physical dimensions)
      45             : /// - The average number of grid points by logical dimension
      46           1 : struct RunAmrDiagnostics {
      47           0 :   using const_global_cache_tags =
      48             :       tmpl::list<logging::Tags::Verbosity<amr::OptionTags::AmrGroup>>;
      49             : 
      50             :   template <typename ParallelComponent, typename DbTagList,
      51             :             typename Metavariables, typename ArrayIndex>
      52           0 :   static void apply(db::DataBox<DbTagList>& box,
      53             :                     const Parallel::GlobalCache<Metavariables>& /*cache*/,
      54             :                     const ArrayIndex& /*array_index*/,
      55             :                     const boost::rational<size_t>& volume,
      56             :                     const size_t number_of_elements,
      57             :                     const size_t number_of_grid_points,
      58             :                     const std::vector<double>& avg_refinement_levels_by_dim,
      59             :                     const std::vector<double>& avg_extents_by_dim) {
      60             :     constexpr size_t volume_dim = Metavariables::volume_dim;
      61             :     const boost::rational<size_t> number_of_blocks{
      62             :         db::get<::domain::Tags::Domain<volume_dim>>(box).blocks().size()};
      63             :     if (number_of_blocks != volume) {
      64             :       sys::abort(MakeString{} << "Check Domain failed!  Expected volume "
      65             :                               << number_of_blocks << ", not " << volume
      66             :                               << "\n");
      67             :     }
      68             :     if (db::get<logging::Tags::Verbosity<amr::OptionTags::AmrGroup>>(box) >=
      69             :         Verbosity::Quiet) {
      70             :       const std::string string_gcc_needs_to_use_in_order_for_printf_to_compile =
      71             :           MakeString{} << "Average refinement levels: "
      72             :                        << avg_refinement_levels_by_dim
      73             :                        << "\nAverage grid points: " << avg_extents_by_dim
      74             :                        << "\n";
      75             :       Parallel::printf(
      76             :           "Number of elements: %zu\n"
      77             :           "Number of grid points: %zu\n"
      78             :           "%s\n",
      79             :           number_of_elements, number_of_grid_points,
      80             :           string_gcc_needs_to_use_in_order_for_printf_to_compile);
      81             :     }
      82             :   }
      83             : };
      84             : }  // namespace amr::Actions

Generated by: LCOV version 1.14