mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add IOobject::objectRelPath() for compact output (#2195)
This commit is contained in:
@ -11,7 +11,7 @@ License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
|
||||
Description
|
||||
Search for the appropriate faMeshDefinition dictionary....
|
||||
Search for the appropriate faMeshDefinition dictionary...
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
@ -86,7 +86,7 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
}
|
||||
|
||||
Info<< "Creating faMesh from definition: "
|
||||
<< runTime.relativePath(meshDictIO.objectPath()) << endl;
|
||||
<< meshDictIO.objectRelPath() << endl;
|
||||
|
||||
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
||||
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
|
||||
IOdictionary meshDict(dictIO);
|
||||
|
||||
Info<< "Creating PDRblockMesh from "
|
||||
<< runTime.relativePath(dictIO.objectPath()) << endl;
|
||||
<< dictIO.objectRelPath() << endl;
|
||||
|
||||
// Always start from a PDRblock
|
||||
PDRblock blkMesh(meshDict, true);
|
||||
|
||||
@ -1,3 +1,20 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2021 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||
|
||||
Description
|
||||
Search for the appropriate blockMeshDict dictionary...
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// Search for the appropriate blockMesh dictionary....
|
||||
const word dictName("blockMeshDict");
|
||||
|
||||
@ -64,9 +81,12 @@ autoPtr<IOdictionary> meshDictPtr;
|
||||
}
|
||||
|
||||
Info<< "Creating block mesh from "
|
||||
<< runTime.relativePath(meshDictIO.objectPath()) << endl;
|
||||
<< meshDictIO.objectRelPath() << endl;
|
||||
|
||||
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
||||
}
|
||||
|
||||
const IOdictionary& meshDict = *meshDictPtr;
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -647,7 +647,7 @@ int main(int argc, char *argv[])
|
||||
cellDecomposition.write();
|
||||
|
||||
Info<< nl << "Wrote decomposition to "
|
||||
<< runTime.relativePath(cellDecomposition.objectPath())
|
||||
<< cellDecomposition.objectRelPath()
|
||||
<< " for use in manual decomposition." << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -160,7 +160,7 @@ void Foam::domainDecompositionDryRun::execute
|
||||
// cellDecomposition.write();
|
||||
//
|
||||
// Info<< nl << "Wrote decomposition to "
|
||||
// << runTime.relativePath(cellDecomposition.objectPath())
|
||||
// << cellDecomposition.objectRelPath()
|
||||
// << " for use in manual decomposition." << endl;
|
||||
|
||||
Info<< nl;
|
||||
|
||||
@ -64,7 +64,7 @@ void Foam::domainDecompositionDryRun::writeVolField
|
||||
cellDist.write();
|
||||
|
||||
Info<< nl << "Wrote decomposition to "
|
||||
<< this->mesh().time().relativePath(cellDist.objectPath())
|
||||
<< cellDist.objectRelPath()
|
||||
<< " (volScalarField) for visualization."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ void Foam::domainDecomposition::writeVolField
|
||||
cellDist.write();
|
||||
|
||||
Info<< nl << "Wrote decomposition to "
|
||||
<< this->mesh().time().relativePath(cellDist.objectPath())
|
||||
<< cellDist.objectRelPath()
|
||||
<< " (volScalarField) for visualization."
|
||||
<< endl;
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ void writeDistribution
|
||||
cellDecomposition.write();
|
||||
|
||||
Info<< nl << "Wrote decomposition to "
|
||||
<< runTime.relativePath(cellDecomposition.objectPath())
|
||||
<< cellDecomposition.objectRelPath()
|
||||
<< " for use in manual decomposition." << endl;
|
||||
|
||||
// Write as volScalarField for postprocessing. Change time to 0
|
||||
@ -434,7 +434,7 @@ void writeDistribution
|
||||
cellDist.write();
|
||||
|
||||
Info<< nl << "Wrote decomposition to "
|
||||
<< runTime.relativePath(cellDist.objectPath())
|
||||
<< cellDist.objectRelPath()
|
||||
<< " (volScalarField) for visualization."
|
||||
<< endl;
|
||||
|
||||
|
||||
@ -542,6 +542,29 @@ Foam::fileName Foam::IOobject::path
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::IOobject::objectRelPath() const
|
||||
{
|
||||
// A file is 'outside' of the case if it has been specified using an
|
||||
// absolute path
|
||||
|
||||
const auto first = instance().find('/');
|
||||
|
||||
if
|
||||
(
|
||||
first == 0
|
||||
#ifdef _WIN32
|
||||
|| (first == 2 && instance()[1] == ':') // Eg, d:/path
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// Absolute path (starts with '/' or 'd:/')
|
||||
return instance()/name();
|
||||
}
|
||||
|
||||
return instance()/db_.dbDir()/local()/name();
|
||||
}
|
||||
|
||||
|
||||
Foam::fileName Foam::IOobject::localFilePath
|
||||
(
|
||||
const word& typeName,
|
||||
|
||||
@ -539,6 +539,9 @@ public:
|
||||
//- The complete path + object name
|
||||
inline fileName objectPath() const;
|
||||
|
||||
//- The object path relative to the root
|
||||
fileName objectRelPath() const;
|
||||
|
||||
//- Helper for filePath that searches locally.
|
||||
// When search is false, simply use the current instance,
|
||||
// otherwise search previous instances.
|
||||
|
||||
Reference in New Issue
Block a user