SpECTRE Documentation Coverage Report
Current view: top level - DataStructures - DynamicVector.hpp Hit Total Coverage
Commit: aabde07399ba7837e5db64eedfd0a21f31f96922 Lines: 2 11 18.2 %
Date: 2024-04-26 02:38:13
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::DynamicVector` is a general-purpose dynamically sized vector type.
       6             : /// This file implements interoperability of `blaze::DynamicVector` with our
       7             : /// data structures.
       8             : 
       9             : #pragma once
      10             : 
      11             : #include <blaze/math/DynamicVector.h>
      12             : #include <pup.h>
      13             : #include <type_traits>
      14             : #include <vector>
      15             : 
      16             : #include "Utilities/MakeWithValue.hpp"
      17             : #include "Utilities/SetNumberOfGridPoints.hpp"
      18             : 
      19             : /// \cond
      20             : namespace Options {
      21             : struct Option;
      22             : template <typename T>
      23             : struct create_from_yaml;
      24             : }  // namespace Options
      25             : /// \endcond
      26             : 
      27             : namespace PUP {
      28             : /// @{
      29             : /// Serialization of blaze::DynamicVector
      30             : template <typename T, bool TF, typename Tag>
      31             : void pup(er& p, blaze::DynamicVector<T, TF, Tag>& t) {
      32             :   size_t size = t.size();
      33             :   p | size;
      34             :   if (p.isUnpacking()) {
      35             :     t.resize(size);
      36             :   }
      37             :   if (std::is_fundamental_v<T>) {
      38             :     PUParray(p, t.data(), size);
      39             :   } else {
      40             :     for (T& element : t) {
      41             :       p | element;
      42             :     }
      43             :   }
      44             : }
      45             : template <typename T, bool TF, typename Tag>
      46             : void operator|(er& p, blaze::DynamicVector<T, TF, Tag>& t) {
      47             :   pup(p, t);
      48             : }
      49             : /// @}
      50             : }  // namespace PUP
      51             : 
      52           1 : namespace MakeWithValueImpls {
      53             : template <typename T, bool TF, typename Tag>
      54           0 : struct NumberOfPoints<blaze::DynamicVector<T, TF, Tag>> {
      55             :   static SPECTRE_ALWAYS_INLINE size_t
      56           0 :   apply(const blaze::DynamicVector<T, TF, Tag>& input) {
      57             :     return input.size();
      58             :   }
      59             : };
      60             : 
      61             : template <typename T, bool TF, typename Tag>
      62           0 : struct MakeWithSize<blaze::DynamicVector<T, TF, Tag>> {
      63           0 :   static SPECTRE_ALWAYS_INLINE blaze::DynamicVector<T, TF, Tag> apply(
      64             :       const size_t size, const T& value) {
      65             :     return blaze::DynamicVector<T, TF, Tag>(size, value);
      66             :   }
      67             : };
      68             : }  // namespace MakeWithValueImpls
      69             : 
      70             : template <typename T, bool TF, typename Tag>
      71           0 : struct SetNumberOfGridPointsImpls::SetNumberOfGridPointsImpl<
      72             :     blaze::DynamicVector<T, TF, Tag>> {
      73           0 :   static constexpr bool is_trivial = false;
      74           0 :   static SPECTRE_ALWAYS_INLINE void apply(
      75             :       const gsl::not_null<blaze::DynamicVector<T, TF, Tag>*> result,
      76             :       const size_t size) {
      77             :     result->resize(size);
      78             :   }
      79             : };
      80             : 
      81             : namespace DynamicVector_detail {
      82             : template <typename T>
      83             : std::vector<T> parse_to_vector(const Options::Option& options);
      84             : }  // namespace DynamicVector_detail
      85             : 
      86             : template <typename T, bool TF, typename Tag>
      87           0 : struct Options::create_from_yaml<blaze::DynamicVector<T, TF, Tag>> {
      88             :   template <typename Metavariables>
      89           0 :   static blaze::DynamicVector<T, TF, Tag> create(
      90             :       const Options::Option& options) {
      91             :     const auto data = DynamicVector_detail::parse_to_vector<T>(options);
      92             :     blaze::DynamicVector<T, TF, Tag> result(data.size());
      93             :     std::copy(std::begin(data), std::end(data), result.begin());
      94             :     return result;
      95             :   }
      96             : };

Generated by: LCOV version 1.14