From adb01bddf40e37e260e49ddcf38cbf0b057716ff Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 11 Nov 2021 11:19:39 +0100 Subject: [PATCH] ENH: use float-narrowing for ensight set writer - replaces hand-rolled checks STYLE: minor cleanup of ensightPTraits --- src/fileFormats/ensight/type/ensightPTraits.C | 3 +- src/fileFormats/ensight/type/ensightPTraits.H | 27 ++-- .../ensight/ensightSetWriter.C | 124 ++++++++---------- 3 files changed, 67 insertions(+), 87 deletions(-) diff --git a/src/fileFormats/ensight/type/ensightPTraits.C b/src/fileFormats/ensight/type/ensightPTraits.C index f1a8894077..9eaf9d30f6 100644 --- a/src/fileFormats/ensight/type/ensightPTraits.C +++ b/src/fileFormats/ensight/type/ensightPTraits.C @@ -62,16 +62,15 @@ template<> const char* const Foam::ensightPTraits::typeName = "scalar"; - template<> const Foam::direction Foam::ensightPTraits::componentOrder[] = {0}; + template<> const char* const Foam::ensightPTraits::typeName = "tensor symm"; - template<> const Foam::direction Foam::ensightPTraits::componentOrder[] = {0, 3, 5, 1, 2, 4}; diff --git a/src/fileFormats/ensight/type/ensightPTraits.H b/src/fileFormats/ensight/type/ensightPTraits.H index 2aed592598..63a86e0ee0 100644 --- a/src/fileFormats/ensight/type/ensightPTraits.H +++ b/src/fileFormats/ensight/type/ensightPTraits.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2015 OpenFOAM Foundation - Copyright (C) 2019 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -28,7 +28,7 @@ Class Foam::ensightPTraits Description - Conversion of OpenFOAM pTraits into the Ensight equivalent + Ensight names and component order for base types. For the purpose of traits, integers (label) are treated like floating point (scalar). Spherical tensors are mapped as a scalar. @@ -38,7 +38,6 @@ Description #ifndef ensightPTraits_H #define ensightPTraits_H -#include "pTraits.H" #include "fieldTypes.H" #include "direction.H" @@ -51,21 +50,21 @@ namespace Foam Class ensightPTraits Declaration \*---------------------------------------------------------------------------*/ -template -class ensightPTraits +template +struct ensightPTraits { -public: + //- The type name used in ensight case files + static const char* const typeName; - // Static data members - - static const char* const typeName; - - //- Ordering table: return OpenFOAM component given Ensight component - // This is used for the symmTensor ordering: Ensight requires - // xx yy zz xy xz yz - static const direction componentOrder[]; + //- Ordering table: return OpenFOAM component given Ensight component + // This is used for the symmTensor ordering: Ensight requires + // xx yy zz xy xz yz + static const direction componentOrder[]; }; + +// Specializations + template<> const char* const ensightPTraits