diff --git a/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H b/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H index 8a678fdcc8c789a5de4eb4151d2d3b7fe0282330..5385d38f370970df3fb593ac273e1b1befad9686 100644 --- a/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H +++ b/applications/utilities/finiteArea/makeFaMesh/findMeshDefinitionDict.H @@ -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); } diff --git a/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C b/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C index cba7c7d968205ec5ac8e44641714a61cf570f903..32d304c6b4caaefdf4a23d4f45f10797464f7b94 100644 --- a/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C +++ b/applications/utilities/mesh/generation/PDRblockMesh/PDRblockMesh.C @@ -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); diff --git a/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H b/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H index b05bda22c82e3261f7b69076b65d4231492524ff..4f81c74ccc9719d81d75ca6ca10fcd041c00ede8 100644 --- a/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H +++ b/applications/utilities/mesh/generation/blockMesh/findBlockMeshDict.H @@ -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; + + +// ************************************************************************* // diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 292e694f71e8d19d31c7473f7dd062bcfa81a961..55d2410b11760e62fa06453ab633c1404de93d1b 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -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; } diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRun.C b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRun.C index b175c96e4fa39bc5ef6e3e7a7572c8cbaa76baed..060ad804e8799fe7b427d826a606cca735c9170b 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRun.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRun.C @@ -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; diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRunWrite.C b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRunWrite.C index 5e02b54f574d1da13138cc3593765ab48a1da7dd..e7b4ad0d7deaafcbc824707f76f26e3e473082fa 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRunWrite.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionDryRunWrite.C @@ -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; } diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C index 271be14e4fa2c4fc5ea9541804765d23beaba721..a94e443d75826850c47cded027f0a2e9b7f62aac 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecompositionWrite.C @@ -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; } diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C index 8ba2ff25ad27c98af06cbafa86bc9e87e000c4af..b92a5dfcc576bc843fa0804d2b1c463ea825b0de 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C +++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C @@ -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; diff --git a/src/OpenFOAM/db/IOobject/IOobject.C b/src/OpenFOAM/db/IOobject/IOobject.C index cd478fea9691f130feb8fb0c25d58ff8de399686..ad2be69cbd19d2a8a7132c6ca970147a55e5ffce 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.C +++ b/src/OpenFOAM/db/IOobject/IOobject.C @@ -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, diff --git a/src/OpenFOAM/db/IOobject/IOobject.H b/src/OpenFOAM/db/IOobject/IOobject.H index 41096629a08afe13a7295a673d119f8bf542c042..25177e5c6700bd6ce9c33f6d60fdfe6667ee7546 100644 --- a/src/OpenFOAM/db/IOobject/IOobject.H +++ b/src/OpenFOAM/db/IOobject/IOobject.H @@ -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.