ENH: add Ensight output support for a labelField (treat like scalarField)

This commit is contained in:
Mark Olesen
2019-02-11 16:03:10 +01:00
committed by Andrew Heather
parent c137d3f823
commit e6937f60de
4 changed files with 37 additions and 7 deletions

View File

@ -326,10 +326,17 @@ void Foam::ensightFile::beginParticleCoordinates(const label nparticles)
}
void Foam::ensightFile::writeList
(
const UList<scalar>& field
)
void Foam::ensightFile::writeList(const UList<label>& field)
{
for (const label val : field)
{
write(scalar(val));
newline();
}
}
void Foam::ensightFile::writeList(const UList<scalar>& field)
{
for (const scalar& val : field)
{
@ -347,6 +354,7 @@ void Foam::ensightFile::writeList
}
void Foam::ensightFile::writeList
(
const UList<scalar>& field,
@ -368,4 +376,5 @@ void Foam::ensightFile::writeList
}
}
// ************************************************************************* //

View File

@ -191,6 +191,9 @@ public:
//- Begin a "particle coordinates" block (measured data)
void beginParticleCoordinates(const label nparticles);
//- Write a list of integers as float values
void writeList(const UList<label>& field);
//- Write a list of floats as "%12.5e" or as binary
// With carriage return after each value (ascii stream)
void writeList(const UList<scalar>& field);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2015 OpenFOAM Foundation
@ -29,6 +29,15 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<>
const char* const
Foam::ensightPTraits<Foam::label>::typeName = "scalar";
template<>
const Foam::direction
Foam::ensightPTraits<Foam::label>::componentOrder[] = {0};
template<>
const char* const
Foam::ensightPTraits<Foam::scalar>::typeName = "scalar";
@ -47,7 +56,7 @@ const Foam::direction
Foam::ensightPTraits<Foam::vector>::componentOrder[] = {0, 1, 2};
// use mag(sphericalTensor) instead
// Use mag(sphericalTensor) instead
template<>
const char* const
Foam::ensightPTraits<Foam::sphericalTensor>::typeName = "scalar";

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
| Copyright (C) 2013-2015 OpenFOAM Foundation
@ -29,6 +29,9 @@ Class
Description
Conversion of OpenFOAM pTraits into the Ensight equivalent
For the purpose of traits, integers (label) are treated like
floating point (scalar). Spherical tensors are mapped as a scalar.
\*---------------------------------------------------------------------------*/
#ifndef ensightPTraits_H
@ -62,6 +65,12 @@ public:
static const direction componentOrder[];
};
template<>
const char* const ensightPTraits<label>::typeName;
template<>
const direction ensightPTraits<label>::componentOrder[];
template<>
const char* const ensightPTraits<scalar>::typeName;