Code indexing in gitaly is broken and leads to code not being visible to the user. We work on the issue with highest priority.

Skip to content
Snippets Groups Projects

Resolve "Add unit tests for BareField"

Merged vinciguerra_a requested to merge 88-add-unit-tests-for-barefield into master
All threads resolved!
+ 49
1
//
// Unit test FieldTest
// Test the functionality of the class Field.
// Test the functionality of the classes Field and BareField.
//
// Copyright (c) 2020, Matthias Frey, Paul Scherrer Institut, Villigen PSI, Switzerland
// All rights reserved
@@ -66,6 +66,54 @@ TEST_F(FieldTest, Sum) {
ASSERT_DOUBLE_EQ(val * std::pow(nPoints, dim), sum);
}
TEST_F(FieldTest, Min) {
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 min = field->min();
// minimum value -1 + nghost + nghost + nghost
ASSERT_DOUBLE_EQ(min, 2.);
}
TEST_F(FieldTest, Max) {
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 max = field->max();
double expected = -1. + nPoints * 3;
ASSERT_DOUBLE_EQ(max, expected);
}
TEST_F(FieldTest, Norm1) {
double val = -1.5;
Loading