9 #ifndef _GMLS_MANIFOLD_HPP_
10 #define _GMLS_MANIFOLD_HPP_
12 #include <Kokkos_Core.hpp>
15 #define PI 3.14159265358979323846
17 KOKKOS_INLINE_FUNCTION
19 return (d1 > d2) ? d1 : d2;
22 KOKKOS_INLINE_FUNCTION
23 double atan4(
const double y,
const double x) {
43 double theta = std::atan2( std::abs(y), std::abs(x) );
44 if (x > 0.0 && y > 0.0)
46 else if ( x < 0.0 && y > 0.0 )
48 else if ( x < 0.0 && y < 0.0 )
50 else if ( x > 0.0 && y < 0.0 )
51 result = 2.0 *
PI - theta;
56 KOKKOS_INLINE_FUNCTION
57 double latitude(
double x,
double y,
double z) {
58 return std::atan2(z, std::sqrt( x*x + y*y));
61 KOKKOS_INLINE_FUNCTION
66 KOKKOS_INLINE_FUNCTION
68 return z * ( z * z - 1.0 ) * ( z * z - 1.0 );
71 KOKKOS_INLINE_FUNCTION
77 KOKKOS_INLINE_FUNCTION
81 const scalar_type sigma_lon_comp = std::pow(sin(lat), 2) * (5.0* std::pow(cos(lat), 2) - 1.0) * cos(4.0 *lon);
82 const scalar_type sigma_lat_comp = 4*cos(lat) * std::pow(sin(lat), 3) * sin(4.0 * lon);
84 curl[0] = -(-sin(lat)*sin(lon)*sigma_lon_comp + cos(lat)*cos(lon)*sigma_lat_comp);
85 curl[1] = -(sin(lat)*cos(lon)*sigma_lon_comp + cos(lat)*sin(lon)*sigma_lat_comp);
86 curl[2] = -(-sin(lat)*sigma_lat_comp);
90 KOKKOS_INLINE_FUNCTION
93 return -30 * std::cos(4.0 * lon) *
legendre54(z);
96 KOKKOS_INLINE_FUNCTION
98 const double lat =
latitude(x, y, z);
101 const double A = -4.0 * std::pow(std::cos(lat),3) * std::sin(4.0 * lon) * std::sin(lat);
102 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 KOKKOS_INLINE_FUNCTION
110 const double lat =
latitude(x, y, z);
113 const double A = -4.0 * std::pow(std::cos(lat),3) * std::sin(4.0 * lon) * std::sin(lat);
114 const double B = 0.5* std::cos(4.0 * lon) * std::pow(std::cos(lat),3) * ( 5 * std::cos(2.0 * lat) - 3.0 );
116 gradient[0] = -A * std::sin(lon) - B * std::sin(lat) * std::cos(lon);
117 gradient[1] = A * std::cos(lon) - B * std::sin(lat) * std::sin(lon);
118 gradient[2] = B * std::cos(lat);
121 KOKKOS_INLINE_FUNCTION
123 const double lat =
latitude(x, y, z);
126 const double U = 0.5* std::cos(4.0 * lon) * std::pow(std::cos(lat),3) * ( 5 * std::cos(2.0 * lat) - 3.0 );
127 const double V = 4.0 * std::pow(std::cos(lat),3) * std::sin(4.0 * lon) * std::sin(lat);
129 velocity[0] = -U * std::sin(lon) - V * std::sin(lat) * std::cos(lon);
130 velocity[1] = U * std::cos(lon) - V * std::sin(lat) * std::sin(lon);
131 velocity[2] = V * std::cos(lat);
140 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)
int main(int argc, char **argv)
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)
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)