add output option and min/max field values to particleCellVolume

as in CFDEMcoupling-PUBLIC
This commit is contained in:
danielque
2020-08-03 12:45:11 +02:00
parent 50bd4a6de3
commit 39d66506a1
2 changed files with 32 additions and 1 deletions

View File

@ -94,8 +94,17 @@ particleCellVolume::particleCellVolume
),
upperThreshold_(readScalar(propsDict_.lookup("upperThreshold"))),
lowerThreshold_(readScalar(propsDict_.lookup("lowerThreshold"))),
verbose_(propsDict_.found("verbose"))
verbose_(propsDict_.found("verbose")),
writeToFile_(propsDict_.lookupOrDefault<Switch>("writeToFile",false)),
filePtr_()
{
// create the path and output file
if(writeToFile_)
{
fileName path(particleCloud_.IOM().createTimeDir("postProcessing/particleCellVolume"));
filePtr_ = new OFstream(path/"particleCellVolume.txt");
filePtr_() << "# time | total particle volume in cells | total volume of cells with particles | average volume fraction | min(voidfraction) | max(voidfraction)" << endl;
}
}
@ -120,6 +129,8 @@ void particleCellVolume::setForce() const
scalar fieldValue=-1;
scalar cellVol=-1;
scalar minFieldVal=1e18;
scalar maxFieldVal=-1e18;
forAll(field,cellI)
{
@ -129,6 +140,8 @@ void particleCellVolume::setForce() const
cellVol = mesh_.V()[cellI];
scalarField_[cellI] = (1-fieldValue) * cellVol;
scalarField2_[cellI] = cellVol;
minFieldVal = min(minFieldVal, fieldValue);
maxFieldVal = max(maxFieldVal, fieldValue);
}
else
{
@ -138,6 +151,8 @@ void particleCellVolume::setForce() const
}
scalarField_.ref() = gSum(scalarField_);
scalarField2_.ref() = gSum(scalarField2_);
reduce(minFieldVal, minOp<scalar>());
reduce(maxFieldVal, maxOp<scalar>());
if(verbose_)
{
@ -147,8 +162,20 @@ void particleCellVolume::setForce() const
<< ", and > " << lowerThreshold_
<< ",\n the total volume of cells holding particles = " << scalarField2_[0]
<< ",\n this results in an average volume fraction of:" << scalarField_[0]/(scalarField2_[0]+SMALL)
<< ",\n the min occurring " << scalarFieldName_ << " is:" << minFieldVal
<< ",\n the max occurring " << scalarFieldName_ << " is:" << maxFieldVal
<< endl;
}
if(writeToFile_)
{
filePtr_() << mesh_.time().value() << " "
<< scalarField_[0] << " "
<< scalarField2_[0] << " "
<< scalarField_[0]/(scalarField2_[0]+SMALL) << " "
<< minFieldVal << " "
<< maxFieldVal << endl;
}
}// end if time >= startTime_
}

View File

@ -74,6 +74,10 @@ private:
const Switch verbose_;
const Switch writeToFile_;
mutable autoPtr<OFstream> filePtr_;
public:
//- Runtime type information