mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: simplify use of case-relative paths
- provide relativePath() for argList and for Time.
These are relative to the case globalPath().
Eg,
Info<< "output: " << runTime.relativePath(outputFile) << nl;
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -38,11 +38,13 @@ using namespace Foam;
|
|||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argList::noBanner();
|
argList::noBanner();
|
||||||
argList::noParallel();
|
argList::noCheckProcessorDirectories(); // parallel OK, but without checks
|
||||||
|
|
||||||
// argList::noFunctionObjects();
|
// argList::noFunctionObjects();
|
||||||
argList::addOption("label", "value", "Test parsing of label");
|
argList::addOption("label", "value", "Test parsing of label");
|
||||||
argList::addOption("scalar", "value", "Test parsing of scalar");
|
argList::addOption("scalar", "value", "Test parsing of scalar");
|
||||||
argList::addOption("string", "value", "Test string lookup");
|
argList::addOption("string", "value", "Test string lookup");
|
||||||
|
argList::addOption("relative", "PATH", "Test relativePath");
|
||||||
|
|
||||||
// These are actually lies (never had -parseLabel, -parseScalar etc),
|
// These are actually lies (never had -parseLabel, -parseScalar etc),
|
||||||
// but good for testing...
|
// but good for testing...
|
||||||
@ -70,20 +72,27 @@ int main(int argc, char *argv[])
|
|||||||
argList::addArgument("label");
|
argList::addArgument("label");
|
||||||
argList::noMandatoryArgs();
|
argList::noMandatoryArgs();
|
||||||
|
|
||||||
argList args(argc, argv);
|
#include "setRootCase.H"
|
||||||
|
|
||||||
Info<< "command-line ("
|
Pout<< "command-line ("
|
||||||
<< args.options().size() << " options, "
|
<< args.options().size() << " options, "
|
||||||
<< args.args().size() << " args)" << nl
|
<< args.args().size() << " args)" << nl
|
||||||
<< " " << args.commandLine().c_str() << nl << nl;
|
<< " " << args.commandLine().c_str() << nl << nl;
|
||||||
|
|
||||||
Info<< "rootPath: " << args.rootPath() << nl
|
Pout<< "rootPath: " << args.rootPath() << nl
|
||||||
<< "globalCase: " << args.globalCaseName() << nl
|
<< "globalCase: " << args.globalCaseName() << nl
|
||||||
<< "globalPath: " << args.globalPath() << nl
|
<< "globalPath: " << args.globalPath() << nl
|
||||||
<< nl;
|
<< nl;
|
||||||
|
|
||||||
Info<<"have: "
|
if (args.found("relative"))
|
||||||
<<args.count({"label", "scalar"}) << " options" << nl;
|
{
|
||||||
|
Pout<< "input path: " << args["relative"] << nl
|
||||||
|
<< "relative : " << args.relativePath(args["relative"], true) << nl
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
|
Info<< "have: "
|
||||||
|
<< args.count({"label", "scalar"}) << " options" << nl;
|
||||||
|
|
||||||
label ival;
|
label ival;
|
||||||
scalar sval;
|
scalar sval;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ Description
|
|||||||
|
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "IOstreams.H"
|
#include "IOstreams.H"
|
||||||
#include "TimePaths.H"
|
#include "Time.H"
|
||||||
#include "timeSelector.H"
|
#include "timeSelector.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
@ -58,13 +58,31 @@ bool print(const instantList& instants)
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argList::addNote("Test timeSelector");
|
argList::addNote("Test timeSelector and TimePaths");
|
||||||
|
|
||||||
timeSelector::addOptions(true, true);
|
timeSelector::addOptions(true, true);
|
||||||
argList::noLibs();
|
argList::noLibs();
|
||||||
argList::noFunctionObjects();
|
argList::noFunctionObjects();
|
||||||
|
|
||||||
|
argList::addOption("relative", "PATH", "Test relativePath");
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
#include "createTime.H"
|
||||||
|
|
||||||
|
Pout<< "Time" << nl
|
||||||
|
<< "rootPath: " << runTime.rootPath() << nl
|
||||||
|
<< "path: " << runTime.path() << nl
|
||||||
|
<< "globalCase: " << runTime.globalCaseName() << nl
|
||||||
|
<< "globalPath: " << runTime.globalPath() << nl
|
||||||
|
<< nl;
|
||||||
|
|
||||||
|
if (args.found("relative"))
|
||||||
|
{
|
||||||
|
Pout<< "input path: " << args["relative"] << nl
|
||||||
|
<< "relative : " << runTime.relativePath(args["relative"], true)
|
||||||
|
<< nl
|
||||||
|
<< nl;
|
||||||
|
}
|
||||||
|
|
||||||
autoPtr<TimePaths> timePaths;
|
autoPtr<TimePaths> timePaths;
|
||||||
|
|
||||||
|
|||||||
@ -94,7 +94,7 @@ if (doLagrangian)
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Lagrangian: "
|
Info<< " Lagrangian: "
|
||||||
<< writer.output().relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(writer.output()) << nl;
|
||||||
|
|
||||||
writer.writeTimeValue(mesh.time().value());
|
writer.writeTimeValue(mesh.time().value());
|
||||||
writer.writeGeometry();
|
writer.writeGeometry();
|
||||||
|
|||||||
@ -107,7 +107,7 @@ Description
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Surface : "
|
Info<< " Surface : "
|
||||||
<< writer.output().relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(writer.output()) << nl;
|
||||||
|
|
||||||
|
|
||||||
writer.writeTimeValue(timeValue);
|
writer.writeTimeValue(timeValue);
|
||||||
@ -211,7 +211,7 @@ Description
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " FaceZone : "
|
Info<< " FaceZone : "
|
||||||
<< writer.output().relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(writer.output()) << nl;
|
||||||
|
|
||||||
|
|
||||||
writer.beginFile(fz.name());
|
writer.beginFile(fz.name());
|
||||||
|
|||||||
@ -42,7 +42,7 @@ if (faceSetName.size())
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " faceSet : "
|
Info<< " faceSet : "
|
||||||
<< outputName.relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(outputName) << nl;
|
||||||
|
|
||||||
vtk::writeFaceSet
|
vtk::writeFaceSet
|
||||||
(
|
(
|
||||||
@ -70,7 +70,7 @@ if (pointSetName.size())
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " pointSet : "
|
Info<< " pointSet : "
|
||||||
<< outputName.relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(outputName) << nl;
|
||||||
|
|
||||||
vtk::writePointSet
|
vtk::writePointSet
|
||||||
(
|
(
|
||||||
|
|||||||
@ -113,7 +113,7 @@ Description
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Internal : "
|
Info<< " Internal : "
|
||||||
<< internalWriter->output().relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(internalWriter->output()) << nl;
|
||||||
|
|
||||||
internalWriter->writeTimeValue(mesh.time().value());
|
internalWriter->writeTimeValue(mesh.time().value());
|
||||||
internalWriter->writeGeometry();
|
internalWriter->writeGeometry();
|
||||||
@ -163,7 +163,7 @@ Description
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Boundaries: "
|
Info<< " Boundaries: "
|
||||||
<< writer->output().relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(writer->output()) << nl;
|
||||||
|
|
||||||
writer->writeTimeValue(timeValue);
|
writer->writeTimeValue(timeValue);
|
||||||
writer->writeGeometry();
|
writer->writeGeometry();
|
||||||
@ -229,7 +229,7 @@ Description
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Boundary : "
|
Info<< " Boundary : "
|
||||||
<< writer->output().relative(runTime.globalPath()) << nl;
|
<< runTime.relativePath(writer->output()) << nl;
|
||||||
|
|
||||||
writer->writeTimeValue(timeValue);
|
writer->writeTimeValue(timeValue);
|
||||||
writer->writeGeometry();
|
writer->writeGeometry();
|
||||||
|
|||||||
@ -650,7 +650,7 @@ int main(int argc, char *argv[])
|
|||||||
if (args.found("overwrite") && isDir(regionDir))
|
if (args.found("overwrite") && isDir(regionDir))
|
||||||
{
|
{
|
||||||
Info<< "Removing old directory "
|
Info<< "Removing old directory "
|
||||||
<< regionDir.relative(runTime.globalPath())
|
<< runTime.relativePath(regionDir)
|
||||||
<< nl << endl;
|
<< nl << endl;
|
||||||
rmDir(regionDir);
|
rmDir(regionDir);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -693,8 +693,7 @@ int main(int argc, char *argv[])
|
|||||||
vtkWriter->writeGeometry();
|
vtkWriter->writeGeometry();
|
||||||
|
|
||||||
Info<< "Writing VTK to "
|
Info<< "Writing VTK to "
|
||||||
<< ((vtkOutputDir/outputName).ext(vtkWriter->ext()))
|
<< runTime.relativePath(vtkWriter->output()) << nl;
|
||||||
.relative(runTime.globalPath()) << nl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@ -35,11 +35,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const InfoProxy<IOobject>& ip)
|
|||||||
|
|
||||||
os << "IOobject: "
|
os << "IOobject: "
|
||||||
<< io.type() << token::SPACE
|
<< io.type() << token::SPACE
|
||||||
<< io.name() << token::SPACE
|
<< io.name()
|
||||||
<< "readOpt:" << token::SPACE << io.readOpt() << token::SPACE
|
<< " local: " << io.local()
|
||||||
<< "writeOpt:" << token::SPACE << io.writeOpt() << token::SPACE
|
<< " readOpt: " << io.readOpt()
|
||||||
<< "globalObject:" << token::SPACE << io.globalObject() << token::SPACE
|
<< " writeOpt: " << io.writeOpt()
|
||||||
<< io.path() << endl;
|
<< " globalObject: " << io.globalObject()
|
||||||
|
<< token::SPACE << io.path() << endl;
|
||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -133,28 +133,6 @@ Foam::TimePaths::TimePaths
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::fileName Foam::TimePaths::caseSystem() const
|
|
||||||
{
|
|
||||||
if (processorCase_)
|
|
||||||
{
|
|
||||||
return ".."/system();
|
|
||||||
}
|
|
||||||
|
|
||||||
return system();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::fileName Foam::TimePaths::caseConstant() const
|
|
||||||
{
|
|
||||||
if (processorCase_)
|
|
||||||
{
|
|
||||||
return ".."/constant();
|
|
||||||
}
|
|
||||||
|
|
||||||
return constant();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Foam::instantList Foam::TimePaths::findTimes
|
Foam::instantList Foam::TimePaths::findTimes
|
||||||
(
|
(
|
||||||
const fileName& directory,
|
const fileName& directory,
|
||||||
|
|||||||
@ -108,86 +108,64 @@ public:
|
|||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
|
|
||||||
|
//- True if case running with parallel distributed directories
|
||||||
|
//- (ie. not NFS mounted)
|
||||||
|
inline bool distributed() const;
|
||||||
|
|
||||||
//- Return true if this is a processor case
|
//- Return true if this is a processor case
|
||||||
bool processorCase() const
|
inline bool processorCase() const;
|
||||||
{
|
|
||||||
return processorCase_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return root path
|
//- Return root path
|
||||||
const fileName& rootPath() const
|
inline const fileName& rootPath() const;
|
||||||
{
|
|
||||||
return rootPath_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return global case name
|
//- Return global case name
|
||||||
const fileName& globalCaseName() const
|
inline const fileName& globalCaseName() const;
|
||||||
{
|
|
||||||
return globalCaseName_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return case name
|
//- Return case name
|
||||||
const fileName& caseName() const
|
inline const fileName& caseName() const;
|
||||||
{
|
|
||||||
return case_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return case name
|
//- The case name for modification (use with caution)
|
||||||
fileName& caseName()
|
inline fileName& caseName();
|
||||||
{
|
|
||||||
return case_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return system name
|
//- Return path for the case
|
||||||
const word& system() const
|
inline fileName path() const;
|
||||||
{
|
|
||||||
return system_;
|
//- Return global path for the case
|
||||||
}
|
inline fileName globalPath() const;
|
||||||
|
|
||||||
|
//- Return the input relative to the globalPath by stripping off
|
||||||
|
//- a leading value of the globalPath
|
||||||
|
//
|
||||||
|
// \param input the directory or filename to make case-relative
|
||||||
|
// \param caseTag replace globalPath with \<case\> for later
|
||||||
|
// use with expand(), or prefix \<case\> if the file name was
|
||||||
|
// not an absolute location
|
||||||
|
inline fileName relativePath
|
||||||
|
(
|
||||||
|
const fileName& input,
|
||||||
|
const bool caseTag = false
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Return the system name for the case, which is
|
|
||||||
//- \c ../system() for parallel runs.
|
|
||||||
fileName caseSystem() const;
|
|
||||||
|
|
||||||
//- Return constant name
|
//- Return constant name
|
||||||
const word& constant() const
|
inline const word& constant() const;
|
||||||
{
|
|
||||||
return constant_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Is case running with parallel distributed directories
|
//- Return system name
|
||||||
// (i.e. not NFS mounted)
|
inline const word& system() const;
|
||||||
bool distributed() const
|
|
||||||
{
|
|
||||||
return distributed_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return the constant name for the case, which is
|
//- Return the constant name for the case, which is
|
||||||
//- \c ../constant() for parallel runs.
|
//- \c ../constant() for parallel runs.
|
||||||
fileName caseConstant() const;
|
inline fileName caseConstant() const;
|
||||||
|
|
||||||
//- Return path for the case
|
//- Return the system name for the case, which is
|
||||||
fileName path() const
|
//- \c ../system() for parallel runs.
|
||||||
{
|
inline fileName caseSystem() const;
|
||||||
return rootPath()/caseName();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return global path for the case
|
|
||||||
fileName globalPath() const
|
|
||||||
{
|
|
||||||
return rootPath()/globalCaseName();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return system path
|
|
||||||
fileName systemPath() const
|
|
||||||
{
|
|
||||||
return path()/system();
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Return constant path
|
//- Return constant path
|
||||||
fileName constantPath() const
|
inline fileName constantPath() const;
|
||||||
{
|
|
||||||
return path()/constant();
|
//- Return system path
|
||||||
}
|
inline fileName systemPath() const;
|
||||||
|
|
||||||
|
|
||||||
// Searching
|
// Searching
|
||||||
@ -223,6 +201,10 @@ public:
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "TimePathsI.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
132
src/OpenFOAM/db/Time/TimePathsI.H
Normal file
132
src/OpenFOAM/db/Time/TimePathsI.H
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
inline bool Foam::TimePaths::distributed() const
|
||||||
|
{
|
||||||
|
return distributed_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Foam::TimePaths::processorCase() const
|
||||||
|
{
|
||||||
|
return processorCase_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::fileName& Foam::TimePaths::rootPath() const
|
||||||
|
{
|
||||||
|
return rootPath_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::fileName& Foam::TimePaths::globalCaseName() const
|
||||||
|
{
|
||||||
|
return globalCaseName_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::fileName& Foam::TimePaths::caseName() const
|
||||||
|
{
|
||||||
|
return case_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName& Foam::TimePaths::caseName()
|
||||||
|
{
|
||||||
|
return case_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::TimePaths::path() const
|
||||||
|
{
|
||||||
|
return rootPath()/caseName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::TimePaths::globalPath() const
|
||||||
|
{
|
||||||
|
return rootPath()/globalCaseName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::TimePaths::relativePath
|
||||||
|
(
|
||||||
|
const fileName& input,
|
||||||
|
const bool caseTag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return input.relative(globalPath(), caseTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::word& Foam::TimePaths::constant() const
|
||||||
|
{
|
||||||
|
return constant_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline const Foam::word& Foam::TimePaths::system() const
|
||||||
|
{
|
||||||
|
return system_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::TimePaths::caseConstant() const
|
||||||
|
{
|
||||||
|
if (processorCase_)
|
||||||
|
{
|
||||||
|
return ".."/constant();
|
||||||
|
}
|
||||||
|
|
||||||
|
return constant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::TimePaths::caseSystem() const
|
||||||
|
{
|
||||||
|
if (processorCase_)
|
||||||
|
{
|
||||||
|
return ".."/system();
|
||||||
|
}
|
||||||
|
|
||||||
|
return system();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::TimePaths::constantPath() const
|
||||||
|
{
|
||||||
|
return path()/constant();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::TimePaths::systemPath() const
|
||||||
|
{
|
||||||
|
return path()/system();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -25,7 +25,6 @@ License
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
|
||||||
inline Foam::scalar Foam::TimeState::timeOutputValue() const
|
inline Foam::scalar Foam::TimeState::timeOutputValue() const
|
||||||
{
|
{
|
||||||
return timeToUserTime(value());
|
return timeToUserTime(value());
|
||||||
|
|||||||
@ -304,6 +304,19 @@ public:
|
|||||||
// \note This is guaranteed to be an absolute path
|
// \note This is guaranteed to be an absolute path
|
||||||
inline fileName globalPath() const;
|
inline fileName globalPath() const;
|
||||||
|
|
||||||
|
//- Return the input relative to the globalPath by stripping off
|
||||||
|
//- a leading value of the globalPath
|
||||||
|
//
|
||||||
|
// \param input the directory or filename to make case-relative
|
||||||
|
// \param caseTag replace globalPath with \<case\> for later
|
||||||
|
// use with expand(), or prefix \<case\> if the file name was
|
||||||
|
// not an absolute location
|
||||||
|
inline fileName relativePath
|
||||||
|
(
|
||||||
|
const fileName& input,
|
||||||
|
const bool caseTag = false
|
||||||
|
) const;
|
||||||
|
|
||||||
//- Return distributed flag
|
//- Return distributed flag
|
||||||
//- (i.e. are rootPaths different on different machines)
|
//- (i.e. are rootPaths different on different machines)
|
||||||
inline bool distributed() const;
|
inline bool distributed() const;
|
||||||
|
|||||||
@ -87,6 +87,16 @@ inline Foam::fileName Foam::argList::globalPath() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline Foam::fileName Foam::argList::relativePath
|
||||||
|
(
|
||||||
|
const fileName& input,
|
||||||
|
const bool caseTag
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
return input.relative(globalPath(), caseTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Foam::argList::distributed() const
|
inline bool Foam::argList::distributed() const
|
||||||
{
|
{
|
||||||
return parRunControl_.distributed();
|
return parRunControl_.distributed();
|
||||||
|
|||||||
@ -96,7 +96,7 @@ namespace Foam
|
|||||||
//- OpenFOAM version (name or stringified number) as a std::string
|
//- OpenFOAM version (name or stringified number) as a std::string
|
||||||
extern const std::string version;
|
extern const std::string version;
|
||||||
|
|
||||||
//- Test if the patch string appeared to be in use,
|
//- Test if the patch string appears to be in use,
|
||||||
//- which is when it is defined (non-zero).
|
//- which is when it is defined (non-zero).
|
||||||
bool patched();
|
bool patched();
|
||||||
|
|
||||||
|
|||||||
@ -367,7 +367,7 @@ std::string Foam::fileName::nameLessExt(const std::string& str)
|
|||||||
Foam::fileName Foam::fileName::relative
|
Foam::fileName Foam::fileName::relative
|
||||||
(
|
(
|
||||||
const fileName& parent,
|
const fileName& parent,
|
||||||
const bool caseRelative
|
const bool caseTag
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const auto top = parent.size();
|
const auto top = parent.size();
|
||||||
@ -383,7 +383,7 @@ Foam::fileName Foam::fileName::relative
|
|||||||
&& f.startsWith(parent)
|
&& f.startsWith(parent)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (caseRelative)
|
if (caseTag)
|
||||||
{
|
{
|
||||||
return "<case>"/f.substr(top+1);
|
return "<case>"/f.substr(top+1);
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ Foam::fileName Foam::fileName::relative
|
|||||||
return f.substr(top+1);
|
return f.substr(top+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (caseRelative && f.size() && !f.isAbsolute())
|
else if (caseTag && f.size() && !f.isAbsolute())
|
||||||
{
|
{
|
||||||
return "<case>"/f;
|
return "<case>"/f;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -294,13 +294,13 @@ public:
|
|||||||
//- where possible.
|
//- where possible.
|
||||||
//
|
//
|
||||||
// \param parent the parent directory
|
// \param parent the parent directory
|
||||||
// \param caseRelative replace the parent with \<case\> for later
|
// \param caseTag replace the parent with \<case\> for later
|
||||||
// use with expand(), or prefix \<case\> if the file name was
|
// use with expand(), or prefix \<case\> if the file name was
|
||||||
// not an absolute location
|
// not an absolute location
|
||||||
fileName relative
|
fileName relative
|
||||||
(
|
(
|
||||||
const fileName& parent,
|
const fileName& parent,
|
||||||
const bool caseRelative = false
|
const bool caseTag = false
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Return file name without extension (part before last .)
|
//- Return file name without extension (part before last .)
|
||||||
|
|||||||
@ -786,7 +786,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
|
|||||||
propsDict.add
|
propsDict.add
|
||||||
(
|
(
|
||||||
"file",
|
"file",
|
||||||
scalarVtkFile.relative(time_.globalPath(), true)
|
time_.relativePath(scalarVtkFile, true)
|
||||||
);
|
);
|
||||||
setProperty(fieldName, propsDict);
|
setProperty(fieldName, propsDict);
|
||||||
}
|
}
|
||||||
@ -798,7 +798,7 @@ bool Foam::functionObjects::streamLineBase::writeToFile()
|
|||||||
propsDict.add
|
propsDict.add
|
||||||
(
|
(
|
||||||
"file",
|
"file",
|
||||||
vectorVtkFile.relative(time_.globalPath(), true)
|
time_.relativePath(vectorVtkFile, true)
|
||||||
);
|
);
|
||||||
setProperty(fieldName, propsDict);
|
setProperty(fieldName, propsDict);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -238,7 +238,7 @@ bool Foam::functionObjects::dataCloud::write()
|
|||||||
if (writeCloud(outputName, cloudName))
|
if (writeCloud(outputName, cloudName))
|
||||||
{
|
{
|
||||||
Log << " cloud : "
|
Log << " cloud : "
|
||||||
<< outputName.relative(time_.globalPath()) << endl;
|
<< time_.relativePath(outputName) << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -318,13 +318,12 @@ bool Foam::functionObjects::vtkCloud::writeCloud
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Shorten file name to be case-local and use "<case>" shortcut
|
// Case-local file name with "<case>" to make relocatable
|
||||||
// to make the content relocatable
|
|
||||||
dictionary propsDict;
|
dictionary propsDict;
|
||||||
propsDict.add
|
propsDict.add
|
||||||
(
|
(
|
||||||
"file",
|
"file",
|
||||||
file.relative(time_.globalPath(), true)
|
time_.relativePath(file, true)
|
||||||
);
|
);
|
||||||
propsDict.add("fields", written);
|
propsDict.add("fields", written);
|
||||||
|
|
||||||
@ -503,7 +502,7 @@ bool Foam::functionObjects::vtkCloud::write()
|
|||||||
if (writeCloud(outputName, cloudName))
|
if (writeCloud(outputName, cloudName))
|
||||||
{
|
{
|
||||||
Log << " cloud : "
|
Log << " cloud : "
|
||||||
<< outputName.relative(time_.globalPath()) << endl;
|
<< time_.relativePath(outputName) << endl;
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -380,7 +380,7 @@ bool Foam::functionObjects::vtkWrite::write()
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Internal : "
|
Info<< " Internal : "
|
||||||
<< internalWriter->output().relative(time_.globalPath())
|
<< time_.relativePath(internalWriter->output())
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
// No sub-block for internal
|
// No sub-block for internal
|
||||||
@ -432,7 +432,7 @@ bool Foam::functionObjects::vtkWrite::write()
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Boundaries: "
|
Info<< " Boundaries: "
|
||||||
<< writer->output().relative(time_.globalPath()) << nl;
|
<< time_.relativePath(writer->output()) << nl;
|
||||||
|
|
||||||
|
|
||||||
writer->writeTimeValue(timeValue);
|
writer->writeTimeValue(timeValue);
|
||||||
@ -497,7 +497,7 @@ bool Foam::functionObjects::vtkWrite::write()
|
|||||||
);
|
);
|
||||||
|
|
||||||
Info<< " Boundary : "
|
Info<< " Boundary : "
|
||||||
<< writer->output().relative(time_.globalPath()) << nl;
|
<< time_.relativePath(writer->output()) << nl;
|
||||||
|
|
||||||
writer->writeTimeValue(timeValue);
|
writer->writeTimeValue(timeValue);
|
||||||
writer->writeGeometry();
|
writer->writeGeometry();
|
||||||
|
|||||||
@ -338,8 +338,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields)
|
|||||||
Pstream::scatter(sampleFile);
|
Pstream::scatter(sampleFile);
|
||||||
if (sampleFile.size())
|
if (sampleFile.size())
|
||||||
{
|
{
|
||||||
// Shorten file name to be case-local and use "<case>" shortcut
|
// Case-local file name with "<case>" to make relocatable
|
||||||
// to make the content relocatable
|
|
||||||
|
|
||||||
forAll(masterFields, fieldi)
|
forAll(masterFields, fieldi)
|
||||||
{
|
{
|
||||||
@ -347,7 +346,7 @@ void Foam::sampledSets::sampleAndWrite(fieldGroup<Type>& fields)
|
|||||||
propsDict.add
|
propsDict.add
|
||||||
(
|
(
|
||||||
"file",
|
"file",
|
||||||
sampleFile.relative(time_.globalPath(), true)
|
time_.relativePath(sampleFile, true)
|
||||||
);
|
);
|
||||||
|
|
||||||
const word& fieldName = masterFields[fieldi].name();
|
const word& fieldName = masterFields[fieldi].name();
|
||||||
|
|||||||
@ -95,14 +95,13 @@ void Foam::sampledSurfaces::writeSurface
|
|||||||
Pstream::scatter(sampleFile);
|
Pstream::scatter(sampleFile);
|
||||||
if (sampleFile.size())
|
if (sampleFile.size())
|
||||||
{
|
{
|
||||||
// Shorten file name to be case-local and use "<case>" shortcut
|
// Case-local file name with "<case>" to make relocatable
|
||||||
// to make the content relocatable
|
|
||||||
|
|
||||||
dictionary propsDict;
|
dictionary propsDict;
|
||||||
propsDict.add
|
propsDict.add
|
||||||
(
|
(
|
||||||
"file",
|
"file",
|
||||||
sampleFile.relative(time_.globalPath(), true)
|
time_.relativePath(sampleFile, true)
|
||||||
);
|
);
|
||||||
setProperty(fieldName, propsDict);
|
setProperty(fieldName, propsDict);
|
||||||
}
|
}
|
||||||
@ -123,14 +122,13 @@ void Foam::sampledSurfaces::writeSurface
|
|||||||
s.interpolate()
|
s.interpolate()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Case-local filename and "<case>" shortcut for readable output
|
// Case-local file name with "<case>" to make relocatable
|
||||||
// and for possibly relocation of files
|
|
||||||
|
|
||||||
dictionary propsDict;
|
dictionary propsDict;
|
||||||
propsDict.add
|
propsDict.add
|
||||||
(
|
(
|
||||||
"file",
|
"file",
|
||||||
fName.relative(time_.globalPath(), true)
|
time_.relativePath(fName, true)
|
||||||
);
|
);
|
||||||
setProperty(fieldName, propsDict);
|
setProperty(fieldName, propsDict);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user