Skip to content
Snippets Groups Projects
Select Git revision
  • 39ecc278652d70b92848a4df7ee542b6139d5b78
  • develop default protected
  • feature/variational-hydro
  • origin/stage/bouguettaia
  • feature/gmsh-reader
  • feature/reconstruction
  • save_clemence
  • feature/kinetic-schemes
  • feature/local-dt-fsi
  • feature/composite-scheme-sources
  • feature/composite-scheme-other-fluxes
  • feature/serraille
  • feature/composite-scheme
  • hyperplastic
  • feature/polynomials
  • feature/gks
  • feature/implicit-solver-o2
  • feature/coupling_module
  • feature/implicit-solver
  • feature/merge-local-dt-fsi
  • master protected
  • v0.5.0 protected
  • v0.4.1 protected
  • v0.4.0 protected
  • v0.3.0 protected
  • v0.2.0 protected
  • v0.1.0 protected
  • Kidder
  • v0.0.4 protected
  • v0.0.3 protected
  • v0.0.2 protected
  • v0 protected
  • v0.0.1 protected
33 results

SchemeModule.cpp

Blame
  • Array.hpp 1.83 KiB
    #ifndef ARRAY_HPP
    #define ARRAY_HPP
    
    #include <PastisMacros.hpp>
    #include <PastisUtils.hpp>
    
    #include <PastisAssert.hpp>
    
    template <typename DataType>
    class Array
    {
     public:
      using data_type = DataType;
      using index_type = size_t;
    
     private:
      Kokkos::View<DataType*> m_values;
    
      // Allows const version to access our data
      friend Array<std::add_const_t<DataType>>;
    
     public:
      PASTIS_INLINE
      size_t size() const
      {
        return m_values.extent(0);
      }
    
      PASTIS_INLINE
      DataType& operator[](const index_type& i) const
      {
        Assert(i<m_values.extent(0));
        return m_values[i];
      }
    
      PASTIS_INLINE
      Array(const size_t& size)
          : m_values("anonymous", size)
      {
        static_assert(not std::is_const<DataType>(),
                      "Cannot allocate Array of const data: only view is supported");
      }
    
      template <typename DataType2>
      PASTIS_INLINE
      Array& operator=(const Array<DataType2>& array)
      {
        // ensures that DataType is the same as source DataType2
        static_assert(std::is_same<std::remove_const_t<DataType>, std::remove_const_t<DataType2>>(),
                      "Cannot assign Array of different type");
        // ensures that const is not lost through copy
        static_assert(((std::is_const<DataType2>() and std::is_const<DataType>())
                       or not std::is_const<DataType2>()),
                      "Cannot assign Array of const to  Array of non-const");
        m_values = array.m_values;
        return *this;
      }
    
      PASTIS_INLINE
      Array& operator=(const Array&) = default;
    
      PASTIS_INLINE
      Array& operator=(Array&&) = default;
    
      PASTIS_INLINE
      Array() = default;
    
      template <typename DataType2>
      PASTIS_INLINE
      Array(const Array<DataType2>& array)
      {
        this->operator=(array);
      }
    
      PASTIS_INLINE
      Array(Array&&) = default;
    
      PASTIS_INLINE
      Array(const Array&) = default;
    
      PASTIS_INLINE
      ~Array() = default;
    };
    
    #endif // ARRAY_HPP