File size: 3,044 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
#ifndef H_TABIPB_TREECODE_STRUCT_H
#define H_TABIPB_TREECODE_STRUCT_H

#include "timer.h"
#include "particles.h"
#include "clusters.h"
#include "interaction_list.h"

struct Timers_BoundaryElement;
struct Timers;

class BoundaryElement
{
private:
    class Particles& particles_;
    class Clusters& clusters_;
    const class Tree& tree_;
    const class InteractionList& interaction_list_;
    const class Molecule& molecule_;
    const struct Params& params_;
    struct Timers_BoundaryElement& timers_;
    
    std::vector<double> potential_;
    
    long int num_iter_;
    double residual_;
    
    double solvation_energy_;
    double free_energy_;
    double coulombic_energy_;
    
    double pot_min_;
    double pot_max_;
    double pot_normal_min_;
    double pot_normal_max_;
    
    int gmres_(long int n, const double* b, double* x, long int restrt,
               double* work, long int ldw, double *h, long int ldh,
               long int& iter, double& residual);
    
    void matrix_vector(double alpha, const double* __restrict potential_old,
                       double beta,        double* __restrict potential_new);
                       
    void precondition_diagonal(double* z, double* r);
    void precondition_block(double* z, double* r);
    
    void particle_particle_interact(double* __restrict potential,
                              const double* __restrict potential_old,
            std::array<std::size_t, 2> target_node_particle_idxs,
            std::array<std::size_t, 2> source_node_particle_idxs);
    
    void particle_cluster_interact(double* __restrict potential,
            std::array<std::size_t, 2> target_node_particle_idxs, std::size_t source_node_idx);
                                   
    void cluster_particle_interact(double* __restrict potential,
            std::size_t target_node_idx, std::array<std::size_t, 2> source_node_particle_idxs);
            
    void cluster_cluster_interact(double* __restrict potential,
            std::size_t target_node_idx, std::size_t source_node_idx);
    
public:
    BoundaryElement(class Particles& particles, class Clusters& clusters,
             const class Tree& tree, const class InteractionList& interaction_list,
             const class Molecule& molecule, const struct Params& params,
             struct Timers_BoundaryElement& timers);
    ~BoundaryElement() = default;
    
    void run_GMRES();
    void finalize();
    
    friend std::array<double, 3> Output(const BoundaryElement&, const Timers&);
};


struct Timers_BoundaryElement
{
    Timer ctor;
    Timer run_GMRES;
    Timer finalize;

    Timer matrix_vector;
    Timer precondition;
    Timer particle_particle_interact;
    Timer particle_cluster_interact;
    Timer cluster_particle_interact;
    Timer cluster_cluster_interact;

    void print() const;
    std::string get_durations() const;
    std::string get_headers() const;

    Timers_BoundaryElement() = default;
    ~Timers_BoundaryElement() = default;
};

#endif /* H_TABIPB_TREECODE_STRUCT_H */