From dec54ed4572f7c89aecdae51c50c72ed87124aa3 Mon Sep 17 00:00:00 2001 From: Michael Kuron <mkuron@icp.uni-stuttgart.de> Date: Tue, 26 Mar 2019 16:09:07 +0100 Subject: [PATCH] Replace Boost lexical_cast, numeric, math, range, demangle, hash --- .../ComplexGeometry/ComplexGeometry.cpp | 2 - apps/benchmarks/DEM/DEM.cpp | 4 +- .../MeshDistance/MeshDistanceBenchmark.cpp | 4 +- .../MotionSingleHeavySphere.cpp | 4 +- .../PoiseuilleChannel/PoiseuilleChannel.cpp | 3 +- .../SchaeferTurek/SchaeferTurek.cpp | 4 +- apps/tutorials/pde/01_SolvingPDE.cpp | 17 ++--- apps/tutorials/pde/01_SolvingPDE.dox | 16 ++--- apps/tutorials/pde/02_HeatEquation.cpp | 7 +- .../pde/03_HeatEquation_Extensions.cpp | 7 +- src/core/DataTypes.h | 71 ++++++++++++++++--- src/core/cell/Cell.h | 12 ++-- src/core/debug/CheckFunctions.impl.h | 2 + src/core/debug/PrintStacktrace.cpp | 19 +++++ src/core/math/DistributedSample.cpp | 18 +++-- src/core/math/PhysicalCheck.cpp | 14 ++-- src/core/math/Sample.cpp | 22 +++--- src/core/math/Utility.h | 21 ++---- src/core/math/Vector2.h | 6 +- src/core/math/Vector3.h | 8 +-- src/core/math/all.h | 1 + .../math/equation_system/EquationParser.cpp | 7 +- src/core/mpi/BufferSystem.h | 4 +- src/core/mpi/BufferSystem.impl.h | 19 +++-- src/core/mpi/OpenMPBufferSystem.impl.h | 8 +-- src/core/mpi/Reduce.h | 1 + src/core/uid/UID.h | 6 +- src/cuda/AddGPUFieldToStorage.h | 2 - src/gather/FileGatherScheme.cpp | 16 ++--- .../initializer/ScalarFieldFromBody.impl.h | 4 +- .../ScalarFieldFromCellInterval.impl.h | 4 +- src/pde/iterations/VCycles.impl.h | 14 ++-- src/pe/cr/HCSITS.impl.h | 2 +- .../correlations/DragForceCorrelations.h | 2 +- .../evaluators/LubricationForceEvaluator.h | 8 +-- .../utility/LubricationCorrection.cpp | 4 +- src/vtk/Initialization.cpp | 6 +- tests/core/debug/CheckMacroTest.cpp | 1 + tests/core/load_balancing/MetisTest.cpp | 6 +- tests/core/load_balancing/ParMetisTest.cpp | 6 +- tests/core/math/GenericAABBTest.cpp | 1 + tests/core/math/PhysicalCheckTest.cpp | 1 - tests/core/math/PlaneTest.cpp | 3 +- .../equation_system/EquationSolverTest.cpp | 5 +- tests/core/mpi/MPITextFileTest.cpp | 2 +- tests/core/timing/TimerTest.cpp | 5 +- tests/core/timing/TimingPoolTest.cpp | 3 +- tests/fft/GreensTest.cpp | 7 +- tests/field/FieldFileIOTest.cpp | 10 ++- tests/geometry/ScalarFieldFromBodyTest.cpp | 8 +-- tests/geometry/VoxelFileTest.cpp | 12 ---- tests/lbm/DiffusionTest.cpp | 25 ++++--- tests/lbm/boundary/BoundaryForce.cpp | 5 +- tests/lbm/boundary/BoundaryForceCouette.cpp | 2 +- tests/lbm/boundary/DiffusionDirichlet.cpp | 19 +++-- .../lbm/boundary/SimpleDiffusionDirichlet.cpp | 21 +++--- tests/lbm/boundary/SimplePABTest.cpp | 11 ++- tests/lbm/evaluations/PermeabilityTest.cpp | 2 +- tests/lbm/refinement/NonConstantDiffusion.cpp | 20 +++--- tests/mesh/MeshAABBIntersectionTest.cpp | 3 +- tests/mesh/MeshAABBSelectionTest.cpp | 5 +- tests/mesh/MeshBlockExclusionTest.cpp | 4 +- tests/mesh/MeshDistancePlausibilityTest.cpp | 4 +- tests/mesh/MeshInitilizationTest.cpp | 6 +- tests/mesh/MeshPeRaytracing.cpp | 2 +- tests/mesh/PeVTKMeshWriterTest.cpp | 2 +- tests/mesh/QHullTest.cpp | 2 +- tests/pde/BoundaryTest.cpp | 7 +- tests/pde/CGTest.cpp | 9 +-- tests/pde/JacobiTest.cpp | 11 +-- tests/pde/RBGSTest.cpp | 9 +-- tests/pde/SORTest.cpp | 9 +-- tests/pe/Collision.cpp | 4 +- tests/pe/GJK_EPA.cpp | 4 +- tests/pe/PeDocumentationSnippets.cpp | 6 +- .../HinderedSettlingDynamicsDPM.cpp | 16 ++--- .../DragForceSphereMEM.cpp | 4 +- .../DragForceSphereMEMRefinement.cpp | 4 +- .../LubricationCorrectionMEM.cpp | 8 +-- .../TorqueSphereMEM.cpp | 2 +- .../DragForceSpherePSM.cpp | 4 +- .../DragForceSpherePSMRefinement.cpp | 4 +- .../TorqueSpherePSM.cpp | 2 +- 83 files changed, 354 insertions(+), 321 deletions(-) diff --git a/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp b/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp index 8a18cbccd..ce7a492f7 100644 --- a/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp +++ b/apps/benchmarks/ComplexGeometry/ComplexGeometry.cpp @@ -78,8 +78,6 @@ #include "core/timing/RemainingTimeLogger.h" -#include <boost/lexical_cast.hpp> - #include <cmath> #include <vector> #include <string> diff --git a/apps/benchmarks/DEM/DEM.cpp b/apps/benchmarks/DEM/DEM.cpp index 52b6e856a..fb9de4611 100644 --- a/apps/benchmarks/DEM/DEM.cpp +++ b/apps/benchmarks/DEM/DEM.cpp @@ -32,13 +32,13 @@ namespace dem { real_t calcCoefficientOfRestitution(const real_t k, const real_t gamma, const real_t meff) { auto a = real_t(0.5) * gamma / meff; - return std::exp(-a * math::PI / std::sqrt(k / meff - a*a)); + return std::exp(-a * math::M_PI / std::sqrt(k / meff - a*a)); } real_t calcCollisionTime(const real_t k, const real_t gamma, const real_t meff) { auto a = real_t(0.5) * gamma / meff; - return math::PI / std::sqrt( k/meff - a*a); + return math::M_PI / std::sqrt( k/meff - a*a); } } diff --git a/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp b/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp index 0e9585346..ec2212242 100644 --- a/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp +++ b/apps/benchmarks/MeshDistance/MeshDistanceBenchmark.cpp @@ -164,8 +164,8 @@ int main( int argc, char * argv[] ) WALBERLA_ABORT_NO_DEBUG_INFO( "USAGE: " << args[0] << " [--no-brute-force] [--force-float] MESH_FILE NUM_POINTS NUM_REPETITIONS" ); const std::string & meshFile = args[1]; - const uint_t numPoints = boost::lexical_cast<uint_t>( args[2] ); - const uint_t numRepetitions = boost::lexical_cast<uint_t>( args[3] ); + const uint_t numPoints = string_to_num<uint_t>( args[2] ); + const uint_t numRepetitions = string_to_num<uint_t>( args[3] ); if(forceFloat) { diff --git a/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp b/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp index 2e6f5af9f..fb355ddde 100644 --- a/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp +++ b/apps/benchmarks/MotionSingleHeavySphere/MotionSingleHeavySphere.cpp @@ -1081,7 +1081,7 @@ int main( int argc, char **argv ) WALBERLA_LOG_INFO_ON_ROOT("Initial simulation has ended.") //evaluate the gravitational force necessary to keep the sphere at a approximately fixed position - gravity = forceEval->getForce() / ( (densityRatio - real_t(1) ) * diameter * diameter * diameter * math::PI / real_t(6) ); + gravity = forceEval->getForce() / ( (densityRatio - real_t(1) ) * diameter * diameter * diameter * math::M_PI / real_t(6) ); GalileoSim = std::sqrt( ( densityRatio - real_t(1) ) * gravity * diameter * diameter * diameter ) / viscosity; ReynoldsSim = uIn * diameter / viscosity; u_ref = std::sqrt( std::fabs(densityRatio - real_t(1)) * gravity * diameter ); @@ -1235,7 +1235,7 @@ int main( int argc, char **argv ) } // add gravity - Vector3<real_t> extForcesOnSphere( real_t(0), real_t(0), - gravity * ( densityRatio - real_t(1) ) * diameter * diameter * diameter * math::PI / real_t(6)); + Vector3<real_t> extForcesOnSphere( real_t(0), real_t(0), - gravity * ( densityRatio - real_t(1) ) * diameter * diameter * diameter * math::M_PI / real_t(6)); timeloop.addFuncAfterTimeStep( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, extForcesOnSphere ), "Add external forces (gravity and buoyancy)" ); // evaluate the sphere properties diff --git a/apps/benchmarks/PoiseuilleChannel/PoiseuilleChannel.cpp b/apps/benchmarks/PoiseuilleChannel/PoiseuilleChannel.cpp index dfb8eefd3..bd9debc51 100644 --- a/apps/benchmarks/PoiseuilleChannel/PoiseuilleChannel.cpp +++ b/apps/benchmarks/PoiseuilleChannel/PoiseuilleChannel.cpp @@ -34,6 +34,7 @@ #include "core/debug/Debug.h" #include "core/debug/TestSubsystem.h" #include "core/logging/Logging.h" +#include "core/math/Constants.h" #include "core/math/Sample.h" #include "core/math/Vector3.h" #include "core/mpi/Environment.h" @@ -762,7 +763,7 @@ void run( const shared_ptr< Config > & config, const LatticeModel_T & latticeMod { setup.maxVelocity_L = ( setup.acceleration_L * setup.radius_L * setup.radius_L ) / ( real_t(4) * setup.viscosity_L ); setup.meanVelocity_L = ( setup.acceleration_L * setup.radius_L * setup.radius_L ) / ( real_t(8) * setup.viscosity_L ); - setup.flowRate_L = setup.meanVelocity_L * math::PI * setup.radius_L * setup.radius_L; + setup.flowRate_L = setup.meanVelocity_L * math::M_PI * setup.radius_L * setup.radius_L; } else { diff --git a/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp b/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp index d83409c4c..42885f958 100644 --- a/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp +++ b/apps/benchmarks/SchaeferTurek/SchaeferTurek.cpp @@ -38,6 +38,7 @@ #include "core/debug/Debug.h" #include "core/debug/TestSubsystem.h" #include "core/logging/Logging.h" +#include "core/math/Constants.h" #include "core/math/Sample.h" #include "core/math/Vector3.h" #include "core/mpi/Environment.h" @@ -746,8 +747,7 @@ public: void operator()( const real_t t ) { - const real_t PI = real_t( 3.141592653589793238462643383279502884 ); - tConstTerm_ = ( sinPeriod_ > real_t(0) ) ? ( std::abs( std::sin( PI * t / sinPeriod_ ) ) ) : real_t(1); + tConstTerm_ = ( sinPeriod_ > real_t(0) ) ? ( std::abs( std::sin( math::M_PI * t / sinPeriod_ ) ) ) : real_t(1); tConstTerm_ *= uTerm_ * HTerm_; tConstTerm_ *= ( raisingTime_ > real_t(0) ) ? std::min( t / raisingTime_, real_t(1) ) : real_t(1); } diff --git a/apps/tutorials/pde/01_SolvingPDE.cpp b/apps/tutorials/pde/01_SolvingPDE.cpp index 55eb90fb2..11b47c0f0 100644 --- a/apps/tutorials/pde/01_SolvingPDE.cpp +++ b/apps/tutorials/pde/01_SolvingPDE.cpp @@ -22,6 +22,7 @@ #include "blockforest/communication/UniformBufferedScheme.h" #include "core/Environment.h" +#include "core/math/Constants.h" #include "field/Field.h" #include "field/AddToStorage.h" @@ -69,9 +70,9 @@ void initBC( const shared_ptr< StructuredBlockStorage > & blocks, const BlockDat // obtain the physical coordinate of the center of the current cell const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - // set the values of the Dirichlet boundary condition given by the function u(x,1) = sin(2*PI*x)*sinh(2*PI) in the source and destination field - src->get( *cell ) = std::sin( real_c(2) * math::PI * p[0] ) * std::sinh( real_c(2) * math::PI ); - dst->get( *cell ) = std::sin( real_c(2) * math::PI * p[0] ) * std::sinh( real_c(2) * math::PI ); + // set the values of the Dirichlet boundary condition given by the function u(x,1) = sin(2*M_PI*x)*sinh(2*M_PI) in the source and destination field + src->get( *cell ) = std::sin( real_c(2) * math::M_PI * p[0] ) * std::sinh( real_c(2) * math::M_PI ); + dst->get( *cell ) = std::sin( real_c(2) * math::M_PI * p[0] ) * std::sinh( real_c(2) * math::M_PI ); } } } @@ -97,9 +98,9 @@ void initRHS( const shared_ptr< StructuredBlockStorage > & blocks, const BlockDa // obtain the physical coordinate of the center of the current cell const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - // set the right-hand side, given by the function f(x,y) = 4*PI*PI*sin(2*PI*x)*sinh(2*PI*y) - f->get( *cell ) = real_c(4) * math::PI * math::PI * std::sin( real_c(2) * math::PI * p[0] ) * - std::sinh( real_c(2) * math::PI * p[1] ); + // set the right-hand side, given by the function f(x,y) = 4*M_PI*PI*sin(2*M_PI*x)*sinh(2*M_PI*y) + f->get( *cell ) = real_c(4) * math::M_PI * math::M_PI * std::sin( real_c(2) * math::M_PI * p[0] ) * + std::sinh( real_c(2) * math::M_PI * p[1] ); } } } @@ -146,7 +147,7 @@ void JacobiSweep::operator()( IBlock * const block ) dst->get(x,y,z) += ( real_c(1) / (dx_ * dx_) ) * src->get( x-1, y , z ); dst->get(x,y,z) += ( real_c(1) / (dy_ * dy_) ) * src->get( x , y+1, z ); dst->get(x,y,z) += ( real_c(1) / (dy_ * dy_) ) * src->get( x , y-1, z ); - dst->get(x,y,z) /= ( real_c(2) / (dx_ * dx_) + real_c(2)/(dy_ * dy_) + real_c(4) * math::PI * math::PI ); + dst->get(x,y,z) /= ( real_c(2) / (dx_ * dx_) + real_c(2)/(dy_ * dy_) + real_c(4) * math::M_PI * math::M_PI ); ) // swap source and destination fields @@ -281,7 +282,7 @@ int main( int argc, char ** argv ) // ...or the variant using the stencil concept // set up the stencil weights std::vector< real_t > weights( Stencil_T::Size ); - weights[ Stencil_T::idx[ stencil::C ] ] = real_c(2) / ( dx * dx ) + real_c(2) / ( dy * dy ) + real_c(4) * math::PI * math::PI; + weights[ Stencil_T::idx[ stencil::C ] ] = real_c(2) / ( dx * dx ) + real_c(2) / ( dy * dy ) + real_c(4) * math::M_PI * math::M_PI; weights[ Stencil_T::idx[ stencil::E ] ] = real_c(-1) / ( dx * dx ); weights[ Stencil_T::idx[ stencil::W ] ] = real_c(-1) / ( dx * dx ); weights[ Stencil_T::idx[ stencil::N ] ] = real_c(-1) / ( dy * dy ); diff --git a/apps/tutorials/pde/01_SolvingPDE.dox b/apps/tutorials/pde/01_SolvingPDE.dox index 9298f9c68..8a7e33dce 100644 --- a/apps/tutorials/pde/01_SolvingPDE.dox +++ b/apps/tutorials/pde/01_SolvingPDE.dox @@ -71,7 +71,7 @@ void JacobiSweep::operator()( IBlock * const block ) dst->get(x,y,z) += ( real_c(1) / (dx_ * dx_) ) * src->get( x-1, y , z ); dst->get(x,y,z) += ( real_c(1) / (dy_ * dy_) ) * src->get( x , y+1, z ); dst->get(x,y,z) += ( real_c(1) / (dy_ * dy_) ) * src->get( x , y-1, z ); - dst->get(x,y,z) /= ( real_c(2) / (dx_ * dx_) + real_c(2)/(dy_ * dy_) + real_c(4) * math::PI * math::PI ); + dst->get(x,y,z) /= ( real_c(2) / (dx_ * dx_) + real_c(2)/(dy_ * dy_) + real_c(4) * math::M_PI * math::M_PI ); ) // swap source and destination fields @@ -90,7 +90,7 @@ typedef stencil::D2Q5 Stencil_T; // set up the stencil weights std::vector< real_t > weights( Stencil_T::Size ); -weights[ Stencil_T::idx[ stencil::C ] ] = real_c(2) / ( dx * dx ) + real_c(2) / ( dy * dy ) + real_c(4) * math::PI * math::PI; +weights[ Stencil_T::idx[ stencil::C ] ] = real_c(2) / ( dx * dx ) + real_c(2) / ( dy * dy ) + real_c(4) * math::M_PI * math::M_PI; weights[ Stencil_T::idx[ stencil::E ] ] = real_c(-1) / ( dx * dx ); weights[ Stencil_T::idx[ stencil::W ] ] = real_c(-1) / ( dx * dx ); weights[ Stencil_T::idx[ stencil::N ] ] = real_c(-1) / ( dy * dy ); @@ -185,9 +185,9 @@ void initRHS( const shared_ptr< StructuredBlockStorage > & blocks, const BlockDa // obtain the physical coordinate of the center of the current cell const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - // set the right-hand side, given by the function f(x,y) = 4*PI*PI*sin(2*PI*x)*sinh(2*PI*y) - f->get( *cell ) = real_c(4) * math::PI * math::PI * std::sin( real_c(2) * math::PI * p[0] ) * - std::sinh( real_c(2) * math::PI * p[1] ); + // set the right-hand side, given by the function f(x,y) = 4*M_PI*PI*sin(2*M_PI*x)*sinh(2*M_PI*y) + f->get( *cell ) = real_c(4) * math::M_PI * math::M_PI * std::sin( real_c(2) * math::M_PI * p[0] ) * + std::sinh( real_c(2) * math::M_PI * p[1] ); } } } @@ -236,10 +236,10 @@ void initBC( const shared_ptr< StructuredBlockStorage > & blocks, const BlockDat // obtain the physical coordinate of the center of the current cell const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - // set the values of the Dirichlet boundary condition given by the function u(x,1) = sin(2*PI*x)*sinh(2*PI) + // set the values of the Dirichlet boundary condition given by the function u(x,1) = sin(2*M_PI*x)*sinh(2*M_PI) // in the source and destination field - src->get( *cell ) = std::sin( real_c(2) * math::PI * p[0] ) * std::sinh( real_c(2) * math::PI ); - dst->get( *cell ) = std::sin( real_c(2) * math::PI * p[0] ) * std::sinh( real_c(2) * math::PI ); + src->get( *cell ) = std::sin( real_c(2) * math::M_PI * p[0] ) * std::sinh( real_c(2) * math::M_PI ); + dst->get( *cell ) = std::sin( real_c(2) * math::M_PI * p[0] ) * std::sinh( real_c(2) * math::M_PI ); } } } diff --git a/apps/tutorials/pde/02_HeatEquation.cpp b/apps/tutorials/pde/02_HeatEquation.cpp index 931644c34..c4ec151ea 100644 --- a/apps/tutorials/pde/02_HeatEquation.cpp +++ b/apps/tutorials/pde/02_HeatEquation.cpp @@ -22,6 +22,7 @@ #include "blockforest/communication/UniformBufferedScheme.h" #include "core/Environment.h" +#include "core/math/Constants.h" #include "core/mpi/Reduce.h" #include "field/Field.h" @@ -65,8 +66,8 @@ void initU( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData // obtain the physical coordinate of the center of the current cell const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - // set the initial condition, given by the function u(x,y,0) = sin(PI*x)*sin(PI*y) - u->get( *cell ) = std::sin( math::PI * p[0] ) * std::sin( math::PI * p[1] ); + // set the initial condition, given by the function u(x,y,0) = sin(M_PI*x)*sin(M_PI*y) + u->get( *cell ) = std::sin( math::M_PI * p[0] ) * std::sin( math::M_PI * p[1] ); } } } @@ -255,4 +256,4 @@ int main( int argc, char ** argv ) int main( int argc, char ** argv ) { walberla::main(argc, argv); -} \ No newline at end of file +} diff --git a/apps/tutorials/pde/03_HeatEquation_Extensions.cpp b/apps/tutorials/pde/03_HeatEquation_Extensions.cpp index 15d8859c1..92f3b79ac 100644 --- a/apps/tutorials/pde/03_HeatEquation_Extensions.cpp +++ b/apps/tutorials/pde/03_HeatEquation_Extensions.cpp @@ -22,6 +22,7 @@ #include "blockforest/communication/UniformBufferedScheme.h" #include "core/Environment.h" +#include "core/math/Constants.h" #include "core/mpi/Reduce.h" #include "field/Field.h" @@ -66,8 +67,8 @@ void initU( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData // obtain the physical coordinate of the center of the current cell const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - // set the initial condition, given by the function u(x,y,0) = sin(PI*x)*sin(PI*y) - u->get( *cell ) = std::sin( math::PI * p[0] ) * std::sin( math::PI * p[1] ); + // set the initial condition, given by the function u(x,y,0) = sin(M_PI*x)*sin(M_PI*y) + u->get( *cell ) = std::sin( math::M_PI * p[0] ) * std::sin( math::M_PI * p[1] ); } } } @@ -352,4 +353,4 @@ int main( int argc, char ** argv ) int main( int argc, char* argv[] ) { return walberla::main( argc, argv ); -} \ No newline at end of file +} diff --git a/src/core/DataTypes.h b/src/core/DataTypes.h index e4c755d10..fb7d16af2 100644 --- a/src/core/DataTypes.h +++ b/src/core/DataTypes.h @@ -24,14 +24,17 @@ #include "waLBerlaDefinitions.h" #include <cstdint> -#include <boost/numeric/conversion/cast.hpp> #include <memory> #include <type_traits> -#include <boost/units/detail/utility.hpp> - +#include <string> #include <cmath> #include <limits> +#if (defined( __has_include ) && __has_include(<cxxabi.h>)) || defined( __GLIBCXX__ ) +#define HAVE_CXXABI_H +#include <cxxabi.h> +#endif + namespace walberla { @@ -41,6 +44,8 @@ namespace walberla { template <typename> struct never_true : std::false_type {}; +template< typename T > bool isIdentical( const T a, const T b ); + // shared ptr @@ -54,15 +59,52 @@ using std::dynamic_pointer_cast; template< typename S, typename T > inline S numeric_cast( T t ) { -#ifdef NDEBUG - return static_cast< S >(t); -#else - return boost::numeric_cast< S >(t); +#ifndef NDEBUG + if( std::is_integral<S>::value && std::is_integral<T>::value && !std::is_same<S,T>::value ) + // integer to different integer: check that forward and back conversion does not change value + { + if( !isIdentical( static_cast<T>( static_cast<S>(t) ), t ) ) + { + throw std::range_error("out of range"); + } + } + else if( !std::is_integral<S>::value && !std::is_integral<T>::value && sizeof(S) < sizeof(T) ) + // float to shorter float: check that value within limits of shorter type + { + using H = typename std::conditional< !std::is_integral<S>::value && !std::is_integral<T>::value && (sizeof(S) < sizeof(T)), T, long double >::type; // always true, but makes Intel's overflow check happy + H h = static_cast<H>(t); + if( h < static_cast<H>(std::numeric_limits<S>::lowest()) || h > static_cast<H>(std::numeric_limits<S>::max()) ) { + throw std::range_error("out of range"); + } + } + else if( std::is_integral<S>::value && !std::is_integral<T>::value ) + // float to integer: check that value within limits of integer + { + using H = typename std::conditional< std::is_integral<S>::value && !std::is_integral<T>::value, T, long double >::type; // always true, but makes Intel's overflow check happy + H h = static_cast<H>(t); + if( h < static_cast<H>(std::numeric_limits<S>::lowest()) || h > static_cast<H>(std::numeric_limits<S>::max()) ) { + throw std::range_error("out of range"); + } + } #endif + return static_cast< S >(t); } +template<typename S> +inline S string_to_num( std::string & t ); +template <> inline float string_to_num( std::string & t ) { return std::stof(t); } +template <> inline double string_to_num( std::string & t ) { return std::stod(t); } +template <> inline long double string_to_num( std::string & t ) { return std::stold(t); } +template <> inline int string_to_num( std::string & t ) { return std::stoi(t); } +template <> inline long string_to_num( std::string & t ) { return std::stol(t); } +template <> inline long long string_to_num( std::string & t ) { return std::stoll(t); } +template <> inline unsigned long string_to_num( std::string & t ) { return std::stoul(t); } +template <> inline unsigned long long string_to_num( std::string & t ) { return std::stoull(t); } + + + // fixed size signed integral types typedef std::int8_t int8_t; ///< 8 bit signed integer typedef std::int16_t int16_t; ///< 16 bit signed integer @@ -286,7 +328,20 @@ template< typename T > inline const char* typeToString( T ) { return typeToStrin inline std::string demangle( const std::string & name ) { - return boost::units::detail::demangle( name.c_str() ); +#ifdef HAVE_CXXABI_H + int status = 0; + std::size_t size = 0; + const char * demangled = abi::__cxa_demangle( name.c_str(), NULL, &size, &status ); + if( demangled == nullptr ) + { + return name; + } + std::string demangled_str(demangled); + std::free( const_cast<char*>(demangled) ); + return demangled_str; +#else + return name; +#endif } diff --git a/src/core/cell/Cell.h b/src/core/cell/Cell.h index cf54ccaae..11fa7d1d1 100644 --- a/src/core/cell/Cell.h +++ b/src/core/cell/Cell.h @@ -28,10 +28,9 @@ #include "core/mpi/RecvBuffer.h" #include "core/mpi/SendBuffer.h" -#include <boost/functional/hash.hpp> #include <algorithm> #include <iterator> -#include <ostream> +#include <iostream> namespace walberla { @@ -336,9 +335,12 @@ inline std::istream & operator>>( std::istream & is, Cell & cell ) inline std::size_t hash_value( const Cell & cell ) { std::size_t seed = 0; - boost::hash_combine( seed, cell.x() ); - boost::hash_combine( seed, cell.y() ); - boost::hash_combine( seed, cell.z() ); + std::hash<cell_idx_t> hasher; + + seed ^= hasher(cell.x()) + 0x9e3779b9 + (seed<<6) + (seed>>2); + seed ^= hasher(cell.y()) + 0x9e3779b9 + (seed<<6) + (seed>>2); + seed ^= hasher(cell.z()) + 0x9e3779b9 + (seed<<6) + (seed>>2); + return seed; } diff --git a/src/core/debug/CheckFunctions.impl.h b/src/core/debug/CheckFunctions.impl.h index fac44221d..71f089565 100644 --- a/src/core/debug/CheckFunctions.impl.h +++ b/src/core/debug/CheckFunctions.impl.h @@ -20,6 +20,8 @@ //====================================================================================================================== +#include <algorithm> + #include <boost/type_traits/integral_constant.hpp> /// \cond internal diff --git a/src/core/debug/PrintStacktrace.cpp b/src/core/debug/PrintStacktrace.cpp index b4a8e6888..a83b13d23 100644 --- a/src/core/debug/PrintStacktrace.cpp +++ b/src/core/debug/PrintStacktrace.cpp @@ -65,6 +65,24 @@ namespace debug { for (i = 0; i < size; i++) { std::string line ( strings[i] ); +#ifdef __APPLE__ + // one line might look like this: + //0 PrintStacktraceTest 0x0000000000408c6b _ZN8walberla4core15printStacktraceEv + 75 + + size_t plusPos = line.find_last_of('+'); + size_t funcPos = line.find_last_of(' ', plusPos-2)+1; + + string functionName = line.substr( funcPos, plusPos-funcPos-1 ); + + size_t addrPos = line.find_last_of('x', funcPos-2)-2; + size_t afterLevelPos = line.find_first_of(' '); + size_t beforeAppPos = line.find_first_not_of(" ", afterLevelPos); + + string appName = line.substr( beforeAppPos, addrPos-beforeAppPos ); + + size_t afterAppPos = appName.find_last_not_of(" ")+1; + appName = appName.substr( 0, afterAppPos ); +#else // one line might look like this: //./PrintStacktraceTest(_ZN8walberla4core15printStacktraceEv+0x4b) [0x408c6b] @@ -80,6 +98,7 @@ namespace debug { size_t plusPos = bracketPart.find_first_of('+'); string functionName = bracketPart.substr(0, plusPos ); string offset = bracketPart.substr( plusPos+1 ); +#endif // try to demangle -> no return code if successfull // but the returned string starts with "demangle" if demangling failed diff --git a/src/core/math/DistributedSample.cpp b/src/core/math/DistributedSample.cpp index 509af72af..3a1d40a7f 100644 --- a/src/core/math/DistributedSample.cpp +++ b/src/core/math/DistributedSample.cpp @@ -25,7 +25,6 @@ #include "core/mpi/Reduce.h" #include <boost/algorithm/string/replace.hpp> -#include <boost/lexical_cast.hpp> @@ -172,28 +171,27 @@ void DistributedSample::mpiGatherRoot() std::string DistributedSample::format( const std::string & formatString ) const { using boost::algorithm::replace_all; - using boost::lexical_cast; std::string result = formatString; if( size_ > uint_t(0) ) { if( result.find( "%min" ) != std::string::npos ) - replace_all(result, "%min", lexical_cast<std::string>( min_ ) ); + replace_all(result, "%min", std::to_string( min_ ) ); if( result.find( "%max" ) != std::string::npos ) - replace_all(result, "%max", lexical_cast<std::string>( max_ ) ); + replace_all(result, "%max", std::to_string( max_ ) ); if( result.find( "%sum" ) != std::string::npos ) - replace_all(result, "%sum",lexical_cast<std::string>( sum_ ) ); + replace_all(result, "%sum",std::to_string( sum_ ) ); if( result.find( "%mean" ) != std::string::npos ) - replace_all(result, "%mean", lexical_cast<std::string>( mean_ ) ); + replace_all(result, "%mean", std::to_string( mean_ ) ); if( result.find( "%var" ) != std::string::npos ) - replace_all(result, "%var", lexical_cast<std::string>( variance_ ) ); + replace_all(result, "%var", std::to_string( variance_ ) ); if( result.find( "%stddev" ) != std::string::npos ) - replace_all(result, "%stddev", lexical_cast<std::string>( stdDeviation() ) ); + replace_all(result, "%stddev", std::to_string( stdDeviation() ) ); if( result.find( "%relstddev" ) != std::string::npos ) - replace_all(result, "%relstddev", lexical_cast<std::string>( relativeStdDeviation() ) ); + replace_all(result, "%relstddev", std::to_string( relativeStdDeviation() ) ); if( result.find( "%size" ) != std::string::npos ) - replace_all(result, "%size", lexical_cast<std::string>( size_ ) ); + replace_all(result, "%size", std::to_string( size_ ) ); } else // empty() { diff --git a/src/core/math/PhysicalCheck.cpp b/src/core/math/PhysicalCheck.cpp index d87a0ad18..7c3342449 100644 --- a/src/core/math/PhysicalCheck.cpp +++ b/src/core/math/PhysicalCheck.cpp @@ -25,8 +25,6 @@ #include "core/math/Parser.h" #include "equation_system/EquationParser.h" -#include <boost/lexical_cast.hpp> - namespace walberla { namespace math { @@ -96,7 +94,7 @@ namespace math { for (size_t i=0; i<equations.size(); ++i){ index = 0; - es_.add( boost::lexical_cast<std::string>(es_.getNumberOfEquations()+1), ep.parseEquation( equations[i], index ) ); + es_.add( std::to_string(es_.getNumberOfEquations()+1), ep.parseEquation( equations[i], index ) ); } } @@ -107,7 +105,7 @@ namespace math { solved_ = false; - es_.add( boost::lexical_cast<std::string>(es_.getNumberOfEquations()+1), ep.parseEquation( equation, index ) ); + es_.add( std::to_string(es_.getNumberOfEquations()+1), ep.parseEquation( equation, index ) ); } void PhysicalCheck::addUnitParameterRelations( const std::map< std::string, std::string >& unitParameterRelations ) @@ -134,7 +132,7 @@ namespace math { if( j < unitString.size() && unitString[j] == '^' ) { ++j; - int expo = factor * boost::lexical_cast<int>( unitString[j] ); + int expo = factor * std::atoi( &unitString[j] ); if( !setVarUnit( i->first, unitString.substr(index,1), expo ) ) WALBERLA_ABORT( "Error in PhysicalCheck::addUnitParameterRelations(). Non-unique description for unit '" << unitString[index] << "' for parameter '" << i->first << "'." ); } @@ -153,7 +151,7 @@ namespace math { if( j < unitString.size() && unitString[j] == '^' ) { ++j; - int expo = factor * boost::lexical_cast<int>( unitString[j] ); + int expo = factor * std::atoi( &unitString[j] ); if( !setVarUnit( i->first, unitString.substr(index,2), expo ) ) WALBERLA_ABORT( "Error in PhysicalCheck::addUnitParameterRelations(). Non-unique description for unit 'kg' for parameter '" << i->first << "'."); } @@ -277,7 +275,9 @@ namespace math { } // set the current parameter to the evaluated result in the current block - configBlock.setParameter( param->first, boost::lexical_cast<std::string>(result) ); + std::ostringstream os; + os << std::setprecision(16) << result; + configBlock.setParameter( param->first, os.str() ); // check for the equality of the parameter and the result double val = configBlock.getParameter<double>( param->first ); diff --git a/src/core/math/Sample.cpp b/src/core/math/Sample.cpp index eabe897cd..8e376edf7 100644 --- a/src/core/math/Sample.cpp +++ b/src/core/math/Sample.cpp @@ -25,7 +25,6 @@ #include "core/mpi/MPIManager.h" #include <boost/algorithm/string/replace.hpp> -#include <boost/lexical_cast.hpp> #include <functional> #include <iterator> @@ -271,32 +270,31 @@ real_t Sample::quantile(const real_t p) const std::string Sample::format(const std::string & formatString) const { using boost::algorithm::replace_all; - using boost::lexical_cast; std::string result = formatString; if( !empty() ) { if( result.find( "%min" ) != std::string::npos ) - replace_all(result, "%min", lexical_cast<std::string>( min() ) ); + replace_all(result, "%min", std::to_string( min() ) ); if( result.find( "%max" ) != std::string::npos ) - replace_all(result, "%max", lexical_cast<std::string>( max() ) ); + replace_all(result, "%max", std::to_string( max() ) ); if( result.find( "%sum" ) != std::string::npos ) - replace_all(result, "%sum",lexical_cast<std::string>( sum() ) ); + replace_all(result, "%sum",std::to_string( sum() ) ); if( result.find( "%mean" ) != std::string::npos ) - replace_all(result, "%mean", lexical_cast<std::string>( mean() ) ); + replace_all(result, "%mean", std::to_string( mean() ) ); if( result.find( "%med" ) != std::string::npos ) - replace_all(result, "%med", lexical_cast<std::string>( median() ) ); + replace_all(result, "%med", std::to_string( median() ) ); if( result.find( "%var" ) != std::string::npos ) - replace_all(result, "%var", lexical_cast<std::string>( variance() ) ); + replace_all(result, "%var", std::to_string( variance() ) ); if( result.find( "%stddev" ) != std::string::npos ) - replace_all(result, "%stddev", lexical_cast<std::string>( stdDeviation() ) ); + replace_all(result, "%stddev", std::to_string( stdDeviation() ) ); if( result.find( "%relstddev" ) != std::string::npos ) - replace_all(result, "%relstddev", lexical_cast<std::string>( relativeStdDeviation() ) ); + replace_all(result, "%relstddev", std::to_string( relativeStdDeviation() ) ); if( result.find( "%mad" ) != std::string::npos ) - replace_all(result, "%mad", lexical_cast<std::string>( mad() ) ); + replace_all(result, "%mad", std::to_string( mad() ) ); if( result.find( "%size" ) != std::string::npos ) - replace_all(result, "%size", lexical_cast<std::string>( size() ) ); + replace_all(result, "%size", std::to_string( size() ) ); } else // empty() { diff --git a/src/core/math/Utility.h b/src/core/math/Utility.h index 198cd4c73..ba1f62c10 100644 --- a/src/core/math/Utility.h +++ b/src/core/math/Utility.h @@ -25,26 +25,15 @@ #include "MathTrait.h" #include "core/DataTypes.h" -#include <boost/math/constants/constants.hpp> #include <cmath> #include <cstddef> #include <limits> +#include <type_traits> namespace walberla { namespace math { -//====================================================================================================================== -// -// MATHEMATICAL CONSTANTS -// -//====================================================================================================================== - -//! Definition of the mathematical value \f$ \pi \f$. -const real_t PI = boost::math::constants::pi<real_t>(); - - - //====================================================================================================================== // // MATHEMATICAL UTILITY FUNCTIONS @@ -58,9 +47,9 @@ template< typename T > inline const T sign( T a ); template< typename T > -inline const typename boost::enable_if_c< boost::is_unsigned<T>::value, T >::type abs( T a ); +inline const typename std::enable_if< std::is_unsigned<T>::value, T >::type abs( T a ); template< typename T > -inline const typename boost::enable_if_c< !boost::is_unsigned<T>::value, T >::type abs( T a ); +inline const typename std::enable_if< !std::is_unsigned<T>::value, T >::type abs( T a ); template< typename T1, typename T2 > @@ -113,13 +102,13 @@ inline const T sign( T a ) // \return The value if it is greater than or equal to zero, -1 times the value if the value is smaller than zero. */ template< typename T > -inline const typename boost::enable_if_c< boost::is_unsigned<T>::value, T >::type abs( T a ) +inline const typename std::enable_if< std::is_unsigned<T>::value, T >::type abs( T a ) { return a; } template< typename T > -inline const typename boost::enable_if_c< !boost::is_unsigned<T>::value, T >::type abs( T a ) +inline const typename std::enable_if< !std::is_unsigned<T>::value, T >::type abs( T a ) { return std::abs( a ); } diff --git a/src/core/math/Vector2.h b/src/core/math/Vector2.h index a6ad5c300..220bb21b0 100644 --- a/src/core/math/Vector2.h +++ b/src/core/math/Vector2.h @@ -37,7 +37,6 @@ #include "core/mpi/RecvBuffer.h" #include "core/mpi/SendBuffer.h" -#include <boost/functional/hash.hpp> #include <boost/type_traits/is_floating_point.hpp> #include <boost/type_traits/is_fundamental.hpp> #include <boost/type_traits/is_same.hpp> @@ -1579,9 +1578,10 @@ template< typename T > size_t hash_value( const Vector2<T> & v ) { size_t seed = 0; + std::hash<T> hasher; - boost::hash_combine( seed, v[0] ); - boost::hash_combine( seed, v[1] ); + seed ^= hasher(v[0]) + 0x9e3779b9 + (seed<<6) + (seed>>2); + seed ^= hasher(v[1]) + 0x9e3779b9 + (seed<<6) + (seed>>2); return seed; diff --git a/src/core/math/Vector3.h b/src/core/math/Vector3.h index 24485fef5..e0c296579 100644 --- a/src/core/math/Vector3.h +++ b/src/core/math/Vector3.h @@ -38,7 +38,6 @@ #include "core/mpi/SendBuffer.h" #include "core/debug/CheckFunctions.h" -#include <boost/functional/hash.hpp> #include <boost/type_traits.hpp> #include <boost/type_traits/is_floating_point.hpp> #include <boost/type_traits/is_fundamental.hpp> @@ -1837,10 +1836,11 @@ template< typename T > size_t hash_value( const Vector3<T> & v ) { size_t seed = 0; + std::hash<T> hasher; - boost::hash_combine( seed, v[0] ); - boost::hash_combine( seed, v[1] ); - boost::hash_combine( seed, v[2] ); + seed ^= hasher(v[0]) + 0x9e3779b9 + (seed<<6) + (seed>>2); + seed ^= hasher(v[1]) + 0x9e3779b9 + (seed<<6) + (seed>>2); + seed ^= hasher(v[2]) + 0x9e3779b9 + (seed<<6) + (seed>>2); return seed; diff --git a/src/core/math/all.h b/src/core/math/all.h index 162414f7b..29295fc4f 100644 --- a/src/core/math/all.h +++ b/src/core/math/all.h @@ -23,6 +23,7 @@ #pragma once #include "AABB.h" +#include "Constants.h" #include "DistributedSample.h" #include "FPClassify.h" #include "FastInvSqrt.h" diff --git a/src/core/math/equation_system/EquationParser.cpp b/src/core/math/equation_system/EquationParser.cpp index a58be4bd7..cba3f45b1 100644 --- a/src/core/math/equation_system/EquationParser.cpp +++ b/src/core/math/equation_system/EquationParser.cpp @@ -26,7 +26,6 @@ #include "core/math/Constants.h" #include <boost/algorithm/string/trim.hpp> -#include <boost/lexical_cast.hpp> #include <memory> @@ -78,10 +77,10 @@ NodePtr EquationParser::parseNumber( const std::string& str, size_t& index ) con THROW( "Number ends with 'e'", str, index ); while( isdigit(str[++index]) != int(0) ); - value = boost::lexical_cast< double >( str.substr(start, estart-start-1) ) * - pow(10.0, boost::lexical_cast< int >( str.substr(estart, index-estart) ) ); + value = std::stod( str.substr(start, estart-start-1) ) * + pow(10.0, std::stoi( str.substr(estart, index-estart) ) ); } else { - value = boost::lexical_cast< double >( str.substr(start, index-start) ); + value = std::stod( str.substr(start, index-start) ); } return std::make_shared<Node>( value ); diff --git a/src/core/mpi/BufferSystem.h b/src/core/mpi/BufferSystem.h index 2a04730f7..6a0048b2c 100644 --- a/src/core/mpi/BufferSystem.h +++ b/src/core/mpi/BufferSystem.h @@ -26,7 +26,6 @@ #include "core/DataTypes.h" #include "core/debug/Debug.h" -#include <boost/range/counting_range.hpp> #include <map> #include <set> #include <vector> @@ -209,8 +208,7 @@ public: //* Rank Ranges ************************************************************************************************* /*! \name Rank Ranges */ //@{ - typedef boost::counting_iterator<MPIRank> RankCountIter; - typedef boost::iterator_range< RankCountIter > RankRange; + typedef std::set<MPIRank> RankRange; static RankRange noRanks(); static RankRange allRanks(); static RankRange allRanksButRoot(); diff --git a/src/core/mpi/BufferSystem.impl.h b/src/core/mpi/BufferSystem.impl.h index 852c7a1fa..483013860 100644 --- a/src/core/mpi/BufferSystem.impl.h +++ b/src/core/mpi/BufferSystem.impl.h @@ -525,36 +525,35 @@ void GenericBufferSystem<Rb, Sb>::setCommunicationType( const bool knownSize ) template< typename Rb, typename Sb> typename GenericBufferSystem<Rb, Sb>::RankRange GenericBufferSystem<Rb,Sb>::noRanks() { - return RankRange ( RankCountIter( 0 ), - RankCountIter( 0 ) ); + return RankRange(); } template< typename Rb, typename Sb> typename GenericBufferSystem<Rb, Sb>::RankRange GenericBufferSystem<Rb,Sb>::allRanks() { int numProcesses = MPIManager::instance()->numProcesses(); - return RankRange ( RankCountIter( 0 ), - RankCountIter( numProcesses ) ); + RankRange r; + std::generate_n( std::inserter(r, r.end()), numProcesses, [&]{ return MPIRank(r.size()); } ); + return r; } template< typename Rb, typename Sb> typename GenericBufferSystem<Rb, Sb>::RankRange GenericBufferSystem<Rb,Sb>::allRanksButRoot() { int numProcesses = MPIManager::instance()->numProcesses(); - return RankRange ( RankCountIter( 1 ), - RankCountIter( numProcesses ) ); + RankRange r; + std::generate_n( std::inserter(r, r.end()), numProcesses-1, [&]{ return MPIRank(r.size()+size_t(1)); } ); + return r; } template< typename Rb, typename Sb> typename GenericBufferSystem<Rb, Sb>::RankRange GenericBufferSystem<Rb,Sb>::onlyRank( int includedRank ) { WALBERLA_ASSERT_LESS( includedRank, MPIManager::instance()->numProcesses() ); - return RankRange ( RankCountIter( includedRank ), - RankCountIter( includedRank+1 ) ); + return RankRange { includedRank }; } template< typename Rb, typename Sb> typename GenericBufferSystem<Rb, Sb>::RankRange GenericBufferSystem<Rb,Sb>::onlyRoot() { - return RankRange ( RankCountIter( 0 ), - RankCountIter( 1 ) ); + return RankRange { 0 }; } diff --git a/src/core/mpi/OpenMPBufferSystem.impl.h b/src/core/mpi/OpenMPBufferSystem.impl.h index c79b961ba..dc042e8f4 100644 --- a/src/core/mpi/OpenMPBufferSystem.impl.h +++ b/src/core/mpi/OpenMPBufferSystem.impl.h @@ -19,8 +19,6 @@ // //====================================================================================================================== -#include <boost/range/adaptor/map.hpp> - namespace walberla { namespace mpi { @@ -69,8 +67,10 @@ void GenericOpenMPBufferSystem<Rb, Sb>::setupBufferSystem() if ( ! dirty_ ) return; - using boost::adaptors::map_keys; - bs_.setReceiverInfo( recvFunctions_ | map_keys, sizeChangesEverytime_ ); + std::set<MPIRank> recvRanks; + std::transform( recvFunctions_.begin(), recvFunctions_.end(), std::inserter(recvRanks, recvRanks.end()), + []( typename decltype(recvFunctions_)::value_type r ){ return r.first; }); + bs_.setReceiverInfo( recvRanks, sizeChangesEverytime_ ); for( auto sendRank = sendRanks_.begin(); sendRank != sendRanks_.end(); ++sendRank ) // Do NOT delete this for loop! This loop is needed ... bs_.sendBuffer( *sendRank ); // ... so that the "sendBuffer(rank)" call in startCommunicationOpenMP is thread-safe! diff --git a/src/core/mpi/Reduce.h b/src/core/mpi/Reduce.h index cb4afcfaa..cc1ba91c2 100644 --- a/src/core/mpi/Reduce.h +++ b/src/core/mpi/Reduce.h @@ -30,6 +30,7 @@ #include "core/mpi/MPIWrapper.h" #include <boost/type_traits/is_arithmetic.hpp> +#include <boost/type_traits/is_same.hpp> #include <vector> diff --git a/src/core/uid/UID.h b/src/core/uid/UID.h index 7739f7a39..f90f7f9de 100644 --- a/src/core/uid/UID.h +++ b/src/core/uid/UID.h @@ -27,8 +27,6 @@ #include "core/debug/Debug.h" #include "core/mpi/BufferDataTypeExtensions.h" -#include <boost/lexical_cast.hpp> - #include <iostream> #include <map> #include <sstream> @@ -201,7 +199,7 @@ void UID<T>::init( const std::string& identifier, const bool newUid, const bool uid_ = T::generateUID(); - std::string idString = ( appendUIDtoIdentifier ? ( identifier + " [" + boost::lexical_cast< std::string >( uid_ ) + "]" ) : identifier ); + std::string idString = ( appendUIDtoIdentifier ? ( identifier + " [" + std::to_string( uid_ ) + "]" ) : identifier ); WALBERLA_ASSERT( stringToUid().find( idString ) == stringToUid().end() ); // 'idString' must not exist @@ -250,7 +248,7 @@ UID<T>::UID( const bool createAnonymousUID ) : uid_( 0 ) { uid_ = T::generateUID(); - std::string identifier = std::string("[anonymous #") + boost::lexical_cast< std::string >( T::toIndex( uid_ ) ) + std::string("]"); + std::string identifier = std::string("[anonymous #") + std::to_string( T::toIndex( uid_ ) ) + std::string("]"); WALBERLA_ASSERT( stringToUid().find( identifier ) == stringToUid().end() ); // 'identifier' must not exist diff --git a/src/cuda/AddGPUFieldToStorage.h b/src/cuda/AddGPUFieldToStorage.h index 358a3397c..3803ff8c8 100644 --- a/src/cuda/AddGPUFieldToStorage.h +++ b/src/cuda/AddGPUFieldToStorage.h @@ -25,8 +25,6 @@ #include "domain_decomposition/StructuredBlockStorage.h" -#include <boost/bind.hpp> - namespace walberla { namespace cuda { diff --git a/src/gather/FileGatherScheme.cpp b/src/gather/FileGatherScheme.cpp index 0aa2e40d7..238fe3410 100644 --- a/src/gather/FileGatherScheme.cpp +++ b/src/gather/FileGatherScheme.cpp @@ -28,7 +28,6 @@ #include "core/mpi/SendBuffer.h" #include "core/Filesystem.h" -#include <boost/lexical_cast.hpp> namespace walberla { @@ -57,12 +56,11 @@ FileGatherScheme::~FileGatherScheme() void FileGatherScheme::deleteTemporaryFiles() { using namespace filesystem; - using std::string; for(int rank=0; rank < MPIManager::instance()->numProcesses(); ++rank) { - string fileName = "tmp_collection_" + boost::lexical_cast<string>(myId_) + "_" - + boost::lexical_cast<string>(rank); + std::string fileName = "tmp_collection_" + std::to_string(myId_) + "_" + + std::to_string(rank); if( exists(fileName) ) remove(fileName); @@ -73,8 +71,6 @@ void FileGatherScheme::deleteTemporaryFiles() void FileGatherScheme::writeToFile() { - using std::string; - static mpi::SendBuffer buffer; buffer.clear(); @@ -88,8 +84,8 @@ void FileGatherScheme::writeToFile() // not important if rank() or worldRank() we need only a distinct number // for each process int rank = MPIManager::instance()->worldRank(); - string fileName = "tmp_collection_" + boost::lexical_cast<string>(myId_) + "_" - + boost::lexical_cast<string>(rank); + std::string fileName = "tmp_collection_" + std::to_string(myId_) + "_" + + std::to_string(rank); fileStream_.open( fileName.c_str(), std::ios::binary ); } @@ -126,8 +122,8 @@ void FileGatherScheme::collectFromFiles() //look for files from all processes for(int rank=0; rank < MPIManager::instance()->numProcesses(); ++rank) { - string fileName = "tmp_collection_" + boost::lexical_cast<string>(myId_) + "_" - + boost::lexical_cast<string>(rank); + string fileName = "tmp_collection_" + to_string(myId_) + "_" + + to_string(rank); if(exists(fileName)) { std::ifstream * str = new std::ifstream(fileName.c_str(),ios::in|ios::binary); diff --git a/src/geometry/initializer/ScalarFieldFromBody.impl.h b/src/geometry/initializer/ScalarFieldFromBody.impl.h index 98b6d2a16..0a166fd0e 100644 --- a/src/geometry/initializer/ScalarFieldFromBody.impl.h +++ b/src/geometry/initializer/ScalarFieldFromBody.impl.h @@ -66,11 +66,11 @@ namespace initializer { try { - Value_T value = boost::lexical_cast<Value_T>(expression); + Value_T value = string_to_num<Value_T>(expression); init ( *bodyFromConfig ( subBlock ), value, addOrSet, id ); } - catch(boost::bad_lexical_cast&) + catch(std::invalid_argument&) { math::FunctionParser p; p.parse(expression); diff --git a/src/geometry/initializer/ScalarFieldFromCellInterval.impl.h b/src/geometry/initializer/ScalarFieldFromCellInterval.impl.h index d9b975449..8e65dcfb4 100644 --- a/src/geometry/initializer/ScalarFieldFromCellInterval.impl.h +++ b/src/geometry/initializer/ScalarFieldFromCellInterval.impl.h @@ -62,11 +62,11 @@ void ScalarFieldFromCellInterval<Field_T>::init( const Config::BlockHandle & blo try { - Value_T value = boost::lexical_cast<Value_T>(expression); + Value_T value = string_to_num<Value_T>(expression); init(globalCellInterval, value, id); } - catch(boost::bad_lexical_cast&) + catch(std::invalid_argument&) { math::FunctionParser p; p.parse(expression); diff --git a/src/pde/iterations/VCycles.impl.h b/src/pde/iterations/VCycles.impl.h index f202d89e2..fea9a4031 100644 --- a/src/pde/iterations/VCycles.impl.h +++ b/src/pde/iterations/VCycles.impl.h @@ -91,9 +91,9 @@ VCycles< Stencil_T, OperatorCoarsening_T, Restrict_T, ProlongateAndCorrect_T >:: for ( uint_t lvl = 1; lvl < numLvl; ++lvl ) { auto getSize = std::bind(VCycles<Stencil_T, OperatorCoarsening_T, Restrict_T, ProlongateAndCorrect_T>::getSizeForLevel, lvl, std::placeholders::_1, std::placeholders::_2); - uId_.push_back( field::addToStorage< PdeField_T >( blocks, "u_"+boost::lexical_cast<std::string>(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); - fId_.push_back( field::addToStorage< PdeField_T >( blocks, "f_"+boost::lexical_cast<std::string>(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); - rId_.push_back( field::addToStorage< PdeField_T >( blocks, "r_"+boost::lexical_cast<std::string>(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); + uId_.push_back( field::addToStorage< PdeField_T >( blocks, "u_"+std::to_string(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); + fId_.push_back( field::addToStorage< PdeField_T >( blocks, "f_"+std::to_string(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); + rId_.push_back( field::addToStorage< PdeField_T >( blocks, "r_"+std::to_string(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); for ( auto & w: weights_[lvl] ) { @@ -197,10 +197,10 @@ VCycles< Stencil_T, OperatorCoarsening_T, Restrict_T, ProlongateAndCorrect_T >:: for ( uint_t lvl = 1; lvl < numLvl; ++lvl ) { auto getSize = std::bind(VCycles<Stencil_T, OperatorCoarsening_T, Restrict_T, ProlongateAndCorrect_T>::getSizeForLevel, lvl, std::placeholders::_1, std::placeholders::_2); - uId_.push_back( field::addToStorage< PdeField_T >( blocks, "u_"+boost::lexical_cast<std::string>(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); - fId_.push_back( field::addToStorage< PdeField_T >( blocks, "f_"+boost::lexical_cast<std::string>(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); - rId_.push_back( field::addToStorage< PdeField_T >( blocks, "r_"+boost::lexical_cast<std::string>(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); - stencilId_.push_back( field::addToStorage< StencilField_T >( blocks, "w_"+boost::lexical_cast<std::string>(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); + uId_.push_back( field::addToStorage< PdeField_T >( blocks, "u_"+std::to_string(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); + fId_.push_back( field::addToStorage< PdeField_T >( blocks, "f_"+std::to_string(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); + rId_.push_back( field::addToStorage< PdeField_T >( blocks, "r_"+std::to_string(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); + stencilId_.push_back( field::addToStorage< StencilField_T >( blocks, "w_"+std::to_string(lvl), getSize, real_t(0), field::zyxf, uint_t(1) ) ); } // CoarsenStencilFieldsDCA<Stencil_T>( blocks, stencilId_, numLvl, uint_t(2)) (); // scaling by ( 1/h^2 )^lvl diff --git a/src/pe/cr/HCSITS.impl.h b/src/pe/cr/HCSITS.impl.h index 314b3d1c1..a03c3107f 100644 --- a/src/pe/cr/HCSITS.impl.h +++ b/src/pe/cr/HCSITS.impl.h @@ -1807,7 +1807,7 @@ inline void HardContactSemiImplicitTimesteppingSolvers::integratePositions( Body v = v * (edge * getSpeedLimitFactor() / dt / speed ); } - const real_t maxPhi = real_t(2) * math::PI * getSpeedLimitFactor(); + const real_t maxPhi = real_t(2) * math::M_PI * getSpeedLimitFactor(); const real_t phi = w.length() * dt; if (phi > maxPhi) { diff --git a/src/pe_coupling/discrete_particle_methods/correlations/DragForceCorrelations.h b/src/pe_coupling/discrete_particle_methods/correlations/DragForceCorrelations.h index 91ae0da40..8d7fc55c0 100644 --- a/src/pe_coupling/discrete_particle_methods/correlations/DragForceCorrelations.h +++ b/src/pe_coupling/discrete_particle_methods/correlations/DragForceCorrelations.h @@ -54,7 +54,7 @@ real_t dragCoeffSchillerNaumann( real_t reynoldsNumber ) } // Coefficient from Stokes' law for drag, only valid for Stokes regime (low Reynolds numbers) -// = 3 * PI * mu * D * fluidVolumeFraction +// = 3 * M_PI * mu * D * fluidVolumeFraction real_t dragCoeffStokes ( real_t fluidVolumeFraction, real_t diameter, real_t fluidDynamicViscosity ) { return real_t(3) * math::M_PI * diameter * fluidDynamicViscosity * fluidVolumeFraction; diff --git a/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h b/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h index b9bf10293..cd036bfc0 100644 --- a/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h +++ b/src/pe_coupling/discrete_particle_methods/evaluators/LubricationForceEvaluator.h @@ -225,9 +225,9 @@ pe::Vec3 LubricationForceEvaluator::compLubricationSphrSphr( real_t gap, const p real_t d = real_t(2) * diameterSphereI * diameterSphereJ / ( diameterSphereI + diameterSphereJ ); real_t h = gap; real_t r = d + h; - real_t a_sq = ( real_t(3) * dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + + real_t a_sq = ( real_t(3) * dynamicViscosity_ * walberla::math::M_PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + ( real_t(9)/real_t(84) ) * ( h / d ) * std::log( d/( real_t(2)*h ) ) ); - real_t a_sh = ( dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); + real_t a_sh = ( dynamicViscosity_ * walberla::math::M_PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); pe::Vec3 fLub( - a_sq * length * rIJ - a_sh * ( real_t(2) / r ) * ( real_t(2) / r ) * ( velDiff - length * rIJ ) ); WALBERLA_LOG_DETAIL_SECTION() @@ -274,9 +274,9 @@ pe::Vec3 LubricationForceEvaluator::compLubricationSphrPlane( real_t gap, const real_t d = real_t(4) * radiusSphereI; real_t h = gap; real_t r = d + h; - real_t a_sq = ( real_t(3) * dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + + real_t a_sq = ( real_t(3) * dynamicViscosity_ * walberla::math::M_PI * d / real_t(2) ) * ( d / ( real_t(4) * h ) + ( real_t(18) / real_t(40) ) * std::log( d / ( real_t(2) * h ) ) + ( real_t(9)/real_t(84) ) * ( h / d ) * std::log( d/( real_t(2)*h ) ) ); - real_t a_sh = ( dynamicViscosity_ * walberla::math::PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); + real_t a_sh = ( dynamicViscosity_ * walberla::math::M_PI * d / real_t(2) ) * std::log( d / ( real_t(2) * h ) ) * ( d + h ) * ( d + h ) / real_t(4); pe::Vec3 fLub( - a_sq * length * rIJ - a_sh * ( real_t(2) / r ) * ( real_t(2) / r ) * ( v1 - length * rIJ ) ); WALBERLA_LOG_DETAIL_SECTION() { diff --git a/src/pe_coupling/utility/LubricationCorrection.cpp b/src/pe_coupling/utility/LubricationCorrection.cpp index eaf195214..6cee7eb43 100644 --- a/src/pe_coupling/utility/LubricationCorrection.cpp +++ b/src/pe_coupling/utility/LubricationCorrection.cpp @@ -189,7 +189,7 @@ pe::Vec3 LubricationCorrection::compLubricationSphrSphr( real_t gap, const pe::S real_t radiiSQR = ( radiusSphereI * radiusSphereJ ) * ( radiusSphereI * radiusSphereJ ); real_t radiiSumSQR = ( radiusSphereI + radiusSphereJ ) * ( radiusSphereI + radiusSphereJ ); - pe::Vec3 fLub = ( -real_t(6) * dynamicViscosity_ * walberla::math::PI * radiiSQR / radiiSumSQR * ( real_t(1) / gap - real_t(1) / cutOffDistance_) * length * rIJ); + pe::Vec3 fLub = ( -real_t(6) * dynamicViscosity_ * walberla::math::M_PI * radiiSQR / radiiSumSQR * ( real_t(1) / gap - real_t(1) / cutOffDistance_) * length * rIJ); WALBERLA_LOG_DETAIL_SECTION() { @@ -247,7 +247,7 @@ pe::Vec3 LubricationCorrection::compLubricationSphrPlane( real_t gap, const pe:: real_t radiiSQR = radiusSphereI * radiusSphereI; - pe::Vec3 fLub( -real_t(6) * dynamicViscosity_ * walberla::math::PI * radiiSQR * (real_t(1) / gap - real_t(1) / cutOffDistance_) * length * rIJ); + pe::Vec3 fLub( -real_t(6) * dynamicViscosity_ * walberla::math::M_PI * radiiSQR * (real_t(1) / gap - real_t(1) / cutOffDistance_) * length * rIJ); WALBERLA_LOG_DETAIL_SECTION() { std::stringstream ss; diff --git a/src/vtk/Initialization.cpp b/src/vtk/Initialization.cpp index d6df0a4fb..7109d9e29 100644 --- a/src/vtk/Initialization.cpp +++ b/src/vtk/Initialization.cpp @@ -49,9 +49,9 @@ static void splitVector( T& x, T& y, T& z, const Config::BlockHandle& bb, const if( coordinates.size() != 3 ) WALBERLA_ABORT( errorMsg ); - x = boost::lexical_cast< T >( coordinates[0] ); - y = boost::lexical_cast< T >( coordinates[1] ); - z = boost::lexical_cast< T >( coordinates[2] ); + x = string_to_num< T >( coordinates[0] ); + y = string_to_num< T >( coordinates[1] ); + z = string_to_num< T >( coordinates[2] ); } diff --git a/tests/core/debug/CheckMacroTest.cpp b/tests/core/debug/CheckMacroTest.cpp index d2e4cf7a8..2b11a23c0 100644 --- a/tests/core/debug/CheckMacroTest.cpp +++ b/tests/core/debug/CheckMacroTest.cpp @@ -27,6 +27,7 @@ #include <iostream> #include <vector> #include <map> +#include <algorithm> // Own data structure with comparison operators but without operator<< diff --git a/tests/core/load_balancing/MetisTest.cpp b/tests/core/load_balancing/MetisTest.cpp index 22038220a..5db60e5ae 100644 --- a/tests/core/load_balancing/MetisTest.cpp +++ b/tests/core/load_balancing/MetisTest.cpp @@ -39,8 +39,6 @@ #include "vtk/VTKOutput.h" #include "vtk/BlockCellDataWriter.h" -#include <boost/lexical_cast.hpp> - int main( int argc, char * argv[] ) { using namespace walberla; @@ -62,8 +60,8 @@ int main( int argc, char * argv[] ) } try { - fieldSize.set( boost::lexical_cast< uint_t >( args.at(1) ), boost::lexical_cast< uint_t >( args.at(2) ) ); - partitions = boost::lexical_cast< uint_t >( args.at(3) ); + fieldSize.set( string_to_num< uint_t >( args.at(1) ), string_to_num< uint_t >( args.at(2) ) ); + partitions = string_to_num< uint_t >( args.at(3) ); } catch( std::exception & e ) { diff --git a/tests/core/load_balancing/ParMetisTest.cpp b/tests/core/load_balancing/ParMetisTest.cpp index fd7206100..a9e79d384 100644 --- a/tests/core/load_balancing/ParMetisTest.cpp +++ b/tests/core/load_balancing/ParMetisTest.cpp @@ -41,8 +41,6 @@ #include "vtk/VTKOutput.h" #include "vtk/BlockCellDataWriter.h" -#include <boost/lexical_cast.hpp> - int main( int argc, char * argv[] ) { using namespace walberla; @@ -57,8 +55,8 @@ int main( int argc, char * argv[] ) bool vtk = true; try { - fieldSize.set( boost::lexical_cast< uint_t >( args.at(1) ), boost::lexical_cast< uint_t >( args.at(2) ) ); - partitions = boost::lexical_cast< uint_t >( args.at(3) ); + fieldSize.set( string_to_num< uint_t >( args.at(1) ), string_to_num< uint_t >( args.at(2) ) ); + partitions = string_to_num< uint_t >( args.at(3) ); auto it = std::find( args.begin(), args.end(), "--no-vtk" ); if(it != args.end()) diff --git a/tests/core/math/GenericAABBTest.cpp b/tests/core/math/GenericAABBTest.cpp index d574ba153..ee6db5576 100644 --- a/tests/core/math/GenericAABBTest.cpp +++ b/tests/core/math/GenericAABBTest.cpp @@ -28,6 +28,7 @@ #include "stencil/D3CornerStencil.h" #include <random> +#include <array> using namespace walberla; diff --git a/tests/core/math/PhysicalCheckTest.cpp b/tests/core/math/PhysicalCheckTest.cpp index 2ad726467..abb019c4a 100644 --- a/tests/core/math/PhysicalCheckTest.cpp +++ b/tests/core/math/PhysicalCheckTest.cpp @@ -26,7 +26,6 @@ #include "core/logging/Logging.h" #include "core/math/PhysicalCheck.h" -#include <boost/lexical_cast.hpp> #include <iostream> #include <map> #include <string> diff --git a/tests/core/math/PlaneTest.cpp b/tests/core/math/PlaneTest.cpp index 98cfdb45e..2f8951191 100644 --- a/tests/core/math/PlaneTest.cpp +++ b/tests/core/math/PlaneTest.cpp @@ -21,6 +21,7 @@ #include "core/debug/TestSubsystem.h" #include "core/logging/Logging.h" +#include "core/math/Constants.h" #include "core/math/Plane.h" #include "core/math/Vector3.h" #include "core/mpi/Environment.h" @@ -137,7 +138,7 @@ int main(int argc, char * argv[]) real_t angle = std::acos( (p1-p0) * (p2-p0) / std::sqrt( (p1-p0).sqrLength() * (p2-p0).sqrLength() ) ); - if( (p0 - p1).sqrLength() < 1e-6 || (p0 - p2).sqrLength() < 1e-6 || (p2 - p1).sqrLength() < 1e-6 || angle < math::PI / real_t(180) ) + if( (p0 - p1).sqrLength() < 1e-6 || (p0 - p2).sqrLength() < 1e-6 || (p2 - p1).sqrLength() < 1e-6 || angle < math::M_PI / real_t(180) ) { --i; continue; diff --git a/tests/core/math/equation_system/EquationSolverTest.cpp b/tests/core/math/equation_system/EquationSolverTest.cpp index 4319769cf..e711d04f8 100644 --- a/tests/core/math/equation_system/EquationSolverTest.cpp +++ b/tests/core/math/equation_system/EquationSolverTest.cpp @@ -26,7 +26,6 @@ #include "core/math/equation_system/EquationParser.h" #include "core/math/equation_system/EquationSystem.h" -#include <boost/lexical_cast.hpp> #include <iostream> #include <string> #include <vector> @@ -128,7 +127,7 @@ int equationInput(){ for (size_t i=0; i<eqStringList.size(); ++i){ index = 0; - es.add( boost::lexical_cast<std::string>(++number), ep.parseEquation( eqStringList[i], index ) ); + es.add( std::to_string(++number), ep.parseEquation( eqStringList[i], index ) ); } WALBERLA_CHECK( es.solve() ); @@ -139,7 +138,7 @@ int equationInput(){ int unitTest(double v) { - std::string s = boost::lexical_cast<std::string>( v ); + std::string s = std::to_string( v ); std::vector<std::string> eqStringList; eqStringList.push_back( "a = " + s ); diff --git a/tests/core/mpi/MPITextFileTest.cpp b/tests/core/mpi/MPITextFileTest.cpp index 1500d730f..a0ed6e61c 100644 --- a/tests/core/mpi/MPITextFileTest.cpp +++ b/tests/core/mpi/MPITextFileTest.cpp @@ -120,7 +120,7 @@ int main( int argc, char * argv[] ) std::string filename; try { - chunkSize = boost::lexical_cast<size_t>( args.at(2) ); + chunkSize = walberla::string_to_num<size_t>( args.at(2) ); filename = args.at( 1 ); } catch( ... ) diff --git a/tests/core/timing/TimerTest.cpp b/tests/core/timing/TimerTest.cpp index 4df41d6a1..a6ef83f9e 100644 --- a/tests/core/timing/TimerTest.cpp +++ b/tests/core/timing/TimerTest.cpp @@ -21,6 +21,7 @@ #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/timing/Timer.h" #include <cmath> @@ -30,7 +31,7 @@ namespace walberla { static double burnTime() { double sum = 0.0; - for( double d = 0.0; d < math::PI; d += 0.000001 ) + for( double d = 0.0; d < math::M_PI; d += 0.000001 ) { sum += std::atan( std::tan( d ) ); sum += std::asin( std::sin( d ) ); @@ -80,4 +81,4 @@ int main() { walberla::debug::enterTestMode(); walberla::mergeTest(); -} \ No newline at end of file +} diff --git a/tests/core/timing/TimingPoolTest.cpp b/tests/core/timing/TimingPoolTest.cpp index 11f5f5b88..65bc2ca5a 100644 --- a/tests/core/timing/TimingPoolTest.cpp +++ b/tests/core/timing/TimingPoolTest.cpp @@ -21,6 +21,7 @@ #include "core/debug/TestSubsystem.h" #include "core/logging/Logging.h" +#include "core/math/Constants.h" #include "core/mpi/MPIManager.h" #include "core/timing/Timer.h" #include "core/timing/TimingPool.h" @@ -61,7 +62,7 @@ void scopedTimer() auto scopedTimer = pool.getScopeTimer( "scope timer" ); double sum = 0.0; - for( double d = 0.0; d < math::PI; d += 0.00001 ) + for( double d = 0.0; d < math::M_PI; d += 0.00001 ) { sum += std::atan( std::tan( d ) ); sum += std::asin( std::sin( d ) ); diff --git a/tests/fft/GreensTest.cpp b/tests/fft/GreensTest.cpp index 720640d7c..aaa669c2a 100644 --- a/tests/fft/GreensTest.cpp +++ b/tests/fft/GreensTest.cpp @@ -3,6 +3,7 @@ #include "core/Environment.h" #include "core/debug/TestSubsystem.h" #include "core/logging/Logging.h" +#include "core/math/Constants.h" #include "field/AddToStorage.h" #include "blockforest/communication/UniformBufferedScheme.h" #include "stencil/D3Q7.h" @@ -55,9 +56,9 @@ int main (int argc, char** argv) auto greens = [&dim] (uint_t x, uint_t y, uint_t z) -> real_t { if (x == 0 && y == 0 && z == 0) return 0; - return real_c(0.5) / ( std::cos( real_c(2) * real_c(M_PI) * real_c(x) / real_c(dim[0])) + - std::cos( real_c(2) * real_c(M_PI) * real_c(y) / real_c(dim[1])) + - std::cos( real_c(2) * real_c(M_PI) * real_c(z) / real_c(dim[2])) - + return real_c(0.5) / ( std::cos( real_c(2) * real_c(math::M_PI) * real_c(x) / real_c(dim[0])) + + std::cos( real_c(2) * real_c(math::M_PI) * real_c(y) / real_c(dim[1])) + + std::cos( real_c(2) * real_c(math::M_PI) * real_c(z) / real_c(dim[2])) - real_c(3) ) / real_c(dim[0]*dim[1]*dim[2]); }; diff --git a/tests/field/FieldFileIOTest.cpp b/tests/field/FieldFileIOTest.cpp index 6e7a95a2d..1214f0199 100644 --- a/tests/field/FieldFileIOTest.cpp +++ b/tests/field/FieldFileIOTest.cpp @@ -33,8 +33,6 @@ #include "field/Field.h" #include "field/FileIO.h" -#include <boost/lexical_cast.hpp> - namespace mpi_file_io_test { @@ -86,10 +84,10 @@ int main( int argc, char* argv[] ) if( args.size() == 5 ) { - numBlocks = boost::lexical_cast<uint_t>( args[1] ); - xBlockSize = boost::lexical_cast<uint_t>( args[2] ); - yBlockSize = boost::lexical_cast<uint_t>( args[3] ); - zBlockSize = boost::lexical_cast<uint_t>( args[4] ); + numBlocks = string_to_num<uint_t>( args[1] ); + xBlockSize = string_to_num<uint_t>( args[2] ); + yBlockSize = string_to_num<uint_t>( args[3] ); + zBlockSize = string_to_num<uint_t>( args[4] ); } else if( args.size() > 5 ) { diff --git a/tests/geometry/ScalarFieldFromBodyTest.cpp b/tests/geometry/ScalarFieldFromBodyTest.cpp index d6c29f3d1..0aa382715 100644 --- a/tests/geometry/ScalarFieldFromBodyTest.cpp +++ b/tests/geometry/ScalarFieldFromBodyTest.cpp @@ -29,6 +29,7 @@ #include "core/debug/TestSubsystem.h" #include "core/logging/Logging.h" +#include "core/math/Constants.h" #include "core/math/Vector3.h" #include "field/AddToStorage.h" @@ -47,7 +48,6 @@ using namespace geometry; const uint_t confBlockCount [] = { 1, 1, 1 }; const uint_t confCells [] = { 30, 30, 30 }; -const real_t PI = real_t(3.1415927); const bool useGui = false; @@ -156,7 +156,7 @@ void ellipsoidTest( StructuredBlockStorage & storage, const Vector3<real_t> axis1 ( real_t(1), real_t(1), real_t(0) ); const Vector3<real_t> axis2 ( -real_t(1), real_t(1), real_t(0) ); - const real_t expectedVolume = real_t(4) / real_t(3) * radii[0] * radii[1] * radii[2] * PI; + const real_t expectedVolume = real_t(4) / real_t(3) * radii[0] * radii[1] * radii[2] * math::M_PI; resetField( storage, fieldID ); @@ -209,7 +209,7 @@ void sphereTest( StructuredBlockStorage & storage, { const Vector3<real_t> midpoint ( real_t(15), real_t(15), real_t(15) ); const real_t radius = real_t(5); - const real_t expectedVolume = real_t(4) / real_t(3) * radius * radius * radius * PI; + const real_t expectedVolume = real_t(4) / real_t(3) * radius * radius * radius * math::M_PI; resetField( storage, fieldID ); @@ -294,4 +294,4 @@ int main( int argc, char ** argv ) int main( int argc, char* argv[] ) { return walberla::main( argc, argv ); -} \ No newline at end of file +} diff --git a/tests/geometry/VoxelFileTest.cpp b/tests/geometry/VoxelFileTest.cpp index 726616dc1..d8ab6ddb6 100644 --- a/tests/geometry/VoxelFileTest.cpp +++ b/tests/geometry/VoxelFileTest.cpp @@ -21,18 +21,6 @@ -#ifdef _MSC_VER -# pragma warning(push) -// disable warning boost/concept/detail/msvc.hpp(22): warning C4100: 'x' : unreferenced formal parameter -# pragma warning( disable : 4100 ) -// disable warning bboost/concept/detail/msvc.hpp(76): warning C4067 : unexpected tokens following preprocessor directive - expected a newline -# pragma warning( disable : 4067 ) - -#include <boost/concept/detail/msvc.hpp> - -# pragma warning(pop) -#endif //_MSC_VER - #ifdef _MSC_VER # pragma warning(push) // disable warning boost/multi_array/base.hpp(475): warning C4189: 'bound_adjustment' : local variable is initialized but not referenced diff --git a/tests/lbm/DiffusionTest.cpp b/tests/lbm/DiffusionTest.cpp index c1aa84508..bdcb97ff6 100644 --- a/tests/lbm/DiffusionTest.cpp +++ b/tests/lbm/DiffusionTest.cpp @@ -59,6 +59,7 @@ #include "core/cell/CellVector.h" #include "core/config/Config.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/math/IntegerFactorization.h" #include "core/mpi/Environment.h" @@ -77,8 +78,6 @@ #include "vtk/VTKOutput.h" -#include <boost/lexical_cast.hpp> - #include <functional> @@ -198,14 +197,14 @@ int run( int argc, char **argv ) if( argc > 1 ) { std::vector<std::string> args( argv, argv + argc ); for( uint_t i = 1; i < uint_c(argc); ++i ) { - if( boost::equals(argv[i], "-d" ) ) d = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-dim" ) ) dim = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-dx" ) ) dx = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-dt" ) ) dt = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-dv" ) ) dv = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-v" ) ) u_in = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-t" ) ) time = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-err" ) ) err = boost::lexical_cast<real_t>( args[++i] ); + if( boost::equals(argv[i], "-d" ) ) d = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-dim" ) ) dim = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-dx" ) ) dx = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-dt" ) ) dt = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-dv" ) ) dv = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-v" ) ) u_in = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-t" ) ) time = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-err" ) ) err = string_to_num<real_t>( args[++i] ); else if( boost::equals(argv[i], "--gui" ) ) useGui = true; else if( boost::equals(argv[i], "--quiet" ) ) quiet = true; else if( boost::equals(argv[i], "--vtk" ) ) useVTK = true; @@ -236,8 +235,8 @@ int run( int argc, char **argv ) if(!quiet) WALBERLA_LOG_RESULT( " -> u = " << u ); if(!quiet) WALBERLA_LOG_RESULT( " -> tau = " << tau ); - const real_t tperiod = real_t(2) * math::PI / real_c( timesteps ); - const real_t cperiod = real_t(2) * math::PI / real_c( cells[dim] ); + const real_t tperiod = real_t(2) * math::M_PI / real_c( timesteps ); + const real_t cperiod = real_t(2) * math::M_PI / real_c( cells[dim] ); // --- create blockstorage --- // auto blockStorage = blockforest::createUniformBlockGrid( @@ -347,7 +346,7 @@ int main(int argc, char **argv) bool corr = true; for( int i=0; i<argc; ++i ){ if( boost::equals(argv[i], "-c" ) ){ - corr = boost::lexical_cast<bool>( argv[++i] ); + corr = std::atoi( argv[++i] ) != 0; break; } } diff --git a/tests/lbm/boundary/BoundaryForce.cpp b/tests/lbm/boundary/BoundaryForce.cpp index 08b41401c..c36db2ec1 100644 --- a/tests/lbm/boundary/BoundaryForce.cpp +++ b/tests/lbm/boundary/BoundaryForce.cpp @@ -25,6 +25,7 @@ #include "boundary/BoundaryHandling.h" +#include "core/math/Constants.h" #include "core/mpi/Environment.h" #include "core/mpi/MPIManager.h" #include "core/mpi/Reduce.h" @@ -167,7 +168,7 @@ int main( int argc, char ** argv ) uint_t timeSteps = uint_c(200); if( argc > 1 ) - timeSteps = boost::lexical_cast<uint_t>( argv[1] ); + timeSteps = uint_c(std::stoul( argv[1] )); SweepTimeloop timeloop( blocks->getBlockStorage(), timeSteps ); blockforest::communication::UniformBufferedScheme< CommunicationStencil_T > communication( blocks ); @@ -211,7 +212,7 @@ int main( int argc, char ** argv ) mpi::allReduceInplace( force[2], mpi::SUM ); real_t visc = lbm::collision_model::viscosityFromOmega( omega ); - Vector3<real_t> stokes = 6 * math::PI * visc * R * velocity; + Vector3<real_t> stokes = 6 * math::M_PI * visc * R * velocity; WALBERLA_LOG_RESULT_ON_ROOT("Expected force: " << stokes); WALBERLA_LOG_RESULT_ON_ROOT("Actual force: " << force); diff --git a/tests/lbm/boundary/BoundaryForceCouette.cpp b/tests/lbm/boundary/BoundaryForceCouette.cpp index 1acf8f8c7..974015b9d 100644 --- a/tests/lbm/boundary/BoundaryForceCouette.cpp +++ b/tests/lbm/boundary/BoundaryForceCouette.cpp @@ -162,7 +162,7 @@ int main( int argc, char ** argv ) uint_t timeSteps = uint_c(2000); if( argc > 1 ) - timeSteps = boost::lexical_cast<uint_t>( argv[1] ); + timeSteps = uint_c(std::stoul( argv[1] )); SweepTimeloop timeloop( blocks->getBlockStorage(), timeSteps ); blockforest::communication::UniformBufferedScheme< CommunicationStencil_T > communication( blocks ); diff --git a/tests/lbm/boundary/DiffusionDirichlet.cpp b/tests/lbm/boundary/DiffusionDirichlet.cpp index 79cee7c42..966176523 100644 --- a/tests/lbm/boundary/DiffusionDirichlet.cpp +++ b/tests/lbm/boundary/DiffusionDirichlet.cpp @@ -56,6 +56,7 @@ #include "core/cell/CellVector.h" #include "core/config/Config.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/math/IntegerFactorization.h" #include "core/mpi/Environment.h" @@ -79,8 +80,6 @@ #include "vtk/VTKOutput.h" -#include <boost/lexical_cast.hpp> - namespace walberla { @@ -107,7 +106,7 @@ public: using cplx_t = std::complex<real_t>; PlugFlow( real_t L, real_t H, real_t u, real_t k ) : - period_( real_t(2)*math::PI/L ), + period_( real_t(2)*math::M_PI/L ), lambda_( period_*sqrt( cplx_t(real_t(1), u/k/period_) ) ), emH_ ( real_t(1) - exp(-lambda_*H) ), epH_ ( real_t(1) - exp(+lambda_*H) ), @@ -220,12 +219,12 @@ int main( int argc, char **argv ) if( argc > 1 ) { std::vector<std::string> args( argv, argv + argc ); for( uint_t i = 1; i < uint_c(argc); ++i ) { - if( boost::equals(argv[i], "-o" ) ) omega = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-l" ) ) length = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-w" ) ) width = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-v" ) ) velx = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-t" ) ) time = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-e" ) ) error = boost::lexical_cast<real_t>( args[++i] ); + if( boost::equals(argv[i], "-o" ) ) omega = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-l" ) ) length = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-w" ) ) width = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-v" ) ) velx = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-t" ) ) time = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-e" ) ) error = string_to_num<real_t>( args[++i] ); else if( boost::equals(argv[i], "--gui" ) ) useGui = true; else if( boost::equals(argv[i], "--vtk" ) ) useVTK = true; else if( argv[i][0] != '-' ){ @@ -252,7 +251,7 @@ int main( int argc, char **argv ) BlockDataID boundaryHandling = MyBoundaryHandling::addDefaultDiffusionBoundaryHandlingToStorage( blockStorage, "BoundaryHandling", flagFieldID, getFluidFlag(), srcFieldID ); - auto cbc = make_shared<CosBoundaryConfiguration>( real_t(2)*math::PI/real_c(length) ); + auto cbc = make_shared<CosBoundaryConfiguration>( real_t(2)*math::M_PI/real_c(length) ); geometry::initializer::BoundaryFromDomainBorder<MyBoundaryHandling::BoundaryHandling_T> bfdb( *blockStorage, boundaryHandling ); bfdb.init( MyBoundaryHandling::getDiffusionDirichletBoundaryUID(), stencil::N, cbc, -1, 1 ); bfdb.init( MyBoundaryHandling::getDiffusionDirichletBoundaryUID(), stencil::S, cbc, -1, 1 ); diff --git a/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp b/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp index 30c95b82a..bb86d552a 100644 --- a/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp +++ b/tests/lbm/boundary/SimpleDiffusionDirichlet.cpp @@ -47,6 +47,7 @@ #include "core/cell/CellVector.h" #include "core/config/Config.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/math/IntegerFactorization.h" #include "core/math/Limits.h" #include "core/mpi/Environment.h" @@ -72,8 +73,6 @@ #include "timeloop/SweepTimeloop.h" -#include <boost/lexical_cast.hpp> - #include <stdexcept> #include <array> #include <functional> @@ -237,8 +236,8 @@ public: delta_( maxValue - minValue), length_(real_c(length)), lengthInv_(real_t(1)/real_c(length)), - pi_(math::PI), - piInv_(real_t(1)/math::PI), + pi_(math::M_PI), + piInv_(real_t(1)/math::M_PI), valid_(uint_c(std::ceil(omega*omega*omega*real_t(10)))), time_( time ), expArray(), @@ -430,13 +429,13 @@ int main( int argc, char **argv ) if( argc > 1 ) { std::vector<std::string> args( argv, argv + argc ); for( uint_t i = 1; i < uint_c(argc); ++i ) { - if( boost::equals(argv[i], "-l" ) ) length = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-w" ) ) width = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-t" ) ) time = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-d" ) ) dv = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-o" ) ) omega = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-c" ) ) closed = boost::lexical_cast< bool >( args[++i] ); - else if( boost::equals(argv[i], "-r" ) ) levels += boost::lexical_cast<uint_t>( args[++i] ); + if( boost::equals(argv[i], "-l" ) ) length = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-w" ) ) width = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-t" ) ) time = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-d" ) ) dv = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-o" ) ) omega = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-c" ) ) closed = string_to_num<int>( args[++i] ) != 0; + else if( boost::equals(argv[i], "-r" ) ) levels += string_to_num<uint_t>( args[++i] ); else if( boost::equals(argv[i], "--vtk" ) ) useVTK = true; else if( argv[i][0] != '-' ){ std::cerr << "Usage: -option value" << std::endl; return EXIT_FAILURE; diff --git a/tests/lbm/boundary/SimplePABTest.cpp b/tests/lbm/boundary/SimplePABTest.cpp index 31bc21a74..6d5b8c478 100644 --- a/tests/lbm/boundary/SimplePABTest.cpp +++ b/tests/lbm/boundary/SimplePABTest.cpp @@ -56,7 +56,6 @@ #include "vtk/VTKOutput.h" -#include <boost/lexical_cast.hpp> #include <stdexcept> @@ -218,11 +217,11 @@ int main( int argc, char **argv ) if( args.size() != 6 ) throw std::invalid_argument( "Wrong number of command line arguments!" ); - channelLength = boost::lexical_cast<uint_t>( args[1] ); - channelWidth = boost::lexical_cast<uint_t>( args[2] ); - omega = boost::lexical_cast<real_t>( args[3] ); - deltaDensity = boost::lexical_cast<real_t>( args[4] ); - numTimesteps = boost::lexical_cast<uint_t>( args[5] ); + channelLength = string_to_num<uint_t>( args[1] ); + channelWidth = string_to_num<uint_t>( args[2] ); + omega = string_to_num<real_t>( args[3] ); + deltaDensity = string_to_num<real_t>( args[4] ); + numTimesteps = string_to_num<uint_t>( args[5] ); } catch( std::exception & ) { diff --git a/tests/lbm/evaluations/PermeabilityTest.cpp b/tests/lbm/evaluations/PermeabilityTest.cpp index 022ad2788..782653935 100644 --- a/tests/lbm/evaluations/PermeabilityTest.cpp +++ b/tests/lbm/evaluations/PermeabilityTest.cpp @@ -107,7 +107,7 @@ real_t permeability( Setup setup ) for( uint_t i = 0; i < 31; i++ ) drag += real_c(qs[i]) * real_c(std::pow( setup.kappa, real_c(i) )); - return ( L * L * L ) / ( real_t(6) * math::PI * r * real_t(2) * drag ); + return ( L * L * L ) / ( real_t(6) * math::M_PI * r * real_t(2) * drag ); } diff --git a/tests/lbm/refinement/NonConstantDiffusion.cpp b/tests/lbm/refinement/NonConstantDiffusion.cpp index 83ac2f989..592d23ce7 100644 --- a/tests/lbm/refinement/NonConstantDiffusion.cpp +++ b/tests/lbm/refinement/NonConstantDiffusion.cpp @@ -72,8 +72,6 @@ #include "timeloop/SweepTimeloop.h" -#include <boost/lexical_cast.hpp> - #include <stdexcept> #include <functional> @@ -275,15 +273,15 @@ int main( int argc, char **argv ) if( argc > 1 ) { std::vector<std::string> args( argv, argv + argc ); for( uint_t i = 1; i < uint_c(argc); ++i ) { - if( boost::equals(argv[i], "-l" ) ) length = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-w" ) ) width = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-t" ) ) time = boost::lexical_cast<uint_t>( args[++i] ); - else if( boost::equals(argv[i], "-dv" ) ) dv = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-v" ) ) v = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-do" ) ) domega = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-o" ) ) omega = boost::lexical_cast<real_t>( args[++i] ); - else if( boost::equals(argv[i], "-c" ) ) closed = boost::lexical_cast< bool >( args[++i] ); - else if( boost::equals(argv[i], "-r" ) ) levels += boost::lexical_cast<uint_t>( args[++i] ); + if( boost::equals(argv[i], "-l" ) ) length = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-w" ) ) width = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-t" ) ) time = string_to_num<uint_t>( args[++i] ); + else if( boost::equals(argv[i], "-dv" ) ) dv = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-v" ) ) v = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-do" ) ) domega = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-o" ) ) omega = string_to_num<real_t>( args[++i] ); + else if( boost::equals(argv[i], "-c" ) ) closed = string_to_num<int>( args[++i] ) != 0; + else if( boost::equals(argv[i], "-r" ) ) levels += string_to_num<uint_t>( args[++i] ); else if( boost::equals(argv[i], "--vtk" ) ) useVTK = true; else if( argv[i][0] != '-' ){ std::cerr << "Usage: -option value" << std::endl; return EXIT_FAILURE; diff --git a/tests/mesh/MeshAABBIntersectionTest.cpp b/tests/mesh/MeshAABBIntersectionTest.cpp index fc4711134..a516342de 100644 --- a/tests/mesh/MeshAABBIntersectionTest.cpp +++ b/tests/mesh/MeshAABBIntersectionTest.cpp @@ -30,7 +30,6 @@ #include "mesh/TriangleMeshes.h" #include <random> -#include <boost/lexical_cast.hpp> #include <vector> #include <string> @@ -88,7 +87,7 @@ int main( int argc, char * argv[] ) if( args.size() != 2 ) WALBERLA_ABORT_NO_DEBUG_INFO( "USAGE: " << args[0] << " NUM_AABBS" ); - const uint_t numAABBs = boost::lexical_cast< uint_t >( args[1] ); + const uint_t numAABBs = string_to_num< uint_t >( args[1] ); runTests< mesh::TriangleMesh >( numAABBs ); runTests< mesh::FloatTriangleMesh >( numAABBs ); diff --git a/tests/mesh/MeshAABBSelectionTest.cpp b/tests/mesh/MeshAABBSelectionTest.cpp index 37d421bfe..df5b67b53 100644 --- a/tests/mesh/MeshAABBSelectionTest.cpp +++ b/tests/mesh/MeshAABBSelectionTest.cpp @@ -32,7 +32,6 @@ #include "mesh/MeshOperations.h" #include <random> -#include <boost/lexical_cast.hpp> #include <algorithm> #include <vector> @@ -52,8 +51,8 @@ int main( int argc, char * argv[] ) WALBERLA_ABORT_NO_DEBUG_INFO( "USAGE: " << args[0] << " MESH_FILE NUM_BOXES NUM_POINTS_TESTED_PER_BOX" ); const std::string & meshFile = args[1]; - const uint_t numBoxes = boost::lexical_cast<uint_t>( args[2] ); - const uint_t numPointsTestedPerBox = boost::lexical_cast<uint_t>( args[3] ); + const uint_t numBoxes = string_to_num<uint_t>( args[2] ); + const uint_t numPointsTestedPerBox = string_to_num<uint_t>( args[3] ); auto mesh = make_shared<TriangleMesh>(); mesh::readAndBroadcast( meshFile, *mesh ); diff --git a/tests/mesh/MeshBlockExclusionTest.cpp b/tests/mesh/MeshBlockExclusionTest.cpp index 7685ac644..996fdb877 100644 --- a/tests/mesh/MeshBlockExclusionTest.cpp +++ b/tests/mesh/MeshBlockExclusionTest.cpp @@ -39,8 +39,6 @@ #include "mesh/distance_octree/DistanceOctree.h" -#include <boost/lexical_cast.hpp> - #include <vector> #include <string> @@ -150,7 +148,7 @@ int main( int argc, char * argv[] ) WALBERLA_ABORT_NO_DEBUG_INFO( "USAGE: " << args[0] << " MESH_FILE NUM_BLOCKS" ); const std::string & meshFile = args[1]; - const uint_t numTotalBlocks = boost::lexical_cast< uint_t >( args[2] ); + const uint_t numTotalBlocks = string_to_num< uint_t >( args[2] ); run< mesh::TriangleMesh >( meshFile, numTotalBlocks ); run< mesh::FloatTriangleMesh >( meshFile, numTotalBlocks ); diff --git a/tests/mesh/MeshDistancePlausibilityTest.cpp b/tests/mesh/MeshDistancePlausibilityTest.cpp index 5ca33efc1..e0fd1a276 100644 --- a/tests/mesh/MeshDistancePlausibilityTest.cpp +++ b/tests/mesh/MeshDistancePlausibilityTest.cpp @@ -44,8 +44,6 @@ #include "stencil/D3Q27.h" -#include <boost/lexical_cast.hpp> - #include <vector> #include <string> @@ -74,7 +72,7 @@ int main( int argc, char * argv[] ) args.erase( vtkArgIt ); } const std::string & meshFile = args[1]; - real_t dx = boost::lexical_cast<real_t>( args[2] ); + real_t dx = string_to_num<real_t>( args[2] ); auto mesh = make_shared<mesh::TriangleMesh>(); mesh::readAndBroadcast( meshFile, *mesh); diff --git a/tests/mesh/MeshInitilizationTest.cpp b/tests/mesh/MeshInitilizationTest.cpp index 494f212fb..7deeee253 100644 --- a/tests/mesh/MeshInitilizationTest.cpp +++ b/tests/mesh/MeshInitilizationTest.cpp @@ -43,8 +43,6 @@ #include "mesh/distance_octree/DistanceOctree.h" -#include <boost/lexical_cast.hpp> - #include <cmath> #include <vector> #include <string> @@ -179,8 +177,8 @@ int main( int argc, char * argv[] ) WALBERLA_ABORT_NO_DEBUG_INFO( "USAGE: " << args[0] << " MESH_FILE NUM_PROCESSES NUM_BLOCKS" ); const std::string & meshFile = args[1]; - const uint_t numProcesses = boost::lexical_cast< uint_t >( args[2] ); - const uint_t numTotalBlocks = boost::lexical_cast< uint_t >( args[3] ); + const uint_t numProcesses = string_to_num< uint_t >( args[2] ); + const uint_t numTotalBlocks = string_to_num< uint_t >( args[3] ); test< mesh::TriangleMesh >( meshFile, numProcesses, numTotalBlocks ); //test< mesh::FloatTriangleMesh >( meshFile, numProcesses, numTotalBlocks ); diff --git a/tests/mesh/MeshPeRaytracing.cpp b/tests/mesh/MeshPeRaytracing.cpp index 7fecb85a8..ce8f27992 100644 --- a/tests/mesh/MeshPeRaytracing.cpp +++ b/tests/mesh/MeshPeRaytracing.cpp @@ -72,7 +72,7 @@ int CpRayIntersectionTest(const int resolution = 10) for (int y = 0; y < resolution; ++y) { const real_t rand2 = real_c(y) * dx; - real_t theta = real_t(2) * M_PI * rand1; + real_t theta = real_t(2) * real_t(M_PI) * rand1; real_t phi = std::acos(real_t(1) - real_t(2) * rand2); Vec3 dir(std::sin(phi) * std::cos(theta), std::sin(phi) * std::sin(theta), std::cos(phi)); diff --git a/tests/mesh/PeVTKMeshWriterTest.cpp b/tests/mesh/PeVTKMeshWriterTest.cpp index 30045036c..e0a980387 100644 --- a/tests/mesh/PeVTKMeshWriterTest.cpp +++ b/tests/mesh/PeVTKMeshWriterTest.cpp @@ -95,7 +95,7 @@ std::vector<Vector3<real_t>> generatPointCloudOnSphere( const real_t radius, con std::vector<Vector3<real_t>> pointCloud( numPoints ); for( auto & p : pointCloud ) { - real_t theta = 2 * math::PI * distribution(rng); + real_t theta = 2 * real_t(M_PI) * distribution(rng); real_t phi = std::acos( real_t(1.0) - real_t(2.0) * distribution(rng) ); p[0] = std::sin(phi) * std::cos(theta) * radius; p[1] = std::sin(phi) * std::sin(theta) * radius; diff --git a/tests/mesh/QHullTest.cpp b/tests/mesh/QHullTest.cpp index ddb4d46e5..78bd8d120 100644 --- a/tests/mesh/QHullTest.cpp +++ b/tests/mesh/QHullTest.cpp @@ -209,7 +209,7 @@ std::vector<Vector3<real_t>> generatPointCloudOnSphere( const real_t radius, con std::vector<Vector3<real_t>> pointCloud( numPoints ); for( auto & p : pointCloud ) { - real_t theta = 2 * math::PI * distribution(rng); + real_t theta = 2 * real_t(M_PI) * distribution(rng); real_t phi = std::acos( real_t(1.0) - real_t(2.0) * distribution(rng) ); p[0] = std::sin(phi) * std::cos(theta) * radius; p[1] = std::sin(phi) * std::sin(theta) * radius; diff --git a/tests/pde/BoundaryTest.cpp b/tests/pde/BoundaryTest.cpp index 17e6b05a3..226d597b8 100644 --- a/tests/pde/BoundaryTest.cpp +++ b/tests/pde/BoundaryTest.cpp @@ -26,6 +26,7 @@ #include "core/Abort.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/mpi/Environment.h" #include "core/mpi/MPIManager.h" @@ -134,7 +135,7 @@ void initRHS( const shared_ptr< StructuredBlockStorage > & blocks, const BlockDa for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - rhs->get( *cell ) = real_t(4) * math::PI * math::PI * std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + rhs->get( *cell ) = real_t(4) * math::M_PI * math::M_PI * std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -180,7 +181,7 @@ void setBoundaryConditionsDirichl( shared_ptr< StructuredBlockForest > & blocks, { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - real_t val = std::sin( real_t( 2 ) * math::PI * p[0] ) * std::sinh( real_t( 2 ) * math::PI * p[1] ); + real_t val = std::sin( real_t( 2 ) * math::M_PI * p[0] ) * std::sinh( real_t( 2 ) * math::M_PI * p[1] ); boundaryHandling->forceBoundary( Dirichlet_Flag, cell->x(), cell->y(), cell->z(), pde::Dirichlet< Stencil_T, flag_t >::DirichletBC( val ) ); @@ -310,7 +311,7 @@ int main( int argc, char** argv ) synchronizeD.addPackInfo( make_shared< field::communication::PackInfo< Field_T > >( dId ) ); std::vector< real_t > weights( Stencil_T::Size ); - weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::PI * math::PI; + weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::M_PI * math::M_PI; weights[ Stencil_T::idx[ stencil::N ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::S ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::E ] ] = real_t(-1) / ( blocks->dx() * blocks->dx() ); diff --git a/tests/pde/CGTest.cpp b/tests/pde/CGTest.cpp index eecd1c6a2..81dd0e18c 100644 --- a/tests/pde/CGTest.cpp +++ b/tests/pde/CGTest.cpp @@ -24,6 +24,7 @@ #include "core/Abort.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/mpi/Environment.h" #include "core/mpi/MPIManager.h" @@ -65,7 +66,7 @@ void initU( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - u->get( *cell ) = std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + u->get( *cell ) = std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -82,7 +83,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - f->get( *cell ) = real_t(4) * math::PI * math::PI * std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + f->get( *cell ) = real_t(4) * math::M_PI * math::M_PI * std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -164,7 +165,7 @@ int main( int argc, char** argv ) synchronizeD.addPackInfo( make_shared< field::communication::PackInfo< PdeField_T > >( dId ) ); std::vector< real_t > weights( Stencil_T::Size ); - weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::PI * math::PI; + weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::M_PI * math::M_PI; weights[ Stencil_T::idx[ stencil::N ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::S ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::E ] ] = real_t(-1) / ( blocks->dx() * blocks->dx() ); @@ -208,4 +209,4 @@ int main( int argc, char** argv ) int main( int argc, char* argv[] ) { return walberla::main( argc, argv ); -} \ No newline at end of file +} diff --git a/tests/pde/JacobiTest.cpp b/tests/pde/JacobiTest.cpp index 275cbf8df..525e0e063 100644 --- a/tests/pde/JacobiTest.cpp +++ b/tests/pde/JacobiTest.cpp @@ -24,6 +24,7 @@ #include "core/Abort.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/mpi/Environment.h" #include "core/mpi/MPIManager.h" @@ -69,8 +70,8 @@ void initU( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - src->get( *cell ) = std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); - dst->get( *cell ) = std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + src->get( *cell ) = std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); + dst->get( *cell ) = std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -87,7 +88,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - f->get( *cell ) = real_t(4) * math::PI * math::PI * std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + f->get( *cell ) = real_t(4) * math::M_PI * math::M_PI * std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -167,7 +168,7 @@ int main( int argc, char** argv ) communication.addPackInfo( make_shared< field::communication::PackInfo< PdeField_T > >( srcId ) ); std::vector< real_t > weights( Stencil_T::Size ); - weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::PI * math::PI; + weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::M_PI * math::M_PI; weights[ Stencil_T::idx[ stencil::N ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::S ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::E ] ] = real_t(-1) / ( blocks->dx() * blocks->dx() ); @@ -215,4 +216,4 @@ int main( int argc, char** argv ) int main( int argc, char* argv[] ) { return walberla::main( argc, argv ); -} \ No newline at end of file +} diff --git a/tests/pde/RBGSTest.cpp b/tests/pde/RBGSTest.cpp index c3a922ea1..8609ace0a 100644 --- a/tests/pde/RBGSTest.cpp +++ b/tests/pde/RBGSTest.cpp @@ -24,6 +24,7 @@ #include "core/Abort.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/mpi/Environment.h" #include "core/mpi/MPIManager.h" @@ -68,7 +69,7 @@ void initU( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - u->get( *cell ) = std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + u->get( *cell ) = std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -85,7 +86,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - f->get( *cell ) = real_t(4) * math::PI * math::PI * std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + f->get( *cell ) = real_t(4) * math::M_PI * math::M_PI * std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -164,7 +165,7 @@ int main( int argc, char** argv ) communication.addPackInfo( make_shared< field::communication::PackInfo< PdeField_T > >( uId ) ); std::vector< real_t > weights( Stencil_T::Size ); - weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::PI * math::PI; + weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::M_PI * math::M_PI; weights[ Stencil_T::idx[ stencil::N ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::S ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::E ] ] = real_t(-1) / ( blocks->dx() * blocks->dx() ); @@ -215,4 +216,4 @@ int main( int argc, char** argv ) int main( int argc, char* argv[] ) { return walberla::main( argc, argv ); -} \ No newline at end of file +} diff --git a/tests/pde/SORTest.cpp b/tests/pde/SORTest.cpp index 520df1cfa..0a5799163 100644 --- a/tests/pde/SORTest.cpp +++ b/tests/pde/SORTest.cpp @@ -24,6 +24,7 @@ #include "core/Abort.h" #include "core/debug/TestSubsystem.h" +#include "core/math/Constants.h" #include "core/mpi/Environment.h" #include "core/mpi/MPIManager.h" @@ -68,7 +69,7 @@ void initU( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - u->get( *cell ) = std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + u->get( *cell ) = std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -85,7 +86,7 @@ void initF( const shared_ptr< StructuredBlockStorage > & blocks, const BlockData for( auto cell = xyz.begin(); cell != xyz.end(); ++cell ) { const Vector3< real_t > p = blocks->getBlockLocalCellCenter( *block, *cell ); - f->get( *cell ) = real_t(4) * math::PI * math::PI * std::sin( real_t(2) * math::PI * p[0] ) * std::sinh( real_t(2) * math::PI * p[1] ); + f->get( *cell ) = real_t(4) * math::M_PI * math::M_PI * std::sin( real_t(2) * math::M_PI * p[0] ) * std::sinh( real_t(2) * math::M_PI * p[1] ); } } } @@ -166,7 +167,7 @@ int main( int argc, char** argv ) communication.addPackInfo( make_shared< field::communication::PackInfo< PdeField_T > >( uId ) ); std::vector< real_t > weights( Stencil_T::Size ); - weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::PI * math::PI; + weights[ Stencil_T::idx[ stencil::C ] ] = real_t(2) / ( blocks->dx() * blocks->dx() ) + real_t(2) / ( blocks->dy() * blocks->dy() ) + real_t(4) * math::M_PI * math::M_PI; weights[ Stencil_T::idx[ stencil::N ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::S ] ] = real_t(-1) / ( blocks->dy() * blocks->dy() ); weights[ Stencil_T::idx[ stencil::E ] ] = real_t(-1) / ( blocks->dx() * blocks->dx() ); @@ -217,4 +218,4 @@ int main( int argc, char** argv ) int main( int argc, char* argv[] ) { return walberla::main( argc, argv ); -} \ No newline at end of file +} diff --git a/tests/pe/Collision.cpp b/tests/pe/Collision.cpp index 958b4de97..e73d9ac35 100644 --- a/tests/pe/Collision.cpp +++ b/tests/pe/Collision.cpp @@ -119,8 +119,8 @@ void BoxTest() b4.rotate( Vec3(1,1,0), real_t(atan(sqrt(2))) ); Box b5(123, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), Vec3(2,2,2), iron, false, true, false); - b5.rotate( Vec3(0,0,1), real_t(math::PI * 0.25) ); - b5.rotate( Vec3(1,0,0), real_t(math::PI * 0.25) ); + b5.rotate( Vec3(0,0,1), real_t(math::M_PI * 0.25) ); + b5.rotate( Vec3(1,0,0), real_t(math::M_PI * 0.25) ); std::vector<Contact> contacts; fcd::AnalyticCollideFunctor< std::vector<Contact> > collideFunc(contacts); diff --git a/tests/pe/GJK_EPA.cpp b/tests/pe/GJK_EPA.cpp index 931d14fd9..9293c3c86 100644 --- a/tests/pe/GJK_EPA.cpp +++ b/tests/pe/GJK_EPA.cpp @@ -128,11 +128,11 @@ int main( int argc, char ** argv ) // WALBERLA_LOG_INFO("**** (" << dir.cx() << ", " << dir.cy() << ", " << dir.cz() << ") ****"); // WALBERLA_LOG_INFO("deltaPoint : |" << contactPoint - contactPointGJK << "| = " << (contactPoint - contactPointGJK).length() ); -// WALBERLA_LOG_INFO("deltaNormal: |" << normal - normalGJK << "| = " << (normal - normalGJK).length() << " (" << acos(normal*normalGJK) / math::PI * 180 << "°)" ); +// WALBERLA_LOG_INFO("deltaNormal: |" << normal - normalGJK << "| = " << (normal - normalGJK).length() << " (" << acos(normal*normalGJK) / math::M_PI * 180 << "°)" ); // WALBERLA_LOG_INFO("deltaPen : " << penetrationDepth << " - " << penetrationDepthGJK << " = " << penetrationDepth - penetrationDepthGJK); point.insert( (contactPoint - contactPointGJK).length() ); - norm.insert( acos(normal*normalGJK) / math::PI * 180 ); + norm.insert( acos(normal*normalGJK) / math::M_PI * 180 ); pen.insert( fabs(penetrationDepth - penetrationDepthGJK) ); } diff --git a/tests/pe/PeDocumentationSnippets.cpp b/tests/pe/PeDocumentationSnippets.cpp index d9b3396bb..e5067ab10 100644 --- a/tests/pe/PeDocumentationSnippets.cpp +++ b/tests/pe/PeDocumentationSnippets.cpp @@ -98,14 +98,14 @@ int main( int argc, char ** argv ) // be used to for instance rotate the box around the global y-axis. BoxID box = createBox( *globalBodyStorage, forest->getBlockStorage(), storageID, 1, Vec3(2,3,4), Vec3(2.5,2.5,2.5) ); if (box != nullptr) - box->rotate( 0.0, real_c(math::PI/3.0), 0.0 ); + box->rotate( 0.0, real_c(math::M_PI/3.0), 0.0 ); //! [Create a Box] //! [Create a Capsule] // Create a capsule and rotate it after successfull creation. CapsuleID capsule = createCapsule( *globalBodyStorage, forest->getBlockStorage(), storageID, 1, Vec3(2,3,4), real_t(1), real_t(1) ); if (capsule != nullptr) - capsule->rotate( 0.0, real_c(math::PI/3.0), 0.0 ); + capsule->rotate( 0.0, real_c(math::M_PI/3.0), 0.0 ); //! [Create a Capsule] //! [Create a Plane] @@ -118,7 +118,7 @@ int main( int argc, char ** argv ) // Create a sphere and rotate it after successfull creation. SphereID sphere = createSphere( *globalBodyStorage, forest->getBlockStorage(), storageID, 1, Vec3(2,3,4), real_t(1) ); if (sphere != nullptr) - sphere->rotate( 0.0, real_c(math::PI/3.0), 0.0 ); + sphere->rotate( 0.0, real_c(math::M_PI/3.0), 0.0 ); //! [Create a Sphere] //! [Create a Union] diff --git a/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp b/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp index 1a4293fec..f3dc7905e 100644 --- a/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp +++ b/tests/pe_coupling/discrete_particle_methods/HinderedSettlingDynamicsDPM.cpp @@ -738,7 +738,7 @@ int main( int argc, char **argv ) const real_t viscosity = ( viscosity_SI/densityFluid_SI ) * dt_SI / ( dx_SI * dx_SI ); const real_t tau = real_t(1) / lbm::collision_model::omegaFromViscosity( viscosity ); - real_t gravitationalForce = - gravity * ( densityRatio - real_t(1) ) * diameter * diameter * diameter * math::PI / real_t(6); + real_t gravitationalForce = - gravity * ( densityRatio - real_t(1) ) * diameter * diameter * diameter * math::M_PI / real_t(6); // unhindered settling velocity of a single sphere in infinite fluid, would come from experiments or DNS, NOT Stokes settling velocity, from Finn et al, Tab 5 const real_t velUnhindered_SI = real_t(-0.048); // m/s @@ -1488,9 +1488,9 @@ int main( int argc, char **argv ) WALBERLA_LOG_INFO_ON_ROOT("initial simulation ended with relative difference of interaction forces of " << relativeForceDiffLimit << " after " << t << " time steps."); - real_t actingExternalForceOnSpheres = real_c(numSpheres) * ( ( - gravity * densityRatio * diameter * diameter * diameter * math::PI / real_t(6) ) + - ( gravity * real_t(1) * diameter * diameter * diameter * math::PI / real_t(6) ) + - ( extForce[2] * real_t(1) * diameter * diameter * diameter * math::PI / real_t(6) ) ); + real_t actingExternalForceOnSpheres = real_c(numSpheres) * ( ( - gravity * densityRatio * diameter * diameter * diameter * math::M_PI / real_t(6) ) + + ( gravity * real_t(1) * diameter * diameter * diameter * math::M_PI / real_t(6) ) + + ( extForce[2] * real_t(1) * diameter * diameter * diameter * math::M_PI / real_t(6) ) ); WALBERLA_LOG_INFO_ON_ROOT("f_interaction_z = " << curInteractionForce << ", f_ext_z = " << actingExternalForceOnSpheres ); if( std::fabs( ( std::fabs( curInteractionForce ) - std::fabs( actingExternalForceOnSpheres ) )/ std::fabs( curInteractionForce ) ) < relativeForceConvergenceLimit ) { @@ -1521,7 +1521,7 @@ int main( int argc, char **argv ) WALBERLA_LOG_INFO_ON_ROOT("===================================================================================" ); WALBERLA_LOG_INFO_ON_ROOT("Starting simulation with:" ); WALBERLA_LOG_INFO_ON_ROOT("external forcing on fluid = " << extForce ); - WALBERLA_LOG_INFO_ON_ROOT("total external forces on all particles = " << real_c(numSpheres) * ( - gravity * ( densityRatio - real_t(1) ) + extForce[2] ) * diameter * diameter * diameter * math::PI / real_t(6) ); + WALBERLA_LOG_INFO_ON_ROOT("total external forces on all particles = " << real_c(numSpheres) * ( - gravity * ( densityRatio - real_t(1) ) + extForce[2] ) * diameter * diameter * diameter * math::M_PI / real_t(6) ); WALBERLA_LOG_INFO_ON_ROOT("simulating " << timesteps << " time steps" ); @@ -1642,9 +1642,9 @@ int main( int argc, char **argv ) // ext forces on bodies timeloop.add() << Sweep( DummySweep(), "Dummy Sweep ") - << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,- gravity * densityRatio * diameter * diameter * diameter * math::PI / real_t(6) ) ), "Gravitational Force Add" ) - << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,gravity * real_t(1) * diameter * diameter * diameter * math::PI / real_t(6) ) ), "Buoyancy Force (due to gravity) Add" ) - << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,extForce[2] * real_t(1) * diameter * diameter * diameter * math::PI / real_t(6) ) ), "Buoyancy Force (due to external fluid force) Add" ) + << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,- gravity * densityRatio * diameter * diameter * diameter * math::M_PI / real_t(6) ) ), "Gravitational Force Add" ) + << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,gravity * real_t(1) * diameter * diameter * diameter * math::M_PI / real_t(6) ) ), "Buoyancy Force (due to gravity) Add" ) + << AfterFunction( pe_coupling::ForceOnBodiesAdder( blocks, bodyStorageID, Vector3<real_t>(0,0,extForce[2] * real_t(1) * diameter * diameter * diameter * math::M_PI / real_t(6) ) ), "Buoyancy Force (due to external fluid force) Add" ) << AfterFunction( pe_coupling::TimeStep( blocks, bodyStorageID, *cr, syncCall, dtInteractionSubCycle, peSubSteps, lubricationEvaluationFunction ), "Pe Time Step" ); timeloop.add() << Sweep( DummySweep(), "Dummy Sweep ") diff --git a/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp b/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp index 2e449157f..0c717fb15 100644 --- a/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEM.cpp @@ -226,9 +226,9 @@ public: real_t uBar = computeAverageVel(); // f_total = f_drag + f_buoyancy - real_t totalForce = forceX + real_c(4.0/3.0) * math::PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; + real_t totalForce = forceX + real_c(4.0/3.0) * math::M_PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; - real_t normalizedDragForce = totalForce / real_c( 6.0 * math::PI * setup_->visc * setup_->radius * uBar ); + real_t normalizedDragForce = totalForce / real_c( 6.0 * math::M_PI * setup_->visc * setup_->radius * uBar ); // update drag force values normalizedDragOld_ = normalizedDragNew_; diff --git a/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEMRefinement.cpp b/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEMRefinement.cpp index 358d165ba..1f61e239c 100644 --- a/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEMRefinement.cpp +++ b/tests/pe_coupling/momentum_exchange_method/DragForceSphereMEMRefinement.cpp @@ -297,9 +297,9 @@ class ForceEval real_t uBar = getAverageVel(); // f_total = f_drag + f_buoyancy - real_t totalForce = forceX + real_c(4.0/3.0) * math::PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; + real_t totalForce = forceX + real_c(4.0/3.0) * math::M_PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; - real_t normalizedDragForce = totalForce / real_c( 6.0 * math::PI * setup_->visc * setup_->radius * uBar ); + real_t normalizedDragForce = totalForce / real_c( 6.0 * math::M_PI * setup_->visc * setup_->radius * uBar ); // update drag force values normalizedDragOld_ = normalizedDragNew_; diff --git a/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp b/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp index 2ebe21f51..f1b545ec0 100644 --- a/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/LubricationCorrectionMEM.cpp @@ -261,10 +261,10 @@ private: WALBERLA_CHECK_FLOAT_EQUAL ( forceSphr2[0], -forceSphr1[0] ); // according to the formula from Ding & Aidun 2003 - // F = 3/2 * PI * rho_L * nu_L * relative velocity of both spheres * r * r * 1/gap + // F = 3/2 * M_PI * rho_L * nu_L * relative velocity of both spheres * r * r * 1/gap // the correct analytically calculated value is 339.2920063998 // in this geometry setup the relative error is 0.1246489711 % - real_t analytical = real_c(3.0)/real_c(2.0) * walberla::math::PI * real_c(1.0) * nu_L_ * real_c(2.0) * real_c(vel_[0]) * radius_ * radius_ * real_c(1.0)/gap; + real_t analytical = real_c(3.0)/real_c(2.0) * walberla::math::M_PI * real_c(1.0) * nu_L_ * real_c(2.0) * real_c(vel_[0]) * radius_ * radius_ * real_c(1.0)/gap; real_t relErr = std::fabs( analytical - forceSphr2[0] ) / analytical * real_c(100.0); WALBERLA_CHECK_LESS( relErr, real_t(1) ); } @@ -357,10 +357,10 @@ private: if ( timestep == uint_t(26399) ) { // according to the formula from Ding & Aidun 2003 - // F = 6 * PI * rho_L * nu_L * relative velocity of both bodies=relative velocity of the sphere * r * r * 1/gap + // F = 6 * M_PI * rho_L * nu_L * relative velocity of both bodies=relative velocity of the sphere * r * r * 1/gap // the correct analytically calculated value is 339.292006996217 // in this geometry setup the relative error is 0.183515322065561 % - real_t analytical = real_c(6.0) * walberla::math::PI * real_c(1.0) * nu_L_ * real_c(-vel_[0]) * radius_ * radius_ * real_c(1.0)/gap; + real_t analytical = real_c(6.0) * walberla::math::M_PI * real_c(1.0) * nu_L_ * real_c(-vel_[0]) * radius_ * radius_ * real_c(1.0)/gap; real_t relErr = std::fabs( analytical - forceSphr1[0] ) / analytical * real_c(100.0); WALBERLA_CHECK_LESS( relErr, real_t(1) ); } diff --git a/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp b/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp index 68a74cde6..dd90350c7 100644 --- a/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp +++ b/tests/pe_coupling/momentum_exchange_method/TorqueSphereMEM.cpp @@ -375,7 +375,7 @@ int main( int argc, char **argv ) setup.checkFrequency = uint_t( 100 ); // evaluate the torque only every checkFrequency time steps setup.radius = real_c(0.5) * chi * real_c( setup.length ); // sphere radius setup.visc = ( setup.tau - real_c(0.5) ) / real_c(3); // viscosity in lattice units - setup.phi = real_c(4.0/3.0) * math::PI * setup.radius * setup.radius * setup.radius / + setup.phi = real_c(4.0/3.0) * math::M_PI * setup.radius * setup.radius * setup.radius / ( real_c( setup.length * setup.length * setup.length ) ); // solid volume fraction const real_t omega = real_c(1) / setup.tau; // relaxation rate const real_t dx = real_c(1); // lattice dx diff --git a/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp b/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp index b5e53a23f..1fadccab9 100644 --- a/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp +++ b/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSM.cpp @@ -178,9 +178,9 @@ public: real_t uBar = computeAverageVel(); // f_total = f_drag + f_buoyancy - real_t totalForce = forceX + real_c(4.0/3.0) * math::PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; + real_t totalForce = forceX + real_c(4.0/3.0) * math::M_PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; - real_t normalizedDragForce = totalForce / real_c( 6.0 * math::PI * setup_->visc * setup_->radius * uBar ); + real_t normalizedDragForce = totalForce / real_c( 6.0 * math::M_PI * setup_->visc * setup_->radius * uBar ); // update drag force values normalizedDragOld_ = normalizedDragNew_; diff --git a/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSMRefinement.cpp b/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSMRefinement.cpp index b0ca02da9..bb890e698 100644 --- a/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSMRefinement.cpp +++ b/tests/pe_coupling/partially_saturated_cells_method/DragForceSpherePSMRefinement.cpp @@ -297,9 +297,9 @@ public: real_t uBar = computeAverageVel(); // f_total = f_drag + f_buoyancy - real_t totalForce = forceX + real_c(4.0/3.0) * math::PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; + real_t totalForce = forceX + real_c(4.0/3.0) * math::M_PI * setup_->radius * setup_->radius * setup_->radius * setup_->extForce ; - real_t normalizedDragForce = totalForce / real_c( 6.0 * math::PI * setup_->visc * setup_->radius * uBar ); + real_t normalizedDragForce = totalForce / real_c( 6.0 * math::M_PI * setup_->visc * setup_->radius * uBar ); // update drag force values normalizedDragOld_ = normalizedDragNew_; diff --git a/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp b/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp index 7cd33d47e..c63f974e8 100644 --- a/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp +++ b/tests/pe_coupling/partially_saturated_cells_method/TorqueSpherePSM.cpp @@ -309,7 +309,7 @@ int main( int argc, char **argv ) setup.checkFrequency = uint_t( 100 ); // evaluate the torque only every checkFrequency time steps setup.radius = real_c(0.5) * chi * real_c( setup.length ); // sphere radius setup.visc = ( setup.tau - real_c(0.5) ) / real_c(3); // viscosity in lattice units - setup.phi = real_c(4.0/3.0) * math::PI * setup.radius * setup.radius * setup.radius / + setup.phi = real_c(4.0/3.0) * math::M_PI * setup.radius * setup.radius * setup.radius / ( real_c( setup.length * setup.length * setup.length ) ); // solid volume fraction const real_t omega = real_c(1) / setup.tau; // relaxation rate const real_t dx = real_c(1); // lattice dx -- GitLab