TimePaths.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-2014 OpenFOAM Foundation
9 Copyright (C) 2016-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27Class
28 Foam::TimePaths
29
30Description
31 Address the time paths without using the Time class.
32
33SourceFiles
34 TimePaths.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef TimePaths_H
39#define TimePaths_H
40
41#include "fileName.H"
42#include "instantList.H"
43
44// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45
46namespace Foam
47{
48
49// Forward Declarations
50class argList;
51
52/*---------------------------------------------------------------------------*\
53 Class TimePaths Declaration
54\*---------------------------------------------------------------------------*/
55
57class TimePaths
58{
59 // Private Data
60
61 bool processorCase_;
62 bool distributed_;
63
64 const fileName rootPath_;
65 fileName globalCaseName_;
66 fileName case_;
67 const word system_;
68 const word constant_;
69
70
71 // Private Member Functions
72
73 //- Determine from case name whether it is a processor directory
74 bool detectProcessorCase();
75
76
77public:
78
79 // Constructors
80
81 //- Construct using characteristics given by the argList
82 explicit TimePaths
83 (
84 const argList& args,
85 const word& systemName = "system",
86 const word& constantName = "constant"
87 );
88
89 //- Construct given database name, rootPath and casePath
91 (
92 const fileName& rootPath,
93 const fileName& caseName,
94 const word& systemName = "system",
95 const word& constantName = "constant"
96 );
97
98
99 //- Construct given database name, rootPath and casePath
101 (
102 const bool processorCase,
103 const fileName& rootPath,
104 const bool distributed,
106 const fileName& caseName,
107 const word& systemName = "system",
108 const word& constantName = "constant"
109 );
110
111
112 // Member Functions
113
114 //- True if case running with parallel distributed directories
115 //- (ie. not NFS mounted)
116 inline bool distributed() const noexcept;
117
118 //- Return true if this is a processor case
119 inline bool processorCase() const noexcept;
120
121 //- Set processor case status. Return old one
122 inline bool processorCase(const bool isProcessorCase) noexcept;
123
124 //- Return root path
125 inline const fileName& rootPath() const;
126
127 //- Return global case name
128 inline const fileName& globalCaseName() const;
129
130 //- Return case name
131 inline const fileName& caseName() const;
132
133 //- The case name for modification (use with caution)
134 inline fileName& caseName();
135
136 //- Return path for the case
137 inline fileName path() const;
138
139 //- Return global path for the case
140 inline fileName globalPath() const;
141
142 //- Return the input relative to the globalPath by stripping off
143 //- a leading value of the globalPath
144 //
145 // \param input the directory or filename to make case-relative
146 // \param caseTag replace globalPath with <case> for later
147 // use with expand(), or prefix <case> if the file name was
148 // not an absolute location
150 (
151 const fileName& input,
152 const bool caseTag = false
153 ) const;
154
155
156 //- Return constant name
157 inline const word& constant() const;
158
159 //- Return system name
160 inline const word& system() const;
161
162 //- Return the constant name for the case, which is
163 //- \c ../constant() for parallel runs.
164 inline fileName caseConstant() const;
165
166 //- Return the system name for the case, which is
167 //- \c ../system() for parallel runs.
168 inline fileName caseSystem() const;
169
170 //- Return constant path
171 inline fileName constantPath() const;
172
173 //- Return system path
174 inline fileName systemPath() const;
175
176
177 // Searching
178
179 //- Search a given directory for valid time directories
180 // Forwards to the current fileHandler
182 (
183 const fileName& directory,
184 const word& constantName = "constant"
185 );
186
187 //- Search instantList for the time index closest to the specified time
188 static label findClosestTimeIndex
189 (
190 const instantList& timeDirs,
191 const scalar t,
192 const word& constantName = "constant"
193 );
194
195 //- Search the case for valid time directories
196 instantList times() const;
197
198 //- Search the case for the time closest to the given time
199 instant findClosestTime(const scalar t) const;
200};
201
202
203// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204
205} // End namespace Foam
206
207// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208
209#include "TimePathsI.H"
210
211// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212
213#endif
214
215// ************************************************************************* //
Address the time paths without using the Time class.
Definition: TimePaths.H:57
const fileName & caseName() const
Return case name.
Definition: TimePathsI.H:62
instantList times() const
Search the case for valid time directories.
Definition: TimePaths.C:149
const word & system() const
Return system name.
Definition: TimePathsI.H:102
const fileName & globalCaseName() const
Return global case name.
Definition: TimePathsI.H:56
bool distributed() const noexcept
Definition: TimePathsI.H:30
static instantList findTimes(const fileName &directory, const word &constantName="constant")
Search a given directory for valid time directories.
Definition: TimePaths.C:140
fileName relativePath(const fileName &input, const bool caseTag=false) const
Definition: TimePathsI.H:87
static label findClosestTimeIndex(const instantList &timeDirs, const scalar t, const word &constantName="constant")
Search instantList for the time index closest to the specified time.
Definition: TimePaths.C:156
fileName caseConstant() const
Definition: TimePathsI.H:108
fileName path() const
Return path for the case.
Definition: TimePathsI.H:74
fileName caseSystem() const
Definition: TimePathsI.H:119
const fileName & rootPath() const
Return root path.
Definition: TimePathsI.H:50
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
bool processorCase() const noexcept
Return true if this is a processor case.
Definition: TimePathsI.H:36
fileName constantPath() const
Return constant path.
Definition: TimePathsI.H:130
instant findClosestTime(const scalar t) const
Search the case for the time closest to the given time.
Definition: TimePaths.C:183
fileName systemPath() const
Return system path.
Definition: TimePathsI.H:136
fileName globalPath() const
Return global path for the case.
Definition: TimePathsI.H:80
Extract command arguments and options from the supplied argc and argv parameters.
Definition: argList.H:124
A class for handling file names.
Definition: fileName.H:76
An instant of time. Contains the time value and name. Uses Foam::Time when formatting the name.
Definition: instant.H:56
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
static Istream & input(Istream &is, IntRange< T > &range)
Definition: IntRanges.C:55
Foam::argList args(argc, argv)