File size: 3,039 Bytes
10f2621
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef H_TABIPB_CLUSTERS_STRUCT_H
#define H_TABIPB_CLUSTERS_STRUCT_H

#include <cstddef>

#include "timer.h"
#include "particles.h"
#include "tree.h"
#include "params.h"

struct Timers_Clusters;

class Clusters
{
private:
    const class Particles& particles_;
    const class Tree& tree_;
    const struct Params& params_;
    struct Timers_Clusters& timers_;

    int num_interp_pts_per_node_;
    int num_charges_per_node_;
    
    std::size_t num_interp_pts_;
    std::size_t num_charges_;

    std::vector<double> interp_x_;
    std::vector<double> interp_y_;
    std::vector<double> interp_z_;
    
    std::vector<double> interp_charge_;
    std::vector<double> interp_charge_dx_;
    std::vector<double> interp_charge_dy_;
    std::vector<double> interp_charge_dz_;
    
    std::vector<double> interp_potential_;
    std::vector<double> interp_potential_dx_;
    std::vector<double> interp_potential_dy_;
    std::vector<double> interp_potential_dz_;
    
    
public:
    Clusters(const class Particles&, const class Tree&, const struct Params&, struct Timers_Clusters&);
    ~Clusters() = default;
    
    void upward_pass();
    void downward_pass(double* potential);
    
    void clear_charges();
    void clear_potentials();
    
    std::size_t num_interp_pts_per_node() const { return num_interp_pts_per_node_; };
    std::size_t num_charges_per_node()    const { return num_charges_per_node_; };
    const std::array<std::size_t, 2> cluster_interp_pts_idxs(std::size_t node_idx) const;
    const std::array<std::size_t, 2> cluster_charges_idxs(std::size_t node_idx) const;
    
    const double* interp_x_ptr() const { return interp_x_.data(); };
    const double* interp_y_ptr() const { return interp_y_.data(); };
    const double* interp_z_ptr() const { return interp_z_.data(); };
    
    const double* interp_charge_ptr()    const { return interp_charge_.data(); };
    const double* interp_charge_dx_ptr() const { return interp_charge_dx_.data(); };
    const double* interp_charge_dy_ptr() const { return interp_charge_dy_.data(); };
    const double* interp_charge_dz_ptr() const { return interp_charge_dz_.data(); };
    
    double* interp_potential_ptr()    { return interp_potential_.data(); };
    double* interp_potential_dx_ptr() { return interp_potential_dx_.data(); };
    double* interp_potential_dy_ptr() { return interp_potential_dy_.data(); };
    double* interp_potential_dz_ptr() { return interp_potential_dz_.data(); };
    
    void compute_all_interp_pts();
    void copyin_to_device() const;
    void delete_from_device() const;
    
};


struct Timers_Clusters
{
    Timer ctor;
    Timer upward_pass;
    Timer downward_pass;
    Timer clear_charges;
    Timer clear_potentials;
    Timer compute_all_interp_pts;
    Timer copyin_to_device;
    Timer delete_from_device;
    
    void print() const;
    std::string get_durations() const;
    std::string get_headers() const;

    Timers_Clusters() = default;
    ~Timers_Clusters() = default;
};

#endif /* H_TABIPB_CLUSTERS_STRUCT_H */