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
{
// Set the precision of the points data to 10
IOstream::defaultPrecision(10);
// More precision (for points data)
IOstream::minPrecision(10);
Info<< nl << "Write finite area mesh." << nl;
aMesh.write();

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2021 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
// More precision (for points data)
IOstream::minPrecision(10);
Info<< "Writing polyMesh" << endl;
pShapeMesh.removeFiles();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
Copyright (C) 2018-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
// More precision (for points data)
IOstream::minPrecision(10);
// Generate the mirrorred mesh
const fvMesh& mMesh = mesh.mirrorMesh();

View File

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

View File

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

View File

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

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019-2023 OpenCFD Ltd.
Copyright (C) 2019-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
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
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
// More precision (for points data)
IOstream::minPrecision(10);
procMesh.write();

View File

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

View File

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

View File

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