From 04cfe2a413cc6e8a4ae86cc48d58b1cc6c1858b1 Mon Sep 17 00:00:00 2001
From: Sebastian Eibl <sebastian.eibl@fau.de>
Date: Tue, 25 Jul 2017 18:08:13 +0200
Subject: [PATCH] added test for load from config functions

---
 src/pe/cr/HCSITS.h          |  4 +++
 tests/pe/CMakeLists.txt     |  3 ++
 tests/pe/LoadFromConfig.cfg | 18 ++++++++++
 tests/pe/LoadFromConfig.cpp | 66 +++++++++++++++++++++++++++++++++++++
 4 files changed, 91 insertions(+)
 create mode 100644 tests/pe/LoadFromConfig.cfg
 create mode 100644 tests/pe/LoadFromConfig.cpp

diff --git a/src/pe/cr/HCSITS.h b/src/pe/cr/HCSITS.h
index 0af5c6fa9..d5fc5075f 100644
--- a/src/pe/cr/HCSITS.h
+++ b/src/pe/cr/HCSITS.h
@@ -135,6 +135,10 @@ public:
    virtual inline size_t            getNumberOfContactsTreated()   const WALBERLA_OVERRIDE;
    inline const std::map<IBlockID::IDType, ContactCache> getContactCache() const { return blockToContactCache_; }
    inline real_t                    getSpeedLimitFactor() const;
+   inline size_t                    getMaxIterations() const { return maxIterations_; }
+   inline real_t                    getRelaxationParameter() const { return relaxationParam_; }
+   inline real_t                    getErrorReductionParameter() const { return erp_; }
+   inline RelaxationModel           getRelaxationModel() const { return relaxationModel_; }
    //@}
    //**********************************************************************************************
 
diff --git a/tests/pe/CMakeLists.txt b/tests/pe/CMakeLists.txt
index feb9e032e..1427603f3 100644
--- a/tests/pe/CMakeLists.txt
+++ b/tests/pe/CMakeLists.txt
@@ -42,6 +42,9 @@ waLBerla_execute_test( NAME   PE_HASHGRIDS_DBG COMMAND $<TARGET_FILE:PE_HASHGRID
 waLBerla_compile_test( NAME   PE_HCSITS FILES HCSITS.cpp DEPENDS core blockforest  )
 waLBerla_execute_test( NAME   PE_HCSITS )
 
+waLBerla_compile_test( NAME   PE_LOADFROMCONFIG FILES LoadFromConfig.cpp DEPENDS core blockforest  )
+waLBerla_execute_test( NAME   PE_LOADFROMCONFIG COMMAND $<TARGET_FILE:PE_LOADFROMCONFIG> ${CMAKE_CURRENT_SOURCE_DIR}/LoadFromConfig.cfg )
+
 waLBerla_compile_test( NAME   PE_MARSHALLING FILES Marshalling.cpp DEPENDS core  )
 waLBerla_execute_test( NAME   PE_MARSHALLING )
 
diff --git a/tests/pe/LoadFromConfig.cfg b/tests/pe/LoadFromConfig.cfg
new file mode 100644
index 000000000..d6e28430b
--- /dev/null
+++ b/tests/pe/LoadFromConfig.cfg
@@ -0,0 +1,18 @@
+
+LoadFromConfig
+{
+   setupRun 0;
+   path .;
+
+   simulationCorner < -15, -15, 0 >;
+   simulationDomain < 12, 23, 34 >;
+   blocks < 3, 4, 5 >;
+   isPeriodic < 0, 1, 0 >;
+
+   HCSITSmaxIterations 123;
+   HCSITSRelaxationParameter 0.123;
+   HCSITSErrorReductionParameter 0.123;
+   HCSITSRelaxationModelStr ApproximateInelasticCoulombContactByDecoupling;
+   globalLinearAcceleration < 1, -2, 3 >;
+
+}
diff --git a/tests/pe/LoadFromConfig.cpp b/tests/pe/LoadFromConfig.cpp
new file mode 100644
index 000000000..7b8fdae29
--- /dev/null
+++ b/tests/pe/LoadFromConfig.cpp
@@ -0,0 +1,66 @@
+//======================================================================================================================
+//
+//  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 LoadFromConfig.cpp
+//! \author Sebastian Eibl <sebastian.eibl@fau.de>
+//
+//======================================================================================================================
+
+
+#include "blockforest/all.h"
+#include "core/all.h"
+#include "domain_decomposition/all.h"
+
+#include "pe/basic.h"
+#include "pe/utility/CreateWorld.h"
+
+#include "core/debug/TestSubsystem.h"
+
+#include <boost/tuple/tuple.hpp>
+
+using namespace walberla;
+using namespace walberla::pe;
+
+int main( int argc, char ** argv )
+{
+   walberla::debug::enterTestMode();
+
+   Environment env(argc, argv);
+   const Config::BlockHandle configBlock  = env.config()->getBlock( "LoadFromConfig" );
+
+   shared_ptr<BodyStorage> globalBodyStorage = make_shared<BodyStorage>();
+
+   // create blocks
+   shared_ptr<BlockForest> forest = createBlockForestFromConfig( configBlock );
+   WALBERLA_CHECK_EQUAL( forest->getXSize(), 3 );
+   WALBERLA_CHECK_EQUAL( forest->getYSize(), 4 );
+   WALBERLA_CHECK_EQUAL( forest->getZSize(), 5 );
+   WALBERLA_CHECK( !forest->isXPeriodic() );
+   WALBERLA_CHECK(  forest->isYPeriodic() );
+   WALBERLA_CHECK( !forest->isZPeriodic() );
+   WALBERLA_CHECK_FLOAT_EQUAL( forest->getDomain().minCorner(), Vec3(-15, -15, 0) );
+   WALBERLA_CHECK_FLOAT_EQUAL( forest->getDomain().maxCorner(), Vec3(-3, 8, 34) );
+
+   BlockDataID blockDataID;
+   cr::HCSITS hcsits( globalBodyStorage, forest, blockDataID, blockDataID, blockDataID);
+   configure(configBlock, hcsits);
+   WALBERLA_CHECK_EQUAL( hcsits.getRelaxationModel(), cr::HCSITS::RelaxationModel::ApproximateInelasticCoulombContactByDecoupling );
+   WALBERLA_CHECK_EQUAL( hcsits.getMaxIterations(), 123 );
+   WALBERLA_CHECK_FLOAT_EQUAL( hcsits.getRelaxationParameter(), real_t(0.123) );
+   WALBERLA_CHECK_FLOAT_EQUAL( hcsits.getErrorReductionParameter(), real_t(0.123) );
+   WALBERLA_CHECK_FLOAT_EQUAL( hcsits.getGlobalLinearAcceleration(), Vec3(1,-2,3) );
+
+   return EXIT_SUCCESS;
+}
-- 
GitLab