IOobject: Added localPath and localObjectPath member functions

For many information and diagnostic messages the absolute path of the object is
not required and the local path relative to the current case is sufficient; the
new localObjectPath() member function of IOobject provides a convenient way of
printing this.
This commit is contained in:
Henry Weller
2020-01-24 11:52:45 +00:00
parent 3c1456571e
commit c8a1c95b06
23 changed files with 74 additions and 56 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -758,7 +758,7 @@ int main(int argc, char *argv[])
if (maxLevel > 0)
{
Info<< "Read existing refinement level from file "
<< refLevel.objectPath() << nl
<< refLevel.localObjectPath() << nl
<< " min level : " << min(refLevel) << nl
<< " max level : " << maxLevel << nl
<< endl;
@ -766,7 +766,7 @@ int main(int argc, char *argv[])
else
{
Info<< "Created zero refinement level in file "
<< refLevel.objectPath() << nl
<< refLevel.localObjectPath() << nl
<< endl;
}

View File

@ -143,7 +143,7 @@ int main(int argc, char *argv[])
const cellSet cellsToRefine(mesh, setName);
Info<< " Read " << cellsToRefine.size()
<< " cells from cellSet " << cellsToRefine.objectPath()
<< " cells from cellSet " << cellsToRefine.localObjectPath()
<< nl << endl;
const labelList allCutCells(cutCells.toc());

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1103,7 +1103,7 @@ int main(int argc, char *argv[])
}
Info<< "Writing mesh to " << mesh.objectRegistry::objectPath()
Info<< "Writing mesh to " << mesh.objectRegistry::localObjectPath()
<< "..." << nl << endl;
@ -1147,8 +1147,8 @@ int main(int argc, char *argv[])
cellTypeField[celli] = foamCellType[celli];
}
Info<< "Writing cellIds as volScalarField to " << cellIdField.objectPath()
<< "..." << nl << endl;
Info<< "Writing cellIds as volScalarField to "
<< cellIdField.localObjectPath() << "..." << nl << endl;
mesh.write();
Info<< "End\n" << endl;

View File

@ -1478,7 +1478,7 @@ int main(int argc, char *argv[])
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
Info<< nl << "Writing mesh to " << mesh.objectPath() << endl;
Info<< nl << "Writing mesh to " << mesh.localObjectPath() << endl;
mesh.write();

View File

@ -42,8 +42,6 @@
else
{
timeName = runTime.timeName();
// Info<< "skip ... missing entry " << io.objectPath() << endl;
// continue;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -201,13 +201,13 @@ int main(int argc, char *argv[])
if (!meshDictIO.typeHeaderOk<IOdictionary>(true))
{
FatalErrorInFunction
<< meshDictIO.objectPath()
<< meshDictIO.localObjectPath()
<< nl
<< exit(FatalError);
}
Info<< "Creating block mesh from\n "
<< meshDictIO.objectPath() << endl;
<< meshDictIO.localObjectPath() << endl;
IOdictionary meshDict(meshDictIO);
blockMesh blocks(meshDict, regionName);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1034,7 +1034,7 @@ int main(int argc, char *argv[])
}
mesh.setInstance(runTimeExtruded.constant());
Info<< "Writing mesh to " << mesh.objectPath() << nl << endl;
Info<< "Writing mesh to " << mesh.localObjectPath() << nl << endl;
if (!mesh.write())
{

View File

@ -316,7 +316,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
// }
//
// Info<< "Writing map from tetDualMesh points to Voronoi mesh to "
// << pointDualAddressing.objectPath() << endl;
// << pointDualAddressing.localObjectPath() << endl;
// pointDualAddressing.write();
//
//
@ -370,7 +370,7 @@ void Foam::conformalVoronoiMesh::writeMesh(const fileName& instance)
// }
//
// Info<< "Writing tetDualMesh points mapped onto Voronoi mesh to "
// << dualPoints.objectPath() << endl
// << dualPoints.localObjectPath() << endl
// << "Replace the polyMesh/points with these." << endl;
// dualPoints.write();
// }

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -209,7 +209,7 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces)
}
Pout<< "Writing " << duplicateSet.size()
<< " duplicate faces to faceSet " << duplicateSet.objectPath()
<< " duplicate faces to faceSet " << duplicateSet.localObjectPath()
<< nl << endl;
duplicateSet.write();
}
@ -365,7 +365,7 @@ int main(int argc, char *argv[])
Pout<< "Writing " << dupPoints.size()
<< " duplicated points to pointSet "
<< dupPoints.objectPath() << nl << endl;
<< dupPoints.localObjectPath() << nl << endl;
dupPoints.write();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -406,7 +406,7 @@ int main(int argc, char *argv[])
}
Info<< "Writing map from new to old cell to "
<< newToOld.objectPath() << nl << endl;
<< newToOld.localObjectPath() << nl << endl;
newToOld.write();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -1412,7 +1412,7 @@ void writeCellToRegion(const fvMesh& mesh, const labelList& cellRegion)
cellToRegion.write();
Info<< "Writing region per cell file (for manual decomposition) to "
<< cellToRegion.objectPath() << nl << endl;
<< cellToRegion.localObjectPath() << nl << endl;
}
// Write for postprocessing
{
@ -1438,7 +1438,7 @@ void writeCellToRegion(const fvMesh& mesh, const labelList& cellRegion)
cellToRegion.write();
Info<< "Writing region per cell as volScalarField to "
<< cellToRegion.objectPath() << nl << endl;
<< cellToRegion.localObjectPath() << nl << endl;
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -506,7 +506,7 @@ int main(int argc, char *argv[])
cellDecomposition.write();
Info<< nl << "Wrote decomposition to "
<< cellDecomposition.objectPath()
<< cellDecomposition.localObjectPath()
<< " for use in manual decomposition." << endl;
// Write as volScalarField for postprocessing.

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -402,7 +402,7 @@ void writeCellDistance
cellDecomposition.write();
Info<< nl << "Wrote decomposition to "
<< cellDecomposition.objectPath()
<< cellDecomposition.localObjectPath()
<< " for use in manual decomposition." << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -209,14 +209,11 @@ Foam::autoPtr<Foam::fvMesh> Foam::loadOrCreateMesh
)
);
dummyMesh.addZones(pz, fz, cz);
// Pout<< "Writing dummy mesh to " << dummyMesh.polyMesh::objectPath()
// << endl;
dummyMesh.write();
Pstream::parRun() = oldParRun;
}
// Pout<< "Reading mesh from " << io.objectPath() << endl;
autoPtr<fvMesh> meshPtr(new fvMesh(io));
fvMesh& mesh = meshPtr();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -189,7 +189,8 @@ int main(int argc, char *argv[])
{
FatalErrorInFunction
<< "Size " << pointDualAddressing.size()
<< " of addressing map " << pointDualAddressing.objectPath()
<< " of addressing map "
<< pointDualAddressing.localObjectPath()
<< " differs from number of points in mesh "
<< tetDualMesh.nPoints()
<< exit(FatalError);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -76,8 +76,8 @@ void Foam::tabulatedWallFunctions::tabulatedWallFunction::write()
"U+ as a function of Re computed using " + type();
}
Info<< "Writing inverted table to\n " << invertedTable_.objectPath()
<< endl;
Info<< "Writing inverted table to\n "
<< invertedTable_.localObjectPath() << endl;
invertedTable_.write();
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -793,7 +793,7 @@ int main(int argc, char *argv[])
);
Info<< nl << "Writing featureEdgeMesh to "
<< bfeMesh.objectPath() << endl;
<< bfeMesh.localObjectPath() << endl;
bfeMesh.regIOobject::write();
}

