change in the type name of timeValue and sample dictionaries for settingsDict and domain

This commit is contained in:
Hamidreza 2025-05-15 12:00:13 +03:30
parent ab856e1df2
commit bf0197f643
30 changed files with 300 additions and 158 deletions

View File

@ -96,7 +96,7 @@ public:
return Control_(); return Control_();
} }
auto inline constexpr usingDoulle()const auto inline constexpr usingDouble()const
{ {
return pFlow::usingDouble__; return pFlow::usingDouble__;
} }

View File

@ -359,7 +359,7 @@ bool pFlow::sphereInteraction<cFM,gMM, cLT>::hearChanges
if(msg.equivalentTo(message::ITEMS_REARRANGE)) if(msg.equivalentTo(message::ITEMS_REARRANGE))
{ {
notImplementedFunction; notImplementedFunction;
return false; return true;
} }
fatalErrorInFunction<<"Event "<< msg.eventNames()<< fatalErrorInFunction<<"Event "<< msg.eventNames()<<

View File

@ -467,7 +467,7 @@ pFlow::postprocessData::fieldsDataBase::fieldsDataBase
systemControl& control, systemControl& control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime TimeValueType startTime
) )
: :
time_(control.time()), time_(control.time()),
@ -492,7 +492,7 @@ pFlow::postprocessData::fieldsDataBase::fieldsDataBase
} }
} }
pFlow::timeValue pFlow::postprocessData::fieldsDataBase::currentTime() const pFlow::TimeValueType pFlow::postprocessData::fieldsDataBase::currentTime() const
{ {
return time_.currentTime(); return time_.currentTime();
} }
@ -914,7 +914,7 @@ pFlow::uniquePtr<pFlow::postprocessData::fieldsDataBase>
systemControl& control, systemControl& control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime TimeValueType startTime
) )
{ {
word dbType; word dbType;

View File

@ -78,7 +78,7 @@ private:
anyList allFields_; anyList allFields_;
/// Map to store the last capture time of each field /// Map to store the last capture time of each field
wordMap<timeValue> captureTime_; wordMap<TimeValueType> captureTime_;
/// Reference to the Time object /// Reference to the Time object
Time& time_; Time& time_;
@ -178,7 +178,7 @@ public:
systemControl& control, systemControl& control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime); TimeValueType startTime);
/// no copy constructor /// no copy constructor
fieldsDataBase(const fieldsDataBase&) = delete; fieldsDataBase(const fieldsDataBase&) = delete;
@ -203,7 +203,7 @@ public:
systemControl& control, systemControl& control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime TimeValueType startTime
), ),
(control, postDict, inSimulation, startTime) (control, postDict, inSimulation, startTime)
); );
@ -211,7 +211,7 @@ public:
// - Public Access Functions // - Public Access Functions
/// returns the current time /// returns the current time
timeValue currentTime()const; TimeValueType currentTime()const;
/// const ref to object Time /// const ref to object Time
const Time& time()const const Time& time()const
@ -282,7 +282,7 @@ public:
/// Get the next avaiable time folder after the current time folder /// Get the next avaiable time folder after the current time folder
/// This is only used for post-simulation processing /// This is only used for post-simulation processing
virtual virtual
timeValue getNextTimeFolder()const TimeValueType getNextTimeFolder()const
{ {
return -1.0; return -1.0;
} }
@ -291,7 +291,7 @@ public:
/// This is used only for post-simulation processing /// This is used only for post-simulation processing
/// @returns the time value of the next folder. /// @returns the time value of the next folder.
virtual virtual
timeValue setToNextTimeFolder() TimeValueType setToNextTimeFolder()
{ {
return -1.0; return -1.0;
} }
@ -300,7 +300,7 @@ public:
/// This is used only for post-simulation processing /// This is used only for post-simulation processing
/// @returns the time value of the skipped folder /// @returns the time value of the skipped folder
virtual virtual
timeValue skipNextTimeFolder() TimeValueType skipNextTimeFolder()
{ {
return -1.0; return -1.0;
} }
@ -316,7 +316,7 @@ public:
systemControl& control, systemControl& control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime); TimeValueType startTime);
}; };
} // namespace pFlow::postprocessData } // namespace pFlow::postprocessData

View File

@ -49,7 +49,7 @@ pFlow::postprocessData::simulationFieldsDataBase::simulationFieldsDataBase
systemControl &control, systemControl &control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime TimeValueType startTime
) )
: :
fieldsDataBase(control, postDict, inSimulation, startTime), fieldsDataBase(control, postDict, inSimulation, startTime),

View File

@ -60,7 +60,7 @@ public:
systemControl& control, systemControl& control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime); TimeValueType startTime);
~simulationFieldsDataBase() override = default; ~simulationFieldsDataBase() override = default;

View File

