ENH: make ITstream positioning methods noexcept

ENH: add rank() method for compound tokens

ENH: add IOstream::minPrecision(unsigned)

- reduced typing, more expressive, no namespace ambiguity with max()

    new: IOstream::minPrecision(10);
    old: IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));

STYLE: namespace qualify min/max for some buffer sizing [clang/hipp]
This commit is contained in:
Mark Olesen
2024-02-29 09:40:42 +01:00
parent 5a70be0846
commit b98f53ceca
51 changed files with 271 additions and 207 deletions

View File

@ -155,8 +155,8 @@ int main(int argc, char *argv[])
} }
else else
{ {
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(10); IOstream::minPrecision(10);
Info<< nl << "Write finite area mesh." << nl; Info<< nl << "Write finite area mesh." << nl;
aMesh.write(); aMesh.write();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2018-2022 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -551,9 +551,13 @@ void subsetMesh
Info<< "Writing refined mesh to time " << runTime.timeName() << nl Info<< "Writing refined mesh to time " << runTime.timeName() << nl
<< endl; << endl;
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); // More precision (for points data)
const auto oldPrec = IOstream::minPrecision(10);
mesh.write(); mesh.write();
refLevel.write(); refLevel.write();
IOstream::defaultPrecision(oldPrec);
} }
// Update cutCells for removed cells. // Update cutCells for removed cells.
@ -922,9 +926,13 @@ int main(int argc, char *argv[])
Info<< " Writing refined mesh to time " << runTime.timeName() Info<< " Writing refined mesh to time " << runTime.timeName()
<< nl << endl; << nl << endl;
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); // More precision (for points data)
const auto oldPrec = IOstream::minPrecision(10);
mesh.write(); mesh.write();
refLevel.write(); refLevel.write();
IOstream::defaultPrecision(oldPrec);
} }
// Update mesh edge stats. // Update mesh edge stats.
@ -993,20 +1001,29 @@ int main(int argc, char *argv[])
<< endl; << endl;
// Write final mesh // Write final mesh
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
// More precision (for points data)
const auto oldPrec = IOstream::minPrecision(10);
mesh.write(); mesh.write();
refLevel.write(); refLevel.write();
IOstream::defaultPrecision(oldPrec);
} }
else if (!writeMesh) else if (!writeMesh)
{ {
// Write final mesh. (will have been written already if writeMesh=true)
Info<< "Writing refined mesh to time " << runTime.timeName() << nl Info<< "Writing refined mesh to time " << runTime.timeName() << nl
<< endl; << endl;
// Write final mesh. (will have been written already if writeMesh=true) // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); const auto oldPrec = IOstream::minPrecision(10);
mesh.write(); mesh.write();
refLevel.write(); refLevel.write();
IOstream::defaultPrecision(oldPrec);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -704,8 +704,8 @@ int main(int argc, char *argv[])
} }
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
pShapeMesh.removeFiles(); pShapeMesh.removeFiles();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2022 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -198,8 +198,8 @@ int main(int argc, char *argv[])
: IOstreamOption::BINARY : IOstreamOption::BINARY
); );
// Increase the precision of the points data // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
// Read control options // Read control options

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd. Copyright (C) 2020-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -756,8 +756,8 @@ int main(int argc, char *argv[])
defaultFacesType defaultFacesType
); );
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
pShapeMesh.removeFiles(); pShapeMesh.removeFiles();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd. Copyright (C) 2022-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -90,8 +90,8 @@ int main(int argc, char *argv[])
argList args(argc, argv); argList args(argc, argv);
Time runTime(args.rootPath(), args.caseName()); Time runTime(args.rootPath(), args.caseName());
// Increase the precision of the points data // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
const fileName geomFile(args.get<fileName>(1)); const fileName geomFile(args.get<fileName>(1));

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -97,8 +97,8 @@ int main(int argc, char *argv[])
: IOstreamOption::BINARY : IOstreamOption::BINARY
); );
// increase the precision of the points data // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
fileFormats::FIREMeshReader reader fileFormats::FIREMeshReader reader

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016,2022 OpenFOAM Foundation Copyright (C) 2011-2016,2022 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1430,8 +1430,8 @@ int main(int argc, char *argv[])
mesh.setInstance(runTime.constant()); mesh.setInstance(runTime.constant());
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< nl << "Writing mesh to " << mesh.objectPath() << endl; Info<< nl << "Writing mesh to " << mesh.objectPath() << endl;
mesh.write(); mesh.write();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd. Copyright (C) 2020-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -1550,8 +1550,8 @@ int main(int argc, char *argv[])
repatcher.repatch(); repatcher.repatch();
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
// Re-do face matching to write sets // Re-do face matching to write sets

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd. Copyright (C) 2020-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -868,8 +868,8 @@ int main(int argc, char *argv[])
defaultFacesType defaultFacesType
); );
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
pShapeMesh.removeFiles(); pShapeMesh.removeFiles();

