SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Amr/Actions - RunAmrDiagnostics.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 25.0 % 4 1
Test Date: 2026-10-22 17:29:42
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*/, const size_t grid_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 title = Metavariables::amr::keep_coarse_grids
      71              :                                     ? MakeString{} << "AMR level " << grid_index
      72              :                                                    << ":\n"
      73              :                                     : std::string{""};
      74              :       const std::string string_gcc_needs_to_use_in_order_for_printf_to_compile =
      75              :           MakeString{} << "Average refinement levels: "
      76              :                        << avg_refinement_levels_by_dim
      77              :                        << "\nAverage grid points: " << avg_extents_by_dim
      78              :                        << "\n";
      79              :       Parallel::printf(
      80              :           "%s"
      81              :           "Number of elements: %zu\n"
      82              :           "Number of grid points: %zu\n"
      83              :           "%s\n",
      84              :           title, number_of_elements, number_of_grid_points,
      85              :           string_gcc_needs_to_use_in_order_for_printf_to_compile);
      86              :     }
      87              :   }
      88              : };
      89              : }  // namespace amr::Actions
        

Generated by: LCOV version 2.0-1