openfoam/applications/utilities/postProcessing/dataConversion/foamToEnsight/getTimeIndex.H
Mark Olesen 3e87a46498 ENH: multi-region support for foamToEnsight (#2080)
- additional finite-area support too.
2021-05-30 21:02:59 +02:00

70 lines
1.9 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Read time index from ../uniform/time, but treat 0 and constant specially
or simply increment from the '-index' option if it was supplied
Note
Does a 'continue' out of the loop if not possible to obtain an index
\*---------------------------------------------------------------------------*/
label timeIndex = 0;
{
bool goodTimeIndex = true;
if (doConsecutive)
{
timeIndex = indexingNumber++;
}
else if
(
runTime.timeName() != runTime.constant()
&& runTime.timeName() != "0"
)
{
IOobject io
(
"time",
runTime.timeName(),
"uniform",
runTime,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
false // no register
);
if (io.typeHeaderOk<IOdictionary>(true, false))
{
io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
IOdictionary timeObject(io);
timeObject.readEntry("index", timeIndex);
}
else
{
goodTimeIndex = false;
Info<< "skip ... missing entry " << io.objectPath() << endl;
}
}
if (!goodTimeIndex)
{
continue;
}
}
// ************************************************************************* //