|
36 | 36 | namespace SPH |
37 | 37 | { |
38 | 38 | template <class NeighborMethodType> |
39 | | -class Neighbor |
| 39 | +class Neighbor : public NeighborMethodType |
40 | 40 | { |
41 | 41 | public: |
42 | 42 | template <class SourceIdentifier, class TargetIdentifier> |
43 | 43 | Neighbor(SourceIdentifier &source_identifier, TargetIdentifier &contact_identifier, |
44 | 44 | DiscreteVariable<Vecd> *dv_source_pos, DiscreteVariable<Vecd> *dv_target_pos) |
45 | | - : neighbor_method_(source_identifier, contact_identifier), |
| 45 | + : NeighborMethodType(source_identifier, contact_identifier), |
46 | 46 | dv_source_pos_(dv_source_pos), dv_target_pos_(dv_target_pos){}; |
47 | 47 |
|
48 | | - class NeighborKernel |
| 48 | + class NeighborKernel : public NeighborMethodType::SmoothingKernel |
49 | 49 | { |
50 | | - using SmoothingKernel = typename NeighborMethodType::SmoothingKernel; |
| 50 | + using BaseKernel = typename NeighborMethodType::SmoothingKernel; |
51 | 51 |
|
52 | 52 | public: |
53 | 53 | template <class ExecutionPolicy, class EncloserType> |
54 | 54 | NeighborKernel(const ExecutionPolicy &ex_policy, EncloserType &encloser) |
55 | | - : smoothing_kernel_(ex_policy, encloser.neighbor_method_), |
| 55 | + : BaseKernel(ex_policy, encloser), |
56 | 56 | source_pos_(encloser.dv_source_pos_->DelegatedData(ex_policy)), |
57 | 57 | target_pos_(encloser.dv_target_pos_->DelegatedData(ex_policy)){}; |
58 | 58 |
|
59 | 59 | inline Vecd vec_r_ij(UnsignedInt i, UnsignedInt j) const { return source_pos_[i] - target_pos_[j]; }; |
60 | 60 | inline Vecd e_ij(UnsignedInt i, UnsignedInt j) const { return vec_r_ij(i, j).normalized(); }; |
61 | | - inline Real W_ij(UnsignedInt i, UnsignedInt j) const { return smoothing_kernel_.W(vec_r_ij(i, j)); }; |
62 | | - inline Real dW_ij(UnsignedInt i, UnsignedInt j) const { return smoothing_kernel_.dW(vec_r_ij(i, j)); }; |
63 | | - inline Real W(const Vecd &displacement) const { return smoothing_kernel_.W(displacement); }; |
| 61 | + inline Real W_ij(UnsignedInt i, UnsignedInt j) const { return BaseKernel::W(vec_r_ij(i, j)); }; |
| 62 | + inline Real dW_ij(UnsignedInt i, UnsignedInt j) const { return BaseKernel::dW(vec_r_ij(i, j)); }; |
64 | 63 |
|
65 | 64 | protected: |
66 | | - SmoothingKernel smoothing_kernel_; |
67 | 65 | Vecd *source_pos_; |
68 | 66 | Vecd *target_pos_; |
69 | 67 | }; |
70 | 68 |
|
71 | | - class NeighborCriterion |
| 69 | + class NeighborCriterion : public NeighborMethodType::NeighborCriterion |
72 | 70 | { |
73 | | - using CriterionKernel = typename NeighborMethodType::CriterionKernel; |
| 71 | + using BaseKernel = typename NeighborMethodType::NeighborCriterion; |
74 | 72 |
|
75 | 73 | public: |
76 | 74 | template <class ExecutionPolicy, class EncloserType> |
77 | 75 | NeighborCriterion(const ExecutionPolicy &ex_policy, EncloserType &encloser) |
78 | | - : criterion_kernel_(ex_policy, encloser.neighbor_method_, |
79 | | - encloser.dv_source_pos_, encloser.dv_target_pos_){}; |
| 76 | + : BaseKernel(ex_policy, encloser, encloser.dv_source_pos_, encloser.dv_target_pos_){}; |
80 | 77 |
|
81 | 78 | inline bool operator()(UnsignedInt target_index, UnsignedInt source_index) const |
82 | 79 | { |
83 | | - return criterion_kernel_(source_index, target_index); |
| 80 | + return BaseKernel::operator()(source_index, target_index); // Note the order of indices |
84 | 81 | }; |
85 | | - |
86 | | - protected: |
87 | | - CriterionKernel criterion_kernel_; |
88 | | - }; |
89 | | - |
90 | | - class SearchDepth |
91 | | - { |
92 | | - using SearchDepthKernel = typename NeighborMethodType::SearchDepthKernel; |
93 | | - |
94 | | - public: |
95 | | - template <class ExecutionPolicy, class EncloserType> |
96 | | - SearchDepth(const ExecutionPolicy &ex_policy, EncloserType &encloser) |
97 | | - : search_depth_kernel_(ex_policy, encloser.neighbor_method_){}; |
98 | | - |
99 | | - inline int operator()(UnsignedInt i) const { return search_depth_kernel_(i); }; |
100 | | - |
101 | | - protected: |
102 | | - SearchDepthKernel search_depth_kernel_; |
103 | | - }; |
104 | | - |
105 | | - class SmoothingRatio |
106 | | - { |
107 | | - using SmoothingRatioKernel = typename NeighborMethodType::SmoothingRatioKernel; |
108 | | - |
109 | | - public: |
110 | | - template <class ExecutionPolicy, class EncloserType> |
111 | | - SmoothingRatio(const ExecutionPolicy &ex_policy, EncloserType &encloser) |
112 | | - : smoothing_ratio_kernel_(ex_policy, encloser.neighbor_method_){}; |
113 | | - |
114 | | - inline Real operator()(UnsignedInt i) const { return smoothing_ratio_kernel_(i); }; |
115 | | - |
116 | | - protected: |
117 | | - SmoothingRatioKernel smoothing_ratio_kernel_; |
118 | 82 | }; |
119 | 83 |
|
120 | 84 | protected: |
121 | | - NeighborMethodType neighbor_method_; /**< The neighbor method for the neighborhood. */ |
122 | 85 | DiscreteVariable<Vecd> *dv_source_pos_; |
123 | 86 | DiscreteVariable<Vecd> *dv_target_pos_; |
124 | 87 | }; |
|
0 commit comments