mirror of
https://github.com/ParticulateFlow/CFDEMcoupling-PFM.git
synced 2025-12-08 06:37:44 +00:00
clean-up and pretty formatting of liggghtsCommandModel and its derived classes
removed an unused member "int stdInterval_" of the class runLiggghts
This commit is contained in:
@ -71,13 +71,13 @@ execute::execute
|
|||||||
timeStamp_(false)
|
timeStamp_(false)
|
||||||
{
|
{
|
||||||
// read list of scalars
|
// read list of scalars
|
||||||
if(propsDict_.found("scalars"))
|
if (propsDict_.found("scalars"))
|
||||||
{
|
{
|
||||||
scalarList_ = scalarList(propsDict_.lookup("scalars"));
|
scalarList_ = scalarList(propsDict_.lookup("scalars"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// read list of labels
|
// read list of labels
|
||||||
if(propsDict_.found("labels"))
|
if (propsDict_.found("labels"))
|
||||||
{
|
{
|
||||||
labelList_ = labelList(propsDict_.lookup("labels"));
|
labelList_ = labelList(propsDict_.lookup("labels"));
|
||||||
}
|
}
|
||||||
@ -91,7 +91,7 @@ execute::execute
|
|||||||
parseCommandList(commandList_, labelList_, scalarList_, command_, propsDict_, timeStamp_);
|
parseCommandList(commandList_, labelList_, scalarList_, command_, propsDict_, timeStamp_);
|
||||||
Info << "liggghtsCommand " << command_ << endl;
|
Info << "liggghtsCommand " << command_ << endl;
|
||||||
|
|
||||||
strCommand_=string(command_);
|
strCommand_ = string(command_);
|
||||||
|
|
||||||
checkTimeMode(propsDict_);
|
checkTimeMode(propsDict_);
|
||||||
|
|
||||||
@ -114,7 +114,7 @@ const char* execute::command(int commandLine)
|
|||||||
|
|
||||||
bool execute::runCommand(int couplingStep)
|
bool execute::runCommand(int couplingStep)
|
||||||
{
|
{
|
||||||
if(timeStamp_) strCommand_=addTimeStamp(command_);
|
if (timeStamp_) strCommand_ = addTimeStamp(command_);
|
||||||
checkTimeSettings(propsDict_);
|
checkTimeSettings(propsDict_);
|
||||||
|
|
||||||
return runThisCommand(couplingStep);
|
return runThisCommand(couplingStep);
|
||||||
|
|||||||
@ -88,24 +88,24 @@ void liggghtsCommandModel::checkTimeMode(dictionary& propsDict)
|
|||||||
{
|
{
|
||||||
runFirst_=Switch(propsDict.lookup("runFirst"));
|
runFirst_=Switch(propsDict.lookup("runFirst"));
|
||||||
|
|
||||||
if(!runFirst_)
|
if (!runFirst_)
|
||||||
{
|
{
|
||||||
// check if being run only at last coupling step
|
// check if being run only at last coupling step
|
||||||
runLast_=Switch(propsDict.lookup("runLast"));
|
runLast_=Switch(propsDict.lookup("runLast"));
|
||||||
|
|
||||||
if(!runLast_)
|
if (!runLast_)
|
||||||
{
|
{
|
||||||
// check if being run every coupling step
|
// check if being run every coupling step
|
||||||
runEveryCouplingStep_=Switch(propsDict.lookup("runEveryCouplingStep"));
|
runEveryCouplingStep_=Switch(propsDict.lookup("runEveryCouplingStep"));
|
||||||
|
|
||||||
if(!runEveryCouplingStep_)
|
if (!runEveryCouplingStep_)
|
||||||
{
|
{
|
||||||
runEveryWriteStep_=Switch(propsDict.lookup("runEveryWriteStep"));
|
runEveryWriteStep_=Switch(propsDict.lookup("runEveryWriteStep"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(verbose_)
|
if (verbose_)
|
||||||
{
|
{
|
||||||
Info << "runFirst = " << runFirst_ << endl;
|
Info << "runFirst = " << runFirst_ << endl;
|
||||||
Info << "runLast = " << runLast_ << endl;
|
Info << "runLast = " << runLast_ << endl;
|
||||||
@ -116,13 +116,13 @@ void liggghtsCommandModel::checkTimeMode(dictionary& propsDict)
|
|||||||
|
|
||||||
void liggghtsCommandModel::checkTimeSettings(const dictionary& propsDict)
|
void liggghtsCommandModel::checkTimeSettings(const dictionary& propsDict)
|
||||||
{
|
{
|
||||||
if(!runFirst_) //lastRun or runEveryCouplingStep or every n steps or every writeStep
|
if (!runFirst_) //lastRun or runEveryCouplingStep or every n steps or every writeStep
|
||||||
{
|
{
|
||||||
scalar DEMts = particleCloud_.dataExchangeM().DEMts();
|
scalar DEMts = particleCloud_.dataExchangeM().DEMts();
|
||||||
scalar couplingInterval = particleCloud_.dataExchangeM().couplingInterval();
|
scalar couplingInterval = particleCloud_.dataExchangeM().couplingInterval();
|
||||||
scalar simStartTime = particleCloud_.mesh().time().startTime().value();
|
scalar simStartTime = particleCloud_.mesh().time().startTime().value();
|
||||||
|
|
||||||
if(runLast_) // last run
|
if (runLast_) // last run
|
||||||
{
|
{
|
||||||
// read time options from subdict
|
// read time options from subdict
|
||||||
endTime_ = particleCloud_.mesh().time().endTime().value()-simStartTime;
|
endTime_ = particleCloud_.mesh().time().endTime().value()-simStartTime;
|
||||||
@ -164,7 +164,7 @@ void liggghtsCommandModel::checkTimeSettings(const dictionary& propsDict)
|
|||||||
couplingStepInterval_ =-1;
|
couplingStepInterval_ =-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(verbose_)
|
if (verbose_)
|
||||||
{
|
{
|
||||||
Info << "firstCouplingStep = " << firstCouplingStep_ << endl;
|
Info << "firstCouplingStep = " << firstCouplingStep_ << endl;
|
||||||
Info << "lastCouplingStep = " << lastCouplingStep_ << endl;
|
Info << "lastCouplingStep = " << lastCouplingStep_ << endl;
|
||||||
@ -175,14 +175,15 @@ void liggghtsCommandModel::checkTimeSettings(const dictionary& propsDict)
|
|||||||
|
|
||||||
bool liggghtsCommandModel::runThisCommand(int couplingStep)
|
bool liggghtsCommandModel::runThisCommand(int couplingStep)
|
||||||
{
|
{
|
||||||
if(verbose_) Info << "couplingStep = " << couplingStep << endl;
|
if (verbose_) Info << "couplingStep = " << couplingStep << endl;
|
||||||
bool runIt=false;
|
bool runIt=false;
|
||||||
if(
|
if
|
||||||
|
(
|
||||||
(!runEveryWriteStep_ && firstCouplingStep_ <= couplingStep && lastCouplingStep_ >= couplingStep) ||
|
(!runEveryWriteStep_ && firstCouplingStep_ <= couplingStep && lastCouplingStep_ >= couplingStep) ||
|
||||||
(runEveryWriteStep_ && particleCloud_.mesh().time().outputTime())
|
(runEveryWriteStep_ && particleCloud_.mesh().time().outputTime())
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if(couplingStep >= nextRun_)
|
if (couplingStep >= nextRun_)
|
||||||
{
|
{
|
||||||
runIt=true;
|
runIt=true;
|
||||||
nextRun_=couplingStep + couplingStepInterval_;
|
nextRun_=couplingStep + couplingStepInterval_;
|
||||||
@ -211,7 +212,7 @@ DynamicList<scalar> liggghtsCommandModel::executionsWithinPeriod(scalar TSstart,
|
|||||||
DynamicList<scalar> executions(0);
|
DynamicList<scalar> executions(0);
|
||||||
|
|
||||||
// current TS within active period
|
// current TS within active period
|
||||||
if(startTime_+SMALL<TSend && endTime_>TSstart-SMALL )
|
if (startTime_+SMALL<TSend && endTime_>TSstart-SMALL )
|
||||||
{
|
{
|
||||||
Info << "working time within this TS" << endl;
|
Info << "working time within this TS" << endl;
|
||||||
|
|
||||||
@ -219,7 +220,7 @@ DynamicList<scalar> liggghtsCommandModel::executionsWithinPeriod(scalar TSstart,
|
|||||||
int startNr = 0;
|
int startNr = 0;
|
||||||
scalar t = startTime_ + startNr * timeInterval_;
|
scalar t = startTime_ + startNr * timeInterval_;
|
||||||
|
|
||||||
if(timeInterval_ > SMALL)
|
if (timeInterval_ > SMALL)
|
||||||
{
|
{
|
||||||
while (TSend - t > SMALL)
|
while (TSend - t > SMALL)
|
||||||
{
|
{
|
||||||
@ -229,7 +230,7 @@ DynamicList<scalar> liggghtsCommandModel::executionsWithinPeriod(scalar TSstart,
|
|||||||
t -= timeInterval_;
|
t -= timeInterval_;
|
||||||
}
|
}
|
||||||
// check if first exec found within TS
|
// check if first exec found within TS
|
||||||
if(TSstart < t + SMALL && t +SMALL < TSend)
|
if (TSstart < t + SMALL && t +SMALL < TSend)
|
||||||
{
|
{
|
||||||
// check for more executions
|
// check for more executions
|
||||||
while (t < endTime_ + SMALL && TSend - t > SMALL)
|
while (t < endTime_ + SMALL && TSend - t > SMALL)
|
||||||
|
|||||||
@ -110,10 +110,10 @@ readLiggghtsData::~readLiggghtsData()
|
|||||||
const char* readLiggghtsData::command(int commandLine)
|
const char* readLiggghtsData::command(int commandLine)
|
||||||
{
|
{
|
||||||
char h[50];
|
char h[50];
|
||||||
sprintf(h,"_%d",insertionNr_);
|
sprintf(h, "_%d", insertionNr_);
|
||||||
word add = h;
|
word add = h;
|
||||||
insertionNr_++;
|
insertionNr_++;
|
||||||
strCommand_=string(command_ + add + " add");
|
strCommand_ = string(command_ + add + " add");
|
||||||
|
|
||||||
return strCommand_.c_str();
|
return strCommand_.c_str();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -64,8 +64,6 @@ private:
|
|||||||
|
|
||||||
word command_;
|
word command_;
|
||||||
|
|
||||||
//word myName_;
|
|
||||||
|
|
||||||
wordList filePathList_;
|
wordList filePathList_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -64,17 +64,16 @@ runLiggghts::runLiggghts
|
|||||||
liggghtsCommandModel(dict,sm,i),
|
liggghtsCommandModel(dict,sm,i),
|
||||||
propsDict_(dict.subOrEmptyDict(typeName + "Props")),
|
propsDict_(dict.subOrEmptyDict(typeName + "Props")),
|
||||||
command_("run"),
|
command_("run"),
|
||||||
preNo_(propsDict_.lookupOrDefault<bool>("preNo", true)),
|
preNo_(propsDict_.lookupOrDefault<bool>("preNo", true))
|
||||||
stdInterval_(0)
|
|
||||||
{
|
{
|
||||||
if (propsDict_.found("verbose"))
|
if (propsDict_.found("verbose"))
|
||||||
{
|
{
|
||||||
verbose_ = propsDict_.lookup("verbose");
|
verbose_ = propsDict_.lookup("verbose");
|
||||||
}
|
}
|
||||||
|
|
||||||
runEveryCouplingStep_=true;
|
runEveryCouplingStep_ = true;
|
||||||
|
|
||||||
strCommand_=createCommand(command_);
|
strCommand_ = createCommand(command_);
|
||||||
|
|
||||||
checkTimeSettings(dict_);
|
checkTimeSettings(dict_);
|
||||||
}
|
}
|
||||||
@ -97,7 +96,7 @@ string runLiggghts::createCommand( word command, int interval, word appendix, wo
|
|||||||
{
|
{
|
||||||
fileName add;
|
fileName add;
|
||||||
char h[50];
|
char h[50];
|
||||||
sprintf(h,"%d",interval);
|
sprintf(h, "%d", interval);
|
||||||
add = h;
|
add = h;
|
||||||
command += " " + add + " " + appendix + " " + appendix2 + " " + appendix3 + " " + appendix4;
|
command += " " + add + " " + appendix + " " + appendix2 + " " + appendix3 + " " + appendix4;
|
||||||
|
|
||||||
@ -108,9 +107,13 @@ bool runLiggghts::runCommand(int couplingStep)
|
|||||||
{
|
{
|
||||||
//change command to "run xxx pre no"
|
//change command to "run xxx pre no"
|
||||||
if (preNo_ && (couplingStep > firstCouplingStep_))
|
if (preNo_ && (couplingStep > firstCouplingStep_))
|
||||||
strCommand_=createCommand(command_, particleCloud_.dataExchangeM().couplingInterval(),"pre","no","post","no");
|
{
|
||||||
|
strCommand_ = createCommand(command_, particleCloud_.dataExchangeM().couplingInterval(),"pre","no","post","no");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
strCommand_=createCommand(command_, particleCloud_.dataExchangeM().couplingInterval());
|
{
|
||||||
|
strCommand_ = createCommand(command_, particleCloud_.dataExchangeM().couplingInterval());
|
||||||
|
}
|
||||||
|
|
||||||
return runThisCommand(couplingStep);
|
return runThisCommand(couplingStep);
|
||||||
}
|
}
|
||||||
@ -118,9 +121,13 @@ bool runLiggghts::runCommand(int couplingStep)
|
|||||||
void runLiggghts::set(int interval)
|
void runLiggghts::set(int interval)
|
||||||
{
|
{
|
||||||
if (preNo_)
|
if (preNo_)
|
||||||
|
{
|
||||||
strCommand_ = createCommand(command_, interval,"pre","no","post","no");
|
strCommand_ = createCommand(command_, interval,"pre","no","post","no");
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
strCommand_ = createCommand(command_, interval);
|
strCommand_ = createCommand(command_, interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|||||||
@ -63,8 +63,6 @@ private:
|
|||||||
|
|
||||||
bool preNo_;
|
bool preNo_;
|
||||||
|
|
||||||
int stdInterval_;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
|
|||||||
@ -77,41 +77,49 @@ writeLiggghts::writeLiggghts
|
|||||||
|
|
||||||
if (propsDict_.found("path"))
|
if (propsDict_.found("path"))
|
||||||
{
|
{
|
||||||
path_=fileName(propsDict_.lookup("path"));
|
path_ = fileName(propsDict_.lookup("path"));
|
||||||
if (!checkPath(path_))
|
if (!checkPath(path_))
|
||||||
FatalError<<"The path you provided in writeLiggghtsProps is incorrect: " << path_ << "\n" << abort(FatalError);
|
{
|
||||||
|
FatalError << "The path you provided in writeLiggghtsProps is incorrect: " << path_ << "\n" << abort(FatalError);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Info << "Using user defined path to write LIGGGHTS restart file: " << path_ << endl;
|
Info << "Using user defined path to write LIGGGHTS restart file: " << path_ << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(propsDict_.found("writeName"))
|
if (propsDict_.found("writeName"))
|
||||||
{
|
{
|
||||||
propsDict_.lookup("writeName") >> writeName_;
|
propsDict_.lookup("writeName") >> writeName_;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!writeLast_ && propsDict_.found("overwrite"))
|
if (!writeLast_ && propsDict_.found("overwrite"))
|
||||||
{
|
{
|
||||||
overwrite_=Switch(propsDict_.lookup("overwrite"));
|
overwrite_ = Switch(propsDict_.lookup("overwrite"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(writeLast_)
|
if (writeLast_)
|
||||||
{
|
{
|
||||||
runLast_=true;
|
runLast_ = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Warning << "Using invalid options of writeLiggghts, please use 'writeLast' option." << endl;
|
//Warning << "Using invalid options of writeLiggghts, please use 'writeLast' option." << endl;
|
||||||
runEveryWriteStep_=true;
|
runEveryWriteStep_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
command_ += " " + path_ + "/" + writeName_;
|
command_ += " " + path_ + "/" + writeName_;
|
||||||
if(overwrite_)
|
if (overwrite_)
|
||||||
|
{
|
||||||
strCommand_=string(command_);
|
strCommand_=string(command_);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
command_ += "_";
|
command_ += "_";
|
||||||
|
}
|
||||||
|
|
||||||
Info << "writeLiggghts: A restart file writeName_"<< command_ <<" is written." << endl;
|
Info << "writeLiggghts: A restart file writeName_" << command_ << " is written." << endl;
|
||||||
|
|
||||||
checkTimeSettings(dict_);
|
checkTimeSettings(dict_);
|
||||||
}
|
}
|
||||||
@ -132,7 +140,7 @@ const char* writeLiggghts::command(int commandLine)
|
|||||||
|
|
||||||
bool writeLiggghts::runCommand(int couplingStep)
|
bool writeLiggghts::runCommand(int couplingStep)
|
||||||
{
|
{
|
||||||
if(!overwrite_) strCommand_=addTimeStamp(command_);
|
if (!overwrite_) strCommand_ = addTimeStamp(command_);
|
||||||
return runThisCommand(couplingStep);
|
return runThisCommand(couplingStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user