Skip to content

File confirmghosts.h

File List > algebra > helpers > confirmghosts.h

Go to the documentation of this file

#ifndef TEMPLAT_LATTICE_ALGEBRA_HELPERS_CONFIRMGHOSTS_H
#define TEMPLAT_LATTICE_ALGEBRA_HELPERS_CONFIRMGHOSTS_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): Wessel Valkenburg, Franz R. Sattler, Year: 2026

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

namespace TempLat
{
  class ConfirmGhosts
  {
  public:
    // Put public methods here. These should change very little over time.
    template <typename U>
      requires HasGhostMethod<U>
    static inline device::Idx apply(U &obj)
    {
      return obj.confirmGhostsUpToDate();
    }

    template <typename U>
      requires(!HasGhostMethod<U>)
    static constexpr inline device::Idx apply(U &obj)
    {
      return 0;
    }

    template <int N, typename U>
      requires HasGhostMethodIndexed<N, U>
    static inline device::Idx apply(U &obj, Tag<N> i)
    {
      return obj.confirmGhostsUpToDate(i);
    }

    template <int N, typename U>
      requires(!HasGhostMethodIndexed<N, U> && HasGhostMethodElement<N, U>)
    static inline device::Idx apply(U &obj, Tag<N> i)
    {
      return obj(i).confirmGhostsUpToDate();
    }

    template <int N, typename U>
      requires(!HasGhostMethodIndexed<N, U> && !HasGhostMethodElement<N, U>)
    static constexpr inline device::Idx apply(U &obj, Tag<N> i)
    {
      return 0;
    }

    template <typename U>
      requires HasGhostMethodDirectIndexed<U>
    static inline device::Idx apply(U &obj, device::Idx i)
    {
      return obj.confirmGhostsUpToDate(i);
    }

    template <typename U>
      requires(!HasGhostMethodDirectIndexed<U> && HasGhostMethodDirectElement<U>)
    static inline device::Idx apply(U &obj, device::Idx i)
    {
      return obj(i).confirmGhostsUpToDate();
    }

    template <typename U>
      requires(!HasGhostMethodDirectIndexed<U> && !HasGhostMethodDirectElement<U>)
    static constexpr inline device::Idx apply(U &obj, device::Idx i)
    {
      return 0;
    }

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

#endif