code clean-up of liggghtsCommandModel and its derived classes

Done away with awful creation of sub-directories for the derived classes of "liggghtsCommandModel"
Followed standard OpenFOAM convention, which can be seen all-over OpenFOAM's sources.
Also fixed some parameter reading from the sub-directories.
This commit is contained in:
Gerhard Holzinger
2017-10-23 17:00:44 +02:00
parent fffc80bb33
commit 7d8d3e115e
9 changed files with 90 additions and 100 deletions

View File

@ -62,32 +62,31 @@ execute::execute
)
:
liggghtsCommandModel(dict,sm,i),
propsDict_(dict.subOrEmptyDict(typeName + "Props")),
nrModel_(i),
myName_("notYetGiven"),
propsDict_(dict),
commandList_(0),
commandList_(wordList(propsDict_.lookup("command"))),
command_(""),
scalarList_(0),
labelList_(0),
timeStamp_(false)
{
// define dictionary
char h[80];
sprintf(h,"%d",nrModel_);
myName_=word(typeName + "Props" + h);
propsDict_=dictionary(dict.subDict(myName_));
// read command from dict
commandList_ = wordList(propsDict_.lookup("command"));
// read list of scalars
if(propsDict_.found("scalars")) scalarList_ = scalarList(propsDict_.lookup("scalars"));
if(propsDict_.found("scalars"))
{
scalarList_ = scalarList(propsDict_.lookup("scalars"));
}
// read list of labels
if(propsDict_.found("labels")) labelList_ = labelList(propsDict_.lookup("labels"));
if(propsDict_.found("labels"))
{
labelList_ = labelList(propsDict_.lookup("labels"));
}
// check if verbose
if (propsDict_.found("verbose")) verbose_=true;
if (propsDict_.found("verbose"))
{
verbose_ = propsDict_.lookup("verbose");
}
parseCommandList(commandList_, labelList_, scalarList_, command_, propsDict_, timeStamp_);
Info << "liggghtsCommand " << command_ << endl;

View File

@ -57,12 +57,10 @@ class execute
{
private:
int nrModel_;
word myName_;
dictionary propsDict_;
int nrModel_;
wordList commandList_;
word command_;
@ -96,11 +94,11 @@ public:
// Member Functions
word name(){return myName_;}
word name(){return "execute";};
const char* command(int);
const char* command(int);
bool runCommand(int);
bool runCommand(int);
};

View File

@ -105,7 +105,8 @@ void liggghtsCommandModel::checkTimeMode(dictionary& propsDict)
}
}
if(verbose_){
if(verbose_)
{
Info << "runFirst = " << runFirst_ << endl;
Info << "runLast = " << runLast_ << endl;
Info << "runEveryCouplingStep = " << runEveryCouplingStep_ << endl;
@ -163,7 +164,8 @@ void liggghtsCommandModel::checkTimeSettings(const dictionary& propsDict)
couplingStepInterval_ =-1;
}
if(verbose_){
if(verbose_)
{
Info << "firstCouplingStep = " << firstCouplingStep_ << endl;
Info << "lastCouplingStep = " << lastCouplingStep_ << endl;
Info << "couplingStepInterval = " << couplingStepInterval_ << endl;
@ -176,9 +178,9 @@ bool liggghtsCommandModel::runThisCommand(int couplingStep)
if(verbose_) Info << "couplingStep = " << couplingStep << endl;
bool runIt=false;
if(
(!runEveryWriteStep_ && firstCouplingStep_ <= couplingStep && lastCouplingStep_ >= couplingStep) ||
(runEveryWriteStep_ && particleCloud_.mesh().time().outputTime())
)
(!runEveryWriteStep_ && firstCouplingStep_ <= couplingStep && lastCouplingStep_ >= couplingStep) ||
(runEveryWriteStep_ && particleCloud_.mesh().time().outputTime())
)
{
if(couplingStep >= nextRun_)
{
@ -280,15 +282,18 @@ void liggghtsCommandModel::parseCommandList(wordList& commandList,labelList& lab
{
add = "";
addBlank = false;
}else if (add=="blanks") // add a blank here and after the following words
}
else if (add=="blanks") // add a blank here and after the following words
{
add = "";
addBlank = true;
}else if (add=="timeStamp") // add a time stamp
}
else if (add=="timeStamp") // add a time stamp
{
add = "";
timeStamp=true;
}else if (add=="number") // next command will be a number read from labelList
}
else if (add=="number") // next command will be a number read from labelList
{
/*if (!propsDict.found("scalars"))
{
@ -299,7 +304,8 @@ void liggghtsCommandModel::parseCommandList(wordList& commandList,labelList& lab
sprintf(h,"%f",scalarList[numberCount]);
add = h;
numberCount ++;
}else if (add=="label") // next command will be a number read from labelList
}
else if (add=="label") // next command will be a number read from labelList
{
/*if (!propsDict.found("labels"))
{
@ -316,7 +322,8 @@ void liggghtsCommandModel::parseCommandList(wordList& commandList,labelList& lab
if (addBlank)
{
command += add + " ";
}else
}
else
{
command += add;
}

View File

@ -62,27 +62,22 @@ readLiggghtsData::readLiggghtsData
)
:
liggghtsCommandModel(dict,sm,i),
propsDict_(dict.subOrEmptyDict(typeName + "Props")),
nrModel_(i),
insertionNr_(0.),
insertionNr_(readLabel(propsDict_.lookup("startIndex"))),
command_("read_data"),
myName_("notYetGiven"),
propsDict_(dict),
filePathList_(0)
{
// define dictionary
char h[80];
sprintf(h,"%d",nrModel_);
myName_=word(typeName + "Props" + h);
propsDict_=dictionary(dict.subDict(myName_));
if (propsDict_.found("exactTiming"))
exactTiming_=true;
{
exactTiming_ = propsDict_.lookup("exactTiming");
}
Info << "exactTiming==" << exactTiming_ << endl;
if (propsDict_.found("verbose")) verbose_=true;
// read first index of data file to be injected
insertionNr_=readScalar(propsDict_.lookup("startIndex"));
if (propsDict_.found("verbose"))
{
verbose_ = propsDict_.lookup("verbose");
}
// read command from dict
filePathList_ = wordList(propsDict_.lookup("filePath"));

View File

@ -56,15 +56,15 @@ class readLiggghtsData
{
private:
dictionary propsDict_;
int nrModel_;
int insertionNr_;
word command_;
word myName_;
dictionary propsDict_;
//word myName_;
wordList filePathList_;
@ -91,11 +91,11 @@ public:
// Member Functions
word name(){return myName_;};
word name(){return "readLiggghtsData";};
const char* command(int);
const char* command(int);
bool runCommand(int);
bool runCommand(int);
};

View File

@ -62,19 +62,14 @@ runLiggghts::runLiggghts
)
:
liggghtsCommandModel(dict,sm,i),
propsDict_(dict),
propsDict_(dict.subOrEmptyDict(typeName + "Props")),
command_("run"),
preNo_(true),
preNo_(propsDict_.lookupOrDefault<bool>("preNo", true)),
stdInterval_(0)
{
word myName=word(typeName + "Props");
if (dict.found(myName))
if (propsDict_.found("verbose"))
{
propsDict_=dictionary(dict.subDict(myName));
preNo_=Switch(propsDict_.lookup("preNo"));
// check if verbose
if (propsDict_.found("verbose")) verbose_=true;
verbose_ = propsDict_.lookup("verbose");
}
runEveryCouplingStep_=true;

View File

@ -88,15 +88,15 @@ public:
// Member Functions
const char* command(int);
const char* command(int);
string createCommand(word="",int=0,word="",word="",word="",word="");
string createCommand(word="",int=0,word="",word="",word="",word="");
bool runCommand(int);
bool runCommand(int);
word name(){return "runLiggghts";};
word name(){return "runLiggghts";};
void set(int);
void set(int);
};

View File

@ -62,46 +62,42 @@ writeLiggghts::writeLiggghts
)
:
liggghtsCommandModel(dict,sm,i),
propsDict_(dict),
propsDict_(dict.subOrEmptyDict(typeName + "Props")),
command_("write_restart"),
path_(word("..")/word("DEM")),
writeName_("liggghts.restartCFDEM"),
writeLast_(true),
writeLast_(propsDict_.lookupOrDefault<Switch>("writeLast" ,true)),
overwrite_(false)
{
if (dict.found(typeName + "Props"))
// check if verbose
if (propsDict_.found("verbose"))
{
propsDict_=dictionary(dict.subDict(typeName + "Props"));
// check if verbose
if (propsDict_.found("verbose")) verbose_=true;
if(propsDict_.found("writeLast"))
{
writeLast_=Switch(propsDict_.lookup("writeLast"));
}
if (propsDict_.found("path"))
{
path_=fileName(propsDict_.lookup("path"));
if (!checkPath(path_))
FatalError<<"The path you provided in writeLiggghtsProps is incorrect: " << path_ << "\n" << abort(FatalError);
else
Info << "Using user defined path to write LIGGGHTS restart file: " << path_ << endl;
}
if(propsDict_.found("writeName"))
{
propsDict_.lookup("writeName") >> writeName_;
}
if (!writeLast_ && propsDict_.found("overwrite"))
{
overwrite_=Switch(propsDict_.lookup("overwrite"));
}
verbose_ = propsDict_.lookup("verbose");
}
if (propsDict_.found("path"))
{
path_=fileName(propsDict_.lookup("path"));
if (!checkPath(path_))
FatalError<<"The path you provided in writeLiggghtsProps is incorrect: " << path_ << "\n" << abort(FatalError);
else
Info << "Using user defined path to write LIGGGHTS restart file: " << path_ << endl;
}
if(propsDict_.found("writeName"))
{
propsDict_.lookup("writeName") >> writeName_;
}
if (!writeLast_ && propsDict_.found("overwrite"))
{
overwrite_=Switch(propsDict_.lookup("overwrite"));
}
if(writeLast_)
{
runLast_=true;
}
else
{
//Warning << "Using invalid options of writeLiggghts, please use 'writeLast' option." << endl;

View File

@ -93,11 +93,11 @@ public:
// Member Functions
const char* command(int);
const char* command(int);
bool runCommand(int);
bool runCommand(int);
word name(){return "writeLiggghts";};
word name(){return "writeLiggghts";};
};