mirror of
https://github.com/ParticulateFlow/CFDEMcoupling-PFM.git
synced 2025-12-08 06:37:44 +00:00
standardRecModel: skip zero time
Add an optional boolean switch to standardRecModel class to allow ignoring the 0 directory when building the recurrence data base. This is useful when using rStatAnalysis as a post-processing tool on a case where OpenFOAM's purgeWrite feature was used. If purgeWrite is set to 0, then all time steps will be written to disk. If purgeWrite is set to N, then only the last N time steps will be stored. As a new time step is written to disk, the oldest one will be discarded. However, the 0 directory is excluded from removal. If purgeWrite is set to 5, and we run a simulation with deltaT=1 und endTime=10, then the time steps on disk will be: 0, 6, 7, 8, 9, 10. Running rStatAnalysis on this case, will end in fatal error, as the time step within the data base will be found to be non-uniform. The quick and dirty fix, would be to remove or rename the 0 directory, so that it does not get read. However, telling the recurrence model whether to include 0 or not seems the more elegant solution.
This commit is contained in:
@ -59,7 +59,8 @@ standardRecModel::standardRecModel
|
||||
dataBaseName_(propsDict_.lookupOrDefault<word>("dataBase", word("dataBase"))),
|
||||
recTime(fileName(dataBaseName_), "", "../system", "../constant", false),
|
||||
timeDirs(recTime.times()),
|
||||
numRecFields_(label(timeDirs.size())),
|
||||
skipZero_(propsDict_.lookupOrDefault<Switch>("skipZero", Switch(false))),
|
||||
numRecFields_(skipZero_ ? label(timeDirs.size())-1 : label(timeDirs.size())),
|
||||
recurrenceMatrix_(numRecFields_,scalar(0.0)),
|
||||
timeIndexList_(numRecFields_-1),
|
||||
timeValueList_(numRecFields_-1),
|
||||
@ -79,8 +80,9 @@ standardRecModel::standardRecModel
|
||||
Info << "recTime.caseName() " << recTime.caseName() << endl;
|
||||
Info << "recTime.path() " << recTime.path() << endl;
|
||||
Info << "recTime.timePath() " << recTime.timePath() << endl;
|
||||
Info << "recTime.timeName() " << recTime.timeName() << endl;
|
||||
Info << "timeDirs " << timeDirs << endl;
|
||||
Info << "recTime.timeName() " << recTime.timeName() << endl;
|
||||
Info << "timeDirs " << timeDirs << endl;
|
||||
Info << "consider 0 directory: " << skipZero_ << endl;
|
||||
}
|
||||
readTimeSeries();
|
||||
|
||||
@ -129,6 +131,16 @@ scalar standardRecModel::checkTimeStep()
|
||||
|
||||
forAll(timeValueList_, i)
|
||||
{
|
||||
// skip zero
|
||||
if (skipZero_ and timeDirs[i].value() == 0)
|
||||
{
|
||||
if (verbose_)
|
||||
{
|
||||
Info << " ... skipping 0 in checkTimeStep()" << endl;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// compute time step
|
||||
if (timeDirs[i].value() == timeDirs.last().value())
|
||||
{
|
||||
@ -197,6 +209,17 @@ void standardRecModel::readFieldSeries()
|
||||
// set time
|
||||
recTime.setTime(*it, it->value());
|
||||
|
||||
// skip zero
|
||||
if (skipZero_ and recTime.timeName() == "0")
|
||||
{
|
||||
if (verbose_)
|
||||
{
|
||||
Info << " ... skipping 0 in readFieldSeries()" << endl;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip constant
|
||||
if (recTime.timeName() == "constant")
|
||||
{
|
||||
@ -282,6 +305,17 @@ void standardRecModel::readTimeSeries()
|
||||
continue;
|
||||
}
|
||||
|
||||
// skip zero
|
||||
if (skipZero_ and recTime.timeName() == "0")
|
||||
{
|
||||
if (verbose_)
|
||||
{
|
||||
Info << " ... skipping 0 in readTimeSeries()" << endl;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (firsttime)
|
||||
{
|
||||
firsttime = false;
|
||||
|
||||
@ -46,6 +46,7 @@ protected:
|
||||
word dataBaseName_;
|
||||
Foam::Time recTime;
|
||||
instantList timeDirs;
|
||||
Switch skipZero_;
|
||||
label numRecFields_;
|
||||
|
||||
// matrix that contains the recurrence ERROR
|
||||
|
||||
Reference in New Issue
Block a user