@@ -11,30 +11,57 @@ template <size_t order> void runTest(Omega_h::Mesh mesh) {
1111 auto dim = mesh.dim ();
1212 auto coords = mesh.coords ();
1313 auto f = KOKKOS_LAMBDA (double x, double y)->double { return 2 * x + 3 * y; };
14+ auto edge2vtx = mesh.ask_down (1 , 0 ).ab2b ;
15+ auto edgeMap = mesh.ask_down (dim, 1 ).ab2b ;
1416 Kokkos::parallel_for (
1517 mesh.nverts (), KOKKOS_LAMBDA (int vtx) {
1618 auto x = coords[vtx * dim];
1719 auto y = coords[vtx * dim + 1 ];
1820 shape_field (vtx, 0 , 0 , MeshField::Mesh_Topology::Vertex) = f (x, y);
1921 });
20- const auto numPtsPerElem = 3 ;
22+ if constexpr (order == 2 ) {
23+ Kokkos::parallel_for (
24+ mesh.nedges (), KOKKOS_LAMBDA (int edge) {
25+ const auto left = edge2vtx[edge * 2 ];
26+ const auto right = edge2vtx[edge * 2 + 1 ];
27+ const auto x = (coords[left * dim] + coords[right * dim]) / 2.0 ;
28+ const auto y =
29+ (coords[left * dim + 1 ] + coords[right * dim + 1 ]) / 2.0 ;
30+ shape_field (edge, 0 , 0 , MeshField::Mesh_Topology::Edge) = f (x, y);
31+ });
32+ }
33+ const auto numPtsPerElem = order == 2 ? 6 : 3 ;
2134 Kokkos::View<double **> local_coords (" " , mesh.nelems () * numPtsPerElem, 3 );
2235 Kokkos::parallel_for (
23- " set" , mesh.nelems () * 3 , KOKKOS_LAMBDA (const int &i) {
24- local_coords (i, 0 ) = (i % 3 == 0 );
25- local_coords (i, 1 ) = (i % 3 == 1 );
26- local_coords (i, 2 ) = (i % 3 == 2 );
36+ " set" , mesh.nelems () * numPtsPerElem, KOKKOS_LAMBDA (const int &i) {
37+ const auto val = i % numPtsPerElem;
38+ local_coords (i, 0 ) = (val == 0 );
39+ local_coords (i, 1 ) = (val == 1 );
40+ local_coords (i, 2 ) = (val == 2 );
41+ if constexpr (order == 2 ) {
42+ if (val == 3 ) {
43+ local_coords (i, 0 ) = 1 / 2.0 ;
44+ local_coords (i, 1 ) = 1 / 2.0 ;
45+ } else if (val == 4 ) {
46+ local_coords (i, 1 ) = 1 / 2.0 ;
47+ local_coords (i, 2 ) = 1 / 2.0 ;
48+ } else if (val == 5 ) {
49+ local_coords (i, 0 ) = 1 / 2.0 ;
50+ local_coords (i, 2 ) = 1 / 2.0 ;
51+ }
52+ }
2753 });
2854
2955 auto eval_results = mesh_field.triangleLocalPointEval (
3056 local_coords, numPtsPerElem, shape_field);
3157
3258 int errors = 0 ;
3359 const auto triVerts = mesh.ask_elem_verts ();
60+ const auto coordField = mesh_field.getCoordField ();
3461 Kokkos::parallel_reduce (
3562 " test" , mesh.nelems (),
3663 KOKKOS_LAMBDA (const int &tri, int &errors) {
37- for (int node = 0 ; node < numPtsPerElem ; ++node) {
64+ for (int node = 0 ; node < 3 ; ++node) {
3865 const auto triDim = 2 ;
3966 const auto vtxDim = 0 ;
4067 const auto ignored = -1 ;
@@ -49,8 +76,28 @@ template <size_t order> void runTest(Omega_h::Mesh mesh) {
4976 if (Kokkos::fabs (expected - actual) > MeshField::MachinePrecision) {
5077 ++errors;
5178 Kokkos::printf (
52- " expected: %lf, actual: %lf, element: %d, node: %d\n " , expected,
53- actual, tri, node);
79+ " expected: %lf, actual: %lf, element: %d, node(vtx): %d\n " ,
80+ expected, actual, tri, node);
81+ }
82+ }
83+ for (int node = 3 ; node < numPtsPerElem; ++node) {
84+ const auto triDim = 2 ;
85+ const auto edgeDim = 1 ;
86+ const auto triToEdgeDegree = Omega_h::simplex_degree (triDim, edgeDim);
87+ const MeshField::LO triNode2DofHolder[3 ] = {0 , 1 , 2 };
88+ int edge =
89+ edgeMap[(tri * triToEdgeDegree) + triNode2DofHolder[node - 3 ]];
90+ auto left = edge2vtx[edge * 2 ];
91+ auto right = edge2vtx[edge * 2 + 1 ];
92+ auto x = (coords[left * dim] + coords[right * dim]) / 2.0 ;
93+ auto y = (coords[left * dim + 1 ] + coords[right * dim + 1 ]) / 2.0 ;
94+ auto expected = f (x, y);
95+ auto actual = eval_results (tri * numPtsPerElem + node, 0 );
96+ if (Kokkos::fabs (expected - actual) > MeshField::MachinePrecision) {
97+ ++errors;
98+ Kokkos::printf (
99+ " expected: %lf, actual: %lf, element: %d, node(edge): %d\n " ,
100+ expected, actual, tri, node);
54101 }
55102 }
56103 },
0 commit comments