TimePaths.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "TimePaths.H"
27 #include "IOstreams.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const fileName& rootPath,
34  const fileName& caseName,
35  const word& systemName,
36  const word& constantName
37 )
38 :
39  processorCase_(false),
40  rootPath_(rootPath),
41  case_(caseName),
42  system_(systemName),
43  constant_(constantName)
44 {
45  // Find out from case name whether a processor directory
46  std::string::size_type pos = caseName.find("processor");
47  if (pos != string::npos)
48  {
49  processorCase_ = true;
50 
51  if (pos == 0)
52  {
53  globalCaseName_ = ".";
54  }
55  else
56  {
57  globalCaseName_ = caseName(pos-1);
58  }
59  }
60  else
61  {
62  globalCaseName_ = caseName;
63  }
64 }
65 
66 
68 (
69  const bool processorCase,
70  const fileName& rootPath,
71  const fileName& globalCaseName,
72  const fileName& caseName,
73  const word& systemName,
74  const word& constantName
75 )
76 :
77  processorCase_(processorCase),
78  rootPath_(rootPath),
79  globalCaseName_(globalCaseName),
80  case_(caseName),
81  system_(systemName),
82  constant_(constantName)
83 {
84  if (!processorCase)
85  {
86  // For convenience: find out from case name whether it is a
87  // processor directory and set processorCase flag so file searching
88  // goes up one level.
89  std::string::size_type pos = caseName.find("processor");
90 
91  if (pos != string::npos)
92  {
93  processorCase_ = true;
94 
95  if (pos == 0)
96  {
97  globalCaseName_ = ".";
98  }
99  else
100  {
101  globalCaseName_ = caseName(pos-1);
102  }
103  }
104  }
105 }
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
111 {
112  if (processorCase_)
113  {
114  return ".."/system();
115  }
116  else
117  {
118  return system();
119  }
120 }
121 
122 
124 {
125  if (processorCase_)
126  {
127  return ".."/constant();
128  }
129  else
130  {
131  return constant();
132  }
133 }
134 
135 
136 
137 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:79
TimePaths(const fileName &rootPath, const fileName &caseName, const word &systemName, const word &constantName)
Construct given database name, rootPath and casePath.
Definition: TimePaths.C:32
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
fileName caseSystem() const
Return system name for the case.
Definition: TimePaths.C:110
dimensionedScalar pos(const dimensionedScalar &ds)
A class for handling words, derived from string.
Definition: word.H:59
const word & constant() const
Return constant name.
Definition: TimePaths.H:123
graph_traits< Graph >::vertices_size_type size_type
Definition: SloanRenumber.C:73
const word & system() const
Return system name.
Definition: TimePaths.H:113
fileName caseConstant() const
Return constant name for the case.
Definition: TimePaths.C:123