Commit e0058121 authored by Christoph Rettinger's avatar Christoph Rettinger
Browse files

Merge branch 'boost-math-range' into 'master'

Replace Boost lexical_cast, numeric, math, range, demangle, hash

See merge request walberla/walberla!184
parents 6b25129d dec54ed4
......@@ -78,8 +78,6 @@
#include "core/timing/RemainingTimeLogger.h"
#include <boost/lexical_cast.hpp>
#include <cmath>
#include <vector>
#include <string>
......
......@@ -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);
}
}
......
......@@ -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)
{
......
......@@ -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
......
......@@ -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
{
......
......@@ -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);
}
......
......@@ -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 );
......
......@@ -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 );
}
}
}
......
......@@ -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
}
......@@ -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
}
......@@ -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
}
......
......@@ -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;
}
......
......@@ -20,6 +20,8 @@
//======================================================================================================================
#include <algorithm>
#include <boost/type_traits/integral_constant.hpp>
/// \cond internal
......
......@@ -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
......
......@@ -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()
{
......
......@@ -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 );
......
......@@ -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()
{
......
......@@ -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>