15 template <
typename T>
static int sgn(
T val)
17 return (
T(0) < val) - (val <
T(0));
22 k_vec[0] = index / ((N/2 + 1)*N);
23 k_vec[1] = (index / (N/2 + 1)) % N;
24 k_vec[2] = index % (N/2 + 1);
26 for (
unsigned int i = 0; i<2; i++) if (k_vec[i] > N/2) k_vec[i] -= N;
31 k_vec[0] = index / ((N/2 + 1)*N);
32 k_vec[1] = (index / (N/2 + 1)) % N;
33 k_vec[2] = index % (N/2 + 1);
35 for (
unsigned int i = 0; i<2; i++) if (k_vec[i] > N/2) k_vec[i] -= N;
43 for (
unsigned int i = 0; i<3; i++) tmp +=
pow2(k_vec[i]);
51 if ((vec >= (
int)per) || (vec < 0) ){
53 return (vec < 0) ? vec + (int)per : vec;
62 return ((vec >= per) || (vec < 0) ) ? vec - per * floor( vec / per ) : vec;
68 for (
T& pos : position) pos =
get_per(pos, per);
74 position[0] =
get_per(position[0], perx);
75 position[1] =
get_per(position[1], pery);
76 position[2] =
get_per(position[2], perz);
81 const size_t Np = particles.size();
82 #pragma omp parallel for 83 for (
size_t i = 0; i < Np; i++)
85 get_per(particles[i].position, per);
92 T d = std::abs(x_2 - x_1);
93 if (d <= per / 2)
return d;
94 else if (d <= per)
return per - d;
95 else d = fmod(d,
T(per));
96 if (d <= per / 2)
return d;
108 if (std::abs(d) <= per / 2)
return d;
109 else if (std::abs(d) <= per)
return d-
sgn(d)*per;
110 else d = fmod(d,
T(per));
111 if (std::abs(d) <= per / 2)
return d;
112 else return d-
sgn(d)*per;
125 for (
unsigned int i = 0; i < 3; i++) dst[i] =
get_sgn_distance_1D(x_from[i], x_to[i], per);
143 for (
unsigned int i = 0; i < 3; i++)
146 if (dx > 1)
return 0;
155 for (
unsigned int i = 0; i < 3; i++)
158 if (dx > 1.5)
return 0;
159 else if (dx > 0.5) w *=
pow2(1.5 - dx) / 2;
160 else w *= 3 / FTYPE_t(4) - dx*dx;
170 template<
unsigned int po
ints>
173 for(
size_t i = 0; i < 3; i++){
174 vec[i] = (int)(pos[i] - 0.5*(
int(points) - 2));
178 template<
unsigned int po
ints>
181 for(
size_t i = 0; i < 3; i++){
182 vec[i] = (int)(pos[i]/Hc) - 1;
186 template<
unsigned int po
ints>
188 if (++
counter == (points*points*points))
return false;
193 if ((
counter % (points*points)) == 0){
206 field(it.
vec) += value * wgh_sch<ORDER>(position, it.
vec, field.
N);
207 }
while( it.
iter() );
215 w = wgh_sch<ORDER>(position, it.
vec, field[0].N);
216 for (
size_t i = 0; i < 3; i++)
219 field[i](it.
vec) += value[i] * w;
221 }
while( it.
iter() );
229 value += field(it.
vec) * mod * wgh_sch<ORDER>(position, it.
vec, field.
N);
230 }
while( it.
iter() );
238 w = mod * wgh_sch<ORDER>(position, it.
vec, field[0].N);
239 for (
unsigned int i = 0; i < 3; i++)
242 value[i] += field[i](it.
vec) * w;
244 }
while( it.
iter() );
250 rho /=
pow((FTYPE_t)rho.
N, 3);
276 template class IT<3>;
FFTW_COMPLEX_TYPE * complex()
get fftw_complex pointer to data
double get_k_sq(size_t N, size_t index)
class handling particles (position only)
double wgh_sch< 1 >(const Vec_3D< double > &x, const Vec_3D< int > &y, size_t mesh_num)
Vec_3D< double > get_sgn_distance(const Vec_3D< double > &x_from, const Vec_3D< double > &x_to, size_t per)
static double wgh_sch(const Vec_3D< double > &x, const Vec_3D< int > &y, size_t mesh_num)
T get_distance_1D(const T x_1, const T x_2, const size_t per)
void fftw_execute_dft_r2c(const FFTW_PLAN_TYPE &p_F, Mesh &rho)
compute forward (real to complex) FFT on mesh (inplace)
: creates a mesh of N*N*(N+2) cells
void assign_to(Mesh &field, const Vec_3D< double > &position, const double value)
: class for effective iteration of cube of mesh cells
void fftw_execute_dft_c2r_triple(const FFTW_PLAN_TYPE &p_B, std::vector< Mesh > &rho)
compute three backward (complex to real) FFTs on vector of meshes (inplace)
void fftw_execute_dft_c2r(const FFTW_PLAN_TYPE &p_B, Mesh &rho)
compute backward (complex to real) FFT on mesh (inplace)
double get_distance(const Vec_3D< double > &x_1, const Vec_3D< double > &x_2, int per)
double wgh_sch< 2 >(const Vec_3D< double > &x, const Vec_3D< int > &y, size_t mesh_num)
Grid< NDIM, T > sqrt(Grid< NDIM, T > lhs)
static CCL_BEGIN_DECLS double x[111][8]
static std::enable_if< std::is_integral< T >::value, T >::type get_per(T vec, size_t per)
T get_sgn_distance_1D(T x_from, T x_to, size_t per)
void get_k_vec(size_t N, size_t index, int *k_vec)
basic functions to work with mesh
float pow(float base, unsigned long int exp)
: class handling basic 3D-vector functions, definitions
auto value(T const &val) -> Generator< T >
void fftw_execute_dft_r2c_triple(const FFTW_PLAN_TYPE &p_F, std::vector< Mesh > &rho)
compute three forward (real to complex) FFTs on vector of meshes (inplace)
void assign_from(const Mesh &field, const Vec_3D< double > &position, double &value, double mod)
IT(const Vec_3D< double > &pos)
static double w[2][28][111]