From 73052d09b8b1b069004f3b81242d7b0c669d74f9 Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Mon, 13 Aug 2018 12:59:26 +0200 Subject: [PATCH] added test to check mapToPeriodicDomain functionality --- tests/domain_decomposition/CMakeLists.txt | 3 + .../MapPointToPeriodicDomain.cpp | 85 +++++++++++++++++++ 2 files changed, 88 insertions(+) create mode 100644 tests/domain_decomposition/MapPointToPeriodicDomain.cpp diff --git a/tests/domain_decomposition/CMakeLists.txt b/tests/domain_decomposition/CMakeLists.txt index 2c7cae262..56fd5c358 100644 --- a/tests/domain_decomposition/CMakeLists.txt +++ b/tests/domain_decomposition/CMakeLists.txt @@ -4,6 +4,9 @@ # ################################################################################################### +waLBerla_compile_test( NAME MapPointToPeriodicDomain FILES MapPointToPeriodicDomain.cpp DEPENDS core ) +waLBerla_execute_test( NAME MapPointToPeriodicDomain ) + waLBerla_compile_test( NAME PeriodicIntersect FILES PeriodicIntersect.cpp DEPENDS core blockforest ) waLBerla_execute_test( NAME PeriodicIntersect ) diff --git a/tests/domain_decomposition/MapPointToPeriodicDomain.cpp b/tests/domain_decomposition/MapPointToPeriodicDomain.cpp new file mode 100644 index 000000000..ee60a1144 --- /dev/null +++ b/tests/domain_decomposition/MapPointToPeriodicDomain.cpp @@ -0,0 +1,85 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file MapToPeriodicDomain.cpp +//! \author Sebastian Eibl <sebastian.eibl@fau.de> +// +//====================================================================================================================== + +#include "core/debug/TestSubsystem.h" +#include "core/Environment.h" +#include "core/math/AABB.h" +#include "core/math/Vector3.h" +#include "domain_decomposition/MapPointToPeriodicDomain.h" + +namespace walberla { +namespace testing { + +int main (int argc, char** argv) +{ + using namespace walberla::domain_decomposition; + + debug::enterTestMode(); + + walberla::Environment walberlaEnv( argc, argv ); + WALBERLA_UNUSED(walberlaEnv); + + std::array<bool, 3> isPeriodic{{true, true, true}}; + math::Vector3<real_t> minCorner(real_t(2), real_t(3), real_t(4)); + math::Vector3<real_t> maxCorner(real_t(3), real_t(4), real_t(5)); + math::AABB domain(minCorner, maxCorner); + + //minCorner -> minCorner + math::Vector3<real_t> p = minCorner; + mapPointToPeriodicDomain( isPeriodic, domain, p); + WALBERLA_CHECK_IDENTICAL( p[0], minCorner[0] ); + WALBERLA_CHECK_IDENTICAL( p[1], minCorner[1] ); + WALBERLA_CHECK_IDENTICAL( p[2], minCorner[2] ); + + //maxCorner -> minCorner + p = maxCorner; + mapPointToPeriodicDomain( isPeriodic, domain, p); + WALBERLA_CHECK_IDENTICAL( p[0], minCorner[0] ); + WALBERLA_CHECK_IDENTICAL( p[1], minCorner[1] ); + WALBERLA_CHECK_IDENTICAL( p[2], minCorner[2] ); + + //minCorner - epsilon -> maxCorner - epsilon + p[0] = std::nextafter(domain.xMin(), real_t(0)); + p[1] = std::nextafter(domain.yMin(), real_t(0)); + p[2] = std::nextafter(domain.zMin(), real_t(0)); + mapPointToPeriodicDomain( isPeriodic, domain, p); + WALBERLA_CHECK_IDENTICAL( p[0], std::nextafter(domain.xMax(), domain.xMin()) ); + WALBERLA_CHECK_IDENTICAL( p[1], std::nextafter(domain.yMax(), domain.yMin()) ); + WALBERLA_CHECK_IDENTICAL( p[2], std::nextafter(domain.zMax(), domain.zMin()) ); + + //maxCorner - epsilon -> maxCorner - epsilon + p[0] = std::nextafter(domain.xMax(), domain.xMin()); + p[1] = std::nextafter(domain.yMax(), domain.yMin()); + p[2] = std::nextafter(domain.zMax(), domain.zMin()); + mapPointToPeriodicDomain( isPeriodic, domain, p); + WALBERLA_CHECK_IDENTICAL( p[0], std::nextafter(domain.xMax(), domain.xMin()) ); + WALBERLA_CHECK_IDENTICAL( p[1], std::nextafter(domain.yMax(), domain.yMin()) ); + WALBERLA_CHECK_IDENTICAL( p[2], std::nextafter(domain.zMax(), domain.zMin()) ); + + return EXIT_SUCCESS; +} + +} //namespace testing +} //namespace walberla + +int main( int argc, char** argv ) +{ + return walberla::testing::main(argc, argv); +} -- GitLab