Skip to content
Snippets Groups Projects
Commit 8337461f authored by Cristian Lalescu's avatar Cristian Lalescu
Browse files

add new per point get_grid_coords

parent cd3b48b1
No related branches found
No related tags found
No related merge requests found
...@@ -50,22 +50,32 @@ void interpolator_base<rnumber, interp_neighbours>::get_grid_coordinates( ...@@ -50,22 +50,32 @@ void interpolator_base<rnumber, interp_neighbours>::get_grid_coordinates(
const double *x, const double *x,
int *xg, int *xg,
double *xx) double *xx)
{
for (int p=0; p<nparticles; p++)
this->get_grid_coordinates(
x + p*pdimension,
xg + p*3,
xx + p*3);
}
template <class rnumber, int interp_neighbours>
void interpolator_base<rnumber, interp_neighbours>::get_grid_coordinates(
const double *x,
int *xg,
double *xx)
{ {
static double grid_size[] = {this->dx, this->dy, this->dz}; static double grid_size[] = {this->dx, this->dy, this->dz};
double tval; double tval;
std::fill_n(xg, nparticles*3, 0); for (int c=0; c<3; c++)
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[c]/grid_size[c]);
{ xg[c] = MOD(int(tval), this->descriptor->sizes[2-c]);
tval = floor(x[p*pdimension+c]/grid_size[c]); xx[c] = (x[c] - tval*grid_size[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 interpolator_base<float, 1>; template class interpolator_base<float, 1>;
template class interpolator_base<float, 2>; template class interpolator_base<float, 2>;
template class interpolator_base<float, 3>; template class interpolator_base<float, 3>;
......
...@@ -70,6 +70,10 @@ class interpolator_base ...@@ -70,6 +70,10 @@ class interpolator_base
const double *__restrict__ x, const double *__restrict__ x,
int *__restrict__ xg, int *__restrict__ xg,
double *__restrict__ xx); double *__restrict__ xx);
void get_grid_coordinates(
const double *__restrict__ x,
int *__restrict__ xg,
double *__restrict__ xx);
/* interpolate field at an array of locations */ /* interpolate field at an array of locations */
virtual void sample( virtual void sample(
const int nparticles, const int nparticles,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment