From 361257d9f44cb50f2e55b2e4ea37d93e979ba680 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 17 Jan 2019 03:10:31 +0100 Subject: [PATCH] STYLE: enumerate Nastran PLOADs in NASCore --- src/fileFormats/nas/NASCore.C | 13 ++++++++++++- src/fileFormats/nas/NASCore.H | 12 +++++++++++- .../writers/nastran/nastranSurfaceWriter.C | 13 +------------ .../writers/nastran/nastranSurfaceWriter.H | 8 +------- .../writers/nastran/nastranSurfaceWriterImpl.C | 8 +++++--- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/fileFormats/nas/NASCore.C b/src/fileFormats/nas/NASCore.C index 610306c17b..b050c03dcb 100644 --- a/src/fileFormats/nas/NASCore.C +++ b/src/fileFormats/nas/NASCore.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,6 +42,17 @@ Foam::fileFormats::NASCore::fieldFormatNames }); +const Foam::Enum +< + Foam::fileFormats::NASCore::loadFormat +> +Foam::fileFormats::NASCore::loadFormatNames +({ + { loadFormat::PLOAD2, "PLOAD2" }, + { loadFormat::PLOAD4, "PLOAD4" }, +}); + + // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // Foam::scalar Foam::fileFormats::NASCore::readNasScalar(const std::string& str) diff --git a/src/fileFormats/nas/NASCore.H b/src/fileFormats/nas/NASCore.H index 5206792ecf..08082f4ded 100644 --- a/src/fileFormats/nas/NASCore.H +++ b/src/fileFormats/nas/NASCore.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,6 +69,16 @@ public: //- Selection names for the NASTRAN file field formats static const Enum fieldFormatNames; + //- Output load format + enum loadFormat + { + PLOAD2, + PLOAD4 + }; + + //- Selection names for the NASTRAN file field formats + static const Enum loadFormatNames; + // Constructors diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C index 403e6d6d1b..87a889740a 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.C @@ -37,17 +37,6 @@ namespace Foam addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict); } -const Foam::Enum -< - Foam::nastranSurfaceWriter::loadFormat -> -Foam::nastranSurfaceWriter::loadFormatNames_ -({ - { loadFormat::PLOAD2, "PLOAD2" }, - { loadFormat::PLOAD4, "PLOAD4" }, -}); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Field writing implementation @@ -356,7 +345,7 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options) fieldMap_.insert ( item.first(), - loadFormatNames_[item.second()] + fileFormats::NASCore::loadFormatNames[item.second()] ); } } diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H index 57dcfaac0b..bb17e65c73 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriter.H @@ -110,19 +110,13 @@ public: using fieldFormat = Foam::fileFormats::NASCore::fieldFormat; //- Output load format - enum loadFormat - { - PLOAD2, - PLOAD4 - }; + using loadFormat = Foam::fileFormats::NASCore::loadFormat; private: // Private data - static const Enum loadFormatNames_; - //- Field format (width and separator) fieldFormat writeFormat_; diff --git a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterImpl.C b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterImpl.C index 479fb5ac24..943a5b2a0e 100644 --- a/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterImpl.C +++ b/src/sampling/sampledSurface/writers/nastran/nastranSurfaceWriterImpl.C @@ -89,7 +89,8 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue Type scaledValue = scale_*value; // Write keyword - writeKeyword(os, loadFormatNames_[format]) << separator_; + writeKeyword(os, fileFormats::NASCore::loadFormatNames[format]) + << separator_; // Write load set ID os.setf(std::ios_base::right); @@ -107,8 +108,9 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue else { WarningInFunction - << loadFormatNames_[format] << " requires scalar values " - << "and cannot be used for higher rank values" + << fileFormats::NASCore::loadFormatNames[format] + << " requires scalar values" + << " - it cannot be used for higher rank values" << endl; writeValue(os, scalar(0)) << separator_;