interpolator.hpp 3.07 KB
Newer Older
Cristian Lalescu's avatar
Cristian Lalescu committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/**********************************************************************
*                                                                     *
*  Copyright 2015 Max Planck Institute                                *
*                 for Dynamics and Self-Organization                  *
*                                                                     *
*  This file is part of bfps.                                         *
*                                                                     *
*  bfps is free software: you can redistribute it and/or modify       *
*  it under the terms of the GNU General Public License as published  *
*  by the Free Software Foundation, either version 3 of the License,  *
*  or (at your option) any later version.                             *
*                                                                     *
*  bfps is distributed in the hope that it will be useful,            *
*  but WITHOUT ANY WARRANTY; without even the implied warranty of     *
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *
*  GNU General Public License for more details.                       *
*                                                                     *
*  You should have received a copy of the GNU General Public License  *
*  along with bfps.  If not, see <http://www.gnu.org/licenses/>       *
*                                                                     *
* Contact: Cristian.Lalescu@ds.mpg.de                                 *
*                                                                     *
**********************************************************************/



Cristian Lalescu's avatar
Cristian Lalescu committed
27
#include <cmath>
28
#include "field_descriptor.hpp"
29
#include "fftw_tools.hpp"
30
#include "fluid_solver_base.hpp"
31
#include "interpolator_base.hpp"
Cristian Lalescu's avatar
Cristian Lalescu committed
32

33
#ifndef INTERPOLATOR
Cristian Lalescu's avatar
Cristian Lalescu committed
34

35
#define INTERPOLATOR
Cristian Lalescu's avatar
Cristian Lalescu committed
36

37
template <class rnumber, int interp_neighbours>
38
class interpolator:public interpolator_base<rnumber, interp_neighbours>
39
{
Cristian Lalescu's avatar
Cristian Lalescu committed
40
41
42
43
    private:
        /* pointer to buffered field */
        rnumber *field;

44
    public:
45
        using interpolator_base<rnumber, interp_neighbours>::operator();
46
        ptrdiff_t buffer_size;
47
48

        /* descriptor for buffered field */
49
        field_descriptor<rnumber> *buffered_descriptor;
50

51
        interpolator(
52
                fluid_solver_base<rnumber> *FSOLVER,
53
54
                base_polynomial_values BETA_POLYS,
                ...);
55
        ~interpolator();
56

57
        int read_rFFTW(const void *src);
58

59
        inline int get_rank(double z)
Cristian Lalescu's avatar
Cristian Lalescu committed
60
        {
61
            return this->descriptor->rank[MOD(int(floor(z/this->dz)), this->descriptor->sizes[0])];
Cristian Lalescu's avatar
Cristian Lalescu committed
62
63
        }

64
65
66
67
68
69
70
71
72
73
74
75
        /* interpolate field at an array of locations */
        void sample(
                const int nparticles,
                const int pdimension,
                const double *__restrict__ x,
                double *__restrict__ y,
                const int *deriv = NULL);
        void operator()(
                const int *__restrict__ xg,
                const double *__restrict__ xx,
                double *__restrict__ dest,
                const int *deriv = NULL);
76
77
};

78
#endif//INTERPOLATOR
Cristian Lalescu's avatar
Cristian Lalescu committed
79