DFT-EFE
 
Loading...
Searching...
No Matches
SphericalDataNumerical.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Avirup Sircar
24 */
25
26#ifndef dftefeSphericalDataNumerical_h
27#define dftefeSphericalDataNumerical_h
28
29#include <utils/TypeConfig.h>
32#include <vector>
33#include <utils/Point.h>
34#include <atoms/SphericalData.h>
35#include <utils/Spline.h>
36#include <memory>
37#include <utils/Point.h>
38#include <atoms/Defaults.h>
41
42namespace dftefe
43{
44 namespace atoms
45 {
47 {
48 public:
49 // Lightweight functor holding all data needed for single-point
50 // evaluation in a specific memory space. Obtained on the host via
51 // getFunc<MemorySpace>(), then passed by value into host or device
52 // (CUDA/HIP/SYCL) kernels.
53 // Func<HOST> — host spline pointers, callable from host code.
54 // Func<DEVICE> — device spline pointers, callable from device kernels.
55 template <dftefe::utils::MemorySpace memorySpace>
56 class Func
57 {
58 public:
59 Func();
60
62 int l,
63 int m,
64 int mEff,
65 double constant,
66 double cutoff,
67 double smoothness,
68 double polarAngleTolerance,
69 double cutoffTolerance,
70 double radiusTolerance);
71
73 getValue(const double *point, const double *origin) const;
74
76 getGradientValue(const double *point,
77 const double *origin,
78 double * grad) const;
79
80 private:
82 int d_l, d_m, d_mEff;
85 };
86
88 const std::vector<int> qNumbers,
89 const std::vector<double> radialPoints,
90 const std::vector<double> radialValues,
91 const double cutoff,
92 const double smoothness,
93 const SphericalHarmonicFunctions &sphericalHarmonicFunc,
94 const double polarAngleTolerance = SphericalDataDefaults::POL_ANG_TOL,
95 const double cutoffTolerance = SphericalDataDefaults::CUTOFF_TOL,
96 const double radiusTolerance = SphericalDataDefaults::RADIUS_TOL,
98
100
101 void
102 initSpline();
103
104 std::vector<double>
105 getValue(const std::vector<utils::Point> &point,
106 const utils::Point & origin) override;
107
108 std::vector<double>
109 getGradientValue(const std::vector<utils::Point> &point,
110 const utils::Point & origin) override;
111
112 std::vector<double>
113 getHessianValue(const std::vector<utils::Point> &point,
114 const utils::Point & origin) override;
115
116 double
117 getValue(const utils::Point &point, const utils::Point &origin) override;
118
119 std::vector<double>
120 getGradientValue(const utils::Point &point,
121 const utils::Point &origin) override;
122
123 std::vector<double>
124 getHessianValue(const utils::Point &point,
125 const utils::Point &origin) override;
126
127#ifdef DFTEFE_WITH_DEVICE
128 void
129 getValueDevice(
130 const size_type numPoints,
131 const double * points,
132 const double * origin,
133 double * out,
134 utils::deviceStream_t streamId = utils::defaultStream) override;
135
136 void
137 getGradientValueDevice(
138 const size_type numPoints,
139 const double * points,
140 const double * origin,
141 double * out,
142 utils::deviceStream_t streamId = utils::defaultStream) override;
143
144 void
145 getHessianValueDevice(
146 const size_type numPoints,
147 const double * points,
148 const double * origin,
149 double * out,
150 utils::deviceStream_t streamId = utils::defaultStream) override;
151#endif
152
153 void
154 getValue(const size_type numPoints,
155 const double * points,
156 const double * origin,
157 double * out) override;
158
159 void
160 getGradientValue(const size_type numPoints,
161 const double * points,
162 const double * origin,
163 double * out) override;
164
165 void
166 getHessianValue(const size_type numPoints,
167 const double * points,
168 const double * origin,
169 double * out) override;
170
171 std::vector<double>
172 getRadialValue(const std::vector<double> &r) override;
173
174 std::vector<double>
175 getAngularValue(const std::vector<double> &r,
176 const std::vector<double> &theta,
177 const std::vector<double> &phi) override;
178
179 std::vector<double>
180 getRadialDerivative(const std::vector<double> &r) override;
181
182 std::vector<std::vector<double>>
183 getAngularDerivative(const std::vector<double> &r,
184 const std::vector<double> &theta,
185 const std::vector<double> &phi) override;
186
187 std::vector<int>
188 getQNumbers() const override;
189
190 double
191 getCutoff() const override;
192
193 double
194 getSmoothness() const override;
195
196 // Returns a Func for the given memory space.
197 // HOST: fills from host std::vector spline data.
198 // DEVICE: fills from device MemoryStorage spline data.
199 // Both are host-callable only — call before launching a kernel.
200 template <dftefe::utils::MemorySpace memorySpace>
202 getFunc() const;
203
204 private:
205 std::vector<int> d_qNumbers;
206 std::vector<double> d_radialPoints;
207 std::vector<double> d_radialValues;
208 double d_cutoff;
210 std::shared_ptr<const utils::Spline> d_spline;
215
217 };
218
219 } // end of namespace atoms
220} // end of namespace dftefe
221
223
224#endif // dftefeSphericalDataNumerical_h
#define DFTEFE_HOST_DEVICE_FUNC
Definition: DeviceKernelLauncherHelpers.h:306
static const double POL_ANG_TOL
Setting all the SphericalDataDefaults.
Definition: Defaults.h:43
static const size_type DEFAULT_DIM
Definition: Defaults.h:60
static const double RADIUS_TOL
Definition: Defaults.h:55
static const double CUTOFF_TOL
Definition: Defaults.h:49
Definition: SphericalDataNumerical.h:57
int d_l
Definition: SphericalDataNumerical.h:82
int d_mEff
Definition: SphericalDataNumerical.h:82
double d_cutoffTolerance
Definition: SphericalDataNumerical.h:84
double d_smoothness
Definition: SphericalDataNumerical.h:83
Func()
Definition: SphericalDataNumericalKernels.h:49
double d_radiusTolerance
Definition: SphericalDataNumerical.h:84
double d_polarAngleTolerance
Definition: SphericalDataNumerical.h:83
double d_cutoff
Definition: SphericalDataNumerical.h:83
DFTEFE_HOST_DEVICE_FUNC double getValue(const double *point, const double *origin) const
Definition: SphericalDataNumericalKernels.h:98
double d_constant
Definition: SphericalDataNumerical.h:83
utils::Spline::Func< memorySpace > d_radialSpline
Definition: SphericalDataNumerical.h:81
DFTEFE_HOST_DEVICE_FUNC void getGradientValue(const double *point, const double *origin, double *grad) const
Definition: SphericalDataNumericalKernels.h:129
int d_m
Definition: SphericalDataNumerical.h:82
Definition: SphericalDataNumerical.h:47
std::shared_ptr< const utils::Spline > d_spline
Definition: SphericalDataNumerical.h:210
const SphericalHarmonicFunctions & d_sphericalHarmonicFunc
Definition: SphericalDataNumerical.h:216
std::vector< int > d_qNumbers
Definition: SphericalDataNumerical.h:205
std::vector< double > d_radialPoints
Definition: SphericalDataNumerical.h:206
std::vector< double > getAngularValue(const std::vector< double > &r, const std::vector< double > &theta, const std::vector< double > &phi) override
Definition: SphericalDataNumerical.cpp:534
std::vector< double > getHessianValue(const std::vector< utils::Point > &point, const utils::Point &origin) override
Definition: SphericalDataNumerical.cpp:410
std::vector< double > getRadialValue(const std::vector< double > &r) override
Definition: SphericalDataNumerical.cpp:518
size_type d_dim
Definition: SphericalDataNumerical.h:214
std::vector< int > getQNumbers() const override
Definition: SphericalDataNumerical.cpp:685
double getCutoff() const override
Definition: SphericalDataNumerical.cpp:691
double d_smoothness
Definition: SphericalDataNumerical.h:209
double d_cutoffTolerance
Definition: SphericalDataNumerical.h:212
double d_radiusTolerance
Definition: SphericalDataNumerical.h:213
std::vector< double > getRadialDerivative(const std::vector< double > &r) override
Definition: SphericalDataNumerical.cpp:554
std::vector< double > getValue(const std::vector< utils::Point > &point, const utils::Point &origin) override
Definition: SphericalDataNumerical.cpp:359
std::vector< std::vector< double > > getAngularDerivative(const std::vector< double > &r, const std::vector< double > &theta, const std::vector< double > &phi) override
Definition: SphericalDataNumerical.cpp:582
double getSmoothness() const override
Definition: SphericalDataNumerical.cpp:697
double d_cutoff
Definition: SphericalDataNumerical.h:208
void initSpline()
Definition: SphericalDataNumerical.cpp:333
Func< memorySpace > getFunc() const
double d_polarAngleTolerance
Definition: SphericalDataNumerical.h:211
std::vector< double > d_radialValues
Definition: SphericalDataNumerical.h:207
std::vector< double > getGradientValue(const std::vector< utils::Point > &point, const utils::Point &origin) override
Definition: SphericalDataNumerical.cpp:382
Definition: SphericalData.h:41
Definition: SphericalHarmonicFunctions.h:19
Definition: PointImpl.h:13
Definition: Spline.h:54
static cudaStream_t defaultStream
Definition: DeviceTypeConfig.cu.h:62
cudaStream_t deviceStream_t
Definition: DeviceTypeConfig.cu.h:27
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9