OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
PairConditions.h
Go to the documentation of this file.
1#ifndef PAIR_CONDITIONS_H
2#define PAIR_CONDITIONS_H
3
4#include "Region/NDRegion.h"
5
6#include <limits>
7
8template<class T, unsigned Dim>
10{
11public:
13 template<class V>
14 bool operator()(const V &/*a*/, const V &/*b*/) const
15 {
16 return true;
17 }
18
19 T getRange(unsigned) const { return std::numeric_limits<T>::max(); }
20};
21
22template<class T, unsigned Dim>
24{
25public:
27 { }
28
29 template<class V>
30 bool operator()(const V &a, const V &b) const
31 {
32 T sqr = 0;
33 for(unsigned int d = 0;d<Dim;++d)
34 {
35 sqr += (a[d]-b[d])*(a[d]-b[d]);
36 }
37 return sqr <= sqradius;
38 }
39
40 //periodic version of radius condition
41 template<class V, class Vec>
42 bool operator()(const V &a, const V &b, const Vec &/*period*/) const
43 {
44 T sqr = 0;
45 //std::cout << "checking radius condition for " << a << " and " << b << std::endl;
46 for(unsigned int d = 0;d<Dim;++d)
47 {
48 //sqr += (std::fmod((a[d]-b[d]+period[d]),period[d])*std::fmod((a[d]-b[d]+period[d]),period[d]));
49 sqr += (a[d]-b[d])*(a[d]-b[d]);
50 }
51 /*
52 if (sqr > sqradius)
53 std::cout << "rejected with dist = " << sqrt(sqr) << std::endl;
54 else
55 std::cout << "accepted with dist = " << sqrt(sqr) << std::endl;
56 */
57 return sqr <= sqradius;
58 }
59
60
61 T getRange(unsigned /*d*/) const { return radius; }
62private:
64};
65
66template<class T, unsigned Dim>
68{
69public:
71 { }
72
73 template<class V>
74 bool operator()(const V &a, const V &b) const
75 {
76 for(unsigned int d = 0;d<Dim;++d)
77 {
78 T diff = a[d]-b[d];
79 if(diff > box[d] || diff < -box[d])
80 return false;
81 }
82 return true;
83 }
84
85 T getRange(unsigned d) const { return box[d]; }
86private:
88};
89
90#endif
const unsigned Dim
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:84
std::complex< double > a
bool operator()(const V &, const V &) const
T getRange(unsigned) const
T getRange(unsigned) const
bool operator()(const V &a, const V &b, const Vec &) const
bool operator()(const V &a, const V &b) const
BoxCondition(T b[Dim])
bool operator()(const V &a, const V &b) const
T getRange(unsigned d) const