1 #ifndef _GMLS_MANIFOLD_HPP_
2 #define _GMLS_MANIFOLD_HPP_
4 #include <Kokkos_Core.hpp>
7 #define PI 3.14159265358979323846
11 return (d1 > d2) ? d1 : d2;
14 KOKKOS_INLINE_FUNCTION
15 double atan4(
const double y,
const double x) {
35 double theta = std::atan2( std::abs(y), std::abs(x) );
36 if (x > 0.0 && y > 0.0)
38 else if ( x < 0.0 && y > 0.0 )
40 else if ( x < 0.0 && y < 0.0 )
42 else if ( x > 0.0 && y < 0.0 )
43 result = 2.0 *
PI - theta;
48 KOKKOS_INLINE_FUNCTION
49 double latitude(
double x,
double y,
double z) {
50 return std::atan2(z, std::sqrt( x*x + y*y));
53 KOKKOS_INLINE_FUNCTION
58 KOKKOS_INLINE_FUNCTION
60 return z * ( z * z - 1.0 ) * ( z * z - 1.0 );
63 KOKKOS_INLINE_FUNCTION
69 KOKKOS_INLINE_FUNCTION
73 const scalar_type sigma_lon_comp = std::pow(sin(lat), 2) * (5.0* std::pow(cos(lat), 2) - 1.0) * cos(4.0 *lon);
74 const scalar_type sigma_lat_comp = 4*cos(lat) * std::pow(sin(lat), 3) * sin(4.0 * lon);
76 curl[0] = -(-sin(lat)*sin(lon)*sigma_lon_comp + cos(lat)*cos(lon)*sigma_lat_comp);
77 curl[1] = -(sin(lat)*cos(lon)*sigma_lon_comp + cos(lat)*sin(lon)*sigma_lat_comp);
78 curl[2] = -(-sin(lat)*sigma_lat_comp);
82 KOKKOS_INLINE_FUNCTION
85 return -30 * std::cos(4.0 * lon) *
legendre54(z);
88 KOKKOS_INLINE_FUNCTION
90 const double lat =
latitude(x, y, z);
93 const double A = -4.0 * std::pow(std::cos(lat),3) * std::sin(4.0 * lon) * std::sin(lat);
94 const double B = 0.5* std::cos(4.0 * lon) * std::pow(std::cos(lat),3) * ( 5 * std::cos(2.0 * lat) - 3.0 );
100 KOKKOS_INLINE_FUNCTION
102 const double lat =
latitude(x, y, z);
105 const double A = -4.0 * std::pow(std::cos(lat),3) * std::sin(4.0 * lon) * std::sin(lat);
106 const double B = 0.5* std::cos(4.0 * lon) * std::pow(std::cos(lat),3) * ( 5 * std::cos(2.0 * lat) - 3.0 );
108 gradient[0] = -A * std::sin(lon) - B * std::sin(lat) * std::cos(lon);
109 gradient[1] = A * std::cos(lon) - B * std::sin(lat) * std::sin(lon);
110 gradient[2] = B * std::cos(lat);
113 KOKKOS_INLINE_FUNCTION
115 const double lat =
latitude(x, y, z);
118 const double U = 0.5* std::cos(4.0 * lon) * std::pow(std::cos(lat),3) * ( 5 * std::cos(2.0 * lat) - 3.0 );
119 const double V = 4.0 * std::pow(std::cos(lat),3) * std::sin(4.0 * lon) * std::sin(lat);
121 velocity[0] = -U * std::sin(lon) - V * std::sin(lat) * std::cos(lon);
122 velocity[1] = U * std::cos(lon) - V * std::sin(lat) * std::sin(lon);
123 velocity[2] = V * std::cos(lat);
132 int main (
int argc,
char* args[]);
KOKKOS_INLINE_FUNCTION double sphere_harmonic54(double x, double y, double z)
KOKKOS_INLINE_FUNCTION void gradient_sphereHarmonic54_local(double *gradient, double x, double y, double z)
KOKKOS_INLINE_FUNCTION double latitude(double x, double y, double z)
KOKKOS_INLINE_FUNCTION void curl_sphere_harmonic54(double *curl, double x, double y, double z)
KOKKOS_INLINE_FUNCTION double atan4(const double y, const double x)
KOKKOS_INLINE_FUNCTION double device_max(double d1, double d2)
int main(int argc, char *args[])
[Parse Command Line Arguments]
KOKKOS_INLINE_FUNCTION double longitude(double x, double y, double z)
KOKKOS_INLINE_FUNCTION double legendre54(double z)
KOKKOS_INLINE_FUNCTION void velocity_sphereHarmonic54_ambient(double *velocity, double x, double y, double z)
KOKKOS_INLINE_FUNCTION void gradient_sphereHarmonic54_ambient(double *gradient, double x, double y, double z)
KOKKOS_INLINE_FUNCTION double laplace_beltrami_sphere_harmonic54(double x, double y, double z)