Skip to content
Snippets Groups Projects
Commit a88e4c19 authored by Chichi Lalescu's avatar Chichi Lalescu
Browse files

move get_grid_coords to interpolator

parent 2bd21b6b
Branches
Tags
No related merge requests found
...@@ -121,12 +121,35 @@ int rFFTW_interpolator<rnumber, interp_neighbours>::read_rFFTW(void *void_src) ...@@ -121,12 +121,35 @@ int rFFTW_interpolator<rnumber, interp_neighbours>::read_rFFTW(void *void_src)
} }
template <class rnumber, int interp_neighbours> template <class rnumber, int interp_neighbours>
void rFFTW_interpolator<rnumber, interp_neighbours>::operator()( void rFFTW_interpolator<rnumber, interp_neighbours>::get_grid_coordinates(
double t, const int nparticles,
const int pdimension,
const double *x,
int *xg, int *xg,
double *xx, double *xx)
{
static double grid_size[] = {this->dx, this->dy, this->dz};
double tval;
std::fill_n(xg, nparticles*3, 0);
std::fill_n(xx, nparticles*3, 0.0);
for (int p=0; p<nparticles; p++)
{
for (int c=0; c<3; c++)
{
tval = floor(x[p*pdimension+c]/grid_size[c]);
xg[p*3+c] = MOD(int(tval), this->descriptor->sizes[2-c]);
xx[p*3+c] = (x[p*pdimension+c] - tval*grid_size[c]) / grid_size[c];
}
}
}
template <class rnumber, int interp_neighbours>
void rFFTW_interpolator<rnumber, interp_neighbours>::operator()(
const double t,
const int *xg,
const double *xx,
double *dest, double *dest,
int *deriv) const int *deriv)
{ {
double bx[interp_neighbours*2+2], by[interp_neighbours*2+2], bz[interp_neighbours*2+2]; double bx[interp_neighbours*2+2], by[interp_neighbours*2+2], bz[interp_neighbours*2+2];
if (deriv == NULL) if (deriv == NULL)
......
...@@ -71,22 +71,24 @@ class rFFTW_interpolator ...@@ -71,22 +71,24 @@ class rFFTW_interpolator
/* map real locations to grid coordinates */ /* map real locations to grid coordinates */
void get_grid_coordinates( void get_grid_coordinates(
const int nparticles,
const int pdimension,
const double *__restrict__ x, const double *__restrict__ x,
const int *__restrict__ xg, int *__restrict__ xg,
const double *__restrict__ xx); double *__restrict__ xx);
/* interpolate field at an array of locations */ /* interpolate field at an array of locations */
void sample( void sample(
const int nparticles, const int nparticles,
const double t, const double t,
const double *__restrict__ x, const double *__restrict__ x,
const double *__restrict__ y, double *__restrict__ y,
const int *deriv = NULL); const int *deriv = NULL);
/* interpolate 1 point */ /* interpolate 1 point */
void operator()( void operator()(
const double t, const double t,
const int *__restrict__ xg, const int *__restrict__ xg,
const double *__restrict__ xx, const double *__restrict__ xx,
const double *__restrict__ dest, double *__restrict__ dest,
const int *deriv = NULL); const int *deriv = NULL);
int read_rFFTW(void *src); int read_rFFTW(void *src);
}; };
......
...@@ -132,7 +132,7 @@ void rFFTW_particles<particle_type, rnumber, interp_neighbours>::sample_vec_fiel ...@@ -132,7 +132,7 @@ void rFFTW_particles<particle_type, rnumber, interp_neighbours>::sample_vec_fiel
double *xx = new double[3*this->nparticles]; double *xx = new double[3*this->nparticles];
double *yy = new double[3*this->nparticles]; double *yy = new double[3*this->nparticles];
std::fill_n(yy, 3*this->nparticles, 0.0); std::fill_n(yy, 3*this->nparticles, 0.0);
this->get_grid_coordinates(x, xg, xx); vec->get_grid_coordinates(this->nparticles, this->ncomponents, x, xg, xx);
/* perform interpolation */ /* perform interpolation */
for (int p=0; p<this->nparticles; p++) for (int p=0; p<this->nparticles; p++)
(*vec)(t, xg + p*3, xx + p*3, yy + p*3, deriv); (*vec)(t, xg + p*3, xx + p*3, yy + p*3, deriv);
......
x 2015-12-04 make code py3 compatible @python3 x 2015-12-04 make code py3 compatible @python3
x 2015-12-23 decide on versioning system +merge0 x 2015-12-23 decide on versioning system +merge0
x 2015-12-24 move get_grid coords to interpolator @optimization +v1.0
(B) FFTW interpolator doesn't need its own field @optimization +v1.0 (B) FFTW interpolator doesn't need its own field @optimization +v1.0
(B) compute z polynomials only when needed @optimization +v1.0 (B) compute z polynomials only when needed @optimization +v1.0
(B) get rid of temporal interpolation @optimization +v1.0 (B) get rid of temporal interpolation @optimization +v1.0
(B) move get_grid coords to interpolator @optimization +v1.0
(B) use less memory @optimization (B) use less memory @optimization
(C) clean up machine_settings mess @design @documentation +v2.0 (C) clean up machine_settings mess @design @documentation +v2.0
(C) code overview @documentation (C) code overview @documentation
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment