Focusing on reals and not integers for the time being, this would result in 4 combinations for Binary Inputs:
My previous post was not making any assumption about OpenFOAM being installed or having any OpenFOAM environment at all, also not really caring about the contents of controlDict much either.
This is what you can expect to actually be on disk:
- arch “label=(32|64);scalar=(32|64)”
In some cases, the arch entry may even have ...;scalar=32;solveScalar=64, but in those cases the solve-scalar is only used for the linear solve and not the field storage, which remain floatand not double.
So only considering OpenFOAM and VTK, you have essentially have the choice to read in OpenFOAM files that are float/double and store them in VTK as float/double, respectively (which is currently not the case), or do read OpenFOAM files (float/double) and store them in VTK as float (which is what the current reader does). So using your 0-3 combination indices, we currently have 32bit→32bit and 64bit →32bit (ie, combination 0, 2). Adding in a single bool switch (eg, “keepNativePrecision”), you would still have 32bit→32bit but also enable 64bit→64bit (combination 3). As far as OpenFOAM and VTK are concerned, this is all you need. So I guess your question is more about other consumers of the VTK data that require double. In this case, it’s not a binary choice but an additional choice to force target 64-bit output too? A selection of (float/double/native) representation.
enum class FloatHandling { Float, Double, Native, Legacy = Float };
if (io.IsFloat64()) // This is what the input files are telling us
{
if (floatHandling == FloatHandling::Float)
{
// narrow double to float (current default)
this->ReadNonUniformList<SCALARLIST, //
vtkFoamRead::listTraits<vtkFloatArray, double>>(io);
}
else
{
// retain double precision
this->ReadNonUniformList<SCALARLIST, //
vtkFoamRead::listTraits<vtkDoubleArray, double>>(io);
}
}
else
{
if (floatHandling == FloatHandling::Double)
{
// Force widening from float to double
this->ReadNonUniformList<SCALARLIST, //
vtkFoamRead::listTraits<vtkDoubleArray, float>>(io);
}
else
{
// retain float precision (current default behaviour)
this->ReadNonUniformList<SCALARLIST, //
vtkFoamRead::listTraits<vtkFloatArray, float>>(io);
}
}