diff --git a/src/lagrangian/cfdemParticle/cfdTools/setupProbeModel.H b/src/lagrangian/cfdemParticle/cfdTools/setupProbeModel.H index d94133eb..cf15a61d 100644 --- a/src/lagrangian/cfdemParticle/cfdTools/setupProbeModel.H +++ b/src/lagrangian/cfdemParticle/cfdTools/setupProbeModel.H @@ -1,3 +1,2 @@ - //set probeModel parameters for this force model - particleCloud_.probeM().setOutputFile(); - particleCloud_.probeM().setCounter(); +//set probeModel parameters for this force model +if (probeIt_) { particleCloud_.probeM().setOutputFile(typeName+".logDat"); } diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C index f46c2a82..3bde71ab 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.C @@ -497,16 +497,6 @@ label cfdemCloud::liggghtsCommandModelIndex(word name) return index; } -std::vector< std::vector >* cfdemCloud::getVprobe() -{ - return probeModel_->getVprobe(); -} - -std::vector< std::vector >* cfdemCloud::getSprobe() -{ - return probeModel_->getSprobe(); -} - // * * * * * * * * * * * * * * * WRITE * * * * * * * * * * * * * // // * * * write cfdemCloud internal data * * * // diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H index 3c05e065..5de625ff 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloud.H @@ -49,7 +49,7 @@ SourceFiles #include "fvCFD.H" #include "IFstream.H" -#include +#include "turbulenceModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -351,7 +351,7 @@ public: inline const IOModel& IOM() const; - inline const probeModel& probeM() const; + inline probeModel& probeM(); inline const averagingModel& averagingM() const; @@ -394,10 +394,6 @@ public: void resetArray(double**&,int,int,double resetVal=0.); - std::vector< std::vector >* getVprobe(); - - std::vector< std::vector >* getSprobe(); - void otherForces(volVectorField&); }; diff --git a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H index 84cd29c5..eeb829b7 100644 --- a/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H +++ b/src/lagrangian/cfdemParticle/cfdemCloud/cfdemCloudI.H @@ -262,9 +262,9 @@ inline const IOModel& cfdemCloud::IOM() const return IOModel_; } -inline const probeModel& cfdemCloud::probeM() const +inline probeModel& cfdemCloud::probeM() { - return probeModel_; + return probeModel_(); } inline const voidFractionModel& cfdemCloud::voidFractionM() const diff --git a/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.C b/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.C index c9bc6826..ca5bab6e 100644 --- a/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.C +++ b/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.C @@ -87,12 +87,12 @@ particleProbe::particleProbe if (propsDict_.found("verbose")) verbose_=true; if (propsDict_.found("verboseToFile")) verboseToFile_=true; - if (propsDict_.found("printEvery")) printEvery_= readScalar(propsDict_.lookup("printEvery")); - if (propsDict_.found("sampleAll")) sampleAll_=true; - if (propsDict_.found("probeDebug")) probeDebug_=true; - if (propsDict_.found("includePosition")) includePosition_=true; + if (propsDict_.found("printEvery")) printEvery_ = readScalar(propsDict_.lookup("printEvery")); + if (propsDict_.found("sampleAll")) sampleAll_ = true; + if (propsDict_.found("probeDebug")) probeDebug_ = true; + if (propsDict_.found("includePosition")) includePosition_ = true; - if (propsDict_.found("writePrecision")) writePrecision_= readScalar(propsDict_.lookup("writePrecision")); + if (propsDict_.found("writePrecision")) writePrecision_ = readScalar(propsDict_.lookup("writePrecision")); } @@ -100,25 +100,36 @@ particleProbe::particleProbe particleProbe::~particleProbe() { - clearProbes(); + forAll(sPtrList_, i) + delete sPtrList_[i]; } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void particleProbe::setOutputFile() const +void particleProbe::setOutputFile(const word& logFileName) { - //set the current item ID - if(currItemId_== itemCounter_) - currItemId_=1; - else - currItemId_+=1; - sPtr = sPtrList_[currItemId_-1]; //set the pointer to the output file from list - probeIndex_=currItemId_-1; + if (itemCounter_ > 0 && verboseToFile_) + { + bool foundFile = false; + forAll(itemsToSample_, i) + { + if (itemsToSample_[i] == logFileName) + { + probeIndex_ = i; + foundFile = true; + } + } + + if(!foundFile) + FatalError << "particleProbe::setOutputFile for logFileName " << logFileName << " : " << "File not found" << abort(FatalError); + currItemId_ = probeIndex_ + 1; + setCounter(); + } } -void particleProbe::initialize(word typeName, word logFileName) const +void particleProbe::initialize(const word& modelName, const word& logFileName) { //update the list of items to be sampled ++itemCounter_; @@ -126,7 +137,7 @@ void particleProbe::initialize(word typeName, word logFileName) const // init environment //propsDict_ = particleCloud_.couplingProperties().subDict(typeName + "Props"); - name_ = typeName; + name_ = modelName; if (verboseToFile_) { @@ -136,8 +147,8 @@ void particleProbe::initialize(word typeName, word logFileName) const MPI_Comm_rank(MPI_COMM_WORLD, &rank_); //open a separate file for each processor - char* filecurrent_ = new char[strlen(logFileName.c_str()) + 4]; //reserve 4 chars for processor name - sprintf(filecurrent_,"%s%s%d", logFileName.c_str(), ".", rank_); + char* filecurrent_ = new char[logFileName.length() + 1 + 4 + 1]; //reserve 4 chars for processor name + sprintf(filecurrent_,"%s.%d", logFileName.c_str(), rank_); Info << "particleProbe for model " << name_ << " will write to file " << filecurrent_ << endl; @@ -171,120 +182,44 @@ void particleProbe::initialize(word typeName, word logFileName) const scalarFields_.clear(); vectorFields_.clear(); } - - return; } + void particleProbe::writeHeader() const { + if (verboseToFile_) + { + *sPtr << "#processor: " << rank_ << endl; + *sPtr << "#index time " << " "; + *sPtr << "|| vectorData: " << " "; - if(verboseToFile_ ) - { - *sPtr<<"#processor: " << rank_ << endl; - *sPtr<<"#index time " << " "; + forAll(vectorFields_, iter) + { + if (!probeDebug_ && iter > 0) break; + *sPtr << vectorFields_(iter) << " "; + } - - *sPtr<<"|| vectorData: " << " "; - - forAll(vectorFields_, iter) - { - if(!probeDebug_ && iter>0) break; - *sPtr << vectorFields_(iter) << " "; - } - - if(probeDebug_) - { - *sPtr<<"|| scalarData: " << " "; + if (probeDebug_) + { + *sPtr << "|| scalarData: " << " "; forAll(scalarFields_, iter) { - *sPtr << scalarFields_(iter) << " "; + *sPtr << scalarFields_(iter) << " "; } - } - - if(includePosition_) *sPtr<<" || position" << endl; - else *sPtr << endl; - } - -} - -void particleProbe::clearProbes() const -{ - for (unsigned int i=0; i sValues, Field vValues) const -{ - int vSize_=vProbes_.size(); - int sSize_=sProbes_.size(); - - //check if the particle already has an allocated vector. If not, create it. It should be only called at the beginning. - while(index >= vSize_) - { - std::vector particleVector_; - vProbes_.push_back(particleVector_); - vSize_=vProbes_.size(); - } - - while(index >= sSize_) - { - std::vector particleScalar_; - sProbes_.push_back(particleScalar_); - sSize_=sProbes_.size(); - } - - //register vector probes on the corresponding vector - forAll(vValues, iter) - { - int ProbeSize_=vProbes_[index].size(); - - if(probeIndex_ sValues, Field vValues) const + +void particleProbe::writeProbe(int index, Field sValues, Field vValues) { - updateProbes(index,sValues,vValues); //update probe vectors - - - if(printNow_ && checkIDForPrint(index) && verboseToFile_) + if (printNow_ && verboseToFile_ && checkIDForPrint(index)) { + sPtr = sPtrList_[probeIndex_]; //set the pointer to the output file from list + //index and time *sPtr << setprecision(IOstream::defaultPrecision()+7); *sPtr << index << tab << particleCloud_.mesh().time().value() << " "; @@ -298,7 +233,6 @@ void particleProbe::writeProbe(int index, Field sValues, Field v *sPtr << vValues[iter][0] << " "; *sPtr << vValues[iter][1] << " "; *sPtr << vValues[iter][2] << " "; - } //scalarFields @@ -324,42 +258,40 @@ void particleProbe::writeProbe(int index, Field sValues, Field v *sPtr << endl; } } - - return; } + bool particleProbe::checkIDForPrint(int index) const { - bool sampleThisId_ = false; - if(sampleAll_) sampleThisId_ = true; - else - { - forAll(particleIDsToSample_, iSample) - { - if(index==particleIDsToSample_[iSample]) sampleThisId_ = true; - } - } - return sampleThisId_; + if(sampleAll_) + { + return true; + } + else + { + forAll(particleIDsToSample_, iSample) + { + if (index == particleIDsToSample_[iSample]) return true; + } + } + return false; } -void particleProbe::setCounter() const +void particleProbe::setCounter() { - - //reset or increment counter for printing to file + //reset or increment counter for printing to file //Do only if called by first item in the list of items! - if(currItemId_==1) + if (currItemId_ == 1) { - printCounter_++; - if( printCounter_ >= printEvery_ ) + ++printCounter_; + + if (printCounter_ >= printEvery_) { - printCounter_=0; + printCounter_ = 0; printNow_ = true; } else printNow_ = false; - } - return; - } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.H b/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.H index 3155a16e..e840f790 100644 --- a/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.H +++ b/src/lagrangian/cfdemParticle/subModels/probeModel/particleProbe/particleProbe.H @@ -63,7 +63,7 @@ private: dictionary propsDict_; - mutable word name_; + word name_; cfdemCloud& particleCloud_; @@ -75,7 +75,7 @@ private: word dirName_; - mutable int rank_; + int rank_; mutable OFstream* sPtr; @@ -89,25 +89,23 @@ private: const labelList particleIDsToSample_; - mutable wordList itemsToSample_; + wordList itemsToSample_; - mutable List sPtrList_; + List sPtrList_; - mutable int itemCounter_; + int itemCounter_; - mutable int currItemId_; + int currItemId_; - mutable int printCounter_; + int printCounter_; - mutable bool printNow_; + bool printNow_; - mutable std::vector< std::vector > sProbes_; + std::vector probeName_; - mutable std::vector< std::vector > vProbes_; + int probeIndex_; - mutable std::vector probeName_; - - mutable int probeIndex_; + void setCounter(); public: @@ -131,17 +129,11 @@ public: ~particleProbe(); // Member Functions - void updateProbes(int index, Field sValues, Field vValues) const; - void initialize(word typeName, word logFileName) const; - void setOutputFile() const; + void initialize(const word& modelName, const word& logFileName); + void setOutputFile(const word& logFileName); void writeHeader() const; - void writeProbe(int index, Field sValues, Field vValues) const; + void writeProbe(int index, Field sValues, Field vValues); bool checkIDForPrint(int) const; - void setCounter() const; - void clearProbes() const; - std::vector< std::vector >* getVprobe() { return &vProbes_; } - std::vector< std::vector >* getSprobe() { return &sProbes_; } - }; diff --git a/src/lagrangian/cfdemParticle/subModels/probeModel/probeModel/probeModel.H b/src/lagrangian/cfdemParticle/subModels/probeModel/probeModel/probeModel.H index d30bd808..a7c811f0 100644 --- a/src/lagrangian/cfdemParticle/subModels/probeModel/probeModel/probeModel.H +++ b/src/lagrangian/cfdemParticle/subModels/probeModel/probeModel/probeModel.H @@ -133,16 +133,12 @@ public: // Member Functions - virtual void initialize(word typeName, word logFileName) const {} - virtual void setOutputFile() const {} + virtual void initialize(const word& modelName, const word& logFileName) {} + virtual void setOutputFile(const word& logFileName) {} virtual void writeHeader() const {} - virtual void writeProbe(int index, Field sValues, Field vValues) const {} + virtual void writeProbe(int index, Field sValues, Field vValues) {} virtual bool checkIDForPrint(int) const { return false; } - virtual void setCounter() const {} virtual bool active() const { return true; } - virtual std::vector< std::vector >* getVprobe() { return NULL; } - virtual std::vector< std::vector >* getSprobe() { return NULL; } - virtual void clearProbes() const {} // Access