@ -86,12 +86,12 @@ private:
word fieldName_; word fieldName_;
/// Timestamp when mask was last updated (-1 indicates never updated) /// Timestamp when mask was last updated (-1 indicates never updated)
timeValue lastUpdated_ = -1; TimeValueType lastUpdated_ = -1;
/// Updates the mask based on current field values if needed, returns true if successful /// Updates the mask based on current field values if needed, returns true if successful
bool updateMask() bool updateMask()
{ {
timeValue t = database().currentTime(); TimeValueType t = database().currentTime();
if( equal( t, lastUpdated_)) return true; if( equal( t, lastUpdated_)) return true;
@ -206,11 +206,11 @@ private:
std::vector<bool> mask_; std::vector<bool> mask_;
timeValue lastUpdated_ = -1; TimeValueType lastUpdated_ = -1;
bool updateMask() bool updateMask()
{ {
timeValue t = database().currentTime(); TimeValueType t = database().currentTime();
if( equal( t, lastUpdated_)) return true; if( equal( t, lastUpdated_)) return true;

View File

@ -46,7 +46,7 @@ inline
bool writeField bool writeField
( (
iOstream& os, iOstream& os,
timeValue t, TimeValueType t,
const regionField<T> field, const regionField<T> field,
uint32 threshold, uint32 threshold,
const T& defValue=T{} const T& defValue=T{}

View File

@ -52,7 +52,7 @@ template<typename T>
inline bool writeField inline bool writeField
( (
iOstream& os, iOstream& os,
timeValue t, TimeValueType t,
const regionField<T>& field, const regionField<T>& field,
const regionPoints& regPoints, const regionPoints& regPoints,
const T& invalidVal = T{} const T& invalidVal = T{}

View File

@ -27,7 +27,7 @@ Licence:
pFlow::postprocessData::postprocessData::postprocessData pFlow::postprocessData::postprocessData::postprocessData
( (
const systemControl &control, const systemControl &control,
timeValue startTime TimeValueType startTime
) )
: :
auxFunctions(control), auxFunctions(control),

View File

@ -85,7 +85,7 @@ public:
/// this constructor is used when postprocesing is active /// this constructor is used when postprocesing is active
/// during simulation. /// during simulation.
/// @param control const reference to systemControl /// @param control const reference to systemControl
postprocessData(const systemControl& control, timeValue startTime = -1.0); postprocessData(const systemControl& control, TimeValueType startTime = -1.0);
~postprocessData()override = default; ~postprocessData()override = default;

View File

@ -55,7 +55,7 @@ private:
mutable T* data_ = nullptr; mutable T* data_ = nullptr;
index size_ = 0; IndexType size_ = 0;
public: public:
@ -104,7 +104,7 @@ public:
/// Returns the number of elements in the span /// Returns the number of elements in the span
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
index size() const IndexType size() const
{ {
return size_; return size_;
} }
@ -139,14 +139,14 @@ public:
/// Returns a reference to the element at the specified index /// Returns a reference to the element at the specified index
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T& operator[](index i) T& operator[](IndexType i)
{ {
return data_[i]; return data_[i];
} }
/// Returns a const reference to the element at the specified index /// Returns a const reference to the element at the specified index
INLINE_FUNCTION_HD INLINE_FUNCTION_HD
T& operator[](index i)const T& operator[](IndexType i)const
{ {
return data_[i]; return data_[i];
} }

View File

@ -23,21 +23,21 @@ Licence:
void pFlow::baseTimeControl::setTimeControl void pFlow::baseTimeControl::setTimeControl
( (
timeValue startTime, TimeValueType startTime,
timeValue endTime, TimeValueType endTime,
timeValue interval, TimeValueType interval,
const word &intervalPrefix const word &intervalPrefix
) )
{ {
isTimeStep_ = false; isTimeStep_ = false;
intervalPrefix_ = intervalPrefix; intervalPrefix_ = intervalPrefix;
rRange_ = stridedRange<timeValue>(startTime, endTime, interval); rRange_ = stridedRange<TimeValueType>(startTime, endTime, interval);
} }
pFlow::baseTimeControl::baseTimeControl( pFlow::baseTimeControl::baseTimeControl(
const dictionary &dict, const dictionary &dict,
const word &intervalPrefix, const word &intervalPrefix,
timeValue defStartTime) TimeValueType defStartTime)
: intervalPrefix_(intervalPrefix) : intervalPrefix_(intervalPrefix)
{ {
auto tControl = dict.getVal<word>("timeControl"); auto tControl = dict.getVal<word>("timeControl");
@ -59,10 +59,10 @@ pFlow::baseTimeControl::baseTimeControl(
if(!isTimeStep_) if(!isTimeStep_)
{ {
auto startTime = (dict.getValOrSet<timeValue>("startTime", defStartTime)); auto startTime = (dict.getValOrSet<TimeValueType>("startTime", defStartTime));
auto endTime = (dict.getValOrSet<timeValue>("endTime", largeValue)); auto endTime = (dict.getValOrSet<TimeValueType>("endTime", largeValue));
auto interval = dict.getVal<timeValue>(intervalWord); auto interval = dict.getVal<TimeValueType>(intervalWord);
rRange_ = stridedRange<timeValue>(startTime, endTime, interval); rRange_ = stridedRange<TimeValueType>(startTime, endTime, interval);
} }
else else
@ -78,9 +78,9 @@ pFlow::baseTimeControl::baseTimeControl(
pFlow::baseTimeControl::baseTimeControl pFlow::baseTimeControl::baseTimeControl
( (
const dictionary& dict, const dictionary& dict,
const timeValue defInterval, const TimeValueType defInterval,
const word& intervalPrefix, const word& intervalPrefix,
const timeValue defStartTime const TimeValueType defStartTime
) )
: :
intervalPrefix_(intervalPrefix) intervalPrefix_(intervalPrefix)
@ -104,10 +104,10 @@ pFlow::baseTimeControl::baseTimeControl
if(!isTimeStep_) if(!isTimeStep_)
{ {
auto startTime = (dict.getValOrSet<timeValue>("startTime", defStartTime)); auto startTime = (dict.getValOrSet<TimeValueType>("startTime", defStartTime));
auto endTime = (dict.getValOrSet<timeValue>("endTime", largeValue)); auto endTime = (dict.getValOrSet<TimeValueType>("endTime", largeValue));
auto interval = dict.getValOrSet<timeValue>(intervalWord, defInterval); auto interval = dict.getValOrSet<TimeValueType>(intervalWord, defInterval);
rRange_ = stridedRange<timeValue>(startTime, endTime, interval); rRange_ = stridedRange<TimeValueType>(startTime, endTime, interval);
} }
else else
@ -131,9 +131,9 @@ pFlow::baseTimeControl::baseTimeControl(int32 start, int32 end, int32 stride, co
pFlow::baseTimeControl::baseTimeControl pFlow::baseTimeControl::baseTimeControl
( (
timeValue start, TimeValueType start,
timeValue end, TimeValueType end,
timeValue stride, TimeValueType stride,
const word &intervalPrefix const word &intervalPrefix
) )
: :
@ -147,7 +147,7 @@ pFlow::baseTimeControl::baseTimeControl
{ {
} }
bool pFlow::baseTimeControl::eventTime(uint32 iter, timeValue t, timeValue dt) const bool pFlow::baseTimeControl::eventTime(uint32 iter, TimeValueType t, TimeValueType dt) const
{ {
if(isTimeStep_) if(isTimeStep_)
{ {
@ -166,7 +166,7 @@ bool pFlow::baseTimeControl::eventTime(const timeInfo &ti) const
} }
bool bool
pFlow::baseTimeControl::isInRange(uint32 iter, timeValue t, timeValue dt) const pFlow::baseTimeControl::isInRange(uint32 iter, TimeValueType t, TimeValueType dt) const
{ {
if(isTimeStep_) if(isTimeStep_)
{ {
@ -178,7 +178,7 @@ pFlow::baseTimeControl::isInRange(uint32 iter, timeValue t, timeValue dt) const
} }
} }
pFlow::timeValue pFlow::TimeValueType
pFlow::baseTimeControl::startTime() const pFlow::baseTimeControl::startTime() const
{ {
if(!isTimeStep_) if(!isTimeStep_)
@ -191,7 +191,7 @@ pFlow::baseTimeControl::startTime() const
return 0; return 0;
} }
pFlow::timeValue pFlow::TimeValueType
pFlow::baseTimeControl::endTime() const pFlow::baseTimeControl::endTime() const
{ {
if(!isTimeStep_) if(!isTimeStep_)
@ -204,7 +204,7 @@ pFlow::baseTimeControl::endTime() const
return 0; return 0;
} }
pFlow::timeValue pFlow::TimeValueType
pFlow::baseTimeControl::rInterval() const pFlow::baseTimeControl::rInterval() const
{ {
if(!isTimeStep_) if(!isTimeStep_)

View File

@ -36,16 +36,16 @@ private:
int32StridedRagne iRange_; int32StridedRagne iRange_;
stridedRange<timeValue> rRange_; stridedRange<TimeValueType> rRange_;
word intervalPrefix_; word intervalPrefix_;
protected: protected:
void setTimeControl( void setTimeControl(
timeValue startTime, TimeValueType startTime,
timeValue endTime, TimeValueType endTime,
timeValue interval, TimeValueType interval,
const word& intervalPrefix); const word& intervalPrefix);
public: public:
@ -53,14 +53,14 @@ public:
baseTimeControl( baseTimeControl(
const dictionary& dict, const dictionary& dict,
const word& intervalPrefix = "", const word& intervalPrefix = "",
timeValue defStartTime = 0.0 TimeValueType defStartTime = 0.0
); );
baseTimeControl( baseTimeControl(
const dictionary& dict, const dictionary& dict,
const timeValue defInterval, const TimeValueType defInterval,
const word& intervalPrefix="", const word& intervalPrefix="",
const timeValue defStartTime=0.0); const TimeValueType defStartTime=0.0);
baseTimeControl( baseTimeControl(
int32 start, int32 start,
@ -70,9 +70,9 @@ public:
); );
baseTimeControl( baseTimeControl(
timeValue start, TimeValueType start,
timeValue end, TimeValueType end,
timeValue stride, TimeValueType stride,
const word& intervalPrefix = "" const word& intervalPrefix = ""
); );
@ -99,17 +99,17 @@ public:
return isTimeStep_; return isTimeStep_;
} }
bool eventTime(uint32 iter, timeValue t, timeValue dt) const; bool eventTime(uint32 iter, TimeValueType t, TimeValueType dt) const;
bool eventTime(const timeInfo& ti)const; bool eventTime(const timeInfo& ti)const;
bool isInRange(uint32 iter, timeValue t, timeValue dt) const; bool isInRange(uint32 iter, TimeValueType t, TimeValueType dt) const;
timeValue startTime() const; TimeValueType startTime() const;
timeValue endTime() const; TimeValueType endTime() const;
timeValue rInterval() const; TimeValueType rInterval() const;
int32 startIter() const; int32 startIter() const;

View File

@ -36,16 +36,16 @@ pFlow::timeControl::timeControl
ti_(dict), ti_(dict),
startTime_ startTime_
( (
dict.getVal<timeValue>("startTime") dict.getVal<TimeValueType>("startTime")
), ),
endTime_ endTime_
( (
dict.getVal<timeValue>("endTime") dict.getVal<TimeValueType>("endTime")
), ),
stopAt_(endTime_), stopAt_(endTime_),
saveInterval_ saveInterval_
( (
dict.getVal<timeValue>("saveInterval") dict.getVal<TimeValueType>("saveInterval")
), ),
lastSaved_(startTime_), lastSaved_(startTime_),
performSorting_ performSorting_
@ -65,9 +65,9 @@ pFlow::timeControl::timeControl
pFlow::timeControl::timeControl( pFlow::timeControl::timeControl(
dictionary& dict, dictionary& dict,
timeValue startTime, TimeValueType startTime,
timeValue endTime, TimeValueType endTime,
timeValue saveInterval, TimeValueType saveInterval,
word startTimeName) word startTimeName)
: :
ti_(startTime, dict), ti_(startTime, dict),
@ -95,9 +95,9 @@ pFlow::timeControl::timeControl(
checkForOutputToFile(); checkForOutputToFile();
} }
pFlow::timeValue pFlow::timeControl::setTime(timeValue t) pFlow::TimeValueType pFlow::timeControl::setTime(TimeValueType t)
{ {
timeValue tmp = ti_.currentTime(); TimeValueType tmp = ti_.currentTime();
ti_.currentTime_ = t; ti_.currentTime_ = t;
lastSaved_ = t; lastSaved_ = t;
checkForOutputToFile(); checkForOutputToFile();

View File

@ -37,7 +37,7 @@ class dictionary;
class timeControl class timeControl
{ {
public: public:
using timeStridedRange = stridedRange<timeValue>; using timeStridedRange = stridedRange<TimeValueType>;
private: private:
@ -47,19 +47,19 @@ private:
timeInfo ti_; timeInfo ti_;
// - start time of simulation // - start time of simulation
timeValue startTime_; TimeValueType startTime_;
// - end time of simulation // - end time of simulation
timeValue endTime_; TimeValueType endTime_;
// - stopAt // - stopAt
timeValue stopAt_; TimeValueType stopAt_;
// - time interval for time folder output // - time interval for time folder output
timeValue saveInterval_; TimeValueType saveInterval_;
// - the last time folder that was saved // - the last time folder that was saved
timeValue lastSaved_; TimeValueType lastSaved_;
bool managedExternaly_ = false; bool managedExternaly_ = false;
@ -80,7 +80,7 @@ private:
inline word timeName_ = "wrongSettings"; // for managedExternamly inline word timeName_ = "wrongSettings"; // for managedExternamly
static static
inline timeValue writeTime_ = 0; // for managedExternamly inline TimeValueType writeTime_ = 0; // for managedExternamly
void checkForOutputToFile(); void checkForOutputToFile();
@ -92,22 +92,22 @@ public:
timeControl( timeControl(
dictionary& dict, dictionary& dict,
timeValue startTime, TimeValueType startTime,
timeValue endTime, TimeValueType endTime,
timeValue saveInterval, TimeValueType saveInterval,
word startTimeName); word startTimeName);
virtual ~timeControl() = default; virtual ~timeControl() = default;
timeValue dt()const TimeValueType dt()const
{ {
return ti_.dt(); return ti_.dt();
} }
timeValue setTime(timeValue t); TimeValueType setTime(TimeValueType t);
void setStopAt(timeValue sT) void setStopAt(TimeValueType sT)
{ {
if(managedExternaly_) if(managedExternaly_)
{ {
@ -115,24 +115,24 @@ public:
} }
} }
timeValue startTime()const TimeValueType startTime()const
{ {
return startTime_; return startTime_;
} }
timeValue endTime()const TimeValueType endTime()const
{ {
return endTime_; return endTime_;
} }
timeValue saveInterval()const TimeValueType saveInterval()const
{ {
return saveInterval_; return saveInterval_;
} }
word timeName()const; word timeName()const;
timeValue currentTime() const TimeValueType currentTime() const
{ {
return ti_.currentTime(); return ti_.currentTime();
} }

View File

@ -36,16 +36,16 @@ private:
uint32 currentIter_; uint32 currentIter_;
// - current time of simulation // - current time of simulation
timeValue currentTime_; TimeValueType currentTime_;
// - integration time step // - integration time step
timeValue dt_; TimeValueType dt_;
inline static uint32 presicion_ = 5; inline static uint32 presicion_ = 5;
public: public:
timeInfo(uint32 cIter, timeValue cTime, timeValue dt) timeInfo(uint32 cIter, TimeValueType cTime, TimeValueType dt)
: currentIter_(cIter), : currentIter_(cIter),
currentTime_(cTime), currentTime_(cTime),
dt_(dt) dt_(dt)
@ -55,31 +55,31 @@ public:
timeInfo(const dictionary& dict) timeInfo(const dictionary& dict)
: :
currentIter_(0), currentIter_(0),
currentTime_(dict.getVal<timeValue>("startTime")), currentTime_(dict.getVal<TimeValueType>("startTime")),
dt_( dict.getVal<timeValue>("dt")) dt_( dict.getVal<TimeValueType>("dt"))
{ {
presicion_ = dict.getValOrSet<uint32>("timePrecision",5); presicion_ = dict.getValOrSet<uint32>("timePrecision",5);
} }
timeInfo(timeValue currentTime, const dictionary& dict) timeInfo(TimeValueType currentTime, const dictionary& dict)
: :
currentIter_(0), currentIter_(0),
currentTime_(currentTime), currentTime_(currentTime),
dt_( dict.getVal<timeValue>("dt")) dt_( dict.getVal<TimeValueType>("dt"))
{ {
presicion_ = dict.getValOrSet<int32>("timePrecision",5); presicion_ = dict.getValOrSet<int32>("timePrecision",5);
} }
inline const timeValue& currentTime()const inline const TimeValueType& currentTime()const
{ {
return currentTime_; return currentTime_;
} }
inline const timeValue& t() const inline const TimeValueType& t() const
{ {
return currentTime_; return currentTime_;
} }
inline const timeValue& dt() const inline const TimeValueType& dt() const
{ {
return dt_; return dt_;
} }
@ -109,7 +109,7 @@ public:
inline inline
word prevTimeName()const word prevTimeName()const
{ {
return real2FixedStripZeros( max(currentTime_-dt_, timeValue(0)), presicion_); return real2FixedStripZeros( max(currentTime_-dt_, TimeValueType(0)), presicion_);
} }
static static

View File

@ -0,0 +1,55 @@
/* -------------------------------*- C++ -*--------------------------------- *\
| phasicFlow File |
| copyright: www.cemf.ir |
\* ------------------------------------------------------------------------- */
objectName settingsDict;
objectType dictionary;
fileFormat ASCII;
/*---------------------------------------------------------------------------*/
// list of libraries that should be loaded during runtime;
// for example, "libPostprocessData.so" (optional)
libs ();
// Auxiliary function to be run during simulation (optional)
auxFunctions postprocessData;
// time step for integration in seconds, (mandatory)
dt 0.00001;
// start time for simulation, can be any valid value. Simulation starts from
// time folder with the same name
startTime 0;
// end time for simulation (mandatory)
endTime 10;
// time interval between each data save on disk, (mandatory)
saveInterval 0.01;
// maximum number of digits for time folder, (opetional, default is 5)
timePrecision 5;
// gravitational acceleration vector (m/s2), (mandatory)
g (0 -9.8 0); // gravity vector (m/s2)
// include a list of objects that are not normally in the save list on disk, (optional)
includeObjects (diameter);
// exculde a list of objects from saving on the disk, (optional)
excludeObjects ();
// integration method for position and velocity, (mandatory)
integrationMethod AdamsBashforth2;
// if keep the integeration history under timeFolder/integeration or not, (optional, default is no)
integrationHistory Yes;
// data writting format (ascii or binary), (mandatory)
writeFormat ascii;
// report timers (Yes or No)?, (optional, default is Yes)
timersReport Yes;
// time interval between each timer report, (optional, default is 0.04)
timersReportInterval 0.01; // time interval for reporting timers

View File

@ -27,11 +27,11 @@ Licence:
namespace pFlow namespace pFlow
{ {
Map<timeValue, fileSystem> getTimeFolders(const fileSystem& path); Map<TimeValueType, fileSystem> getTimeFolders(const fileSystem& path);
class timeFolder class timeFolder
{ {
using timeList = Map<timeValue, fileSystem>; using timeList = Map<TimeValueType, fileSystem>;
protected: protected:
@ -61,14 +61,14 @@ public:
} }
inline inline
timeValue currentTime()const TimeValueType currentTime()const
{ {
if(folders_.empty()) return -1; if(folders_.empty()) return -1;
return currentFolder_->first; return currentFolder_->first;
} }
inline inline
timeValue nextTime()const TimeValueType nextTime()const
{ {
auto next = currentFolder_; auto next = currentFolder_;
next++; next++;
@ -98,7 +98,7 @@ public:
return !finished(); return !finished();
} }
bool setTime(timeValue upto) bool setTime(TimeValueType upto)
{ {
timeList::iterator orgFolder = currentFolder_; timeList::iterator orgFolder = currentFolder_;
@ -140,14 +140,14 @@ public:
return false; return false;
} }
timeValue startTime()const TimeValueType startTime()const
{ {
if(folders_.empty()) return -1; if(folders_.empty()) return -1;
auto [t,f] = *folders_.begin(); auto [t,f] = *folders_.begin();
return t; return t;
} }
timeValue endTime()const TimeValueType endTime()const
{ {
if(folders_.empty()) return -1; if(folders_.empty()) return -1;
auto [t,f] = *(--folders_.end()); auto [t,f] = *(--folders_.end());
@ -162,16 +162,16 @@ public:
}; };
inline inline
Map<timeValue, fileSystem> getTimeFolders(const fileSystem& path) Map<TimeValueType, fileSystem> getTimeFolders(const fileSystem& path)
{ {
Map<timeValue, fileSystem> tFolders; Map<TimeValueType, fileSystem> tFolders;
auto subDirs = subDirectories(path); auto subDirs = subDirectories(path);
for(auto& subD: subDirs) for(auto& subD: subDirs)
{ {
auto timeName = tailName(subD.wordPath(), '/'); auto timeName = tailName(subD.wordPath(), '/');
timeValue TIME; TimeValueType TIME;
if( auto success = readReal(timeName, TIME); success) if( auto success = readReal(timeName, TIME); success)
{ {
if(!tFolders.insertIf(TIME, subD)) if(!tFolders.insertIf(TIME, subD))

View File

@ -0,0 +1,64 @@
/* -------------------------------*- C++ -*--------------------------------- *\
| phasicFlow File |
| copyright: www.cemf.ir |
\* ------------------------------------------------------------------------- */
objectName domainDict;
objectType dictionary;
fileFormat ASCII;
/*---------------------------------------------------------------------------*/
// Simulation domain: every particles that goes outside this domain will be deleted
globalBox
{
min (-0.12 -0.12 0.00);
max (0.12 0.12 0.11);
}
pointSorting
{
active Yes; // optional (default: No)
dx 0.01; // optional (default: 0.01)
timeControl simulationTime; // runTime, or timeStep
startTime 0.0;
endTime 100; // optional (default: very large number)
sortingInterval 0.1; // in seconds
}
boundaries
{
left
{
type exit; // other options: periodict, reflective
}
right
{
type exit; // other options: periodict, reflective
}
bottom
{
type exit; // other options: periodict, reflective
}
top
{
type exit; // other options: periodict, reflective
}
rear
{
type exit; // other options: periodict, reflective
}
front
{
type exit; // other options: periodict, reflective
}
}

View File

@ -32,15 +32,23 @@ pFlow::pointSorting::pointSorting(const dictionary & dict)
dx_( dx_(
performSorting_()? performSorting_()?
dict.getVal<real>("dx"): dict.getVal<real>("dx"):
1.0 0.01
) )
{ {
if( performSorting_() ) if( performSorting_() )
REPORT(2)<<"Point sorting is "<<Yellow_Text("active")<<" in simulation"<<END_REPORT; {
else REPORT(2)<<"Point sorting is "<<Yellow_Text("active")<<" in the simulation"<<END_REPORT;
REPORT(2)<<"Point sorting is "<<Yellow_Text("inactive")<<" in simulation"<<END_REPORT; dictionary dict2("pointSorting");
dict2.add("avtive", performSorting_);
dict2.add("dx", dx_);
timeControl_.write(dict2);
output.incrIndent();
output<<dict2<<endl;
output.decrIndent();
}
} }
pFlow::uint32IndexContainer pFlow::uint32IndexContainer
pFlow::pointSorting::getSortedIndices( pFlow::pointSorting::getSortedIndices(
const box& boundingBox, const box& boundingBox,

View File

@ -50,9 +50,9 @@ public:
return performSorting_(); return performSorting_();
} }
bool sortTime(uint32 iter, real t, real dt)const bool sortTime(const timeInfo& ti)const
{ {
return performSorting_() && timeControl_.eventTime(iter, t, dt); return performSorting_() && timeControl_.eventTime(ti);
} }
uint32IndexContainer getSortedIndices( uint32IndexContainer getSortedIndices(

View File

@ -178,7 +178,7 @@ bool pFlow::pointStructure::beforeIteration()
{ {
const timeInfo ti = TimeInfo(); const timeInfo ti = TimeInfo();
if(pointSorting_().sortTime(ti.iter(), ti.t(), ti.dt())) if(pointSorting_().sortTime(ti))
{ {
auto sortedIndices = pointSorting_().getSortedIndices( auto sortedIndices = pointSorting_().getSortedIndices(
simulationDomain_().globalBox(), simulationDomain_().globalBox(),

View File

@ -25,11 +25,14 @@ Licence:
pFlow::Logical::Logical(const word& l) pFlow::Logical::Logical(const word& l)
{ {
if (!evaluteWord(l, s_, yesNoSet_)) bool s;
int yesNoSet;
if (!evaluteWord(l, s, yesNoSet))
{ {
fatalErrorInFunction << " invalid input for Logical: " << l << endl; fatalErrorInFunction << " invalid input for Logical: " << l << endl;
fatalExit; fatalExit;
} }
*this = Logical(s, yesNoSet);
} }
pFlow::Logical::Logical(const char* ch) pFlow::Logical::Logical(const char* ch)
@ -42,7 +45,7 @@ pFlow::Logical::evaluteWord(const word& l, bool& b, int& yesNoSet)
{ {
auto Ul = toUpper(l); auto Ul = toUpper(l);
for (int i = 0; i < 4; ++i) for (int i = 1; i < 5; ++i)
{ {
if (toUpper(YesNo__[i][0]) == Ul) if (toUpper(YesNo__[i][0]) == Ul)
{ {
@ -89,20 +92,26 @@ pFlow::Logical::read(iIstream& is)
is.setBad(); is.setBad();
return false; return false;
} }
bool s;
return evaluteWord(w, s_, yesNoSet_); int yesNoSet;
if( evaluteWord(w, s, yesNoSet) )
{
*this = Logical(s, yesNoSet);
return true;
}
return false;
} }
bool bool
pFlow::Logical::write(iOstream& os) const pFlow::Logical::write(iOstream& os) const
{ {
if (s_) if (s_ > 0)
{ {
os << YesNo__[yesNoSet_][0]; os << YesNo__[s_][0];
} }
else else
{ {
os << YesNo__[yesNoSet_][1]; os << YesNo__[-s_][1];
} }
return os.check(FUNCTION_NAME); return os.check(FUNCTION_NAME);
} }

View File

@ -41,24 +41,30 @@ class Logical
private: private:
/// bool value /// bool value
bool s_ = false; /// negative value means false
/// positive value means true
/// 0 means not set, but still valid as true
int8_t s_ = -1;
/// Set numbe of of Yes or No
int yesNoSet_ = 0;
/// Set of Yes or Nos /// Set of Yes or Nos
inline static const word YesNo__[4][2] = { { "Yes", "No" }, inline static const word YesNo__[5][2] = { { "Y", "Y" },
{ "Yes", "No" },
{ "on", "off" }, { "on", "off" },
{ "true", "false" }, { "true", "false" },
{ "Ok", "No" } }; { "Ok", "No" } };
/// Construct from bool and set number /// Construct from bool and set number
inline explicit Logical(bool s, int yns) inline Logical(bool s, int yns)
: s_(s),
yesNoSet_(yns)
{ {
yns = std::max(1, std::min(4, yns));
s_ = s ? static_cast<int8_t>(yns) : static_cast<int8_t>(-yns);
} }
inline explicit Logical(int8_t s)
{
s_ = s;
}
public: public:
/// Type info /// Type info
@ -79,7 +85,8 @@ public:
/// Construct from bool /// Construct from bool
inline explicit Logical(bool s) inline explicit Logical(bool s)
: s_(s) :
Logical(s, 1)
{ {
} }
@ -104,8 +111,7 @@ public:
/// Assignment with bool /// Assignment with bool
inline Logical& operator=(const bool& b) inline Logical& operator=(const bool& b)
{ {
s_ = b; *this = Logical(b);
yesNoSet_ = 0;
return *this; return *this;
} }
@ -114,19 +120,19 @@ public:
/// () operator, return bool value /// () operator, return bool value
inline bool operator()() const inline bool operator()() const
{ {
return s_; return s_ > 0;
} }
/// Return bool value /// Return bool value
inline explicit operator bool() const inline explicit operator bool() const
{ {
return s_; return s_ > 0;
} }
/// Not operator /// Not operator
inline Logical operator!() const inline Logical operator!() const
{ {
return Logical(!s_, yesNoSet_); return Logical(static_cast<int8_t>(-s_));
} }
//// IO operations //// IO operations

View File

@ -21,7 +21,6 @@ Licence:
\brief Helper functions for built-in types. \brief Helper functions for built-in types.
*/ */
#ifndef __bTypesFunctions_hpp__ #ifndef __bTypesFunctions_hpp__
#define __bTypesFunctions_hpp__ #define __bTypesFunctions_hpp__

View File

@ -61,25 +61,26 @@ using uint64 = unsigned long long int;
using word = std::string; using word = std::string;
using timeValue = double; /// type for time values
using TimeValueType = double;
/// type for indexing arrays and vectors
#ifdef pFlow_Build_Index64 #ifdef pFlow_Build_Index64
#define Index64 1 #define Index64 1
using index = std::size_t; using IndexType = std::size_t;
inline const char* IndexType__ = "std::size_t"; inline const char* IndexType__ = "std::size_t";
#else #else
#define Index64 0 #define Index64 0
using index = uint32; using IndexType = uint32;
inline const char* IndexType__ = "uint32"; inline const char* IndexType__ = "uint32";
#endif #endif
inline word inline word
floatingPointDescription() floatingPointDescription()
{ {
return word("In this build, ") + word(floatingPointType__) + return word("In this build, ") + word(floatingPointType__) +
word(" is used for floating point operations and ") + word(" is used for floating point operations and ") +
IndexType__ + "for indexing."; IndexType__ + " for indexing.";
} }
} // end of pFlow } // end of pFlow

View File

@ -192,7 +192,7 @@ postSimulationFieldsDataBase::postSimulationFieldsDataBase
systemControl &control, systemControl &control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime TimeValueType startTime
) )
: :
fieldsDataBase(control, postDict, inSimulation, startTime), fieldsDataBase(control, postDict, inSimulation, startTime),
@ -231,14 +231,14 @@ const pointStructure& postSimulationFieldsDataBase::pStruct()const
return pStructPtr_(); return pStructPtr_();
} }
timeValue postSimulationFieldsDataBase::getNextTimeFolder() const TimeValueType postSimulationFieldsDataBase::getNextTimeFolder() const
{ {
return allValidFolders_.nextTime(); return allValidFolders_.nextTime();
} }
timeValue postSimulationFieldsDataBase::setToNextTimeFolder() TimeValueType postSimulationFieldsDataBase::setToNextTimeFolder()
{ {
timeValue nextTime = allValidFolders_.nextTime(); TimeValueType nextTime = allValidFolders_.nextTime();
if(nextTime < 0.0) return nextTime; if(nextTime < 0.0) return nextTime;
allValidFolders_++; allValidFolders_++;
@ -254,9 +254,9 @@ timeValue postSimulationFieldsDataBase::setToNextTimeFolder()
return nextTime; return nextTime;
} }
timeValue postSimulationFieldsDataBase::skipNextTimeFolder() TimeValueType postSimulationFieldsDataBase::skipNextTimeFolder()
{ {
timeValue nextTime = allValidFolders_.nextTime(); TimeValueType nextTime = allValidFolders_.nextTime();
if(nextTime < 0.0) return nextTime; if(nextTime < 0.0) return nextTime;
allValidFolders_++; allValidFolders_++;

View File

@ -71,7 +71,7 @@ public:
systemControl& control, systemControl& control,
const dictionary& postDict, const dictionary& postDict,
bool inSimulation, bool inSimulation,
timeValue startTime); TimeValueType startTime);
~postSimulationFieldsDataBase() override = default; ~postSimulationFieldsDataBase() override = default;
@ -84,11 +84,11 @@ public:
const pointStructure& pStruct()const override; const pointStructure& pStruct()const override;
timeValue getNextTimeFolder()const override; TimeValueType getNextTimeFolder()const override;
timeValue setToNextTimeFolder() override; TimeValueType setToNextTimeFolder() override;
timeValue skipNextTimeFolder() override; TimeValueType skipNextTimeFolder() override;
}; };

View File

@ -67,7 +67,7 @@ int main(int argc, char** argv )
#include "initialize_Control.hpp" #include "initialize_Control.hpp"
// time in command line // time in command line
pFlow::combinedRange<pFlow::timeValue> validRange; pFlow::combinedRange<pFlow::TimeValueType> validRange;
if( cmds.count("--time") ) if( cmds.count("--time") )
{ {
@ -86,7 +86,7 @@ int main(int argc, char** argv )
validRange.addIntervalRange(1.0e-7, 1.0e+15); validRange.addIntervalRange(1.0e-7, 1.0e+15);
} }
pFlow::timeValue nextTime = validRange.minVal(); pFlow::TimeValueType nextTime = validRange.minVal();
if(nextTime <0.0) if(nextTime <0.0)
{ {