diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.C b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.C index c13c59e6..a824fcab 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.C +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.C @@ -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; diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.H b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.H index 813eb546..477c97d1 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.H +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/execute/execute.H @@ -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); }; diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/liggghtsCommandModel/liggghtsCommandModel.C b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/liggghtsCommandModel/liggghtsCommandModel.C index 9b6ef7f4..9d7da2ed 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/liggghtsCommandModel/liggghtsCommandModel.C +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/liggghtsCommandModel/liggghtsCommandModel.C @@ -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; } diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.C b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.C index 3605ce97..15e2bc34 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.C +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.C @@ -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")); diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.H b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.H index 345d2c4d..5b14a00b 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.H +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/readLiggghtsData/readLiggghtsData.H @@ -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); }; diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.C b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.C index 2969a052..4922dc6e 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.C +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.C @@ -62,19 +62,14 @@ runLiggghts::runLiggghts ) : liggghtsCommandModel(dict,sm,i), - propsDict_(dict), + propsDict_(dict.subOrEmptyDict(typeName + "Props")), command_("run"), - preNo_(true), + preNo_(propsDict_.lookupOrDefault("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; diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.H b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.H index 39aaa3ee..6437adde 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.H +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/runLiggghts/runLiggghts.H @@ -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); }; diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.C b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.C index 19547a66..137d4fa8 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.C +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.C @@ -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("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; diff --git a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.H b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.H index c6e1fdc6..18b26519 100644 --- a/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.H +++ b/src/lagrangian/cfdemParticle/subModels/liggghtsCommandModel/writeLiggghts/writeLiggghts.H @@ -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";}; };