STYLE: enumerate Nastran PLOADs in NASCore

This commit is contained in:
Mark Olesen
2019-01-17 03:10:31 +01:00
parent c44814c100
commit 361257d9f4
5 changed files with 30 additions and 24 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License 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 * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::scalar Foam::fileFormats::NASCore::readNasScalar(const std::string& str) Foam::scalar Foam::fileFormats::NASCore::readNasScalar(const std::string& str)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd. \\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -69,6 +69,16 @@ public:
//- Selection names for the NASTRAN file field formats //- Selection names for the NASTRAN file field formats
static const Enum<fieldFormat> fieldFormatNames; static const Enum<fieldFormat> fieldFormatNames;
//- Output load format
enum loadFormat
{
PLOAD2,
PLOAD4
};
//- Selection names for the NASTRAN file field formats
static const Enum<loadFormat> loadFormatNames;
// Constructors // Constructors

View File

@ -37,17 +37,6 @@ namespace Foam
addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict); addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict);
} }
const Foam::Enum
<
Foam::nastranSurfaceWriter::loadFormat
>
Foam::nastranSurfaceWriter::loadFormatNames_
({
{ loadFormat::PLOAD2, "PLOAD2" },
{ loadFormat::PLOAD4, "PLOAD4" },
});
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing implementation // Field writing implementation
@ -356,7 +345,7 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
fieldMap_.insert fieldMap_.insert
( (
item.first(), item.first(),
loadFormatNames_[item.second()] fileFormats::NASCore::loadFormatNames[item.second()]
); );
} }
} }

View File

@ -110,19 +110,13 @@ public:
using fieldFormat = Foam::fileFormats::NASCore::fieldFormat; using fieldFormat = Foam::fileFormats::NASCore::fieldFormat;
//- Output load format //- Output load format
enum loadFormat using loadFormat = Foam::fileFormats::NASCore::loadFormat;
{
PLOAD2,
PLOAD4
};
private: private:
// Private data // Private data
static const Enum<loadFormat> loadFormatNames_;
//- Field format (width and separator) //- Field format (width and separator)
fieldFormat writeFormat_; fieldFormat writeFormat_;

View File

@ -89,7 +89,8 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue
Type scaledValue = scale_*value; Type scaledValue = scale_*value;
// Write keyword // Write keyword
writeKeyword(os, loadFormatNames_[format]) << separator_; writeKeyword(os, fileFormats::NASCore::loadFormatNames[format])
<< separator_;
// Write load set ID // Write load set ID
os.setf(std::ios_base::right); os.setf(std::ios_base::right);
@ -107,8 +108,9 @@ Foam::Ostream& Foam::nastranSurfaceWriter::writeFaceValue
else else
{ {
WarningInFunction WarningInFunction
<< loadFormatNames_[format] << " requires scalar values " << fileFormats::NASCore::loadFormatNames[format]
<< "and cannot be used for higher rank values" << " requires scalar values"
<< " - it cannot be used for higher rank values"
<< endl; << endl;
writeValue(os, scalar(0)) << separator_; writeValue(os, scalar(0)) << separator_;