particles.hpp 3.43 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
27
28
29
30
31
/**********************************************************************
*                                                                     *
*  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                                 *
*                                                                     *
**********************************************************************/



#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <hdf5.h>
#include "base.hpp"
32
#include "particles_base.hpp"
Cristian Lalescu's avatar
Cristian Lalescu committed
33
#include "fluid_solver_base.hpp"
34
#include "interpolator_base.hpp"
Cristian Lalescu's avatar
Cristian Lalescu committed
35
36
37
38
39

#ifndef PARTICLES

#define PARTICLES

40
template <particle_types particle_type, class rnumber, int interp_neighbours>
41
class particles: public particles_io_base<particle_type>
Cristian Lalescu's avatar
Cristian Lalescu committed
42
{
43
    private:
Cristian Lalescu's avatar
Cristian Lalescu committed
44
45
        double *state;
        double *rhs[6];
46
47

    public:
Cristian Lalescu's avatar
Cristian Lalescu committed
48
49
        int array_size;
        int integration_steps;
50
        interpolator_base<rnumber, interp_neighbours> *vel;
Cristian Lalescu's avatar
Cristian Lalescu committed
51
52
53
54
55
56
57
58
59
60
61
62
63

        /* simulation parameters */
        double dt;

        /* methods */

        /* constructor and destructor.
         * allocate and deallocate:
         *  this->state
         *  this->rhs
         * */
        particles(
                const char *NAME,
Cristian Lalescu's avatar
Cristian Lalescu committed
64
                const hid_t data_file_id,
65
                interpolator_base<rnumber, interp_neighbours> *FIELD,
Cristian Lalescu's avatar
Cristian Lalescu committed
66
67
68
69
                const int TRAJ_SKIP,
                const int INTEGRATION_STEPS = 2);
        ~particles();

70
71
72
        void sample(
                interpolator_base<rnumber, interp_neighbours> *field,
                const char *dset_name);
73

74
75
        inline void sample(
                interpolator_base<rnumber, interp_neighbours> *field,
76
                double *y)
77
        {
78
            field->sample(this->nparticles, state_dimension(particle_type), this->state, y);
79
80
        }

81
82
83
        void get_rhs(
                double *__restrict__ x,
                double *__restrict__ rhs);
Cristian Lalescu's avatar
Cristian Lalescu committed
84
85

        /* input/output */
86
        void read();
87
88
89
        void write(
                const char *dset_name,
                const double *data);
90
        void write(const bool write_rhs = true);
Cristian Lalescu's avatar
Cristian Lalescu committed
91
92
93
94

        /* solvers */
        void step();
        void roll_rhs();
95
        void AdamsBashforth(const int nsteps);
Cristian Lalescu's avatar
Cristian Lalescu committed
96
97
98
99
};

#endif//PARTICLES