ENH: cleanup ensight surface reader (#2535)

- some central (core) bits under fileFormats,

- general surface reading relocated from sampling to surfMesh since it
  does not use any sampling-specific components and will permit
  re-use in meshTools (for example)

- remove old mask, subDir methods from ensightFile which were
  previously relocated to ensightCase

- improve handling of 'undef' values when generating and reading,
  respect Ensight component ordering when reading.
This commit is contained in:
Mark Olesen
2022-07-14 16:37:04 +02:00
parent c4d18e97a3
commit b4612b4c04
26 changed files with 440 additions and 438 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -24,10 +24,11 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Description
Print max limits.
Print some numerical limits.
\*---------------------------------------------------------------------------*/
#include <cmath>
#include <limits>
#include "int.H"
#include "uint.H"
@ -37,21 +38,63 @@ Description
using namespace Foam;
std::ostream& print(const char* tag, float val)
{
std::cout
<< tag << val
<< " 0x" << std::hex << *reinterpret_cast<const uint32_t*>(&val);
return std::cout;
}
std::ostream& print(const char* tag, double val)
{
std::cout
<< tag << val
<< " 0x" << std::hex << *reinterpret_cast<const uint64_t*>(&val);
return std::cout;
}
// Have (float|double)Scalar(GREAT|SMALL|..)
#define PrintFloatLimits(FloatType, NanFunction) \
{ \
print("max:", std::numeric_limits<FloatType>::max()); \
print(" VGREAT:", FloatType##ScalarVGREAT); \
print(" ROOTVGREAT:", FloatType##ScalarROOTVGREAT) << nl; \
\
print("min:", std::numeric_limits<FloatType>::min()); \
print(" VSMALL:", FloatType##ScalarVSMALL); \
print(" ROOTVSMALL:", FloatType##ScalarROOTVSMALL) << nl; \
\
print("epsilon:", std::numeric_limits<FloatType>::epsilon()); \
print(" SMALL:", FloatType##ScalarSMALL); \
print(" ROOTSMALL:", FloatType##ScalarROOTSMALL) << nl; \
\
print("1/epsilon:", 1/std::numeric_limits<FloatType>::epsilon()); \
print(" GREAT:", FloatType##ScalarGREAT); \
print(" ROOTGREAT:", FloatType##ScalarROOTGREAT) << nl; \
\
print("nan:", std::NanFunction("nan")) << nl; \
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
//NONE Info<<"int16:" << pTraits<int16_t>::max << nl;
Info<< "=max=" << nl;
Info<< "uint8:" << pTraits<uint8_t>::max << nl;
Info<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
Info<< "int32:" << pTraits<int32_t>::max << nl;
Info<< "uint32:" << pTraits<uint32_t>::max << nl;
Info<< "int64:" << pTraits<int64_t>::max << nl;
Info<< "uint64:" << pTraits<uint64_t>::max << nl;
//NONE cout<<"int16:" << pTraits<int16_t>::max << nl;
cout<< "=max=" << nl;
cout<< "uint8:" << pTraits<uint8_t>::max << nl;
cout<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
cout<< "int32:" << pTraits<int32_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;
cout<< nl;
cout<< "int16:" << std::numeric_limits<int16_t>::max() << nl;
cout<< "int32:" << pTraits<int32_t>::max << nl;
@ -59,7 +102,7 @@ int main(int argc, char *argv[])
cout<< "int64:" << pTraits<int64_t>::max << nl;
cout<< "uint64:" << pTraits<uint64_t>::max << nl;
Info<< nl << "=digits=" << nl;
cout<< nl << "=digits=" << nl;
cout<< "int16:" << std::numeric_limits<int16_t>::digits << nl;
cout<< "int32:" << std::numeric_limits<int32_t>::digits << nl;
@ -70,29 +113,15 @@ int main(int argc, char *argv[])
cout<< "double:" << std::numeric_limits<double>::digits << nl;
cout<< "long double:" << std::numeric_limits<long double>::digits << nl;
Info<< nl << "=float=" << nl;
// std::nanl (long double)
cout<< nl;
cout<< nl << "=float=" << nl;
PrintFloatLimits(float, nanf);
cout<< "max:" << std::numeric_limits<float>::max()
<< " VGREAT:" << floatScalarVGREAT << nl;
cout<< "min:" << std::numeric_limits<float>::min()
<< " VSMALL:" << floatScalarVSMALL << nl;
cout<< "epsilon:" << std::numeric_limits<float>::epsilon()
<< " SMALL:" << floatScalarSMALL << nl;
cout<< "1/epsilon:" << 1.0f/std::numeric_limits<float>::epsilon()
<< " GREAT:" << floatScalarGREAT << nl;
cout<< nl << "=double=" << nl;
PrintFloatLimits(double, nan);
Info<< nl << "=double=" << nl;
cout<< "max:" << std::numeric_limits<double>::max()
<< " VGREAT:" << doubleScalarVGREAT << nl;
cout<< "min:" << std::numeric_limits<double>::min()
<< " VSMALL:" << doubleScalarVSMALL << nl;
cout<< "epsilon:" << std::numeric_limits<double>::epsilon()
<< " SMALL:" << doubleScalarSMALL << nl;
cout<< "1/epsilon:" << 1.0f/std::numeric_limits<double>::epsilon()
<< " GREAT:" << doubleScalarGREAT << nl;
Info << "---\nEnd\n" << endl;
cout<< "---\nEnd\n" << std::endl;
return 0;
}