From 472fbded8959a8d68a27c63b2c8192155ecb2e09 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 13 Aug 2013 10:19:10 +0100 Subject: [PATCH] BUG: ensight: symmTensor writing --- .../foamToEnsight/ensightField.C | 13 ++- .../writers/ensight/ensightPTraits.C | 46 ++++++++ .../writers/ensight/ensightPTraits.H | 108 ++++++++++++++++++ .../writers/ensight/ensightSurfaceWriter.C | 7 +- 4 files changed, 165 insertions(+), 9 deletions(-) create mode 100644 src/sampling/sampledSurface/writers/ensight/ensightPTraits.C create mode 100644 src/sampling/sampledSurface/writers/ensight/ensightPTraits.H diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C index 0b07b7f2eb..8284a0ddf0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C @@ -33,6 +33,7 @@ License #include "ensightBinaryStream.H" #include "ensightAsciiStream.H" #include "globalIndex.H" +#include "ensightPTraits.H" using namespace Foam; @@ -198,7 +199,7 @@ void writePatchField ensightCaseFile.setf(ios_base::left); ensightCaseFile - << pTraits::typeName + << ensightPTraits::typeName << " per element: 1 " << setw(15) << pfName << (' ' + prepend + "****." + pfName).c_str() @@ -230,7 +231,7 @@ void writePatchField if (Pstream::master()) { - ensightFile.write(pTraits::typeName); + ensightFile.write(ensightPTraits::typeName); } if (patchi >= 0) @@ -341,14 +342,14 @@ void ensightField ensightCaseFile.setf(ios_base::left); ensightCaseFile - << pTraits::typeName + << ensightPTraits::typeName << " per element: 1 " << setw(15) << vf.name() << (' ' + prepend + "****." + vf.name()).c_str() << nl; } - ensightFile.write(pTraits::typeName); + ensightFile.write(ensightPTraits::typeName); ensightFile.writePartHeader(1); } @@ -555,14 +556,14 @@ void ensightPointField ensightCaseFile.setf(ios_base::left); ensightCaseFile - << pTraits::typeName + << ensightPTraits::typeName << " per node: 1 " << setw(15) << pf.name() << (' ' + prepend + "****." + pf.name()).c_str() << nl; } - ensightFile.write(pTraits::typeName); + ensightFile.write(ensightPTraits::typeName); ensightFile.writePartHeader(1); } diff --git a/src/sampling/sampledSurface/writers/ensight/ensightPTraits.C b/src/sampling/sampledSurface/writers/ensight/ensightPTraits.C new file mode 100644 index 0000000000..8d3ed3be5f --- /dev/null +++ b/src/sampling/sampledSurface/writers/ensight/ensightPTraits.C @@ -0,0 +1,46 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "ensightPTraits.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const char* const Foam::ensightPTraits::typeName = + Foam::pTraits::typeName; + +const char* const Foam::ensightPTraits::typeName = + Foam::pTraits::typeName; + +const char* const Foam::ensightPTraits::typeName = + Foam::pTraits::typeName; + +const char* const Foam::ensightPTraits::typeName = + "tensor symm"; + +const char* const Foam::ensightPTraits::typeName = + Foam::pTraits::typeName; + + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/ensight/ensightPTraits.H b/src/sampling/sampledSurface/writers/ensight/ensightPTraits.H new file mode 100644 index 0000000000..70e26756dc --- /dev/null +++ b/src/sampling/sampledSurface/writers/ensight/ensightPTraits.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::ensightPTraits + +Description + Conversion of OpenFOAM pTraits into the Ensight equivalent + +\*---------------------------------------------------------------------------*/ + +#ifndef ensightPTraits_H +#define ensightPTraits_H + +#include "pTraits.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class ensightPTraits Declaration +\*---------------------------------------------------------------------------*/ + +template +class ensightPTraits +{ +public: + + // Static data members + + static const char* const typeName; + +}; + + +template<> +class ensightPTraits +{ +public: + + static const char* const typeName; +}; + +template<> +class ensightPTraits +{ +public: + + static const char* const typeName; +}; + +template<> +class ensightPTraits +{ +public: + + static const char* const typeName; +}; + +template<> +class ensightPTraits +{ +public: + + static const char* const typeName; +}; + +template<> +class ensightPTraits +{ +public: + + static const char* const typeName; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C index 9d4a653819..5e2ab17114 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,7 @@ License #include "OSspecific.H" #include "IOmanip.H" #include "ensightPartFaces.H" +#include "ensightPTraits.H" #include "makeSurfaceWriterMethods.H" @@ -89,7 +90,7 @@ void Foam::ensightSurfaceWriter::writeTemplate << "model: 1 " << osGeom.name().name() << nl << nl << "VARIABLE" << nl - << pTraits::typeName << " per " + << ensightPTraits::typeName << " per " << word(isNodeValues ? "node:" : "element:") << setw(10) << 1 << " " << fieldName << " " << surfaceName.c_str() << ".***." << fieldName << nl @@ -107,7 +108,7 @@ void Foam::ensightSurfaceWriter::writeTemplate osGeom << ensPart; // Write field - osField.writeKeyword(pTraits::typeName); + osField.writeKeyword(ensightPTraits::typeName); ensPart.writeField(osField, values, isNodeValues); }