Skip to content
Snippets Groups Projects
Select Git revision
  • f38904e3d21ff1b6cc44d9c7fda05ac1961a0d59
  • develop default protected
  • feature/gmsh-reader
  • origin/stage/bouguettaia
  • feature/kinetic-schemes
  • feature/reconstruction
  • feature/local-dt-fsi
  • feature/composite-scheme-sources
  • feature/composite-scheme-other-fluxes
  • feature/serraille
  • feature/variational-hydro
  • 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
  • feature/escobar-smoother
  • 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

MeshData.hpp

Blame
    • Stéphane Del Pino's avatar
      f38904e3
      Fix MeshData and MeshDataManager · f38904e3
      Stéphane Del Pino authored
      MeshData constructor can now only be called by MeshDataManager! This
      ensures only one construction of the data storage for each mesh
      
      Also fix following issues
      - volume calculation and checking was dangerously nested
      - few iterators were poorly named (due to copy/paste in MeshDataManager)
      f38904e3
      History
      Fix MeshData and MeshDataManager
      Stéphane Del Pino authored
      MeshData constructor can now only be called by MeshDataManager! This
      ensures only one construction of the data storage for each mesh
      
      Also fix following issues
      - volume calculation and checking was dangerously nested
      - few iterators were poorly named (due to copy/paste in MeshDataManager)
    SubItemValuePerItem.hpp 4.29 KiB
    #ifndef SUBITEM_VALUE_PER_ITEM_HPP
    #define SUBITEM_VALUE_PER_ITEM_HPP
    
    #include <Kokkos_StaticCrsGraph.hpp>
    #include <TypeOfItem.hpp>
    #include <PastisAssert.hpp>
    
    #include <ConnectivityMatrix.hpp>
    #include <IConnectivity.hpp>
    
    template <typename DataType,
              TypeOfItem SubItemType,
              TypeOfItem ItemType>
    class SubItemValuePerItem
    {
     private:
      ConnectivityMatrix::HostRowType m_host_row_map;
      Kokkos::View<DataType*> m_values;
    
     public:
      class SubView
      {
       private:
        KOKKOS_RESTRICT DataType* const m_sub_values;
        const size_t m_size;
       public:
        KOKKOS_INLINE_FUNCTION
        const DataType& operator[](const size_t& i) const
        {
          Assert(i<m_size);
          return m_sub_values[i];
        }
    
        KOKKOS_FORCEINLINE_FUNCTION
        DataType& operator[](const size_t& i)
        {
          Assert(i<m_size);
          return m_sub_values[i];
        }
    
        KOKKOS_INLINE_FUNCTION
        const size_t& size() const
        {
          return m_size;
        }
    
        SubView(const SubView&) = delete;
    
        KOKKOS_INLINE_FUNCTION
        SubView(SubView&&) = default;
    
        KOKKOS_INLINE_FUNCTION
        SubView(const Kokkos::View<DataType*>& values,
                const size_t& begin,
                const size_t& end)
            : m_sub_values(&(values[begin])),
              m_size(end-begin)
        {
          Assert(begin<=end);
          Assert(end<=values.extent(0));
        }
      };
    
      class SubViewConst
      {
       private:
        KOKKOS_RESTRICT const DataType* const m_sub_values;
        const size_t m_size;
       public:
        KOKKOS_FORCEINLINE_FUNCTION
        const DataType& operator[](const size_t& i) const
        {
          Assert(i<m_size);
          return m_sub_values[i];
        }
    
        KOKKOS_INLINE_FUNCTION
        const size_t& size() const
        {
          return m_size;
        }
    
        SubViewConst(const SubViewConst&) = delete;
    
        KOKKOS_INLINE_FUNCTION
        SubViewConst(SubViewConst&&) = default;
    
        KOKKOS_INLINE_FUNCTION
        SubViewConst(const Kokkos::View<DataType*>& values,
                     const size_t& begin,
                     const size_t& end)
            : m_sub_values(&(values[begin])),
              m_size(end-begin)
        {
          Assert(begin<=end);
          Assert(end<=values.extent(0));
        }
      };
    
      SubItemValuePerItem& operator=(const SubItemValuePerItem&) = default;
    
      KOKKOS_FORCEINLINE_FUNCTION
      DataType& operator()(const size_t& j, const size_t& r)
      {
        return m_values[m_host_row_map(j)+r];
      }
    
      KOKKOS_FORCEINLINE_FUNCTION
      const DataType& operator()(const size_t& j, const size_t& r) const
      {
        return m_values[m_host_row_map(j)+r];
      }
    
      KOKKOS_INLINE_FUNCTION
      size_t numberOfValues() const
      {
        return m_values.extent(0);
      }
    
      KOKKOS_FORCEINLINE_FUNCTION
      DataType& operator[](const size_t& i)
      {
        return m_values[i];
      }
    
      KOKKOS_FORCEINLINE_FUNCTION
      const DataType& operator[](const size_t & i) const
      {
        return m_values[i];
      }
    
      KOKKOS_INLINE_FUNCTION
      size_t numberOfItems() const
      {
        Assert(m_host_row_map.extent(0) != 0>0);
        return m_host_row_map.extent(0);
      }
    
      KOKKOS_INLINE_FUNCTION
      size_t numberOfSubValues(const size_t& i_cell) const
      {
        return m_host_row_map(i_cell+1)-m_host_row_map(i_cell);
      }
    
      KOKKOS_INLINE_FUNCTION
      SubView itemValues(const size_t& i_cell)
      {
        const auto& cell_begin = m_host_row_map(i_cell);
        const auto& cell_end = m_host_row_map(i_cell+1);
        return SubView(m_values, cell_begin, cell_end);
      }
    
      KOKKOS_INLINE_FUNCTION
      SubViewConst itemValues(const size_t& i_cell) const
      {
        const auto& cell_begin = m_host_row_map(i_cell);
        const auto& cell_end = m_host_row_map(i_cell+1);
        return SubViewConst(m_values, cell_begin, cell_end);
      }
    
      SubItemValuePerItem() = default;
    
      SubItemValuePerItem(const IConnectivity& connectivity)
      {
        ConnectivityMatrix connectivity_matrix
            = connectivity.itemToItemMatrix(ItemType,SubItemType);
        m_host_row_map = connectivity_matrix.rowsMap();
        m_values = Kokkos::View<DataType*>("values", connectivity_matrix.numEntries());
      }
    
      ~SubItemValuePerItem() = default;
    };
    
    template <typename DataType>
    using NodeValuePerCell = SubItemValuePerItem<DataType, TypeOfItem::node, TypeOfItem::cell>;
    
    template <typename DataType>
    using CellValuePerNode = SubItemValuePerItem<DataType, TypeOfItem::cell, TypeOfItem::node>;
    
    template <typename DataType>
    using CellValuePerFace = SubItemValuePerItem<DataType, TypeOfItem::cell, TypeOfItem::face>;
    
    #endif // SUBITEM_VALUE_PER_ITEM_HPP