BUG: incorrect order for VTK symmTensor (fixes #892)

- affected manually generated legacy output (vtkSetWriter, vtkSurfaceWriter)

- the order emitted by vtkSetWriter remains, but needs to revisited again.
This commit is contained in:
Mark Olesen
2018-06-21 09:38:25 +02:00
parent f9dc9dbf5f
commit 813a0500e2
3 changed files with 24 additions and 15 deletions

View File

@ -28,6 +28,10 @@ Description
A collection of static methods to assist converting OpenFOAM data
structures into VTK internal data structures.
Remapping of the symmTensor order is required in input or output
directions. OpenFOAM uses (XX, XY, XZ, YY, YZ, ZZ) order,
VTK uses (XX, YY, ZZ, XY, YZ, XZ) order.
Note
The class is implemented as headers-only.
@ -204,13 +208,13 @@ public:
};
//- Remapping for some OpenFOAM data types
//- Remapping for some OpenFOAM data types (eg, symmTensor)
template<class Type>
inline static void remapTuple(float vec[]) {}
inline static void remapTuple(float data[]) {}
//- Remapping for some OpenFOAM data types
//- Remapping for some OpenFOAM data types (eg, symmTensor)
template<class Type>
inline static void remapTuple(double vec[]) {}
inline static void remapTuple(double data[]) {}
// Field Conversion Functions
@ -248,21 +252,21 @@ public:
};
//- Template specialization for symmTensor
//- Template specialization for symmTensor ordering
template<>
inline void Foam::vtk::Tools::remapTuple<Foam::symmTensor>(float vec[])
inline void Foam::vtk::Tools::remapTuple<Foam::symmTensor>(float data[])
{
std::swap(vec[1], vec[3]); // swap XY <-> YY
std::swap(vec[2], vec[5]); // swap XZ <-> ZZ
std::swap(data[1], data[3]); // swap XY <-> YY
std::swap(data[2], data[5]); // swap XZ <-> ZZ
}
//- Template specialization for symmTensor
//- Template specialization for symmTensor ordering
template<>
inline void Foam::vtk::Tools::remapTuple<Foam::symmTensor>(double vec[])
inline void Foam::vtk::Tools::remapTuple<Foam::symmTensor>(double data[])
{
std::swap(vec[1], vec[3]); // swap XY <-> YY
std::swap(vec[2], vec[5]); // swap XZ <-> ZZ
std::swap(data[1], data[3]); // swap XY <-> YY
std::swap(data[2], data[5]); // swap XZ <-> ZZ
}

View File

@ -26,6 +26,9 @@ Class
Description
Note
The output order of symmTensor is incorrect.
SourceFiles
vtkSetWriter.C

View File

@ -161,13 +161,15 @@ namespace Foam
{
os << "6 " << values.size() << " float" << nl;
// symmTensor ( XX, XY, XZ, YY, YZ, ZZ )
// VTK order ( XX, YY, ZZ, XY, YZ, XZ ) -> (0, 3, 5, 1, 4, 2)
for (const symmTensor& v : values)
{
os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2])
os << float(v[0]) << ' ' << float(v[3]) << ' ' << float(v[5])
<< ' '
<< float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5])
<< float(v[1]) << ' ' << float(v[4]) << ' ' << float(v[2])
<< nl;
}
}