View File

@ -1691,8 +1691,8 @@ int main(int argc, char *argv[])
repatcher.changePatches(newPatches); repatcher.changePatches(newPatches);
} }
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
mesh.write(); mesh.write();

View File

@ -1268,8 +1268,8 @@ int main(int argc, char *argv[])
Info << endl; Info << endl;
} }
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
mesh.write(); mesh.write();

View File

@ -569,8 +569,8 @@ polyMesh pShapeMesh
defaultFacesType defaultFacesType
); );
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info << "Writing polyMesh" << endl; Info << "Writing polyMesh" << endl;
pShapeMesh.removeFiles(); pShapeMesh.removeFiles();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -161,8 +161,8 @@ int main(int argc, char *argv[])
wordList() wordList()
); );
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing mesh ..." << endl; Info<< "Writing mesh ..." << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd. Copyright (C) 2020-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -318,8 +318,8 @@ int main(int argc, char *argv[])
patchPhysicalTypes patchPhysicalTypes
); );
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing mesh ..." << endl; Info<< "Writing mesh ..." << endl;
mesh.removeFiles(); mesh.removeFiles();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2020-2021 OpenCFD Ltd. Copyright (C) 2020-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -264,8 +264,8 @@ int main(int argc, char *argv[])
patchPhysicalTypes patchPhysicalTypes
); );
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing polyMesh" << endl; Info<< "Writing polyMesh" << endl;
pShapeMesh.removeFiles(); pShapeMesh.removeFiles();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -103,8 +103,8 @@ int main(int argc, char *argv[])
: IOstreamOption::BINARY : IOstreamOption::BINARY
); );
// Increase the precision of the points data // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
// Remove extensions and/or trailing '.' // Remove extensions and/or trailing '.'

View File

@ -542,8 +542,8 @@ int main(int argc, char *argv[])
); );
} }
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing mesh to " << runTime.constant() << endl << endl; Info<< "Writing mesh to " << runTime.constant() << endl << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -88,8 +88,8 @@ int main(int argc, char *argv[])
wordList() wordList()
); );
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing mesh ..." << endl; Info<< "Writing mesh ..." << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2022 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -231,8 +231,8 @@ int main(int argc, char *argv[])
polyMesh& mesh = *meshPtr; polyMesh& mesh = *meshPtr;
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< nl << "Writing polyMesh with " Info<< nl << "Writing polyMesh with "
<< mesh.cellZones().size() << " cellZones" << endl; << mesh.cellZones().size() << " cellZones" << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2023 OpenCFD Ltd. Copyright (C) 2016-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -289,8 +289,8 @@ int main(int argc, char *argv[])
// Handle cyclic patches // Handle cyclic patches
#include "handleCyclicPatches.H" #include "handleCyclicPatches.H"
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< nl << "Writing polyMesh with " Info<< nl << "Writing polyMesh with "
<< mesh.cellZones().size() << " cellZones"; << mesh.cellZones().size() << " cellZones";

View File

@ -67,8 +67,8 @@ scalar getMergeDistance
const scalar mergeTol = const scalar mergeTol =
args.getOrDefault<scalar>("mergeTol", defaultMergeTol); args.getOrDefault<scalar>("mergeTol", defaultMergeTol);
scalar writeTol = const scalar writeTol =
Foam::pow(scalar(10), -scalar(IOstream::defaultPrecision())); std::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
Info<< "Merge tolerance : " << mergeTol << nl Info<< "Merge tolerance : " << mergeTol << nl
<< "Write tolerance : " << writeTol << endl; << "Write tolerance : " << writeTol << endl;

View File

@ -269,8 +269,8 @@ int main(int argc, char *argv[])
mesh.setInstance(oldInstance); mesh.setInstance(oldInstance);
} }
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
mesh.write(); mesh.write();

View File

@ -1456,8 +1456,8 @@ int main(int argc, char *argv[])
} }
} }
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
// Write resulting mesh // Write resulting mesh
forAll(meshes, meshi) forAll(meshes, meshi)

View File

