From e0ad5883a011fde0341d83f1b57b4e8207014827 Mon Sep 17 00:00:00 2001 From: hamidrezanorouzi Date: Mon, 31 Oct 2022 21:24:06 +0330 Subject: [PATCH] correction of levels and Istream for underflow doubles --- .../contactSearch/methods/NBSLevels.H | 6 +++-- src/phasicFlow/streams/Stream/Istream.C | 2 +- .../types/basicTypes/bTypesFunctions.C | 24 ++++++++++++++++--- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/Interaction/contactSearch/methods/NBSLevels.H b/src/Interaction/contactSearch/methods/NBSLevels.H index d945ced4..d30a1ec4 100644 --- a/src/Interaction/contactSearch/methods/NBSLevels.H +++ b/src/Interaction/contactSearch/methods/NBSLevels.H @@ -267,6 +267,7 @@ public: nbsLevels_[lvl].findPairsCountCross(pairs, nbsLevels_[crsLvl]); } + } return notInsertedCount; } @@ -401,8 +402,9 @@ public: } auto diameter = nbsLevels_[0].diameter(); - auto maxSizes = maxSizeLevels_; + auto const maxSizes = maxSizeLevels_; auto particleLevel = particleLevel_; + auto const sizeRatio = 0.999*nbsLevels_[0].sizeRatio(); int8 maxLvl = sizeRangeLevels_.size(); @@ -415,7 +417,7 @@ public: { for(int8 lvl = 0; lvl bool pFlow::readReal( const word& w, real & val) { try{ val = std::stod(w); } + catch (std:: out_of_range& e) + { + val = static_cast( std::stold(w) ); + } catch (...){ return false; } @@ -325,8 +329,22 @@ bool pFlow::readReal( const word& w, real & val) bool pFlow::readReal( const char* buf, real & val ) { - word w(buf); - return readReal(w, val); + char* c; + + val = std::strtod(buf, &c); + if(val == HUGE_VAL) + { + val = static_cast( std::strtold(buf, &c) ); + if(val == HUGE_VAL || c==buf) + return false; + } + else if(c == buf) + { + return false; + } + + + return true; }