From 674891d18b9b6b92fcb25810e1deb20ce449a6ac Mon Sep 17 00:00:00 2001 From: Matthias Frey <mf248@st-andrews.ac.uk> Date: Mon, 3 May 2021 11:48:21 +0200 Subject: [PATCH] more rigorous normInf test --- unit_tests/Field/Field.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/unit_tests/Field/Field.cpp b/unit_tests/Field/Field.cpp index 8c275076..be490629 100644 --- a/unit_tests/Field/Field.cpp +++ b/unit_tests/Field/Field.cpp @@ -27,7 +27,7 @@ public: typedef ippl::Field<double, dim> field_type; FieldTest() - : nPoints(4) + : nPoints(8) { setup(); } @@ -89,12 +89,30 @@ TEST_F(FieldTest, Norm2) { } TEST_F(FieldTest, NormInf) { - double val = 1.5; - *field = val; + const ippl::NDIndex<dim> lDom = field->getLayout().getLocalNDIndex(); + + auto view = field->getView(); + auto policy = field->getRangePolicy(0); + + Kokkos::parallel_for("Assign field", + policy, + KOKKOS_LAMBDA(const int i, + const int j, + const int k) + { + const size_t ig = i + lDom[0].first(); + const size_t jg = j + lDom[1].first(); + const size_t kg = k + lDom[2].first(); + + view(i, j, k) = -1.0 + (ig + jg + kg); + }); + double normInf = ippl::normInf(*field); + double val = -1.0 + 3 * nPoints; + ASSERT_DOUBLE_EQ(val, normInf); } -- GitLab