@ -100,8 +100,8 @@ int main(int argc, char *argv[])
twoDCorr.correctPoints(points); twoDCorr.correctPoints(points);
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing points into directory " << points.path() << nl << endl; Info<< "Writing points into directory " << points.path() << nl << endl;
points.write(); points.write();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -101,8 +101,8 @@ int main(int argc, char *argv[])
} }
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
// Generate the mirrorred mesh // Generate the mirrorred mesh
const fvMesh& mMesh = mesh.mirrorMesh(); const fvMesh& mMesh = mesh.mirrorMesh();

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -153,8 +153,8 @@ int main(int argc, char *argv[])
points = transform(rotT, points); points = transform(rotT, points);
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
Info<< "Writing points into directory " Info<< "Writing points into directory "
<< runTime.relativePath(points.path()) << nl << runTime.relativePath(points.path()) << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -440,8 +440,8 @@ int main(int argc, char *argv[])
//PtrList<surfaceTensorField> surfaceTensorFields; //PtrList<surfaceTensorField> surfaceTensorFields;
//ReadFields(mesh, objects, surfaceTensorFields); //ReadFields(mesh, objects, surfaceTensorFields);
// Increase precision for output mesh points // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
polyTopoChanger stitcher(mesh, IOobject::NO_READ); polyTopoChanger stitcher(mesh, IOobject::NO_READ);

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2022 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -552,9 +552,8 @@ int main(int argc, char *argv[])
// Output scaling // Output scaling
applyScaling(points, getScalingOpt("scale", args)); applyScaling(points, getScalingOpt("scale", args));
// More precision (for points data)
// Set the precision of the points data to 10 IOstream::minPrecision(10);
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
Info<< "Writing points into directory " Info<< "Writing points into directory "
<< runTime.relativePath(points.path()) << nl << runTime.relativePath(points.path()) << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -735,8 +735,8 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets)
} }
} }
// Set the precision of the points data to be min 10 // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
procMesh.write(); procMesh.write();

View File

@ -657,7 +657,7 @@ int main(int argc, char *argv[])
if (fullMatch || procMatch) if (fullMatch || procMatch)
{ {
const scalar writeTol = const scalar writeTol =
Foam::pow(10.0, -scalar(IOstream::defaultPrecision())); std::pow(scalar(10), -scalar(IOstream::defaultPrecision()));
Info<< "Merge tolerance : " << mergeTol << nl Info<< "Merge tolerance : " << mergeTol << nl
<< "Write tolerance : " << writeTol << endl; << "Write tolerance : " << writeTol << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2023 OpenCFD Ltd. Copyright (C) 2015-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -951,8 +951,8 @@ autoPtr<mapDistributePolyMesh> redistributeAndWrite
} }
// Set the minimum write precision // More precision (for points data)
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::minPrecision(10);
if (!overwrite) if (!overwrite)

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd. Copyright (C) 2021-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,8 +47,8 @@ using namespace Foam;
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
// Increase the precision of the output for JANAF coefficients // More precision (for output of JANAF coefficients)
Ostream::defaultPrecision(10); IOstream::minPrecision(10);
argList::addNote argList::addNote
( (

View File

@ -349,7 +349,7 @@ public:
} }
//- Reset the default precision //- Reset the default precision
// \return the previous value // \return the previous default precision
static unsigned int defaultPrecision(unsigned int prec) noexcept static unsigned int defaultPrecision(unsigned int prec) noexcept
{ {
unsigned int old(precision_); unsigned int old(precision_);
@ -357,6 +357,18 @@ public:
return old; return old;
} }
//- Set the minimum default precision
// \return the previous default precision
static unsigned int minPrecision(unsigned int prec) noexcept
{
unsigned int old(precision_);
if (precision_ < prec)
{
precision_ = prec;
}
return old;
}
//- Set stream state as reached 'eof' //- Set stream state as reached 'eof'
void setEof() noexcept void setEof() noexcept
{ {
@ -370,7 +382,7 @@ public:
} }
//- Set stream state to be 'bad' //- Set stream state to be 'bad'
void setBad() void setBad() noexcept
{ {
ioState_ |= std::ios_base::badbit; ioState_ |= std::ios_base::badbit;
} }

View File

@ -563,7 +563,7 @@ Foam::label Foam::PstreamBuffers::maxNonLocalRecvCount
if (excludeProci != proci) if (excludeProci != proci)
{ {
label len(recvBuffers_[proci].size() - recvPositions_[proci]); label len(recvBuffers_[proci].size() - recvPositions_[proci]);
maxLen = max(maxLen, len); maxLen = Foam::max(maxLen, len);
} }
} }
} }

View File

