Skip to content

File getngrid.h

File List > algebra > helpers > getngrid.h

Go to the documentation of this file

#ifndef TEMPLAT_LATTICE_ALGEBRA_HELPERS_GETNGRID_H
#define TEMPLAT_LATTICE_ALGEBRA_HELPERS_GETNGRID_H

/* This file is part of TempLat, available at https://cosmolattice.github.io/templat .
   Copyright 2021-2026 The TempLat authors, see AUTHORS.md.
   Released under the MIT license, see LICENSE.md. */

// File info: Main contributor(s): Adrien Florio, Year: 2020

#include "TempLat/lattice/algebra/helpers/hastoolbox.h"

namespace TempLat
{
  class GetNGrid
  {
  public:
    // Put public methods here. These should change very little over time.

    template <typename U>
      requires HasToolBox<U>
    static inline device::Idx get(U &&obj)
    {                                              // for isotropic lattices
      return obj.getToolBox()->mNGridPointsVec[0]; // Isotropic lattices only.
    }

    template <typename U>
      requires(!HasToolBox<U>)
    static inline device::Idx get(U &&obj)
    {
      return 1;
    }

    template <typename U>
      requires HasToolBox<U>
    static inline auto getVec(U &obj)
    {                                           // for isotropic lattices
      return obj.getToolBox()->mNGridPointsVec; // Isotropic lattices only.
    }

    template <typename U>
      requires(!HasToolBox<U>)
    static inline std::vector<device::Idx> getVec(U &obj)
    {
      return {};
    }

  private:
    /* Put all member variables and private methods here. These may change arbitrarily. */
  };
} // namespace TempLat

#endif