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.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
|
|
||||||
Description
|
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: "
|
Info<< "Creating faMesh from definition: "
|
||||||
<< runTime.relativePath(meshDictIO.objectPath()) << endl;
|
<< meshDictIO.objectRelPath() << endl;
|
||||||
|
|
||||||
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2019-2020 OpenCFD Ltd.
|
Copyright (C) 2019-2021 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -165,7 +165,7 @@ int main(int argc, char *argv[])
|
|||||||
IOdictionary meshDict(dictIO);
|
IOdictionary meshDict(dictIO);
|
||||||
|
|
||||||
Info<< "Creating PDRblockMesh from "
|
Info<< "Creating PDRblockMesh from "
|
||||||
<< runTime.relativePath(dictIO.objectPath()) << endl;
|
<< dictIO.objectRelPath() << endl;
|
||||||
|
|
||||||
// Always start from a PDRblock
|
// Always start from a PDRblock
|
||||||
PDRblock blkMesh(meshDict, true);
|
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....
|
// Search for the appropriate blockMesh dictionary....
|
||||||
const word dictName("blockMeshDict");
|
const word dictName("blockMeshDict");
|
||||||
|
|
||||||
@ -64,9 +81,12 @@ autoPtr<IOdictionary> meshDictPtr;
|
|||||||
}
|
}
|
||||||
|
|
||||||
Info<< "Creating block mesh from "
|
Info<< "Creating block mesh from "
|
||||||
<< runTime.relativePath(meshDictIO.objectPath()) << endl;
|
<< meshDictIO.objectRelPath() << endl;
|
||||||
|
|
||||||
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
meshDictPtr = autoPtr<IOdictionary>::New(meshDictIO);
|
||||||
}
|
}
|
||||||
|
|
||||||
const IOdictionary& meshDict = *meshDictPtr;
|
const IOdictionary& meshDict = *meshDictPtr;
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -647,7 +647,7 @@ int main(int argc, char *argv[])
|
|||||||
cellDecomposition.write();
|
cellDecomposition.write();
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition to "
|
Info<< nl << "Wrote decomposition to "
|
||||||
<< runTime.relativePath(cellDecomposition.objectPath())
|
<< cellDecomposition.objectRelPath()
|
||||||
<< " for use in manual decomposition." << endl;
|
<< " for use in manual decomposition." << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -160,7 +160,7 @@ void Foam::domainDecompositionDryRun::execute
|
|||||||
// cellDecomposition.write();
|
// cellDecomposition.write();
|
||||||
//
|
//
|
||||||
// Info<< nl << "Wrote decomposition to "
|
// Info<< nl << "Wrote decomposition to "
|
||||||
// << runTime.relativePath(cellDecomposition.objectPath())
|
// << cellDecomposition.objectRelPath()
|
||||||
// << " for use in manual decomposition." << endl;
|
// << " for use in manual decomposition." << endl;
|
||||||
|
|
||||||
Info<< nl;
|
Info<< nl;
|
||||||
|
|||||||
@ -64,7 +64,7 @@ void Foam::domainDecompositionDryRun::writeVolField
|
|||||||
cellDist.write();
|
cellDist.write();
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition to "
|
Info<< nl << "Wrote decomposition to "
|
||||||
<< this->mesh().time().relativePath(cellDist.objectPath())
|
<< cellDist.objectRelPath()
|
||||||
<< " (volScalarField) for visualization."
|
<< " (volScalarField) for visualization."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,7 +65,7 @@ void Foam::domainDecomposition::writeVolField
|
|||||||
cellDist.write();
|
cellDist.write();
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition to "
|
Info<< nl << "Wrote decomposition to "
|
||||||
<< this->mesh().time().relativePath(cellDist.objectPath())
|
<< cellDist.objectRelPath()
|
||||||
<< " (volScalarField) for visualization."
|
<< " (volScalarField) for visualization."
|
||||||
<< endl;
|
<< endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -396,7 +396,7 @@ void writeDistribution
|
|||||||
cellDecomposition.write();
|
cellDecomposition.write();
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition to "
|
Info<< nl << "Wrote decomposition to "
|
||||||
<< runTime.relativePath(cellDecomposition.objectPath())
|
<< cellDecomposition.objectRelPath()
|
||||||
<< " for use in manual decomposition." << endl;
|
<< " for use in manual decomposition." << endl;
|
||||||
|
|
||||||
// Write as volScalarField for postprocessing. Change time to 0
|
// Write as volScalarField for postprocessing. Change time to 0
|
||||||
@ -434,7 +434,7 @@ void writeDistribution
|
|||||||
cellDist.write();
|
cellDist.write();
|
||||||
|
|
||||||
Info<< nl << "Wrote decomposition to "
|
Info<< nl << "Wrote decomposition to "
|
||||||
<< runTime.relativePath(cellDist.objectPath())
|
<< cellDist.objectRelPath()
|
||||||
<< " (volScalarField) for visualization."
|
<< " (volScalarField) for visualization."
|
||||||
<< endl;
|
<< 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
|
Foam::fileName Foam::IOobject::localFilePath
|
||||||
(
|
(
|
||||||
const word& typeName,
|
const word& typeName,
|
||||||
|
|||||||
@ -539,6 +539,9 @@ public:
|
|||||||
//- The complete path + object name
|
//- The complete path + object name
|
||||||
inline fileName objectPath() const;
|
inline fileName objectPath() const;
|
||||||
|
|
||||||
|
//- The object path relative to the root
|
||||||
|
fileName objectRelPath() const;
|
||||||
|
|
||||||
//- Helper for filePath that searches locally.
|
//- Helper for filePath that searches locally.
|
||||||
// When search is false, simply use the current instance,
|
// When search is false, simply use the current instance,
|
||||||
// otherwise search previous instances.
|
// otherwise search previous instances.
|
||||||
|
|||||||
Reference in New Issue
Block a user