@ -67,7 +67,7 @@ inline void Foam::UOPstreamBase::prepareBuffer
const label pos = byteAlign(sendBuf_.size(), align); const label pos = byteAlign(sendBuf_.size(), align);
// Extend buffer (as required) // Extend buffer (as required)
sendBuf_.reserve(max(1000, label(pos + count))); sendBuf_.reserve(Foam::max(label(1024), label(pos + count)));
// Move to the aligned output position. Fill any gap with nul char. // Move to the aligned output position. Fill any gap with nul char.
sendBuf_.resize(pos, '\0'); sendBuf_.resize(pos, '\0');
@ -115,7 +115,7 @@ inline void Foam::UOPstreamBase::putChar(const char c)
{ {
if (!sendBuf_.capacity()) if (!sendBuf_.capacity())
{ {
sendBuf_.setCapacity(1000); sendBuf_.setCapacity(1024);
} }
sendBuf_.push_back(c); sendBuf_.push_back(c);
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -55,7 +55,7 @@ static label parseStream(ISstream& is, tokenList& tokens)
if (count >= tokens.size()) if (count >= tokens.size())
{ {
// Increase capacity (doubling) with min-size [64] // Increase capacity (doubling) with min-size [64]
tokens.resize(max(label(64), 2*tokens.size())); tokens.resize(Foam::max(label(64), label(2*tokens.size())));
} }
tokens[count] = std::move(tok); tokens[count] = std::move(tok);
@ -77,7 +77,7 @@ Foam::ITstream& Foam::ITstream::empty_stream()
if (emptyStreamPtr_) if (emptyStreamPtr_)
{ {
emptyStreamPtr_->ITstream::clear(); // Ensure it really is empty emptyStreamPtr_->ITstream::clear(); // Ensure it really is empty
emptyStreamPtr_->ITstream::seek(0); // rewind(), but bypasss virtual emptyStreamPtr_->ITstream::seek(0); // rewind() bypassing virtual
} }
else else
{ {
@ -113,7 +113,7 @@ void Foam::ITstream::reset(const char* input, size_t nbytes)
ISpanStream is(input, nbytes, static_cast<IOstreamOption>(*this)); ISpanStream is(input, nbytes, static_cast<IOstreamOption>(*this));
parseStream(is, static_cast<tokenList&>(*this)); parseStream(is, static_cast<tokenList&>(*this));
ITstream::seek(0); // rewind(), but bypasss virtual ITstream::seek(0); // rewind() bypassing virtual
} }
@ -333,7 +333,7 @@ std::string Foam::ITstream::toString() const
} }
const Foam::token& Foam::ITstream::peek() const const Foam::token& Foam::ITstream::peek() const noexcept
{ {
// Use putback token if it exists // Use putback token if it exists
if (Istream::hasPutback()) if (Istream::hasPutback())
@ -359,45 +359,30 @@ Foam::token& Foam::ITstream::currentToken()
} }
void Foam::ITstream::seek(label pos) void Foam::ITstream::seek(label pos) noexcept
{ {
lineNumber_ = 0; lineNumber_ = 0;
const tokenList& toks = *this;
const label nToks = toks.size();
if (!pos) if (pos < 0 || pos >= tokenList::size())
{
// Seek begin (rewind)
tokenIndex_ = 0;
if (nToks)
{
lineNumber_ = toks.front().lineNumber();
}
setOpened();
setGood();
}
else if (pos < 0 || pos >= nToks)
{ {
// Seek end (-1) or seek is out of range // Seek end (-1) or seek is out of range
tokenIndex_ = nToks; tokenIndex_ = tokenList::size();
if (nToks) if (!tokenList::empty())
{ {
lineNumber_ = toks.back().lineNumber(); // The closest reference lineNumber
lineNumber_ = tokenList::cdata()[tokenIndex_-1].lineNumber();
} }
setEof(); setEof();
} }
else else
{ {
// Seek middle (from the beginning)
tokenIndex_ = pos; tokenIndex_ = pos;
if (nToks) if (tokenIndex_ < tokenList::size())
{ {
lineNumber_ = toks[tokenIndex_].lineNumber(); lineNumber_ = tokenList::cdata()[tokenIndex_].lineNumber();
} }
setOpened(); setOpened();
@ -406,7 +391,7 @@ void Foam::ITstream::seek(label pos)
} }
bool Foam::ITstream::skip(label n) bool Foam::ITstream::skip(label n) noexcept
{ {
if (!n) if (!n)
{ {
@ -433,14 +418,14 @@ bool Foam::ITstream::skip(label n)
if (!tokenList::empty()) if (!tokenList::empty())
{ {
// The closest reference lineNumber // The closest reference lineNumber
lineNumber_ = tokenList::back().lineNumber(); lineNumber_ = tokenList::cdata()[tokenIndex_-1].lineNumber();
} }
} }
// Update stream information // Update stream information
if (tokenIndex_ < tokenList::size()) if (tokenIndex_ < tokenList::size())
{ {
lineNumber_ = tokenList::operator[](tokenIndex_).lineNumber(); lineNumber_ = tokenList::cdata()[tokenIndex_].lineNumber();
setOpened(); setOpened();
setGood(); setGood();
} }
@ -585,7 +570,8 @@ Foam::ITstream Foam::ITstream::extract(const labelRange& range)
// Move tokens into result list // Move tokens into result list
std::move(first, last, result.begin()); std::move(first, last, result.begin());
result.seek(0); // rewind result.seek(0); // rewind() bypassing virtual
(void) remove(slice); // Adjust the original list (void) remove(slice); // Adjust the original list
@ -708,12 +694,6 @@ Foam::Istream& Foam::ITstream::read(char*, std::streamsize)
} }
void Foam::ITstream::rewind()
{
ITstream::seek(0);
}
void Foam::ITstream::add_tokens(const token& tok) void Foam::ITstream::add_tokens(const token& tok)
{ {
reserveCapacity(tokenIndex_ + 1); reserveCapacity(tokenIndex_ + 1);
@ -763,7 +743,7 @@ void Foam::ITstream::operator=(const ITstream& is)
Istream::operator=(is); Istream::operator=(is);
tokenList::operator=(is); tokenList::operator=(is);
name_ = is.name_; name_ = is.name_;
ITstream::seek(0); // rewind(), but bypasss virtual ITstream::seek(0); // rewind() bypassing virtual
} }
} }
@ -771,14 +751,14 @@ void Foam::ITstream::operator=(const ITstream& is)
void Foam::ITstream::operator=(const UList<token>& toks) void Foam::ITstream::operator=(const UList<token>& toks)
{ {
tokenList::operator=(toks); tokenList::operator=(toks);
ITstream::seek(0); // rewind(), but bypasss virtual ITstream::seek(0); // rewind() bypassing virtual
} }
void Foam::ITstream::operator=(List<token>&& toks) void Foam::ITstream::operator=(List<token>&& toks)
{ {
tokenList::operator=(std::move(toks)); tokenList::operator=(std::move(toks));
ITstream::seek(0); // rewind(), but bypasss virtual ITstream::seek(0); // rewind() bypassing virtual
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -91,12 +91,12 @@ class ITstream
//- Failsafe read-access to token at specified location //- Failsafe read-access to token at specified location
//- or undefinedToken //- or undefinedToken
inline const token& peekNoFail(const label i) const inline const token& peekNoFail(const label i) const noexcept
{ {
return return
( (
(i >= 0 && i < tokenList::size()) (i >= 0 && i < tokenList::size())
? tokenList::operator[](i) ? tokenList::cdata()[i]
: token::undefinedToken : token::undefinedToken
); );
} }
@ -353,20 +353,29 @@ public:
//- Failsafe peek at the token at the \b front of the tokenList //- Failsafe peek at the token at the \b front of the tokenList
// \return \c undefinedToken if the list is empty. // \return \c undefinedToken if the list is empty.
const token& front() const { return peekNoFail(0); } const token& front() const noexcept
{
return peekNoFail(0);
}
//- Failsafe peek at the token at the \b back of the tokenList //- Failsafe peek at the token at the \b back of the tokenList
// \return \c undefinedToken if the list is empty. // \return \c undefinedToken if the list is empty.
const token& back() const { return peekNoFail(tokenList::size()-1); } const token& back() const noexcept
{
return peekNoFail(tokenList::size()-1);
}
//- Failsafe peek at what the next read would return, //- Failsafe peek at what the next read would return,
//- including handling of any putback //- including handling of any putback
// \return \c undefinedToken if list is exhausted // \return \c undefinedToken if list is exhausted
const token& peek() const; const token& peek() const noexcept;
//- Read access to the token at the current tokenIndex. //- Read access to the token at the current tokenIndex.
//- \returns \c undefinedToken if list is exhausted //- \returns \c undefinedToken if list is exhausted
const token& currentToken() const { return peekNoFail(tokenIndex_); } const token& currentToken() const noexcept
{
return peekNoFail(tokenIndex_);
}
//- Write access to the token at the current tokenIndex. //- Write access to the token at the current tokenIndex.
//- Fatal if not in range //- Fatal if not in range
@ -397,9 +406,10 @@ public:
} }
//- Move tokenIndex to the specified position //- Move tokenIndex to the specified position
// Using seek(0) is identical to rewind. //- and adjust the stream status (open/good/eof ...)
// Using seek(0) is identical to rewind().
// Using seek(-1) moves to the end. // Using seek(-1) moves to the end.
void seek(label pos); void seek(label pos) noexcept;
//- Move tokenIndex relative to the current position. //- Move tokenIndex relative to the current position.
// Will not overrun the beginning (0) or one-past end positions. // Will not overrun the beginning (0) or one-past end positions.
@ -407,7 +417,7 @@ public:
// Use skip(2) to move forward two tokens. // Use skip(2) to move forward two tokens.
// Use skip(-2) to move backward two tokens. // Use skip(-2) to move backward two tokens.
// \return True if the indexing completed without underflow/overflow // \return True if the indexing completed without underflow/overflow
bool skip(label n = 1); bool skip(label n = 1) noexcept;
// Searching // Searching
@ -525,7 +535,7 @@ public:
virtual bool endRawRead() override { return false; } virtual bool endRawRead() override { return false; }
//- Rewind the stream so that it may be read again. Same as seek(0) //- Rewind the stream so that it may be read again. Same as seek(0)
virtual void rewind() override; virtual void rewind() override { ITstream::seek(0); }
// Output // Output

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2023 OpenCFD Ltd. Copyright (C) 2019-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -249,20 +249,20 @@ public:
// Other // Other
//- Rewind the output stream to position 0 (non-virtual!)
//- and adjust the stream status (open/good/eof ...)
//- Reset the output buffer and rewind the stream //- Reset the output buffer and rewind the stream
void reset() void reset() noexcept
{
this->rewind();
}
//- Rewind the output stream
virtual void rewind()
{ {
DynamicList<token>::clear(); DynamicList<token>::clear();
setOpened(); setOpened();
setGood(); setGood();
} }
//- Rewind the output stream to position 0
//- and adjust the stream status (open/good/eof ...)
virtual void rewind() { OTstream::reset(); }
//- Print stream description to Ostream //- Print stream description to Ostream
void print(Ostream& os) const override; void print(Ostream& os) const override;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -279,6 +279,9 @@ public:
//- of the underlying data content //- of the underlying data content
virtual direction nComponents() const = 0; virtual direction nComponents() const = 0;
//- The vector-space rank associated with the data content
virtual direction rank() const = 0;
//- Pointer to the underlying data as byte data //- Pointer to the underlying data as byte data
virtual const char* cdata_bytes() const = 0; virtual const char* cdata_bytes() const = 0;
@ -419,6 +422,12 @@ public:
return pTraits_nComponents<value_type>(); return pTraits_nComponents<value_type>();
} }
//- The vector-space rank associated with the data content
virtual direction rank() const
{
return pTraits_rank<value_type>();
}
//- Pointer to the underlying data as byte data //- Pointer to the underlying data as byte data
virtual const char* cdata_bytes() const virtual const char* cdata_bytes() const
{ {
@ -474,7 +483,7 @@ private:
//- The token type //- The token type
tokenType type_; tokenType type_;
//- Line number in the file the token was read from //- The file line number where the token was read from
label line_; label line_;
@ -516,6 +525,8 @@ public:
inline explicit token(punctuationToken p, label lineNum=0) noexcept; inline explicit token(punctuationToken p, label lineNum=0) noexcept;
//- Construct label token //- Construct label token
//- \note Use boolean() static method for creating a \b bool token
//- since \c bool and \c int are otherwise indistinguishable
inline explicit token(const label val, label lineNum=0) noexcept; inline explicit token(const label val, label lineNum=0) noexcept;
//- Construct float token //- Construct float token
@ -635,7 +646,7 @@ public:
inline bool isLabel() const noexcept; inline bool isLabel() const noexcept;
//- True if token is LABEL and equal to parameter //- True if token is LABEL and equal to parameter
inline bool isLabel(const label val) const noexcept; inline bool isLabel(const label value) const noexcept;
//- Token is FLOAT //- Token is FLOAT
inline bool isFloat() const noexcept; inline bool isFloat() const noexcept;

View File

@ -604,17 +604,35 @@ inline Foam::token::punctuationToken Foam::token::pToken() const
inline bool Foam::token::isLabel() const noexcept inline bool Foam::token::isLabel() const noexcept
{
return (type_ == tokenType::LABEL);
}
inline bool Foam::token::isLabel(const label val) const noexcept
{ {
return return
( (
type_ == tokenType::LABEL type_ == tokenType::LABEL
&& data_.labelVal == val // FUTURE?
// || type_ == tokenType::INT32
// || type_ == tokenType::INT64
);
}
inline bool Foam::token::isLabel(const label value) const noexcept
{
// FUTURE?
// return
// (
// type_ == tokenType::LABEL
// ? value == data_.labelVal
// : type_ == tokenType::INT32
// ? value == data_.int32Val
// : type_ == tokenType::INT64
// ? value == data_.int64Val
// : false
// );
return
(
type_ == tokenType::LABEL
&& value == data_.labelVal
); );
} }
@ -695,7 +713,7 @@ inline Foam::scalar Foam::token::scalarToken() const
inline bool Foam::token::isNumber() const noexcept inline bool Foam::token::isNumber() const noexcept
{ {
return (type_ == tokenType::LABEL || isScalar()); return (isLabel() || isScalar());
} }
@ -894,6 +912,15 @@ Foam::token::tokenType Foam::token::Compound<T>::typeCode() const
{ {
// List<label>, List<labelVector> etc // List<label>, List<labelVector> etc
return token::tokenType::LABEL; return token::tokenType::LABEL;
// FUTURE?
// return
// (
// sizeof(int32_t) == sizeof(Foam::label)
// ? token::tokenType::INT32
// : token::tokenType::INT64
// );
} }
else if (is_contiguous_scalar<valueType>::value) else if (is_contiguous_scalar<valueType>::value)
{ {

View File

@ -57,6 +57,14 @@ static OS& printTokenInfo(OS& os, const token& tok)
os << "punctuation '" << tok.pToken() << '\''; os << "punctuation '" << tok.pToken() << '\'';
break; break;
// case token::tokenType::INT32:
// os << "int32 " << tok.int32Token();
// break;
//
// case token::tokenType::INT64:
// os << "int64 " << tok.int64Token();
// break;
case token::tokenType::LABEL: case token::tokenType::LABEL:
os << "label " << tok.labelToken(); os << "label " << tok.labelToken();
break; break;
@ -146,6 +154,9 @@ Foam::word Foam::token::name(const token::tokenType tokType)
case token::tokenType::BOOL: return "bool"; case token::tokenType::BOOL: return "bool";
case token::tokenType::FLAG: return "flag"; case token::tokenType::FLAG: return "flag";
case token::tokenType::PUNCTUATION: return "punctuation"; case token::tokenType::PUNCTUATION: return "punctuation";
// case token::tokenType::INT32: return "int32";
// case token::tokenType::INT64: return "int64";
case token::tokenType::LABEL: return "label"; case token::tokenType::LABEL: return "label";
case token::tokenType::FLOAT: return "float"; case token::tokenType::FLOAT: return "float";
case token::tokenType::DOUBLE: return "double"; case token::tokenType::DOUBLE: return "double";

View File

@ -70,7 +70,8 @@ Foam::label Foam::dictionaryEntry::endLineNumber() const
Foam::ITstream& Foam::dictionaryEntry::stream() const Foam::ITstream& Foam::dictionaryEntry::stream() const
{ {
FatalIOErrorInFunction(*this) FatalIOErrorInFunction(*this)
<< "Attempt to return dictionary entry as a primitive" << "Attempt to return stream of primitives from a dictionary entry: "
<< entry::keyword() << nl
<< abort(FatalIOError); << abort(FatalIOError);
// Need to return something - send back an empty stream // Need to return something - send back an empty stream

View File

@ -37,7 +37,6 @@ Description
comment. Can be used to e.g. manipulate polyMesh/boundary files. comment. Can be used to e.g. manipulate polyMesh/boundary files.
SourceFiles SourceFiles
dictionaryListEntry.C
dictionaryListEntryIO.C dictionaryListEntryIO.C
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -193,16 +193,10 @@ public:
// Member Functions // Member Functions
//- Return keyword //- Return keyword
const keyType& keyword() const noexcept const keyType& keyword() const noexcept { return keyword_; }
{
return keyword_;
}
//- Return non-const access to keyword //- Return non-const access to keyword
keyType& keyword() noexcept keyType& keyword() noexcept { return keyword_; }
{
return keyword_;
}
//- Return the entry name //- Return the entry name
virtual const fileName& name() const = 0; virtual const fileName& name() const = 0;
@ -221,34 +215,26 @@ public:
//- Return true if this entry is a stream //- Return true if this entry is a stream
virtual bool isStream() const noexcept virtual bool isStream() const noexcept { return false; }
{
return false; //- Return pointer to token stream, if entry is a primitive entry
} // Return nullptr if the entry is not a primitive entry
virtual ITstream* streamPtr() const { return nullptr; }
//- Return token stream, if entry is a primitive entry //- Return token stream, if entry is a primitive entry
virtual ITstream& stream() const = 0; virtual ITstream& stream() const = 0;
//- Return true if this entry is a dictionary //- Return true if this entry is a dictionary
virtual bool isDict() const noexcept virtual bool isDict() const noexcept { return this->dictPtr(); }
{
return this->dictPtr();
}
//- Return pointer to dictionary, if entry is a dictionary. //- Return pointer to dictionary, if entry is a dictionary.
// Return nullptr if the entry is not a dictionary. // Return nullptr if the entry is not a dictionary.
virtual const dictionary* dictPtr() const noexcept virtual const dictionary* dictPtr() const noexcept { return nullptr; }
{
return nullptr;
}
//- Return non-const pointer to dictionary, if entry is a dictionary //- Return non-const pointer to dictionary, if entry is a dictionary
// Return nullptr if the entry is not a dictionary. // Return nullptr if the entry is not a dictionary.
virtual dictionary* dictPtr() noexcept virtual dictionary* dictPtr() noexcept { return nullptr; }
{
return nullptr;
}
//- Return dictionary, if entry is a dictionary //- Return dictionary, if entry is a dictionary
virtual const dictionary& dict() const = 0; virtual const dictionary& dict() const = 0;

View File

@ -198,7 +198,7 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
// - #eval INT "expr" // - #eval INT "expr"
// - #eval INT { expr } // - #eval INT { expr }
// - #eval INT #{ expr #} // - #eval INT #{ expr #}
fieldWidth = max(1, tok.labelToken()); fieldWidth = Foam::max(1, tok.labelToken());
is >> tok; is >> tok;
} }

View File

@ -273,10 +273,18 @@ Foam::primitiveEntry::primitiveEntry
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::ITstream* Foam::primitiveEntry::streamPtr() const
{
ITstream* ptr = const_cast<primitiveEntry*>(this);
ptr->seek(0);
return ptr;
}
Foam::ITstream& Foam::primitiveEntry::stream() const Foam::ITstream& Foam::primitiveEntry::stream() const
{ {
ITstream& is = const_cast<primitiveEntry&>(*this); ITstream& is = const_cast<primitiveEntry&>(*this);
is.rewind(); is.seek(0);
return is; return is;
} }

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -187,6 +187,9 @@ public:
return true; return true;
} }
//- Return pointer to token stream for this primitive entry
virtual ITstream* streamPtr() const;
//- Return token stream for this primitive entry //- Return token stream for this primitive entry
virtual ITstream& stream() const; virtual ITstream& stream() const;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2017-2023 OpenCFD Ltd. Copyright (C) 2017-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -333,16 +333,16 @@ Foam::Ostream& Foam::operator<<
e.print(os); e.print(os);
constexpr label nPrintTokens = 10; const label nPrintTokens = Foam::min(label(10), label(e.size()));
os << " primitiveEntry '" << e.keyword() << "' comprises "; os << " primitiveEntry '" << e.keyword() << "' comprises ";
for (label i=0; i<min(e.size(), nPrintTokens); ++i) for (label i = 0; i < nPrintTokens; ++i)
{ {
os << nl << " " << e[i].info(); os << nl << " " << e[i].info();
} }
if (e.size() > nPrintTokens) if (10 < e.size())
{ {
os << " ..."; os << " ...";
} }

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2020-2023 OpenCFD Ltd. Copyright (C) 2020-2024 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -814,8 +814,8 @@ void Foam::PDRblock::writeBlockMeshDict(const IOobject& io) const
<< "Generate blockMeshDict: " << "Generate blockMeshDict: "
<< iodict.db().time().relativePath(os.name()) << endl; << iodict.db().time().relativePath(os.name()) << endl;
// Set precision for points to 10 // More precision (for points data)
os.precision(max(10u, IOstream::defaultPrecision())); os.precision(Foam::max(10u, IOstream::defaultPrecision()));
iodict.writeHeader(os); iodict.writeHeader(os);

View File

@ -1239,8 +1239,8 @@ bool Foam::faMeshDecomposition::writeDecomposition()
// Add boundary patches // Add boundary patches
procMesh.addFaPatches(procPatches); procMesh.addFaPatches(procPatches);
// Set the precision of the points data to 10 // More precision (for points data)
IOstream::defaultPrecision(10); IOstream::minPrecision(10);
procMesh.write(); procMesh.write();