Skip to content

Commit cf8bd0f

Browse files
author
Kloepfer
committed
added comments and changed variable names
1 parent f9c06e0 commit cf8bd0f

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

test/testOmegahTet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct QuadraticFunction {
3333
}
3434
};
3535

36-
Omega_h::Mesh createMeshTri18(Omega_h::Library &lib) {
36+
Omega_h::Mesh createMeshTet18(Omega_h::Library &lib) {
3737
auto world = lib.world();
3838
const auto family = OMEGA_H_SIMPLEX;
3939
auto len = 1.0;
@@ -262,14 +262,14 @@ int main(int argc, char **argv) {
262262
MeshField::Debug = true;
263263
#ifdef MESHFIELDS_ENABLE_CABANA
264264
{
265-
auto mesh = createMeshTri18(lib);
265+
auto mesh = createMeshTet18(lib);
266266
MeshField::OmegahMeshField<ExecutionSpace, 3, MeshField::CabanaController>
267267
omf(mesh);
268268
doRun<MeshField::CabanaController>(mesh, omf);
269269
}
270270
#endif
271271
{
272-
auto mesh = createMeshTri18(lib);
272+
auto mesh = createMeshTet18(lib);
273273
MeshField::OmegahMeshField<ExecutionSpace, 3, MeshField::KokkosController>
274274
omf(mesh);
275275
doRun<MeshField::KokkosController>(mesh, omf);

test/testPointMapping.cpp

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
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+
59
template <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

Comments
 (0)