ENH: add instance searching routines

- find start index
- find index range spanning a time
This commit is contained in:
Mark Olesen
2022-07-15 14:43:31 +02:00
parent b4612b4c04
commit dfdbe7efd0
11 changed files with 166 additions and 151 deletions

View File

@ -239,26 +239,6 @@ bool Foam::noiseModel::validateBounds(const scalarList& p) const
}
Foam::label Foam::noiseModel::findStartTimeIndex
(
const instantList& allTimes,
const scalar startTime
) const
{
forAll(allTimes, timeI)
{
const instant& i = allTimes[timeI];
if (i.value() >= startTime)
{
return timeI;
}
}
return 0;
}
Foam::fileName Foam::noiseModel::baseFileDir(const label dataseti) const
{
return

View File

@ -239,11 +239,15 @@ protected:
bool validateBounds(const scalarList& p) const;
//- Find and return start time index
label findStartTimeIndex
FOAM_DEPRECATED_FOR(2022-07, "instant::findStart() static method")
static label findStartTimeIndex
(
const instantList& allTimes,
const scalar startTime
) const;
)
{
return instant::findStart(allTimes, startTime);
}
//- Return the base output directory
fileName baseFileDir(const label dataseti) const;

View File

@ -50,6 +50,7 @@ void surfaceNoise::initialise(const fileName& fName)
{
Info<< "Reading data file " << fName << endl;
instantList allTimes;
label nAvailableTimes = 0;
// All reading performed on the master processor only
@ -75,8 +76,8 @@ void surfaceNoise::initialise(const fileName& fName)
// the heavy lifting
// Set the time range
const instantList allTimes = readerPtr_->times();
startTimeIndex_ = findStartTimeIndex(allTimes, startTime_);
allTimes = readerPtr_->times();
startTimeIndex_ = instant::findStart(allTimes, startTime_);
// Determine the windowing
nAvailableTimes = allTimes.size() - startTimeIndex_;
@ -97,8 +98,6 @@ void surfaceNoise::initialise(const fileName& fName)
if (Pstream::master())
{
// Restrict times
const instantList allTimes = readerPtr_->times();
times_.setSize(nRequiredTimes);
forAll(times_, timeI)
{