Merge pull request #35 from PhasicFlow/solvers
correction for time control and precision
This commit is contained in:
commit
5c9623c9b7
|
@ -105,8 +105,7 @@ public:
|
||||||
|
|
||||||
word currentTimeWord() const
|
word currentTimeWord() const
|
||||||
{
|
{
|
||||||
word ctw = real2Word( currentTime(), timePrecision());
|
return real2FixedStripZeros( currentTime(), timePrecision());;
|
||||||
return ctw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 currentIter()const
|
int32 currentIter()const
|
||||||
|
|
|
@ -72,6 +72,38 @@ pFlow::word pFlow::int322Word(const int32 & v)
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pFlow::word pFlow::removeDecimalZeros(const word& str)
|
||||||
|
{
|
||||||
|
auto dec = str.find('.');
|
||||||
|
if(dec == word::npos) return str;
|
||||||
|
|
||||||
|
auto len = str.size();
|
||||||
|
if(len == word::npos) return str;
|
||||||
|
|
||||||
|
auto firstZero = word::npos;
|
||||||
|
for(auto n=len-1; n>dec;n--)
|
||||||
|
{
|
||||||
|
if( str[n] == '0' )
|
||||||
|
{
|
||||||
|
firstZero = n;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(firstZero == dec+1) firstZero = dec;
|
||||||
|
|
||||||
|
return str.substr(0,firstZero);
|
||||||
|
}
|
||||||
|
|
||||||
|
pFlow::word pFlow::real2FixedStripZeros(const real & v, int32 numPrecision)
|
||||||
|
{
|
||||||
|
word strVal = real2Fixed(v, numPrecision);
|
||||||
|
return removeDecimalZeros(strVal);
|
||||||
|
}
|
||||||
|
|
||||||
pFlow::word pFlow::toUpper(const word & inStr)
|
pFlow::word pFlow::toUpper(const word & inStr)
|
||||||
{
|
{
|
||||||
word oStr(inStr);
|
word oStr(inStr);
|
||||||
|
|
|
@ -57,6 +57,10 @@ word real2Fixed(const real & v, int32 numPrecision = 6);
|
||||||
|
|
||||||
word real2Word(const real & v, int32 numPrecision = 6);
|
word real2Word(const real & v, int32 numPrecision = 6);
|
||||||
|
|
||||||
|
word removeDecimalZeros(const word& str);
|
||||||
|
|
||||||
|
word real2FixedStripZeros(const real & v, int32 numPrecision = 6);
|
||||||
|
|
||||||
word int322Word(const int32 & v);
|
word int322Word(const int32 & v);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue