timeInfo and timeValue

- timeInfo updated
- timeValue type is added = double
- AB2 bug fixed
- updateInterval for broadSearch is activated
This commit is contained in:
HRN 2025-01-25 19:18:11 +03:30
parent 1ccc321c1d
commit 0fc9eea561
26 changed files with 442 additions and 240 deletions

View File

@ -50,7 +50,7 @@ bool intAllActive(
"AdamsBashforth2::correct", "AdamsBashforth2::correct",
rpIntegration (activeRng.start(), activeRng.end()), rpIntegration (activeRng.start(), activeRng.end()),
LAMBDA_HD(uint32 i){ LAMBDA_HD(uint32 i){
d_y[i] = damping*(d_dy[i] + dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i])); d_y[i] = damping*(d_y[i] + dt*(static_cast<real>(1.5) * d_dy[i] - static_cast<real>(0.5) * d_dy1[i]));
d_dy1[i] = d_dy[i]; d_dy1[i] = d_dy[i];
}); });
Kokkos::fence(); Kokkos::fence();

View File

@ -25,12 +25,6 @@ Licence:
#include "symArrays.hpp" #include "symArrays.hpp"
namespace pFlow::cfModels namespace pFlow::cfModels
{ {
@ -159,7 +153,7 @@ protected:
{ {
etha_t[i] = -2.0*log( et[i])*sqrt(kt[i]*2/7) / etha_t[i] = -2.0*log( et[i])*sqrt(kt[i]*2/7) /
sqrt(log(pow(et[i],2.0))+ pow(Pi,2.0)); sqrt(log(pow(et[i],2))+ pow(Pi,2));
} }
Vector<linearProperties> prop("prop", nElem); Vector<linearProperties> prop("prop", nElem);
@ -285,8 +279,8 @@ public:
history.overlap_t_ += Vt*dt; history.overlap_t_ += Vt*dt;
real mi = 3*Pi/4*pow(Ri,3.0)*rho_[propId_i]; real mi = 3*Pi/4*pow(Ri,3)*rho_[propId_i];
real mj = 3*Pi/4*pow(Rj,3.0)*rho_[propId_j]; real mj = 3*Pi/4*pow(Rj,3)*rho_[propId_j];
real sqrt_meff = sqrt((mi*mj)/(mi+mj)); real sqrt_meff = sqrt((mi*mj)/(mi+mj));
@ -299,29 +293,24 @@ public:
else if (addDissipationModel_==3) else if (addDissipationModel_==3)
{ {
auto pie =3.14; auto pie =3.14;
prop.en_ = exp((pow(f_,1.5)*log(prop.en_)*sqrt( (1-((pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(pie,2))))/(1-(pow(f_,3)*(pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(pie,2)))) ) )); prop.en_ = exp((pow(f_,static_cast<real>(1.5))*log(prop.en_)*sqrt( (1-((pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(pie,2))))/(1-(pow(f_,3)*(pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(pie,2)))) ) ));
} }
real ethan_ = -2.0*log(prop.en_)*sqrt(prop.kn_)/ real ethan_ = -2.0*log(prop.en_)*sqrt(prop.kn_)/
sqrt(pow(log(prop.en_),2.0)+ pow(Pi,2.0)); sqrt(pow(log(prop.en_),2)+ pow(Pi,2));
//REPORT(0)<<"\n en n is : "<<END_REPORT; //REPORT(0)<<"\n en n is : "<<END_REPORT;
//REPORT(0)<< prop.en_ <<END_REPORT; //REPORT(0)<< prop.en_ <<END_REPORT;
FCn = ( -pow(f_,3.0)*prop.kn_ * ovrlp_n - sqrt_meff * pow(f_,1.5) * ethan_ * vrn)*Nij; FCn = ( -pow(f_,3)*prop.kn_ * ovrlp_n - sqrt_meff * pow(f_,static_cast<real>(1.5)) * ethan_ * vrn)*Nij;
FCt = ( -pow(f_,3.0)*prop.kt_ * history.overlap_t_ - sqrt_meff * pow(f_,1.5) * prop.ethat_*Vt); FCt = ( -pow(f_,3)*prop.kt_ * history.overlap_t_ - sqrt_meff * pow(f_,static_cast<real>(1.5)) * prop.ethat_*Vt);
real ft = length(FCt); real ft = length(FCt);
real ft_fric = prop.mu_ * length(FCn); real ft_fric = prop.mu_ * length(FCn);
if(ft > ft_fric) if(ft > ft_fric)
{ {
if( length(history.overlap_t_) >static_cast<real>(0.0)) if( length(history.overlap_t_) >zero)
{ {
if constexpr (limited) if constexpr (limited)
{ {

View File

@ -236,7 +236,7 @@ public:
const auto prop = nonlinearProperties_(propId_i,propId_j); const auto prop = nonlinearProperties_(propId_i,propId_j);
const real f = 2.0/( 1.0/cGFi + 1.0/cGFj ); const real f = 2/( 1/cGFi + 1/cGFj );
real vrn = dot(Vr, Nij); real vrn = dot(Vr, Nij);
realx3 Vt = Vr - vrn*Nij; realx3 Vt = Vr - vrn*Nij;
@ -245,7 +245,7 @@ public:
real mi = 3*Pi/4*pow(Ri,static_cast<real>(3))*rho_[propId_i]; real mi = 3*Pi/4*pow(Ri,static_cast<real>(3))*rho_[propId_i];
real mj = 3*Pi/4*pow(Rj,static_cast<real>(3))*rho_[propId_j]; real mj = 3*Pi/4*pow(Rj,static_cast<real>(3))*rho_[propId_j];
real Reff = 1.0/(1/Ri + 1/Rj); real Reff = 1/(1/Ri + 1/Rj);
real K_hertz = 4.0/3.0*prop.Yeff_*sqrt(Reff); real K_hertz = 4.0/3.0*prop.Yeff_*sqrt(Reff);
real sqrt_meff_K_hertz = sqrt((mi*mj)/(mi+mj) * K_hertz); real sqrt_meff_K_hertz = sqrt((mi*mj)/(mi+mj) * K_hertz);
@ -258,13 +258,13 @@ public:
else if (addDissipationModel_==3) else if (addDissipationModel_==3)
{ {
en = exp((pow(f,1.5)*log(prop.en_)*sqrt( (1-((pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(Pi,2))))/(1-(pow(f,3)*(pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(Pi,2)))) ) )); en = exp((pow(f,static_cast<real>(1.5))*log(prop.en_)*sqrt( (1-((pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(Pi,2))))/(1-(pow(f,3)*(pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(Pi,2)))) ) ));
} }
real Kn = static_cast<real>(4.0/3.0) * prop.Yeff_ * sqrt(Reff*ovrlp_n); real Kn = static_cast<real>(4.0/3.0) * prop.Yeff_ * sqrt(Reff*ovrlp_n);
real ethan_ = -2.0*log(en)*sqrt(Kn)/ real ethan_ = -2.0*log(en)*sqrt(Kn)/
sqrt(pow(log(en),2.0)+ pow(Pi,2.0)); sqrt(pow(log(en),2)+ pow(Pi,2));
FCn = ( - Kn*ovrlp_n - FCn = ( - Kn*ovrlp_n -
sqrt_meff_K_hertz*ethan_*pow(ovrlp_n,static_cast<real>(0.25))*vrn)*Nij; sqrt_meff_K_hertz*ethan_*pow(ovrlp_n,static_cast<real>(0.25))*vrn)*Nij;

View File

@ -255,8 +255,8 @@ public:
history.overlap_t_ += Vt*dt; history.overlap_t_ += Vt*dt;
real mi = 3*Pi/4*pow(Ri,3.0)*rho_[propId_i]; real mi = 3*Pi/4*pow(Ri,3)*rho_[propId_i];
real mj = 3*Pi/4*pow(Rj,3.0)*rho_[propId_j]; real mj = 3*Pi/4*pow(Rj,3)*rho_[propId_j];
real sqrt_meff = sqrt((mi*mj)/(mi+mj)); real sqrt_meff = sqrt((mi*mj)/(mi+mj));
@ -268,14 +268,26 @@ public:
else if (addDissipationModel_==3) else if (addDissipationModel_==3)
{ {
en = exp((pow(f_,1.5)*log(prop.en_)*sqrt( (1-((pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(Pi,2))))/(1-(pow(f_,3)*(pow(log(prop.en_),2))/(pow(log(prop.en_),2)+pow(Pi,2)))) ) )); en = exp(
(
pow(f_,static_cast<real>(1.5))*
log(prop.en_)*
sqrt(
(1-((pow(log(prop.en_),static_cast<real>(2.0))
)/
(
pow(log(prop.en_),static_cast<real>(2.0))+
pow(Pi,static_cast<real>(2.0)))))/
(1-(pow(f_,3)*(pow(log(prop.en_),2))/
(pow(log(prop.en_),static_cast<real>(2.0))+
pow(Pi,static_cast<real>(2.0))))) ) ));
} }
real ethan_ = -2.0*log(en)*sqrt(prop.kn_)/ real ethan_ = -2.0*log(en)*sqrt(prop.kn_)/
sqrt(pow(log(en),2.0)+ pow(Pi,2.0)); sqrt(pow(log(en),2)+ pow(Pi,2));
FCn = ( -f_*prop.kn_ * ovrlp_n - sqrt_meff * pow(f_,0.5) * ethan_ * vrn)*Nij; FCn = ( -f_*prop.kn_ * ovrlp_n - sqrt_meff * pow(f_,half) * ethan_ * vrn)*Nij;
FCt = ( -f_*prop.kt_ * history.overlap_t_); FCt = ( -f_*prop.kt_ * history.overlap_t_);

View File

@ -139,10 +139,10 @@ protected:
ForAll(i , kn) ForAll(i , kn)
{ {
etha_n[i] = -2.0*log(en[i])*sqrt(kn[i])/ etha_n[i] = -2.0*log(en[i])*sqrt(kn[i])/
sqrt(pow(log(en[i]),2.0)+ pow(Pi,2.0)); sqrt(pow(log(en[i]),static_cast<real>(2.0))+ pow(Pi,static_cast<real>(2.0)));
etha_t[i] = -2.0*log( et[i]*sqrt(kt[i]) )/ etha_t[i] = -2.0*log( et[i]*sqrt(kt[i]) )/
sqrt(pow(log(et[i]),2.0)+ pow(Pi,2.0)); sqrt(pow(log(et[i]),static_cast<real>(2.0))+ pow(Pi,static_cast<real>(2.0)));
} }
Vector<linearProperties> prop("prop", nElem); Vector<linearProperties> prop("prop", nElem);
@ -243,8 +243,8 @@ public:
history.overlap_t_ += Vt*dt; history.overlap_t_ += Vt*dt;
real mi = 3*Pi/4*pow(Ri,3.0)*rho_[propId_i]; real mi = 3*Pi/4*pow(Ri,static_cast<real>(3.0))*rho_[propId_i];
real mj = 3*Pi/4*pow(Rj,3.0)*rho_[propId_j]; real mj = 3*Pi/4*pow(Rj,static_cast<real>(3.0))*rho_[propId_j];
real sqrt_meff = sqrt((mi*mj)/(mi+mj)); real sqrt_meff = sqrt((mi*mj)/(mi+mj));

View File

@ -131,7 +131,7 @@ protected:
// we take out sqrt(meff*K_hertz) here and then consider this term // we take out sqrt(meff*K_hertz) here and then consider this term
// when calculating damping part. // when calculating damping part.
etha_n[i] = -2.2664*log(en[i])/ etha_n[i] = -2.2664*log(en[i])/
sqrt(pow(log(en[i]),2.0)+ pow(Pi,2.0)); sqrt(pow(log(en[i]),static_cast<real>(2.0))+ pow(Pi,static_cast<real>(2.0)));
// no damping for tangential part // no damping for tangential part
@ -255,7 +255,7 @@ public:
// apply friction // apply friction
if(ft > ft_fric) if(ft > ft_fric)
{ {
if( length(history.overlap_t_) >0.0) if( length(history.overlap_t_) >zero)
{ {
if constexpr (limited) if constexpr (limited)
{ {

View File

@ -96,10 +96,10 @@ public:
realx3 w_hat = wi-wj; realx3 w_hat = wi-wj;
real w_hat_mag = length(w_hat); real w_hat_mag = length(w_hat);
if( !equal(w_hat_mag,0.0) ) if( !equal(w_hat_mag,zero) )
w_hat /= w_hat_mag; w_hat /= w_hat_mag;
else else
w_hat = 0.0; w_hat = zero;
auto Reff = (Ri*Rj)/(Ri+Rj); auto Reff = (Ri*Rj)/(Ri+Rj);

View File

@ -94,10 +94,10 @@ public:
realx3 w_hat = wi-wj; realx3 w_hat = wi-wj;
real w_hat_mag = length(w_hat); real w_hat_mag = length(w_hat);
if( !equal(w_hat_mag,0.0) ) if( !equal(w_hat_mag,zero) )
w_hat /= w_hat_mag; w_hat /= w_hat_mag;
else else
w_hat = 0.0; w_hat = zero;
auto Reff = (Ri*Rj)/(Ri+Rj); auto Reff = (Ri*Rj)/(Ri+Rj);

View File

@ -11,7 +11,7 @@ pFlow::wallBoundaryContactSearch::wallBoundaryContactSearch
const ViewType1D<realx3, memory_space> &normals const ViewType1D<realx3, memory_space> &normals
) )
: :
cellExtent_( max(cellExtent, 0.5 ) ), cellExtent_( max(cellExtent, half ) ),
numElements_(numElements), numElements_(numElements),
numPoints_(numPoints), numPoints_(numPoints),
vertices_(vertices), vertices_(vertices),

View File

@ -31,6 +31,7 @@ pFlow::contactSearch::contactSearch(
Timers& timers) Timers& timers)
: :
extendedDomainBox_(extDomain), extendedDomainBox_(extDomain),
updateInterval_(dict.getValMax<uint32>("updateInterval", 1u)),
particles_(prtcl), particles_(prtcl),
geometry_(geom), geometry_(geom),
bTimer_("Boundary particles contact search", &timers), bTimer_("Boundary particles contact search", &timers),

View File

@ -44,8 +44,8 @@ pFlow::NBS::NBS
position, position,
flags, flags,
diam), diam),
sizeRatio_(max(dict.getVal<real>("sizeRatio"), 1.0)), sizeRatio_(max(dict.getVal<real>("sizeRatio"), one)),
cellExtent_(max(dict.getVal<real>("cellExtent"), 0.5)), cellExtent_(max(dict.getVal<real>("cellExtent"), half)),
adjustableBox_(dict.getVal<Logical>("adjustableBox")), adjustableBox_(dict.getVal<Logical>("adjustableBox")),
NBSLevel0_ NBSLevel0_
( (

View File

@ -31,7 +31,7 @@ pFlow::cellsWallLevel0::cellsWallLevel0
const ViewType1D<realx3, memory_space>& normals const ViewType1D<realx3, memory_space>& normals
) )
: :
cellExtent_( max(cellExtent, 0.5 ) ), cellExtent_( max(cellExtent, half ) ),
numElements_(numElements), numElements_(numElements),
numPoints_(numPoints), numPoints_(numPoints),
vertices_(vertices), vertices_(vertices),

View File

@ -47,7 +47,7 @@ pFlow::rotatingAxis::rotatingAxis
timeInterval(), timeInterval(),
line(p1, p2), line(p1, p2),
omega_(omega), omega_(omega),
rotating_(!equal(omega,0.0)) rotating_(!equal(omega,zero))
{ {
} }
@ -58,7 +58,7 @@ pFlow::real pFlow::rotatingAxis::setOmega(real omega)
{ {
auto tmp = omega_; auto tmp = omega_;
omega_ = omega; omega_ = omega;
rotating_ = !equal(omega, 0.0); rotating_ = !equal(omega, zero);
return tmp; return tmp;
} }
@ -72,7 +72,7 @@ bool pFlow::rotatingAxis::read
if(!timeInterval::read(dict))return false; if(!timeInterval::read(dict))return false;
if(!line::read(dict)) return false; if(!line::read(dict)) return false;
real omega = dict.getValOrSet("omega", 0.0); real omega = dict.getValOrSet("omega", zero);
setOmega(omega); setOmega(omega);
return true; return true;

View File

@ -239,7 +239,7 @@ public:
{ {
real nr = 0.5*(sqrt(8.0*nElem+1)-1); real nr = 0.5*(sqrt(8.0*nElem+1)-1);
n = static_cast<uint32>(nr); n = static_cast<uint32>(nr);
if( equal(nr-static_cast<real>(n) , 0.0) ) return true; if( equal(nr-static_cast<real>(n) , zero) ) return true;
return false; return false;
} }

View File

@ -111,7 +111,7 @@ public:
{ {
if(!isInRange(val)) return false; if(!isInRange(val)) return false;
if(T dist = val-begin_; abs(dist%stride_)<= epsilon) return true; if(const T dist = val-begin_; abs(dist%stride_)<=epsilon) return true;
if(equal(val,begin_))return true; if(equal(val,begin_))return true;
if(equal(val,end_))return true; if(equal(val,end_))return true;
return false; return false;
@ -151,19 +151,34 @@ public:
template<> template<>
inline inline
bool stridedRange<real>::isMember(real val, real epsilon)const bool stridedRange<float>::isMember(float val, float epsilon)const
{ {
if(!isInRange(val)) return false; /*if(!isInRange(val)) return false;
real dist = val-begin_; real dist = val-begin_;
if(abs( if(abs(
(dist-(static_cast<uint64>((dist+0.01*epsilon)/stride_)*stride_)) (dist-(static_cast<uint64>((dist+0.01*epsilon)/stride_)*stride_))
)<= epsilon) return true; )<= epsilon) return true;
if(equal(val,begin_))return true; if(equal(val,begin_))return true;
if(equal(val,end_))return true; if(equal(val,end_))return true;
return false;*/
if(!isInRange(val)) return false;
if(const float dist = val-begin_; abs(remainder(dist,stride_)<= epsilon)) return true;
if(equal(val,begin_))return true;
if(equal(val,end_))return true;
return false; return false;
} }
template<>
inline
bool stridedRange<double>::isMember(double val, double epsilon)const
{
if(!isInRange(val)) return false;
if(const double dist = val-begin_; abs(remainder(dist,stride_)<= epsilon)) return true;
if(equal(val,begin_))return true;
if(equal(val,end_))return true;
return false;
}
} }

View File

@ -25,7 +25,7 @@ Licence:
bool pFlow::timeControl::screenReport()const bool pFlow::timeControl::screenReport()const
{ {
return screenReportInterval_.isMember(currentIter_); return screenReportInterval_.isMember(ti_.currentIter());
} }
pFlow::timeControl::timeControl pFlow::timeControl::timeControl
@ -36,16 +36,16 @@ pFlow::timeControl::timeControl
ti_(dict), ti_(dict),
startTime_ startTime_
( (
dict.getVal<real>("startTime") dict.getVal<timeValue>("startTime")
), ),
endTime_ endTime_
( (
dict.getVal<real>("endTime") dict.getVal<timeValue>("endTime")
), ),
stopAt_(endTime_), stopAt_(endTime_),
saveInterval_ saveInterval_
( (
dict.getVal<real>("saveInterval") dict.getVal<timeValue>("saveInterval")
), ),
lastSaved_(startTime_), lastSaved_(startTime_),
performSorting_ performSorting_
@ -65,50 +65,40 @@ pFlow::timeControl::timeControl
pFlow::timeControl::timeControl( pFlow::timeControl::timeControl(
dictionary& dict, dictionary& dict,
real startTime, timeValue startTime,
real endTime, timeValue endTime,
real saveInterval, timeValue saveInterval,
word startTimeName) word startTimeName)
: :
dt_ ti_(startTime, dict),
(
dict.getVal<real>("dt")
),
startTime_(startTime), startTime_(startTime),
endTime_(endTime), endTime_(endTime),
stopAt_(endTime_), stopAt_(endTime_),
currentTime_(startTime_),
saveInterval_(saveInterval), saveInterval_(saveInterval),
lastSaved_(startTime_), lastSaved_(startTime_),
currentIter_(0),
timePrecision_
(
dict.getValOrSet("timePrecision", 4)
),
managedExternaly_(true), managedExternaly_(true),
timeName_(startTimeName),
timersReportInterval_
(
startTime_,
dict.getValOrSet("timersReportInterval", 0.04)
),
performSorting_ performSorting_
( (
dict.getValOrSet("performSorting", Logical("No")) dict.getValOrSet("performSorting", Logical("No"))
),
sortingInterval_
(
startTime_,
dict.getValOrSet("sortingInterval", static_cast<real>(1.0))
) )
{ {
timeName_ = startTimeName;
timersReportInterval_ = timeStridedRange(
startTime_,
dict.getValOrSet("timersReportInterval", 0.04));
sortingInterval_ = timeStridedRange(
startTime_,
dict.getValOrSet("sortingInterval", 1.0));
checkForOutputToFile(); checkForOutputToFile();
} }
pFlow::real pFlow::timeControl::setTime(real t) pFlow::timeValue pFlow::timeControl::setTime(timeValue t)
{ {
real tmp = currentTime_; timeValue tmp = ti_.currentTime();
currentTime_ = t; ti_.currentTime_ = t;
lastSaved_ = t; lastSaved_ = t;
checkForOutputToFile(); checkForOutputToFile();
return tmp; return tmp;
@ -124,15 +114,15 @@ pFlow::word pFlow::timeControl::timeName()const
bool pFlow::timeControl::finalTime()const bool pFlow::timeControl::finalTime()const
{ {
if( currentTime_ >= endTime_ ) return true; if( ti_.currentTime_ >= endTime_ ) return true;
if( std::abs(currentTime_-endTime_) < 0.5*dt_ )return true; if( std::abs(ti_.currentTime_-endTime_) < 0.5*ti_.dt_ )return true;
return false; return false;
} }
bool pFlow::timeControl::reachedStopAt()const bool pFlow::timeControl::reachedStopAt()const
{ {
if( currentTime_ >= stopAt_ ) return true; if( ti_.currentTime_ >= stopAt_ ) return true;
if( std::abs(currentTime_-stopAt_) < 0.5*dt_ )return true; if( std::abs(ti_.currentTime_-stopAt_) < 0.5*ti_.dt_ )return true;
return false; return false;
} }
@ -142,22 +132,22 @@ void pFlow::timeControl::checkForOutputToFile()
bool save = false; bool save = false;
if(managedExternaly_) if(managedExternaly_)
{ {
if( std::abs(currentTime_-writeTime_) < 0.5*dt_) if( std::abs(ti_.currentTime_-writeTime_) < 0.5*ti_.dt_)
{ {
save = true; save = true;
lastSaved_ = currentTime_; lastSaved_ = ti_.currentTime_;
} }
} }
else else
{ {
if ( std::abs(currentTime_ - lastSaved_ - saveInterval_) < 0.5 * dt_ ) if ( std::abs(ti_.currentTime_ - lastSaved_ - saveInterval_) < 0.5 * ti_.dt_ )
{ {
lastSaved_ = currentTime_; lastSaved_ = ti_.currentTime_;
save = true; save = true;
} }
else if( std::abs(currentTime_ - lastSaved_) < std::min( pow(10.0,-1.0*timePrecision_), static_cast<real>(0.5 *dt_)) ) else if( std::abs(ti_.currentTime_ - lastSaved_) < std::min( std::pow(10.0,-1.0*ti_.precision()), 0.5 *ti_.dt_) )
{ {
lastSaved_ = currentTime_; lastSaved_ = ti_.currentTime_;
save = true; save = true;
} }
@ -168,13 +158,13 @@ void pFlow::timeControl::checkForOutputToFile()
bool pFlow::timeControl::timersReportTime()const bool pFlow::timeControl::timersReportTime()const
{ {
if(currentIter_<=1)return false; if(ti_.currentIter_<=1)return false;
return timersReportInterval_.isMember(currentTime_, 0.55*dt_); return timersReportInterval_.isMember(ti_.currentTime_, 0.55*ti_.dt_);
} }
bool pFlow::timeControl::sortTime()const bool pFlow::timeControl::sortTime()const
{ {
return performSorting_()&&sortingInterval_.isMember(currentTime_,dt_); return performSorting_()&&sortingInterval_.isMember(ti_.currentTime_,ti_.dt_);
} }
void pFlow::timeControl::setSaveTimeFolder( void pFlow::timeControl::setSaveTimeFolder(
@ -192,10 +182,10 @@ bool pFlow::timeControl::operator ++(int)
{ {
if( reachedStopAt() ) return false; if( reachedStopAt() ) return false;
// increament iteration number
currentIter_++;
currentTime_ += dt_; // increament iteration number
ti_.martchDT();
if(screenReport() && !managedExternaly_) if(screenReport() && !managedExternaly_)
{ {
REPORT(0)<<"Time (s): "<<Cyan_Text( currentTimeWord() )<<END_REPORT; REPORT(0)<<"Time (s): "<<Cyan_Text( currentTimeWord() )<<END_REPORT;

View File

@ -36,53 +36,51 @@ class dictionary;
class timeControl class timeControl
{ {
public:
using timeStridedRange = stridedRange<timeValue>;
private: private:
//// - Data members //// - Data members
// - integration time step // - time information
real dt_; timeInfo ti_;
// - start time of simulation // - start time of simulation
real startTime_; timeValue startTime_;
// - end time of simulation // - end time of simulation
real endTime_; timeValue endTime_;
// - stopAt // - stopAt
real stopAt_; timeValue stopAt_;
// - current time of simulation
real currentTime_;
// - time interval for time folder output // - time interval for time folder output
real saveInterval_; timeValue saveInterval_;
// - the last time folder that was saved // - the last time folder that was saved
real lastSaved_; timeValue lastSaved_;
// - current iteration number (for this execution)
int32 currentIter_;
// - time precision for output time folders
int32 timePrecision_;
bool managedExternaly_ = false; bool managedExternaly_ = false;
word timeName_ = "wrongSettings"; // for managedExternamly bool outputToFile_ = false;
real writeTime_ = 0; // for managedExternamly
realStridedRange timersReportInterval_;
Logical performSorting_; Logical performSorting_;
realStridedRange sortingInterval_; static
inline int32StridedRagne screenReportInterval_ ={0,100};
int32StridedRagne screenReportInterval_ ={0,100}; static
inline timeStridedRange timersReportInterval_{0,100};
bool outputToFile_ = false; static
inline timeStridedRange sortingInterval_{0,100};
static
inline word timeName_ = "wrongSettings"; // for managedExternamly
static
inline timeValue writeTime_ = 0; // for managedExternamly
void checkForOutputToFile(); void checkForOutputToFile();
@ -94,22 +92,22 @@ public:
timeControl( timeControl(
dictionary& dict, dictionary& dict,
real startTime, timeValue startTime,
real endTime, timeValue endTime,
real saveInterval, timeValue saveInterval,
word startTimeName); word startTimeName);
virtual ~timeControl() = default; virtual ~timeControl() = default;
real dt()const timeValue dt()const
{ {
return dt_; return ti_.dt();
} }
real setTime(real t); timeValue setTime(timeValue t);
void setStopAt(real sT) void setStopAt(timeValue sT)
{ {
if(managedExternaly_) if(managedExternaly_)
{ {
@ -117,37 +115,27 @@ public:
} }
} }
real startTime()const timeValue startTime()const
{ {
return startTime_; return startTime_;
} }
word timeName()const; word timeName()const;
real currentTime() const timeValue currentTime() const
{ {
return currentTime_; return ti_.currentTime();
} }
word currentTimeWord(bool forSave = true)const word currentTimeWord(bool forSave = true)const
{ {
return real2FixedStripZeros( currentTime(), timePrecision()); return ti_.timeName();
/*if(forSave)
{
if(!managedExternaly_)
else
return timeName_;
}
else
{
return real2FixedStripZeros( currentTime(), timePrecision());
}*/
} }
int32 currentIter()const int32 currentIter()const
{ {
return currentIter_; return ti_.currentIter();
} }
bool finalTime()const; bool finalTime()const;
@ -179,17 +167,17 @@ public:
bool saveToFile, bool saveToFile,
const word& timeName = "wrongTimeFolder"); const word& timeName = "wrongTimeFolder");
int32 timePrecision()const
{
return timePrecision_;
}
inline inline
timeInfo TimeInfo()const const timeInfo& TimeInfo()const
{ {
return {static_cast<uint32>(currentIter_), currentTime_, dt_}; return ti_;
} }
static
int32 timePrecision()
{
return timeInfo::precision();
}
}; };

View File

@ -21,6 +21,7 @@ Licence:
#define __timeInfo__hpp_ #define __timeInfo__hpp_
#include "types.hpp" #include "types.hpp"
#include "dictionary.hpp"
namespace pFlow namespace pFlow
{ {
@ -29,33 +30,87 @@ class timeInfo
{ {
private: private:
uint32 currentIter_; friend class timeControl;
real currentTime_; // - current iteration number (for this execution)
int32 currentIter_;
real dt_; // - current time of simulation
timeValue currentTime_;
// - integration time step
timeValue dt_;
inline static int32 presicion_ = 5;
public: public:
timeInfo(uint32 cIter, real cTime, real dt) timeInfo(int32 cIter, timeValue cTime, timeValue dt)
: currentIter_(cIter), : currentIter_(cIter),
currentTime_(cTime), currentTime_(cTime),
dt_(dt) dt_(dt)
{ {
} }
inline const real& t() const timeInfo(const dictionary& dict)
:
currentIter_(0),
currentTime_(dict.getVal<timeValue>("startTime")),
dt_( dict.getVal<timeValue>("dt"))
{
presicion_ = dict.getValOrSet<int32>("timePrecision",5);
}
timeInfo(timeValue currentTime, const dictionary& dict)
:
currentIter_(0),
currentTime_(currentTime),
dt_( dict.getVal<timeValue>("dt"))
{
presicion_ = dict.getValOrSet<int32>("timePrecision",5);
}
inline const timeValue& currentTime()const
{ {
return currentTime_; return currentTime_;
} }
inline const real& dt() const
inline const timeValue& t() const
{
return currentTime_;
}
inline const timeValue& dt() const
{ {
return dt_; return dt_;
} }
inline const uint32& iter() const inline const int32& iter() const
{ {
return currentIter_; return currentIter_;
} }
inline const int32& currentIter() const
{
return currentIter_;
}
inline
void martchDT()
{
currentIter_++;
currentTime_ += dt_;
}
inline
word timeName()const
{
return real2FixedStripZeros(currentTime_, presicion_);
}
static
int32 precision()
{
return presicion_;
}
}; };
} // namespace pFlow } // namespace pFlow

View File

@ -29,7 +29,7 @@ pFlow::infinitePlane::infinitePlane
{ {
auto ln = cross(p2-p1, p3-p1); auto ln = cross(p2-p1, p3-p1);
if( equal(ln.length(),0.0) ) if( equal(ln.length(),zero) )
{ {
fatalErrorInFunction<< fatalErrorInFunction<<
"invalid input to form a infinte wall "<< realx3x3(p1,p2,p3)<<endl; "invalid input to form a infinte wall "<< realx3x3(p1,p2,p3)<<endl;
@ -60,5 +60,5 @@ bool pFlow::infinitePlane::validPlane3
const realx3& p3 const realx3& p3
) )
{ {
return !equal(cross(p2-p1, p3-p1).length(), 0.0); return !equal(cross(p2-p1, p3-p1).length(), zero);
} }

View File

@ -22,7 +22,6 @@ Licence:
#define __infinitePlane_hpp__ #define __infinitePlane_hpp__
#include "types.hpp" #include "types.hpp"
//#include "dictionary.hpp"
#include "iIstream.hpp" #include "iIstream.hpp"
#include "iOstream.hpp" #include "iOstream.hpp"
@ -113,20 +112,20 @@ public:
bool inPositiveDistance(const realx3& p, real dist)const bool inPositiveDistance(const realx3& p, real dist)const
{ {
real d = pointFromPlane(p); real d = pointFromPlane(p);
return d >= 0.0 && d <= dist; return d >= zero && d <= dist;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool inNegativeDistance(const realx3& p, real dist)const bool inNegativeDistance(const realx3& p, real dist)const
{ {
real d = pointFromPlane(p); real d = pointFromPlane(p);
return d < 0.0 && d >= -dist; return d < zero && d >= -dist;
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool pointOnPlane(const realx3& p)const bool pointOnPlane(const realx3& p)const
{ {
return equal(pointFromPlane(p),0.0); return equal(pointFromPlane(p),zero);
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD

View File

@ -38,8 +38,8 @@ INLINE_FUNCTION_HD
realx3 normal(const realx3& p1, const realx3& p2, const realx3& p3) realx3 normal(const realx3& p1, const realx3& p2, const realx3& p3)
{ {
auto n = cross(p2-p1, p3-p1); auto n = cross(p2-p1, p3-p1);
if( equal(n.length(), 0.0) ) if( equal(n.length(), zero) )
return realx3(0); return zero3;
else else
return normalize(n); return normalize(n);
} }
@ -52,11 +52,9 @@ bool valid
const realx3& p3 const realx3& p3
) )
{ {
return !equal(cross(p2-p1, p3-p1).length(), 0.0); return !equal(cross(p2-p1, p3-p1).length(), zero);
} }
} }
#endif #endif

View File

@ -81,7 +81,7 @@ pFlow::isNo(const word& str)
} }
pFlow::word pFlow::word
pFlow::real2Fixed(const real& v, int32 numPrecision) pFlow::real2Fixed(const float& v, int32 numPrecision)
{ {
std::stringstream ss; std::stringstream ss;
@ -90,7 +90,32 @@ pFlow::real2Fixed(const real& v, int32 numPrecision)
} }
pFlow::word pFlow::word
pFlow::real2Word(const real& v, int32 numPrecision) pFlow::real2Fixed(const double& v, int32 numPrecision)
{
std::stringstream ss;
ss << std::fixed << std::setprecision(numPrecision) << v;
return ss.str();
}
pFlow::word
pFlow::real2Word(const float& v, int32 numPrecision)
{
std::stringstream ss;
if (abs(v) < verySmallValue)
{
ss << "0";
}
else
{
ss << std::setprecision(numPrecision) << v;
}
return ss.str();
}
pFlow::word
pFlow::real2Word(const double& v, int32 numPrecision)
{ {
std::stringstream ss; std::stringstream ss;
if (abs(v) < verySmallValue) if (abs(v) < verySmallValue)
@ -145,7 +170,14 @@ pFlow::removeDecimalZeros(const word& str)
} }
pFlow::word pFlow::word
pFlow::real2FixedStripZeros(const real& v, int32 numPrecision) pFlow::real2FixedStripZeros(const float& v, int32 numPrecision)
{
word strVal = real2Fixed(v, numPrecision);
return removeDecimalZeros(strVal);
}
pFlow::word
pFlow::real2FixedStripZeros(const double& v, int32 numPrecision)
{ {
word strVal = real2Fixed(v, numPrecision); word strVal = real2Fixed(v, numPrecision);
return removeDecimalZeros(strVal); return removeDecimalZeros(strVal);

View File

@ -39,6 +39,8 @@ inline const real zero = 0.0;
/// one real variable /// one real variable
inline const real one = 1.0; inline const real one = 1.0;
inline const real half = 0.5;
/// zero int32 variable /// zero int32 variable
inline const int32 zero32 = 0; inline const int32 zero32 = 0;
@ -76,11 +78,17 @@ isNo(const word& str);
/// Convert floating point variable to string with fixed number of precisions /// Convert floating point variable to string with fixed number of precisions
word word
real2Fixed(const real& v, int32 numPrecision = 6); real2Fixed(const float& v, int32 numPrecision = 6);
word
real2Fixed(const double& v, int32 numPrecision = 6);
/// Convert floating point variable to string with general format /// Convert floating point variable to string with general format
word word
real2Word(const real& v, int32 numPrecision = 6); real2Word(const float& v, int32 numPrecision = 6);
word
real2Word(const double& v, int32 numPrecision = 6);
/// Convert int32 to word /// Convert int32 to word
word word
@ -92,7 +100,10 @@ removeDecimalZeros(const word& str);
/// Convert to fixed point variable and remove zeros /// Convert to fixed point variable and remove zeros
word word
real2FixedStripZeros(const real& v, int32 numPrecision = 6); real2FixedStripZeros(const float& v, int32 numPrecision = 6);
word
real2FixedStripZeros(const double& v, int32 numPrecision = 6);
/// Output <w1,w2> /// Output <w1,w2>
word word
@ -225,7 +236,14 @@ readValue(const word& w, bool& val)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
bool bool
equal(const real& s1, const real& s2, real tol = smallValue) equal(const float& s1, const float& s2, float tol = smallValue)
{
return abs(s1 - s2) <= tol;
}
INLINE_FUNCTION_HD
bool
equal(const double& s1, const double& s2, double tol = smallValue)
{ {
return abs(s1 - s2) <= tol; return abs(s1 - s2) <= tol;
} }

View File

@ -63,6 +63,8 @@ using size_t = std::size_t;
using word = std::string; using word = std::string;
using timeValue = double;
inline const int numBytesForReal__ = sizeof(real); inline const int numBytesForReal__ = sizeof(real);
inline word inline word

View File

@ -42,8 +42,19 @@ namespace pFlow
{ {
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real double
abs(real x) abs(double x)
{
#ifdef __CUDACC__
return ::fabs(x);
#else
return std::fabs(x);
#endif
}
INLINE_FUNCTION_HD
float
abs(float x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::fabs(x); return ::fabs(x);
@ -73,8 +84,18 @@ abs(int32 x)
#endif #endif
} }
INLINE_FUNCTION_HD real INLINE_FUNCTION_HD float
mod(real x, real y) mod(float x, float y)
{
#ifdef __CUDACC__
return ::fmod(x, y);
#else
return std::fmod(x, y);
#endif
}
INLINE_FUNCTION_HD double
mod(double x, double y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::fmod(x, y); return ::fmod(x, y);
@ -108,8 +129,18 @@ mod(uint32 x, uint32 y)
return x % y; return x % y;
} }
INLINE_FUNCTION_HD real INLINE_FUNCTION_HD float
remainder(real x, real y) remainder(float x, float y)
{
#ifdef __CUDACC__
return ::remainder(x,y);
#else
return std::remainder(x, y);
#endif
}
INLINE_FUNCTION_HD double
remainder(double x, double y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::remainder(x,y); return ::remainder(x,y);
@ -120,8 +151,19 @@ remainder(real x, real y)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real float
exp(real x) exp(float x)
{
#ifdef __CUDACC__
return ::exp(x);
#else
return std::exp(x);
#endif
}
INLINE_FUNCTION_HD
double
exp(double x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::exp(x); return ::exp(x);
@ -132,8 +174,17 @@ exp(real x)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real float log(float x)
log(real x) {
#ifdef __CUDACC__
return ::log(x);
#else
return std::log(x);
#endif
}
INLINE_FUNCTION_HD
double log(double x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::log(x); return ::log(x);
@ -144,8 +195,7 @@ log(real x)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real float log10(float x)
log10(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::log10(x); return ::log10(x);
@ -155,8 +205,27 @@ log10(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real double log10(double x)
pow(real x, real y) {
#ifdef __CUDACC__
return ::log10(x);
#else
return std::log10(x);
#endif
}
INLINE_FUNCTION_HD
float pow(float x, float y)
{
#ifdef __CUDACC__
return ::pow(x,y);
#else
return std::pow(x, y);
#endif
}
INLINE_FUNCTION_HD
double pow(double x, double y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::pow(x,y); return ::pow(x,y);
@ -167,8 +236,17 @@ pow(real x, real y)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real float sqrt(float x)
sqrt(real x) {
#ifdef __CUDACC__
return ::sqrt(x);
#else
return std::sqrt(x);
#endif
}
INLINE_FUNCTION_HD
double sqrt(double x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::sqrt(x); return ::sqrt(x);
@ -180,8 +258,7 @@ sqrt(real x)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real float cbrt(float x)
cbrt(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::cbrt(x); return ::cbrt(x);
@ -191,8 +268,17 @@ cbrt(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real double cbrt(double x)
sin(real x) {
#ifdef __CUDACC__
return ::cbrt(x);
#else
return std::cbrt(x);
#endif
}
INLINE_FUNCTION_HD
float sin(float x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::sin(x); return ::sin(x);
@ -202,8 +288,17 @@ sin(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real double sin(double x)
cos(real x) {
#ifdef __CUDACC__
return ::sin(x);
#else
return std::sin(x);
#endif
}
INLINE_FUNCTION_HD
real cos(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::cos(x); return ::cos(x);
@ -215,8 +310,7 @@ cos(real x)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real real tan(real x)
tan(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::tan(x); return ::tan(x);
@ -226,8 +320,7 @@ tan(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real real asin(real x)
asin(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::asin(x); return ::asin(x);
@ -237,8 +330,7 @@ asin(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real real acos(real x)
acos(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::acos(x); return ::acos(x);
@ -248,8 +340,7 @@ acos(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real real atan(real x)
atan(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::atan(x); return ::atan(x);
@ -269,8 +360,7 @@ atan2(real y, real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real real sinh(real x)
sinh(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::sinh(x); return ::sinh(x);
@ -280,8 +370,7 @@ sinh(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real real cosh(real x)
cosh(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::cosh(x); return ::cosh(x);
@ -322,8 +411,7 @@ acosh(real x)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
real real atanh(real x)
atanh(real x)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::atanh(x); return ::atanh(x);
@ -333,8 +421,8 @@ atanh(real x)
} }
INLINE_FUNCTION_HD real INLINE_FUNCTION_HD
min(real x, real y) float min(float x, float y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::fmin(x, y); return ::fmin(x, y);
@ -344,8 +432,17 @@ min(real x, real y)
} }
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
int64 double min(double x, double y)
min(int32 x, int32 y) {
#ifdef __CUDACC__
return ::fmin(x, y);
#else
return std::fmin(x, y);
#endif
}
INLINE_FUNCTION_HD
int64 min(int32 x, int32 y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::min(x,y); return ::min(x,y);
@ -356,8 +453,7 @@ min(int32 x, int32 y)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
int64 int64 min(int64 x, int64 y)
min(int64 x, int64 y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::min(x,y); return ::min(x,y);
@ -369,8 +465,17 @@ min(int64 x, int64 y)
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
uint64 uint64 min(uint64 x, uint64 y)
min(uint64 x, uint64 y) {
#ifdef __CUDACC__
return ::min(x,y);
#else
return std::min(x, y);
#endif
}
INLINE_FUNCTION_HD
uint32 min(uint32 x, uint32 y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::min(x,y); return ::min(x,y);
@ -380,20 +485,18 @@ min(uint64 x, uint64 y)
} }
INLINE_FUNCTION_HD
INLINE_FUNCTION_HD uint32 float max(float x, float y)
min(uint32 x, uint32 y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::min(x,y); return ::fmax(x, y);
#else #else
return std::min(x, y); return std::fmax(x, y);
#endif #endif
} }
INLINE_FUNCTION_HD
INLINE_FUNCTION_HD real double max(double x, double y)
max(real x, real y)
{ {
#ifdef __CUDACC__ #ifdef __CUDACC__
return ::fmax(x, y); return ::fmax(x, y);

View File

@ -103,7 +103,7 @@ int main(int argc, char** argv )
continue; continue;
} }
if( !withZeroFolder && pFlow::equal(folders.time() , 0.0))continue; if( !withZeroFolder && pFlow::equal(folders.time() , pFlow::zero))continue;
post.processTimeFolder(folders); post.processTimeFolder(folders);