From 776a16ac86b2668f2e17297fb7278bcb977282f6 Mon Sep 17 00:00:00 2001 From: Sebastian Eibl <sebastian.eibl@fau.de> Date: Thu, 18 May 2017 13:43:27 +0200 Subject: [PATCH] added configure function to HCSITS --- src/pe/cr/HCSITS.h | 16 +++++++++----- src/pe/cr/HCSITS.impl.h | 47 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 57 insertions(+), 6 deletions(-) diff --git a/src/pe/cr/HCSITS.h b/src/pe/cr/HCSITS.h index 17987b7a5..41f863e37 100644 --- a/src/pe/cr/HCSITS.h +++ b/src/pe/cr/HCSITS.h @@ -32,6 +32,7 @@ #include "pe/rigidbody/RigidBody.h" #include "pe/Types.h" +#include <core/config/Config.h> #include <core/DataTypes.h> #include <core/debug/Debug.h> #include <core/logging/Logging.h> @@ -261,9 +262,6 @@ private: typedef HardContactSemiImplicitTimesteppingSolvers HCSITS; - - - //================================================================================================= // // GET FUNCTIONS @@ -455,8 +453,16 @@ inline bool HardContactSemiImplicitTimesteppingSolvers::isSyncRequiredLocally() } //************************************************************************************************* -} +} // namespace cr } // namespace pe -} + +/** + * \brief configures HardContactSemiImplicitTimesteppingSolvers with parameters from config file + * \param config handle to config block + * \param cr collision resolution object to configure + */ +void configure( const Config::BlockHandle& config, pe::cr::HCSITS& cr); + +} // namespace walberla #include "HCSITS.impl.h" diff --git a/src/pe/cr/HCSITS.impl.h b/src/pe/cr/HCSITS.impl.h index 30f991458..d2c8b9ba7 100644 --- a/src/pe/cr/HCSITS.impl.h +++ b/src/pe/cr/HCSITS.impl.h @@ -1798,8 +1798,53 @@ inline void HardContactSemiImplicitTimesteppingSolvers::integratePositions( Body } //************************************************************************************************* - } // namespace cr } // namespace pe + +inline +void configure( const Config::BlockHandle& config, pe::cr::HCSITS& cr ) +{ + using namespace pe; + + int HCSITSmaxIterations = config.getParameter<int>("HCSITSmaxIterations", 10); + WALBERLA_LOG_INFO_ON_ROOT("HCSITSmaxIterations: " << HCSITSmaxIterations); + + real_t HCSITSRelaxationParameter = config.getParameter<real_t>("HCSITSRelaxationParameter", real_t(0.75) ); + WALBERLA_LOG_INFO_ON_ROOT("HCSITSRelaxationParameter: " << HCSITSRelaxationParameter); + + real_t HCSITSErrorReductionParameter = config.getParameter<real_t>("HCSITSErrorReductionParameter", real_t(0.8) ); + WALBERLA_LOG_INFO_ON_ROOT("HCSITSErrorReductionParameter: " << HCSITSErrorReductionParameter); + + std::string HCSITSRelaxationModelStr = config.getParameter<std::string>("HCSITSRelaxationModelStr", "ApproximateInelasticCoulombContactByDecoupling" ); + WALBERLA_LOG_INFO_ON_ROOT("HCSITSRelaxationModelStr: " << HCSITSRelaxationModelStr); + + cr::HCSITS::RelaxationModel HCSITSRelaxationModel; + if (HCSITSRelaxationModelStr == "InelasticFrictionlessContact") + { + HCSITSRelaxationModel = cr::HCSITS::InelasticFrictionlessContact; + } else if (HCSITSRelaxationModelStr == "ApproximateInelasticCoulombContactByDecoupling") + { + HCSITSRelaxationModel = cr::HCSITS::ApproximateInelasticCoulombContactByDecoupling; + } else if (HCSITSRelaxationModelStr == "InelasticCoulombContactByDecoupling") + { + HCSITSRelaxationModel = cr::HCSITS::InelasticCoulombContactByDecoupling; + } else if (HCSITSRelaxationModelStr == "InelasticGeneralizedMaximumDissipationContact") + { + HCSITSRelaxationModel = cr::HCSITS::InelasticGeneralizedMaximumDissipationContact; + } else + { + WALBERLA_ABORT("Unknown HCSITSRelaxationModel: " << HCSITSRelaxationModelStr); + } + + Vec3 globalLinearAcceleration = config.getParameter<Vec3>("globalLinearAcceleration", Vec3(0, 0, 0)); + WALBERLA_LOG_INFO_ON_ROOT("globalLinearAcceleration: " << globalLinearAcceleration); + + cr.setMaxIterations( uint_c(HCSITSmaxIterations) ); + cr.setRelaxationModel( HCSITSRelaxationModel ); + cr.setRelaxationParameter( HCSITSRelaxationParameter ); + cr.setErrorReductionParameter( HCSITSErrorReductionParameter ); + cr.setGlobalLinearAcceleration( globalLinearAcceleration ); +} + } // namespace walberla -- GitLab