SpECTRE Documentation Coverage Report
Current view: top level - DataStructures - StaticVector.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 10.0 % 10 1
Test Date: 2026-10-22 17:29:42
Legend: Lines:     hit not hit

            Line data    Source code
       1            1 : // Distributed under the MIT License.
       2              : // See LICENSE.txt for details.
       3              : 
       4              : /// \file
       5              : /// `blaze::StaticVector` is a general-purpose fixed size vector type. This file
       6              : /// implements interoperability of `blaze::StaticVector` with our data
       7              : /// structures.
       8              : 
       9              : #pragma once
      10              : 
      11              : #include <array>
      12              : #include <blaze/math/StaticVector.h>
      13              : #include <pup.h>
      14              : #include <type_traits>
      15              : 
      16              : #include "Options/ParseOptions.hpp"
      17              : #include "Utilities/ErrorHandling/Assert.hpp"
      18              : #include "Utilities/ErrorHandling/Error.hpp"
      19              : #include "Utilities/MakeWithValue.hpp"
      20              : #include "Utilities/SetNumberOfGridPoints.hpp"
      21              : 
      22              : namespace PUP {
      23              : /// @{
      24              : /// Serialization of blaze::StaticVector
      25              : template <typename T, size_t N, bool TF, blaze::AlignmentFlag AF,
      26              :           blaze::PaddingFlag PF, typename Tag>
      27              : void pup(er& p, blaze::StaticVector<T, N, TF, AF, PF, Tag>& t) {
      28              :   if (std::is_fundamental_v<T>) {
      29              :     PUParray(p, t.data(), N);
      30              :   } else {
      31              :     for (T& element : t) {
      32              :       p | element;
      33              :     }
      34              :   }
      35              : }
      36              : template <typename T, size_t N, bool TF, blaze::AlignmentFlag AF,
      37              :           blaze::PaddingFlag PF, typename Tag>
      38              : void operator|(er& p, blaze::StaticVector<T, N, TF, AF, PF, Tag>& t) {
      39              :   pup(p, t);
      40              : }
      41              : /// @}
      42              : }  // namespace PUP
      43              : 
      44              : namespace MakeWithValueImpls {
      45              : template <typename T, size_t N, bool TF, blaze::AlignmentFlag AF,
      46              :           blaze::PaddingFlag PF, typename Tag>
      47            0 : struct NumberOfPoints<blaze::StaticVector<T, N, TF, AF, PF, Tag>> {
      48            0 :   static constexpr size_t apply(
      49              :       const blaze::StaticVector<T, N, TF, AF, PF, Tag>& /*input*/) {
      50              :     return N;
      51              :   }
      52              : };
      53              : 
      54              : template <typename T, size_t N, bool TF, blaze::AlignmentFlag AF,
      55              :           blaze::PaddingFlag PF, typename Tag>
      56            0 : struct MakeWithSize<blaze::StaticVector<T, N, TF, AF, PF, Tag>> {
      57            0 :   static SPECTRE_ALWAYS_INLINE blaze::StaticVector<T, N, TF, AF, PF, Tag> apply(
      58              :       const size_t size, const T& value) {
      59              :     ASSERT(size == N, "Size mismatch for StaticVector: Expected "
      60              :                           << N << ", got " << size << ".");
      61              :     return blaze::StaticVector<T, N, TF, AF, PF, Tag>(value);
      62              :   }
      63              : };
      64              : }  // namespace MakeWithValueImpls
      65              : 
      66              : template <typename T, size_t N, bool TF, blaze::AlignmentFlag AF,
      67              :           blaze::PaddingFlag PF, typename Tag>
      68            0 : struct SetNumberOfGridPointsImpls::SetNumberOfGridPointsImpl<
      69              :     blaze::StaticVector<T, N, TF, AF, PF, Tag>> {
      70            0 :   static constexpr bool is_trivial = false;
      71            0 :   static SPECTRE_ALWAYS_INLINE void apply(
      72              :       const gsl::not_null<blaze::StaticVector<T, N, TF, AF, PF, Tag>*>
      73              :       /*result*/,
      74              :       const size_t size) {
      75              :     ERROR("Tried to resize a StaticVector to " << size);
      76              :   }
      77              : };
      78              : 
      79              : template <typename T, size_t N, bool TF, blaze::AlignmentFlag AF,
      80              :           blaze::PaddingFlag PF, typename Tag>
      81            0 : struct Options::create_from_yaml<blaze::StaticVector<T, N, TF, AF, PF, Tag>> {
      82              :   template <typename Metavariables>
      83            0 :   static blaze::StaticVector<T, N, TF, AF, PF, Tag> create(
      84              :       const Options::Option& options) {
      85              :     return {options.parse_as<std::array<T, N>>()};
      86              :   }
      87              : };
        

Generated by: LCOV version 2.0-1