SpECTRE Documentation Coverage Report
Current view: top level - NumericalAlgorithms/Spectral - PrecomputedSpectralQuantity.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 0 2 0.0 %
Date: 2025-12-05 05:03:31
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 <cstddef>
       7             : 
       8             : #include "NumericalAlgorithms/Spectral/MaximumNumberOfPoints.hpp"
       9             : #include "NumericalAlgorithms/Spectral/MinimumNumberOfPoints.hpp"
      10             : #include "Utilities/ErrorHandling/Assert.hpp"
      11             : #include "Utilities/StaticCache.hpp"
      12             : 
      13             : /// \cond
      14             : namespace Spectral {
      15             : enum class Basis : uint8_t;
      16             : enum class Quadrature : uint8_t;
      17             : }  // namespace Spectral
      18             : /// \endcond
      19             : 
      20             : namespace Spectral::detail {
      21             : template <Basis BasisType, Quadrature QuadratureType,
      22             :           typename SpectralQuantityGenerator>
      23             : const auto& precomputed_spectral_quantity(const size_t num_points) {
      24             :   constexpr size_t max_num_points =
      25             :       Spectral::maximum_number_of_points<BasisType>;
      26             :   constexpr size_t min_num_points =
      27             :       Spectral::minimum_number_of_points<BasisType, QuadratureType>;
      28             :   ASSERT(num_points >= min_num_points,
      29             :          "Tried to work with less than the minimum number of collocation "
      30             :          "points for this quadrature.");
      31             :   ASSERT(num_points <= max_num_points,
      32             :          "Exceeded maximum number of collocation points.");
      33             :   // We compute the quantity for all possible `num_point`s the first time this
      34             :   // function is called and keep the data around for the lifetime of the
      35             :   // program. The computation is handled by the call operator of the
      36             :   // `SpectralQuantityType` instance.
      37             :   static const auto precomputed_data =
      38             :       make_static_cache<CacheRange<min_num_points, max_num_points + 1>>(
      39             :           SpectralQuantityGenerator{});
      40             :   return precomputed_data(num_points);
      41             : }
      42             : }  // namespace Spectral::detail
      43             : 
      44             : // clang-tidy: Macro arguments should be in parentheses, but we want to append
      45             : // template parameters here.
      46             : #define PRECOMPUTED_SPECTRAL_QUANTITY(function_name, return_type, \
      47           0 :                                       generator_name)             \
      48             :   template <Basis BasisType, Quadrature QuadratureType>           \
      49             :   const return_type& function_name(const size_t num_points) {     \
      50             :     return Spectral::detail::precomputed_spectral_quantity<       \
      51             :         BasisType, QuadratureType,                                \
      52             :         generator_name<BasisType, QuadratureType>>(/* NOLINT */   \
      53             :                                                    num_points);   \
      54             :   }

Generated by: LCOV version 1.14