mirror of
https://github.com/PhasicFlow/phasicFlow.git
synced 2025-06-12 16:26:23 +00:00
first modifications for coupling
This commit is contained in:
@ -47,6 +47,37 @@ pFlow::Time::Time
|
||||
|
||||
}
|
||||
|
||||
pFlow::Time::Time(
|
||||
repository* owner,
|
||||
dictionary& setiingsDict,
|
||||
real startTime,
|
||||
real endTime,
|
||||
real saveInterval,
|
||||
word startTimeName)
|
||||
:
|
||||
repository("Time", "", owner),
|
||||
timeControl(
|
||||
setiingsDict,
|
||||
startTime,
|
||||
endTime,
|
||||
saveInterval,
|
||||
startTimeName),
|
||||
geometry_
|
||||
(
|
||||
geometryRepository_,
|
||||
geometryFolder__,
|
||||
this
|
||||
),
|
||||
integration_
|
||||
(
|
||||
integrationRepository__,
|
||||
integrationFolder__,
|
||||
this
|
||||
)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool pFlow::Time::write
|
||||
(
|
||||
bool verbose
|
||||
|
@ -55,6 +55,14 @@ public:
|
||||
// Constructor with owner and settings dict
|
||||
Time( repository* owner, const dictionary& setiingsDict);
|
||||
|
||||
Time(
|
||||
repository* owner,
|
||||
dictionary& setiingsDict,
|
||||
real startTime,
|
||||
real endTime,
|
||||
real saveInterval,
|
||||
word startTimeName);
|
||||
|
||||
|
||||
//// - Methods
|
||||
virtual fileSystem localPath()const
|
||||
|
@ -63,13 +63,47 @@ pFlow::timeControl::timeControl
|
||||
)
|
||||
|
||||
{
|
||||
checkForOutputToFile();
|
||||
}
|
||||
|
||||
pFlow::timeControl::timeControl(
|
||||
dictionary& dict,
|
||||
real startTime,
|
||||
real endTime,
|
||||
real saveInterval,
|
||||
word startTimeName)
|
||||
:
|
||||
dt_
|
||||
(
|
||||
dict.getVal<real>("dt")
|
||||
),
|
||||
startTime_(startTime),
|
||||
endTime_(endTime),
|
||||
currentTime_(startTime_),
|
||||
saveInterval_(saveInterval),
|
||||
lastSaved_(startTime_),
|
||||
currentIter_(0),
|
||||
timePrecision_
|
||||
(
|
||||
dict.getValOrSet("timePrecision", 4)
|
||||
),
|
||||
managedExternaly_(true),
|
||||
timeName_(startTimeName),
|
||||
timersReportInterval_
|
||||
(
|
||||
startTime_,
|
||||
dict.getValOrSet("timersReportInterval", 0.04)
|
||||
)
|
||||
{
|
||||
checkForOutputToFile();
|
||||
}
|
||||
|
||||
|
||||
void pFlow::timeControl::checkForOutputToFile()
|
||||
{
|
||||
|
||||
if(managedExternaly_) return;
|
||||
|
||||
bool save = false;
|
||||
|
||||
if ( abs(currentTime_ - lastSaved_ - saveInterval_) < 0.5 * dt_ )
|
||||
@ -92,4 +126,14 @@ bool pFlow::timeControl::timersReportTime()const
|
||||
return timersReportInterval_.isMember(currentTime_, dt_);
|
||||
}
|
||||
|
||||
void pFlow::timeControl::setSaveTimeFolder(
|
||||
bool saveToFile,
|
||||
const word& timeName)
|
||||
{
|
||||
if(managedExternaly_)
|
||||
{
|
||||
outputToFile_ = saveToFile;
|
||||
timeName_ = timeName;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,6 +65,10 @@ protected:
|
||||
// - time precision for output time folders
|
||||
int32 timePrecision_;
|
||||
|
||||
bool managedExternaly_ = false;
|
||||
|
||||
word timeName_ = "wrongSettings";
|
||||
|
||||
realStridedRange timersReportInterval_;
|
||||
|
||||
int32StridedRagne screenReportInterval_ ={0,100};
|
||||
@ -78,6 +82,13 @@ protected:
|
||||
public:
|
||||
|
||||
timeControl(const dictionary& dict);
|
||||
|
||||
timeControl(
|
||||
dictionary& dict,
|
||||
real startTime,
|
||||
real endTime,
|
||||
real saveInterval,
|
||||
word startTimeName);
|
||||
|
||||
virtual ~timeControl()
|
||||
{}
|
||||
@ -103,9 +114,19 @@ public:
|
||||
return currentTime_;
|
||||
}
|
||||
|
||||
word currentTimeWord() const
|
||||
word currentTimeWord(bool forSave = true)const
|
||||
{
|
||||
return real2FixedStripZeros( currentTime(), timePrecision());;
|
||||
if(forSave)
|
||||
{
|
||||
if(!managedExternaly_)
|
||||
return real2FixedStripZeros( currentTime(), timePrecision());
|
||||
else
|
||||
return timeName_;
|
||||
}
|
||||
else
|
||||
{
|
||||
return real2FixedStripZeros( currentTime(), timePrecision());
|
||||
}
|
||||
}
|
||||
|
||||
int32 currentIter()const
|
||||
@ -145,6 +166,9 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
void setSaveTimeFolder(
|
||||
bool saveToFile,
|
||||
const word& timeName = "wrongTimeFolder");
|
||||
|
||||
int32 timePrecision()const
|
||||
{
|
||||
|
@ -154,6 +154,75 @@ pFlow::systemControl::systemControl
|
||||
writeToFileTimer_("Write to file", &timers_)
|
||||
{}
|
||||
|
||||
pFlow::systemControl::systemControl(
|
||||
const real startTime,
|
||||
const real endTime,
|
||||
const real saveInterval,
|
||||
const word startTimeName,
|
||||
const fileSystem path)
|
||||
:
|
||||
repository
|
||||
(
|
||||
"systemControl",
|
||||
path, // local path
|
||||
nullptr // no owner
|
||||
),
|
||||
runName_
|
||||
(
|
||||
getRunName(path)
|
||||
),
|
||||
topLevelFolder_
|
||||
(
|
||||
getTopFolder(path)
|
||||
),
|
||||
settings_
|
||||
(
|
||||
settingsRepository__,
|
||||
settingsFolder__,
|
||||
this
|
||||
),
|
||||
caseSetup_
|
||||
(
|
||||
caseSetupRepository__,
|
||||
caseSetupFolder__,
|
||||
this
|
||||
),
|
||||
settingsDict_
|
||||
(
|
||||
settings().emplaceObject<dictionary>
|
||||
(
|
||||
objectFile
|
||||
(
|
||||
settingsFile__,
|
||||
"",
|
||||
objectFile::READ_ALWAYS,
|
||||
objectFile::WRITE_NEVER
|
||||
),
|
||||
settingsFile__,
|
||||
true
|
||||
)
|
||||
),
|
||||
Time_
|
||||
(
|
||||
this,
|
||||
settingsDict_
|
||||
),
|
||||
externalTimeControl_(true),
|
||||
g_(
|
||||
settingsDict_.getVal<realx3>("g")
|
||||
),
|
||||
domain_(
|
||||
settingsDict_.subDict("domain")
|
||||
),
|
||||
timers_(runName_),
|
||||
timersReport_
|
||||
(
|
||||
settingsDict_.getValOrSet("timersReport", Logical("Yes"))
|
||||
),
|
||||
writeToFileTimer_("Write to file", &timers_)
|
||||
{}
|
||||
|
||||
|
||||
bool pFlow::systemControl::operator ++(int)
|
||||
{
|
||||
|
||||
@ -188,27 +257,4 @@ bool pFlow::systemControl::operator ++(int)
|
||||
|
||||
}
|
||||
|
||||
pFlow::Map<pFlow::real, pFlow::fileSystem>
|
||||
pFlow::systemControl::getTimeFolders()const
|
||||
{
|
||||
Map<real, fileSystem> tFolders;
|
||||
|
||||
auto subDirs = subDirectories(this->path());
|
||||
|
||||
for(auto& subD: subDirs)
|
||||
{
|
||||
auto timeName = tailName(subD.wordPath(), '/');
|
||||
real TIME;
|
||||
if( auto success = readReal(timeName, TIME); success)
|
||||
{
|
||||
if(!tFolders.insertIf(TIME, subD))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" duplicate time folder! time = " << TIME <<endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tFolders;
|
||||
}
|
||||
|
@ -61,6 +61,10 @@ protected:
|
||||
// - time repository
|
||||
Time Time_;
|
||||
|
||||
// - if time control is managed externaly
|
||||
|
||||
bool externalTimeControl_ = false;
|
||||
|
||||
// - acceleration
|
||||
realx3 g_;
|
||||
|
||||
@ -78,10 +82,18 @@ protected:
|
||||
|
||||
static word getTopFolder(const fileSystem& path);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
systemControl( const fileSystem path = CWD() );
|
||||
|
||||
systemControl(const fileSystem path = CWD());
|
||||
|
||||
systemControl(
|
||||
const real startTime,
|
||||
const real endTime,
|
||||
const real saveInterval,
|
||||
const word startTimeName,
|
||||
const fileSystem path = CWD() );
|
||||
|
||||
const repository& settings() const{
|
||||
return settings_;
|
||||
}
|
||||
@ -159,7 +171,12 @@ public:
|
||||
|
||||
bool operator ++(int);
|
||||
|
||||
Map<real, fileSystem> getTimeFolders()const;
|
||||
void setSaveTimeFolder(
|
||||
bool saveToFile,
|
||||
const word& timeName = "wrongTimeFolder")
|
||||
{
|
||||
Time_.setSaveTimeFolder(saveToFile, timeName);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -27,13 +27,13 @@ Licence:
|
||||
namespace pFlow
|
||||
{
|
||||
|
||||
Map<real, fileSystem> getTimeFolders(const fileSystem& path);
|
||||
|
||||
class timeFolder
|
||||
{
|
||||
using timeList = Map<real, fileSystem>;
|
||||
protected:
|
||||
const systemControl& control_;
|
||||
|
||||
|
||||
timeList folders_;
|
||||
|
||||
timeList::iterator currentFolder_;
|
||||
@ -41,12 +41,19 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
timeFolder(const systemControl& control ):
|
||||
control_(control),
|
||||
folders_(control.getTimeFolders()),
|
||||
currentFolder_(folders_.begin())
|
||||
timeFolder(const systemControl& control )
|
||||
:
|
||||
timeFolder(control.path())
|
||||
{}
|
||||
|
||||
timeFolder(const fileSystem& path)
|
||||
:
|
||||
folders_(getTimeFolders(path)),
|
||||
currentFolder_(folders_.begin())
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
real time()const
|
||||
{
|
||||
return currentFolder_->first;
|
||||
@ -108,6 +115,32 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
inline
|
||||
Map<real, fileSystem> getTimeFolders(const fileSystem& path)
|
||||
{
|
||||
Map<real, fileSystem> tFolders;
|
||||
|
||||
auto subDirs = subDirectories(path);
|
||||
|
||||
for(auto& subD: subDirs)
|
||||
{
|
||||
auto timeName = tailName(subD.wordPath(), '/');
|
||||
real TIME;
|
||||
if( auto success = readReal(timeName, TIME); success)
|
||||
{
|
||||
if(!tFolders.insertIf(TIME, subD))
|
||||
{
|
||||
fatalErrorInFunction<<
|
||||
" duplicate time folder! time = " << TIME <<endl;
|
||||
fatalExit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return tFolders;
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // pFlow
|
||||
|
||||
|
@ -447,7 +447,7 @@ pFlow::iIstream& pFlow::Istream::read(token& t)
|
||||
putback(c);
|
||||
|
||||
word val;
|
||||
if (read(val).bad())
|
||||
if (readString(val).bad())
|
||||
{
|
||||
t.setBad();
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ bool pFlow::iIstream::findToken( const word & w )
|
||||
{
|
||||
rewind();
|
||||
token next;
|
||||
bool isFirstToken = true;
|
||||
|
||||
while( !eof() && good() )
|
||||
{
|
||||
@ -73,10 +74,17 @@ bool pFlow::iIstream::findToken( const word & w )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( next.isWord() )
|
||||
|
||||
|
||||
if( next.isWord() && isFirstToken)
|
||||
{
|
||||
if(next.wordToken() == w) return true;
|
||||
if(next.wordToken() == w ) return true;
|
||||
}
|
||||
|
||||
if(next.isEndStatement()|| next.isEndBlock())
|
||||
isFirstToken = true;
|
||||
else
|
||||
isFirstToken = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -86,6 +94,7 @@ bool pFlow::iIstream::findTokenSilent( const word & w, int32 limitLine )
|
||||
{
|
||||
rewind();
|
||||
token next;
|
||||
bool isFirstToken = true;
|
||||
|
||||
while( !eof() && good() && lineNumber()<limitLine )
|
||||
{
|
||||
@ -95,10 +104,15 @@ bool pFlow::iIstream::findTokenSilent( const word & w, int32 limitLine )
|
||||
return false;
|
||||
}
|
||||
|
||||
if( next.isWord() )
|
||||
if( next.isWord() && isFirstToken)
|
||||
{
|
||||
if(next.wordToken() == w) return true;
|
||||
}
|
||||
|
||||
if(next.isEndStatement()|| next.isEndBlock())
|
||||
isFirstToken = true;
|
||||
else
|
||||
isFirstToken = false;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -133,11 +133,11 @@ public:
|
||||
virtual bool findToken( const word & w );
|
||||
|
||||
|
||||
// - search for all tokesn and find the first word token tbat matchs
|
||||
// - search for all tokesn and find the first word token that matchs
|
||||
virtual bool findTokenSilent( const word & w, int32 limitLine = 100 );
|
||||
|
||||
// - search for all tokens and find the first word token and also next word token
|
||||
// chekck if it i seneded with end statement ;
|
||||
// chekck if it is eneded with end statement ;
|
||||
virtual bool findTokenAndNext( const word& w, word& nextW, bool checkEndStatement = true);
|
||||
|
||||
|
||||
|
@ -313,6 +313,8 @@ public:
|
||||
//- Tolen is end statement
|
||||
inline bool isEndStatement() const;
|
||||
|
||||
inline bool isEndBlock()const;
|
||||
|
||||
//- Token is INT64
|
||||
inline bool isInt64() const;
|
||||
|
||||
|
@ -439,6 +439,16 @@ inline bool pFlow::token::isEndStatement() const
|
||||
}
|
||||
|
||||
|
||||
inline bool pFlow::token::isEndBlock() const
|
||||
{
|
||||
if( type_ == tokenType::PUNCTUATION )
|
||||
{
|
||||
return pToken() == punctuationToken::END_BLOCK;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline pFlow::token::punctuationToken pFlow::token::pToken() const
|
||||
{
|
||||
if (type_ == tokenType::PUNCTUATION)
|
||||
|
@ -191,6 +191,17 @@ bool pFlow::validWord(char c)
|
||||
);
|
||||
}
|
||||
|
||||
bool pFlow::validWordWithQuote(char c)
|
||||
{
|
||||
return
|
||||
(
|
||||
!isspace(c)
|
||||
&& c != ';' // end statement
|
||||
&& c != '{' // beg subdict
|
||||
&& c != '}' // end subdict
|
||||
);
|
||||
}
|
||||
|
||||
bool pFlow::validWord(const word& w)
|
||||
{
|
||||
for(auto wi:w)
|
||||
@ -201,6 +212,16 @@ bool pFlow::validWord(const word& w)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pFlow::validWordWithQuote(const word& w)
|
||||
{
|
||||
for(auto wi:w)
|
||||
{
|
||||
char c = wi;
|
||||
if ( !validWordWithQuote(c) ) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool pFlow::readLabel( const word& w, label & val)
|
||||
{
|
||||
|
@ -81,9 +81,12 @@ word tailName(const word& w, char sep = '.');
|
||||
// is the character valid for a word name
|
||||
bool validWord(char c);
|
||||
|
||||
bool validWordWithQuote(char c);
|
||||
|
||||
|
||||
bool validWord(const word& w);
|
||||
|
||||
bool validWordWithQuote(const word& c);
|
||||
|
||||
|
||||
bool readLabel( const word& w, label & val);
|
||||
|
@ -25,6 +25,25 @@ Licence:
|
||||
#include "initialize.H"
|
||||
|
||||
Report(0)<<"\nCreating Control repository . . ."<<endReport;
|
||||
pFlow::systemControl Control;
|
||||
pFlow::uniquePtr<pFlow::systemControl> ControlPtr = nullptr;
|
||||
|
||||
if(isCoupling)
|
||||
{
|
||||
pFlow::readControlDict controlDict;
|
||||
|
||||
ControlPtr = pFlow::makeUnique<pFlow::systemControl>
|
||||
(
|
||||
controlDict.startTime(),
|
||||
controlDict.endTime(),
|
||||
controlDict.saveInterval(),
|
||||
controlDict.startTimeName()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
ControlPtr = pFlow::makeUnique<pFlow::systemControl>();
|
||||
}
|
||||
|
||||
auto& Control = ControlPtr();
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user