Commit 8f8a4dc6 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: add foamDictionary -precision option (issue #1177)

- since foamDictionary doesn't use system/controlDict it will use the
  standard default precision. The '-precision' option allows adjusting
  that value.
parent 789c5d00
......@@ -40,20 +40,33 @@ using namespace Foam;
int main(int argc, char *argv[])
{
//NONE Info<<"int16:" << pTraits<int16_t>::max << nl;
Info<<"=max=" << nl;
Info<<"uint8:" << std::numeric_limits<uint8_t>::max() << nl;
Info<<"int16:" << std::numeric_limits<int16_t>::max() << nl;
Info<<"int32:" << pTraits<int32_t>::max << nl;
Info<<"int64:" << pTraits<int64_t>::max << nl;
Info<<"uint32:" << pTraits<uint32_t>::max << nl;
Info<<"int64:" << pTraits<int64_t>::max << nl;
Info<<"uint64:" << pTraits<uint64_t>::max << nl;
Info<< nl;
cout<<"int16:" << std::numeric_limits<int16_t>::max() << nl;
cout<<"int32:" << pTraits<int32_t>::max << nl;
cout<<"int64:" << pTraits<int64_t>::max << nl;
cout<<"uint32:" << pTraits<uint32_t>::max << nl;
cout<<"int64:" << pTraits<int64_t>::max << nl;
cout<<"uint64:" << pTraits<uint64_t>::max << nl;
Info<< nl << "=digits=" << nl;
cout<<"int16:" << std::numeric_limits<int16_t>::digits << nl;
cout<<"int32:" << std::numeric_limits<int32_t>::digits << nl;
cout<<"uint32:" << std::numeric_limits<uint32_t>::digits << nl;
cout<<"int64:" << std::numeric_limits<int64_t>::digits << nl;
cout<<"uint64:" << std::numeric_limits<uint64_t>::digits << nl;
cout<<"float:" << std::numeric_limits<float>::digits << nl;
cout<<"double:" << std::numeric_limits<double>::digits << nl;
cout<<"long double:" << std::numeric_limits<long double>::digits << nl;
Info << "---\nEnd\n" << endl;
return 0;
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2016-2017 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2017-2018 OpenCFD Ltd.
\\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -64,6 +64,9 @@ Usage
- \par -disableFunctionEntries
Do not expand macros or directives (\#include etc)
- \par -precision int
Set default write precision for IOstreams
Example usage:
- Change simulation to run for one timestep only:
\verbatim
......@@ -307,6 +310,12 @@ int main(int argc, char *argv[])
"As per -diff, but locate the file as per foamEtcFile"
);
argList::addOptionCompat("diff-etc", {"diffEtc", 1712});
argList::addOption
(
"precision",
"int",
"Set default write precision for IOstreams"
);
argList::addBoolOption
(
......@@ -346,6 +355,20 @@ int main(int argc, char *argv[])
entry::disableFunctionEntries = true;
}
// Set the default output precision
{
const unsigned prec = args.lookupOrDefault<unsigned>("precision", 0u);
if (prec)
{
// if (Pstream::master())
// {
// Serr<< "Output write precision set to " << prec << endl;
// }
IOstream::defaultPrecision(prec);
Sout.precision(prec);
}
}
const fileName dictFileName(args[1]);
......
......@@ -89,20 +89,23 @@ int main(int argc, char *argv[])
);
argList::addOption
(
"writePrecision",
"label",
"precision",
"int",
"Write to output with the specified precision"
);
argList::addOptionCompat("precision", {"writePrecision", 1812});
argList args(argc, argv);
if (args.found("writePrecision"))
{
const label prec = args.opt<label>("writePrecision");
Info<< "Output write precision set to " << prec << endl;
IOstream::defaultPrecision(prec);
Sout.precision(prec);
const unsigned prec = args.lookupOrDefault<unsigned>("precision", 0u);
if (prec)
{
Info<< "Output write precision set to " << prec << endl;
IOstream::defaultPrecision(prec);
Sout.precision(prec);
}
}
const fileName importName = args[1];
......
......@@ -83,7 +83,7 @@ _of_complete_cache_[fluentMeshToFoam]="-2D -case -fileHandler -scale | -noFuncti
_of_complete_cache_[FMSToSurface]="-case -fileHandler | -exportFeatureEdges -exportSubsets -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[FMSToVTK]="-case -fileHandler | -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[foamDataToFluent]="-case -fileHandler -time | -latestTime -noFunctionObjects -noZero -doc -doc-source -help"
_of_complete_cache_[foamDictionary]="-add -case -decomposeParDict -diff -diff-etc -entry -fileHandler -set | -disableFunctionEntries -expand -includes -keywords -noFunctionObjects -parallel -remove -value -doc -doc-source -help"
_of_complete_cache_[foamDictionary]="-add -case -decomposeParDict -diff -diff-etc -entry -fileHandler -precision -set | -disableFunctionEntries -expand -includes -keywords -noFunctionObjects -parallel -remove -value -doc -doc-source -help"
_of_complete_cache_[foamFormatConvert]="-case -decomposeParDict -fileHandler -region -time | -constant -enableFunctionEntries -latestTime -noConstant -noFunctionObjects -noZero -parallel -doc -doc-source -help"
_of_complete_cache_[foamHelp]="-case -decomposeParDict -fileHandler -region | -noFunctionObjects -parallel -doc -doc-source -help"
_of_complete_cache_[foamListRegions]="-case -fileHandler | -doc -doc-source -help"
......@@ -246,7 +246,7 @@ _of_complete_cache_[surfaceBooleanFeatures]="-case -fileHandler -scale -trim | -
_of_complete_cache_[surfaceCheck]="-case -fileHandler -outputThreshold -writeSets | -blockMesh -checkSelfIntersection -noFunctionObjects -splitNonManifold -verbose -doc -doc-source -help"
_of_complete_cache_[surfaceClean]="-case -fileHandler -scale | -noClean -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[surfaceCoarsen]="-case -fileHandler -scale | -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[surfaceConvert]="-case -fileHandler -scale -writePrecision | -clean -group -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[surfaceConvert]="-case -fileHandler -precision -scale | -clean -group -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[surfaceFeatureConvert]="-case -fileHandler -scale | -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[surfaceFeatureEdges]="-angle -case -fileHandler | -noFunctionObjects -doc -doc-source -help"
_of_complete_cache_[surfaceFeatureExtract]="-case -dict -fileHandler | -doc -doc-source -help"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment