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_();
}
auto inline constexpr usingDoulle()const
auto inline constexpr usingDouble()const
{
return pFlow::usingDouble__;
}

View File

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

View File

@ -467,7 +467,7 @@ pFlow::postprocessData::fieldsDataBase::fieldsDataBase
systemControl& control,
const dictionary& postDict,
bool inSimulation,
timeValue startTime
TimeValueType startTime
)
:
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();
}
@ -914,7 +914,7 @@ pFlow::uniquePtr<pFlow::postprocessData::fieldsDataBase>
systemControl& control,
const dictionary& postDict,
bool inSimulation,
timeValue startTime
TimeValueType startTime
)
{
word dbType;

View File

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

View File

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

View File

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

View File

@ -86,12 +86,12 @@ private:
word fieldName_;
/// 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
bool updateMask()
{
timeValue t = database().currentTime();
TimeValueType t = database().currentTime();
if( equal( t, lastUpdated_)) return true;
@ -206,11 +206,11 @@ private:
std::vector<bool> mask_;
timeValue lastUpdated_ = -1;
TimeValueType lastUpdated_ = -1;
bool updateMask()
{
timeValue t = database().currentTime();
TimeValueType t = database().currentTime();
if( equal( t, lastUpdated_)) return true;

View File

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

View File

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

View File

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

View File

@ -85,7 +85,7 @@ public:
/// this constructor is used when postprocesing is active
/// during simulation.
/// @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;

View File

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

View File

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

View File

@ -36,16 +36,16 @@ private:
int32StridedRagne iRange_;
stridedRange<timeValue> rRange_;
stridedRange<TimeValueType> rRange_;
word intervalPrefix_;
protected:
void setTimeControl(
timeValue startTime,
timeValue endTime,
timeValue interval,
TimeValueType startTime,
TimeValueType endTime,
TimeValueType interval,
const word& intervalPrefix);
public:
@ -53,14 +53,14 @@ public:
baseTimeControl(
const dictionary& dict,
const word& intervalPrefix = "",
timeValue defStartTime = 0.0
TimeValueType defStartTime = 0.0
);
baseTimeControl(
const dictionary& dict,
const timeValue defInterval,
const TimeValueType defInterval,
const word& intervalPrefix="",
const timeValue defStartTime=0.0);
const TimeValueType defStartTime=0.0);
baseTimeControl(
int32 start,
@ -70,9 +70,9 @@ public:
);
baseTimeControl(
timeValue start,
timeValue end,
timeValue stride,
TimeValueType start,
TimeValueType end,
TimeValueType stride,
const word& intervalPrefix = ""
);
@ -99,17 +99,17 @@ public:
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 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;

View File

@ -36,16 +36,16 @@ pFlow::timeControl::timeControl
ti_(dict),
startTime_
(
dict.getVal<timeValue>("startTime")
dict.getVal<TimeValueType>("startTime")
),
endTime_
(
dict.getVal<timeValue>("endTime")
dict.getVal<TimeValueType>("endTime")
),
stopAt_(endTime_),
saveInterval_
(
dict.getVal<timeValue>("saveInterval")
dict.getVal<TimeValueType>("saveInterval")
),
lastSaved_(startTime_),
performSorting_
@ -65,9 +65,9 @@ pFlow::timeControl::timeControl
pFlow::timeControl::timeControl(
dictionary& dict,
timeValue startTime,
timeValue endTime,
timeValue saveInterval,
TimeValueType startTime,
TimeValueType endTime,
TimeValueType saveInterval,
word startTimeName)
:
ti_(startTime, dict),
@ -95,9 +95,9 @@ pFlow::timeControl::timeControl(
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;
lastSaved_ = t;
checkForOutputToFile();

View File

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

View File

@ -36,16 +36,16 @@ private:
uint32 currentIter_;
// - current time of simulation
timeValue currentTime_;
TimeValueType currentTime_;
// - integration time step
timeValue dt_;
TimeValueType dt_;
inline static uint32 presicion_ = 5;
public:
timeInfo(uint32 cIter, timeValue cTime, timeValue dt)
timeInfo(uint32 cIter, TimeValueType cTime, TimeValueType dt)
: currentIter_(cIter),
currentTime_(cTime),
dt_(dt)
@ -55,31 +55,31 @@ public:
timeInfo(const dictionary& dict)
:
currentIter_(0),
currentTime_(dict.getVal<timeValue>("startTime")),
dt_( dict.getVal<timeValue>("dt"))
currentTime_(dict.getVal<TimeValueType>("startTime")),
dt_( dict.getVal<TimeValueType>("dt"))
{
presicion_ = dict.getValOrSet<uint32>("timePrecision",5);
}
timeInfo(timeValue currentTime, const dictionary& dict)
timeInfo(TimeValueType currentTime, const dictionary& dict)
:
currentIter_(0),
currentTime_(currentTime),
dt_( dict.getVal<timeValue>("dt"))
dt_( dict.getVal<TimeValueType>("dt"))
{
presicion_ = dict.getValOrSet<int32>("timePrecision",5);
}
inline const timeValue& currentTime()const
inline const TimeValueType& currentTime()const
{
return currentTime_;
}
inline const timeValue& t() const
inline const TimeValueType& t() const
{
return currentTime_;
}
inline const timeValue& dt() const
inline const TimeValueType& dt() const
{
return dt_;
}
@ -109,7 +109,7 @@ public:
inline
word prevTimeName()const
{
return real2FixedStripZeros( max(currentTime_-dt_, timeValue(0)), presicion_);
return real2FixedStripZeros( max(currentTime_-dt_, TimeValueType(0)), presicion_);
}
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
{
Map<timeValue, fileSystem> getTimeFolders(const fileSystem& path);
Map<TimeValueType, fileSystem> getTimeFolders(const fileSystem& path);
class timeFolder
{
using timeList = Map<timeValue, fileSystem>;
using timeList = Map<TimeValueType, fileSystem>;
protected:
@ -61,14 +61,14 @@ public:
}
inline
timeValue currentTime()const
TimeValueType currentTime()const
{
if(folders_.empty()) return -1;
return currentFolder_->first;
}
inline
timeValue nextTime()const
TimeValueType nextTime()const
{
auto next = currentFolder_;
next++;
@ -98,7 +98,7 @@ public:
return !finished();
}
bool setTime(timeValue upto)
bool setTime(TimeValueType upto)
{
timeList::iterator orgFolder = currentFolder_;
@ -140,14 +140,14 @@ public:
return false;
}
timeValue startTime()const
TimeValueType startTime()const
{
if(folders_.empty()) return -1;
auto [t,f] = *folders_.begin();
return t;
}
timeValue endTime()const
TimeValueType endTime()const
{
if(folders_.empty()) return -1;
auto [t,f] = *(--folders_.end());
@ -162,16 +162,16 @@ public:
};
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);
for(auto& subD: subDirs)
{
auto timeName = tailName(subD.wordPath(), '/');
timeValue TIME;
TimeValueType TIME;
if( auto success = readReal(timeName, TIME); success)
{
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_(
performSorting_()?
dict.getVal<real>("dx"):
1.0
0.01
)
{
if( performSorting_() )
REPORT(2)<<"Point sorting is "<<Yellow_Text("active")<<" in simulation"<<END_REPORT;
else
REPORT(2)<<"Point sorting is "<<Yellow_Text("inactive")<<" in simulation"<<END_REPORT;
{
REPORT(2)<<"Point sorting is "<<Yellow_Text("active")<<" in the 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::pointSorting::getSortedIndices(
const box& boundingBox,

View File

@ -50,9 +50,9 @@ public:
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(

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -71,7 +71,7 @@ public:
systemControl& control,
const dictionary& postDict,
bool inSimulation,
timeValue startTime);
TimeValueType startTime);
~postSimulationFieldsDataBase() override = default;
@ -84,11 +84,11 @@ public:
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"
// time in command line
pFlow::combinedRange<pFlow::timeValue> validRange;
pFlow::combinedRange<pFlow::TimeValueType> validRange;
if( cmds.count("--time") )
{
@ -86,7 +86,7 @@ int main(int argc, char** argv )
validRange.addIntervalRange(1.0e-7, 1.0e+15);
}
pFlow::timeValue nextTime = validRange.minVal();
pFlow::TimeValueType nextTime = validRange.minVal();
if(nextTime <0.0)
{