mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: impose type-narrowing for Ensight output
This commit is contained in:
@ -225,28 +225,62 @@ Foam::Ostream& Foam::ensightFile::write
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::ensightFile::write(const label value)
|
||||
Foam::Ostream& Foam::ensightFile::write(const int32_t val)
|
||||
{
|
||||
if (format() == IOstream::BINARY)
|
||||
{
|
||||
unsigned int ivalue(value);
|
||||
|
||||
write
|
||||
(
|
||||
reinterpret_cast<const char *>(&ivalue),
|
||||
sizeof(ivalue)
|
||||
reinterpret_cast<const char *>(&val),
|
||||
sizeof(int32_t)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
stdStream().width(10);
|
||||
stdStream() << value;
|
||||
stdStream() << val;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::ensightFile::write(const int64_t val)
|
||||
{
|
||||
int32_t ivalue(narrowInt32(val));
|
||||
|
||||
return write(ivalue);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::ensightFile::write(const floatScalar val)
|
||||
{
|
||||
if (format() == IOstream::BINARY)
|
||||
{
|
||||
write
|
||||
(
|
||||
reinterpret_cast<const char *>(&val),
|
||||
sizeof(floatScalar)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
stdStream().width(12);
|
||||
stdStream() << val;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::ensightFile::write(const doubleScalar val)
|
||||
{
|
||||
float fvalue(narrowFloat(val));
|
||||
|
||||
return write(fvalue);
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::ensightFile::write
|
||||
(
|
||||
const label value,
|
||||
@ -255,13 +289,7 @@ Foam::Ostream& Foam::ensightFile::write
|
||||
{
|
||||
if (format() == IOstream::BINARY)
|
||||
{
|
||||
unsigned int ivalue(value);
|
||||
|
||||
write
|
||||
(
|
||||
reinterpret_cast<const char *>(&ivalue),
|
||||
sizeof(ivalue)
|
||||
);
|
||||
write(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -273,36 +301,6 @@ Foam::Ostream& Foam::ensightFile::write
|
||||
}
|
||||
|
||||
|
||||
Foam::Ostream& Foam::ensightFile::write(const scalar value)
|
||||
{
|
||||
float fvalue(value);
|
||||
|
||||
// TBD: limit range?
|
||||
// #if defined(WM_DP)
|
||||
// if (mag(value) < scalar(floatScalarVSMALL))
|
||||
// {
|
||||
// fvalue = 0;
|
||||
// }
|
||||
// #endif
|
||||
|
||||
if (format() == IOstream::BINARY)
|
||||
{
|
||||
write
|
||||
(
|
||||
reinterpret_cast<const char *>(&fvalue),
|
||||
sizeof(fvalue)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
stdStream().width(12);
|
||||
stdStream() << fvalue;
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightFile::newline()
|
||||
{
|
||||
if (format() == IOstream::ASCII)
|
||||
|
||||
Reference in New Issue
Block a user