mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-12-28 03:37:59 +00:00
ENH: add instance searching routines
- find start index - find index range spanning a time
This commit is contained in:
@ -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
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user