ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
core/pair_criteria/PairCriterion.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef ESPRESSO_SRC_CORE_PAIR_CRITERIA_PAIR_CRITERION_HPP
20#define ESPRESSO_SRC_CORE_PAIR_CRITERIA_PAIR_CRITERION_HPP
21
22#include "Particle.hpp"
23#include "particle_node.hpp"
24
25namespace PairCriteria {
26/**
27 * @brief Criterion which returns a true/false value for a pair of particles.
28 */
30public:
31 /** @brief Make a decision based on two particles */
32 virtual bool decide(Particle const &p1, Particle const &p2) const = 0;
33 /**
34 * @brief Make a decision based on particle ids.
35 * This can only run on the head node outside of the integration loop.
36 */
37 bool decide(int id1, int id2) const {
38 // Retrieve particle data
39 auto const &p1 = get_particle_data(id1);
40 auto const &p2 = get_particle_data(id2);
41 const bool res = decide(p1, p2);
42 return res;
43 }
44 virtual ~PairCriterion() = default;
45};
46} // namespace PairCriteria
47
48#endif
Criterion which returns a true/false value for a pair of particles.
bool decide(int id1, int id2) const
Make a decision based on particle ids.
virtual ~PairCriterion()=default
virtual bool decide(Particle const &p1, Particle const &p2) const =0
Make a decision based on two particles.
const Particle & get_particle_data(int p_id)
Get particle data.
Particles creation and deletion.
Struct holding all information for one particle.
Definition Particle.hpp:395