22#include < MeshField.hpp>
33#include < Omega_h_build.hpp>
44#include < Omega_h_mesh.hpp>
5+
6+ // this test verifies that the mapping used in meshFields
7+ // properly matches the expected canonical ordering
8+
59template <size_t order, size_t dim> void runTest (Omega_h::Mesh mesh) {
610 MeshField::OmegahMeshField<Kokkos::DefaultExecutionSpace, dim> mesh_field (
711 mesh);
8- const auto vertexNodes = (dim == 3 ? 4 : 3 );
12+ const auto numComponent = (dim == 3 ? 4 : 3 );
913 auto shape_field =
1014 mesh_field.template CreateLagrangeField <double , order, 1 >();
1115 // initialize vertices
@@ -37,47 +41,49 @@ template <size_t order, size_t dim> void runTest(Omega_h::Mesh mesh) {
3741 shape_field (edge, 0 , 0 , MeshField::Mesh_Topology::Edge) = f (x, y, z);
3842 });
3943 }
40- const auto numNodesPerElem = order == 2 ? (dim == 3 ? 10 : 6 ) : vertexNodes;
44+ // We specify one point per a node for all elements. We use
45+ // numComponent to specify the size of the barycentric coordinates
46+ const auto numNodesPerElem = order == 2 ? (dim == 3 ? 10 : 6 ) : numComponent;
4147 Kokkos::View<double **> local_coords (" " , mesh.nelems () * numNodesPerElem,
42- vertexNodes );
48+ numComponent );
4349 Kokkos::parallel_for (
4450 " set" , mesh.nelems () * numNodesPerElem, KOKKOS_LAMBDA (const int &i) {
45- const auto val = i % numNodesPerElem;
46- local_coords (i, 0 ) = (val == 0 );
47- local_coords (i, 1 ) = (val == 1 );
48- local_coords (i, 2 ) = (val == 2 );
51+ const auto nodeIndex = i % numNodesPerElem;
52+ local_coords (i, 0 ) = (nodeIndex == 0 );
53+ local_coords (i, 1 ) = (nodeIndex == 1 );
54+ local_coords (i, 2 ) = (nodeIndex == 2 );
4955 if constexpr (dim == 3 ) {
50- local_coords (i, 3 ) = (val == 3 );
56+ local_coords (i, 3 ) = (nodeIndex == 3 );
5157 if constexpr (order == 2 ) {
52- if (val == 4 ) {
58+ if (nodeIndex == 4 ) {
5359 local_coords (i, 0 ) = 1 / 2.0 ;
5460 local_coords (i, 1 ) = 1 / 2.0 ;
55- } else if (val == 5 ) {
61+ } else if (nodeIndex == 5 ) {
5662 local_coords (i, 1 ) = 1 / 2.0 ;
5763 local_coords (i, 2 ) = 1 / 2.0 ;
58- } else if (val == 6 ) {
64+ } else if (nodeIndex == 6 ) {
5965 local_coords (i, 0 ) = 1 / 2.0 ;
6066 local_coords (i, 2 ) = 1 / 2.0 ;
61- } else if (val == 7 ) {
67+ } else if (nodeIndex == 7 ) {
6268 local_coords (i, 0 ) = 1 / 2.0 ;
6369 local_coords (i, 3 ) = 1 / 2.0 ;
64- } else if (val == 8 ) {
70+ } else if (nodeIndex == 8 ) {
6571 local_coords (i, 1 ) = 1 / 2.0 ;
6672 local_coords (i, 3 ) = 1 / 2.0 ;
67- } else if (val == 9 ) {
73+ } else if (nodeIndex == 9 ) {
6874 local_coords (i, 2 ) = 1 / 2.0 ;
6975 local_coords (i, 3 ) = 1 / 2.0 ;
7076 }
7177 }
7278
7379 } else if constexpr (order == 2 ) {
74- if (val == 3 ) {
80+ if (nodeIndex == 3 ) {
7581 local_coords (i, 0 ) = 1 / 2.0 ;
7682 local_coords (i, 1 ) = 1 / 2.0 ;
77- } else if (val == 4 ) {
83+ } else if (nodeIndex == 4 ) {
7884 local_coords (i, 1 ) = 1 / 2.0 ;
7985 local_coords (i, 2 ) = 1 / 2.0 ;
80- } else if (val == 5 ) {
86+ } else if (nodeIndex == 5 ) {
8187 local_coords (i, 0 ) = 1 / 2.0 ;
8288 local_coords (i, 2 ) = 1 / 2.0 ;
8389 }
@@ -95,7 +101,7 @@ template <size_t order, size_t dim> void runTest(Omega_h::Mesh mesh) {
95101 Kokkos::parallel_reduce (
96102 " test" , mesh.nelems (),
97103 KOKKOS_LAMBDA (const int &tri, int &errors) {
98- for (int node = 0 ; node < vertexNodes ; ++node) {
104+ for (int node = 0 ; node < numComponent ; ++node) {
99105 const auto elemDim = (dim == 3 ? 3 : 2 );
100106 const auto vtxDim = 0 ;
101107 const auto ignored = -1 ;
@@ -115,14 +121,14 @@ template <size_t order, size_t dim> void runTest(Omega_h::Mesh mesh) {
115121 expected, actual, tri, node);
116122 }
117123 }
118- for (int node = vertexNodes ; node < numNodesPerElem; ++node) {
124+ for (int node = numComponent ; node < numNodesPerElem; ++node) {
119125 const auto elemDim = (dim == 3 ? 3 : 2 );
120126 const auto edgeDim = 1 ;
121127 const auto triToEdgeDegree =
122128 Omega_h::simplex_degree (elemDim, edgeDim);
123129 const MeshField::LO triNode2DofHolder[6 ] = {0 , 1 , 2 , 3 , 4 , 5 };
124130 int edge = edgeMap[(tri * triToEdgeDegree) +
125- triNode2DofHolder[node - (dim == 3 ? 4 : 3 ) ]];
131+ triNode2DofHolder[node - numComponent ]];
126132 auto left = edge2vtx[edge * 2 ];
127133 auto right = edge2vtx[edge * 2 + 1 ];
128134 auto x = (coords[left * dim] + coords[right * dim]) / 2.0 ;
0 commit comments