View File

@ -387,7 +387,7 @@ namespace Foam
feMesh.writeStats(Info);
Info<< nl << "Writing extendedFeatureEdgeMesh to "
<< feMesh.objectPath() << endl;
<< feMesh.localObjectPath() << endl;
mkDir(feMesh.path());
@ -420,7 +420,7 @@ namespace Foam
);
Info<< nl << "Writing featureEdgeMesh to "
<< bfeMesh.objectPath() << endl;
<< bfeMesh.localObjectPath() << endl;
bfeMesh.regIOobject::write();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -337,7 +337,8 @@ int main(int argc, char *argv[])
move(surf)
);
Info<< "writing surfMesh as well: " << surfOut.objectPath() << endl;
Info<< "writing surfMesh as well: "
<< surfOut.localObjectPath() << endl;
surfOut.write();
surfLabelField zoneIds
@ -366,7 +367,8 @@ int main(int argc, char *argv[])
Info<< "writing surfMesh again well: " << surfOut.objectPath()
Info<< "writing surfMesh again well: "
<< surfOut.localObjectPath()
<< endl;
surfOut.write();
@ -386,7 +388,7 @@ int main(int argc, char *argv[])
}
Info<< "write zoneIds (for testing only): "
<< zoneIds.objectPath() << endl;
<< zoneIds.localObjectPath() << endl;
zoneIds.write();
surfPointLabelField pointIds
@ -394,9 +396,7 @@ int main(int argc, char *argv[])
IOobject
(
"zoneIds.",
// "pointIds",
surfOut.instance(),
// "pointFields",
surfOut,
IOobject::NO_READ,
IOobject::NO_WRITE
@ -411,7 +411,7 @@ int main(int argc, char *argv[])
}
Info<< "write pointIds (for testing only): "
<< pointIds.objectPath() << endl;
<< pointIds.localObjectPath() << endl;
pointIds.write();
Info<<"surfMesh with these names: " << surfOut.names() << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -238,7 +238,7 @@ int main(int argc, char *argv[])
)
);
Info<< "read surfMesh:\n " << smesh.objectPath() << endl;
Info<< "read surfMesh:\n " << smesh.localObjectPath() << endl;
// Simply copy for now, but really should have a separate write method

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -288,7 +288,7 @@ int main(int argc, char *argv[])
);
Info<< "writing surfMesh:\n " << smesh.objectPath() << endl;
Info<< "writing surfMesh:\n " << smesh.localObjectPath() << endl;
smesh.write();
Info<< "\nEnd\n" << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -379,6 +379,19 @@ Foam::fileName Foam::IOobject::path
}
Foam::fileName Foam::IOobject::localPath() const
{
if (instance().isAbsolute())
{
return instance();
}
else
{
return instance()/db_.dbDir()/local();
}
}
Foam::fileName Foam::IOobject::localFilePath(const word& typeName) const
{
// Do not check for undecomposed files

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -413,12 +413,21 @@ public:
const fileName& local = ""
) const;
//- Return the path relative to the case
fileName localPath() const;
//- Return complete path + object name
fileName objectPath() const
{
return path()/name();
}
//- Return complete localPath + object name
fileName localObjectPath() const
{
return localPath()/name();
}
//- Helper for filePath that searches locally.
fileName localFilePath(const word& typeName) const;