<commit_before>#ifndef MJOLNIR_PLANE_HPP
#define MJOLNIR_PLANE_HPP
#include <mjolnir/core/System.hpp>
#include <mjolnir/core/BoundaryCondition.hpp>

namespace mjolnir
{

/*! @brief Plane for ExternalDistanceInteraction.                             *
 *  @details represents flat Plane. It provides a method to calculate         *
 *           a distance between particle and the plane, force direction       *
 *           a position of a particle. It also provide a functionality of     *
 *           a neighbor-list.                                                 */
template<typename traitsT>
class Plane
{
  public:
    typedef traitsT traits_type;
    typedef System<traits_type> system_type;
    typedef typename traits_type::real_type        real_type;
    typedef typename traits_type::coordinate_type  coordinate_type;
    typedef typename traits_type::boundary_type    boundary_type;
    typedef typename traits_type::particle_type    particle_type;

    static_assert(!std::is_same<boundary_type,
            CubicPeriodicBoundary<real_type, coordinate_type>>::value,
    "Plane that is NOT aligned with axes is not suitable to PeriodicBoundary");

  public:

    Plane(const coordinate_type& pos, const coordinate_type& n,
          const real_type mergin = 1)
        : position_(pos), normal_(n), mergin_(mergin), current_mergin_(-1)
    {}

    real_type calc_distance(
            const coordinate_type& pos, const boundary_type& bd) const
    {
        return dot_product(this->normal_,
                bd.adjust_direction(pos - this->position_));
    }

    coordinate_type calc_force_direction(
            const coordinate_type& pos, const boundary_type& bd) const
    {
        // calculate `f` that will be used in this form `F = -dV * f`;
        const real_type sign = std::copysign(real_type(1.0), dot_product(
                this->normal_, bd.adjust_direction(pos - this->position_)));
        return sign * normal_;
    }

    //! after calling it, update() should be called!
    void set_cutoff(const real_type rc) noexcept
    {this->cutoff_ = rc; this->current_mergin_ = -1;}
    void set_mergin(const real_type mg) noexcept
    {this->mergin_ = mg; this->current_mergin_ = -1;}

    template<typename Potential>
    void initialize(const system_type& sys, const Potential& pot)
    {
        const auto& topol = sys.topology();

        // update potential parameter
        this->exclusion_ = pot.ignored_particle(); // these are required by
        this->cutoff_    = pot.cutoff_length();    // ExternalPotential concept.
        // to use binary_search in this->make(), firstly sort this list.
        std::sort(this->exclusion_.begin(), this->exclusion_.end());

        // reconstruct neighbor list
        this->make(sys);
        return;
    }

    void make(const system_type& sys)
    {
        this->neighbors_.clear();
        const real_type threshold = cutoff_ * (1 + mergin_);
        for(std::size_t i=0; i<sys.size(); ++i)
        {
            if(std::binary_search(exclusion_.cbegin(), exclusion_.cend(), i))
            {continue;}

            const real_type dist =<commit_msg>fix function name<commit_after>#ifndef MJOLNIR_PLANE_HPP
#define MJOLNIR_PLANE_HPP
#include <mjolnir/core/System.hpp>
#include <mjolnir/core/BoundaryCondition.hpp>

namespace mjolnir
{

/*! @brief Plane for ExternalDistanceInteraction.                             *
 *  @details represents flat Plane. It provides a method to calculate         *
 *           a distance between particle and the plane, force direction       *
 *           a position of a particle. It also provide a functionality of     *
 *           a neighbor-list.                                                 */
template<typename traitsT>
class Plane
{
  public:
    typedef traitsT traits_type;
    typedef System<traits_type> system_type;
    typedef typename traits_type::real_type        real_type;
    typedef typename traits_type::coordinate_type  coordinate_type;
    typedef typename traits_type::boundary_type    boundary_type;
    typedef typename traits_type::particle_type    particle_type;

    static_assert(!std::is_same<boundary_type,
            CubicPeriodicBoundary<real_type, coordinate_type>>::value,
    "Plane that is NOT aligned with axes is not suitable to PeriodicBoundary");

  public:

    Plane(const coordinate_type& pos, const coordinate_type& n,
          const real_type mergin = 1)
        : position_(pos), normal_(n), mergin_(mergin), current_mergin_(-1)
    {}

    real_type calc_distance(
            const coordinate_type& pos, const boundary_type& bd) const
    {
        return dot_product(this->normal_,
                bd.adjust_direction(pos - this->position_));
    }

    coordinate_type calc_force_direction(
            const coordinate_type& pos, const boundary_type& bd) const
    {
        // calculate `f` that will be used in this form `F = -dV * f`;
        const real_type sign = std::copysign(real_type(1.0), dot_product(
                this->normal_, bd.adjust_direction(pos - this->position_)));
        return sign * normal_;
    }

    //! after calling it, update() should be called!
    void set_cutoff(const real_type rc) noexcept
    {this->cutoff_ = rc; this->current_mergin_ = -1;}
    void set_mergin(const real_type mg) noexcept
    {this->mergin_ = mg; this->current_mergin_ = -1;}

    template<typename Potential>
    void initialize(const system_type& sys, const Potential& pot)
    {
        const auto& topol = sys.topology();

        // update potential parameter
        this->exclusion_ = pot.ignored_particle();  // these are required by
        this->cutoff_    = pot.max_cutoff_length(); // ExternalPotential concept
        // to use binary_search in this->make(), firstly sort this list.
        std::sort(this->exclusion_.begin(), this->exclusion_.end());

        // reconstruct neighbor list
        this->make(sys);
        return;
    }

    void make(const system_type& sys)
    {
        this->neighbors_.clear();
        const real_type threshold = cutoff_ * (1 + mergin_);
        for(std::size_t i=0; i<sys.size(); ++i)
        {
            if(std::binary_search(exclusion_.cbegin(), exclusion_.cend(), i))
            {continue;}

            const real_type dist =
{'fraction_non_alphanumeric': 0.09778274046897432, 'fraction_numerical': 0.002552241186792152, 'mean_word_length': 2.574686431014823, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 47, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4189810', 'n_tokens_mistral': 1852, 'n_tokens_neox': 1763, 'n_words': 476}