Intrepid2
Intrepid2_ProjectedGeometryExamples.hpp
Go to the documentation of this file.
1// @HEADER
2// *****************************************************************************
3// Intrepid2 Package
4//
5// Copyright 2007 NTESS and the Intrepid2 contributors.
6// SPDX-License-Identifier: BSD-3-Clause
7// *****************************************************************************
8// @HEADER
9
16#ifndef Intrepid2_ProjectedGeometryExamples_h
17#define Intrepid2_ProjectedGeometryExamples_h
18
19namespace Intrepid2 {
23 template<typename Scalar, const int spaceDim>
25 {
26 public:
28 KOKKOS_INLINE_FUNCTION
29 Scalar operator()(const Kokkos::Array<Scalar,spaceDim> &coords, const ordinal_type &d) const
30 {
31 return coords[d];
32 }
33
35 KOKKOS_INLINE_FUNCTION
36 Scalar operator()(const Kokkos::Array<Scalar,spaceDim> &coords, const ordinal_type &d1, const ordinal_type &d2) const
37 {
38 return (d1 == d2) ? 1.0 : 0.0;
39 }
40 };
41
47 template<typename Scalar>
49 {
50 public:
52 KOKKOS_INLINE_FUNCTION
53 Scalar operator()(const Kokkos::Array<Scalar,2> &coords, const ordinal_type &d) const
54 {
55 const Scalar &x = coords[0];
56 const Scalar &y = coords[1];
57
58 Scalar x_prime = x * sqrt(1. - y * y / 2.);
59 Scalar y_prime = y * sqrt(1. - x * x / 2.);
60
61 return (d==0) ? x_prime : y_prime;
62 }
63
65 KOKKOS_INLINE_FUNCTION
66 Scalar operator()(const Kokkos::Array<Scalar,2> &coords, const ordinal_type &d1, const ordinal_type &d2) const
67 {
68 const Scalar &x = coords[0];
69 const Scalar &y = coords[1];
70
71 Scalar x_prime_dx = sqrt(1. - y * y / 2.);
72 Scalar x_prime_dy = - x * y / sqrt(1. - y * y / 2.);
73 Scalar y_prime_dx = - x * y / sqrt(1. - x * x / 2.);
74 Scalar y_prime_dy = sqrt(1. - x * x / 2.);
75
76 if ((d1 == 0) && (d2 == 0)) return x_prime_dx;
77 else if ((d1 == 0) && (d2 == 1)) return x_prime_dy;
78 else if ((d1 == 1) && (d2 == 0)) return y_prime_dx;
79 else if ((d1 == 1) && (d2 == 1)) return y_prime_dy;
80
81 INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(true, std::invalid_argument, "Unsupported dim");
82 return 0;
83 }
84 };
85
91 template<typename Scalar>
93 {
95 KOKKOS_INLINE_FUNCTION
96 Scalar operator()(const Kokkos::Array<Scalar,3> &coords, const ordinal_type &d) const
97 {
98 const int spaceDim = 3;
99 // value is x_i * sqrt(1 - sum(x_j * x_j / 2.)) where j ≠ i
100 const Scalar &x_d = coords[d];
101
102 Scalar radical = 1.0;
103 for (int d1=0; d1<spaceDim; d1++)
104 {
105 const Scalar valueToSubtract = (d1 == d) ? 0.0 : coords[d1] * coords[d1] / 2.0;
106 radical -= valueToSubtract;
107 }
108
109 return x_d * sqrt(radical);
110 }
111
113 KOKKOS_INLINE_FUNCTION
114 Scalar operator()(const Kokkos::Array<Scalar,3> &coords, const ordinal_type &d1, const ordinal_type &d2) const
115 {
116 const int spaceDim = 3;
117 const Scalar &x_d1 = coords[d1];
118 const Scalar &x_d2 = coords[d2];
119
120 Scalar radical = 1.0;
121 for (int d=0; d<spaceDim; d++)
122 {
123 const Scalar valueToSubtract = (d1 == d) ? 0.0 : coords[d] * coords[d] / 2.0;
124 radical -= valueToSubtract;
125 }
126
127 Scalar weight = (d1 == d2) ? 1.0 : - x_d1 * x_d2;
128 return weight * sqrt(radical);
129 }
130 };
131
132}
133#endif /* Intrepid2_ProjectedGeometryExamples_h */
#define INTREPID2_TEST_FOR_EXCEPTION_DEVICE_SAFE(test, x, msg)
Identity map; simply preserves linear geometry. Intended primarily for tests.
KOKKOS_INLINE_FUNCTION Scalar operator()(const Kokkos::Array< Scalar, spaceDim > &coords, const ordinal_type &d1, const ordinal_type &d2) const
gradient of the (identity) mapping
KOKKOS_INLINE_FUNCTION Scalar operator()(const Kokkos::Array< Scalar, spaceDim > &coords, const ordinal_type &d) const
coordinate values
Maps unit cube [-1,1]x[-1,1]x[-1,1] to sphere of radius 1.
KOKKOS_INLINE_FUNCTION Scalar operator()(const Kokkos::Array< Scalar, 3 > &coords, const ordinal_type &d) const
coordinate values
KOKKOS_INLINE_FUNCTION Scalar operator()(const Kokkos::Array< Scalar, 3 > &coords, const ordinal_type &d1, const ordinal_type &d2) const
gradient of the mapping
Maps unit square [-1,1]x[-1,1] to circle of radius 1.
KOKKOS_INLINE_FUNCTION Scalar operator()(const Kokkos::Array< Scalar, 2 > &coords, const ordinal_type &d) const
coordinate values
KOKKOS_INLINE_FUNCTION Scalar operator()(const Kokkos::Array< Scalar, 2 > &coords, const ordinal_type &d1, const ordinal_type &d2) const
gradient of the mapping