getTimeIndex.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
13
14Description
15 Read time index from ../uniform/time, but treat 0 and constant specially
16 or simply increment from the '-index' option if it was supplied
17
18Note
19 Does a 'continue' out of the loop if not possible to obtain an index
20
21\*---------------------------------------------------------------------------*/
22
23label timeIndex = 0;
24{
25 bool goodTimeIndex = true;
26
27 if (doConsecutive)
28 {
29 timeIndex = indexingNumber++;
30 }
31 else if
32 (
33 runTime.timeName() != runTime.constant()
34 && runTime.timeName() != "0"
35 )
36 {
37 IOobject io
38 (
39 "time",
40 runTime.timeName(),
41 "uniform",
42 runTime,
43 IOobject::READ_IF_PRESENT,
44 IOobject::NO_WRITE,
45 false // no register
46 );
47
48 if (io.typeHeaderOk<IOdictionary>(true, false))
49 {
50 io.readOpt(IOobject::MUST_READ_IF_MODIFIED);
51 IOdictionary timeObject(io);
52
53 timeObject.readEntry("index", timeIndex);
54 }
55 else
56 {
57 goodTimeIndex = false;
58 Info<< "skip ... missing entry " << io.objectPath() << endl;
59 }
60 }
61
62 if (!goodTimeIndex)
63 {
64 continue;
65 }
66}
67
68
69// ************************************************************************* //
engineTime & runTime
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
label timeIndex
Definition: getTimeIndex.H:30