ENH: Added scale option to nastranSurfaceWriter

This commit is contained in:
andy
2013-01-16 16:41:08 +00:00
parent 55b083336c
commit 9e5e2c8bea
3 changed files with 16 additions and 9 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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -336,15 +336,17 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter()
: :
surfaceWriter(), surfaceWriter(),
writeFormat_(wfShort), writeFormat_(wfShort),
fieldMap_() fieldMap_(),
scale_(1.0)
{} {}
Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options) Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
: :
surfaceWriter(), surfaceWriter(),
writeFormat_(wfShort), writeFormat_(wfLong),
fieldMap_() fieldMap_(),
scale_(options.lookupOrDefault("scale", 1.0))
{ {
if (options.found("format")) if (options.found("format"))
{ {

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -75,6 +75,9 @@ private:
//- Map of OpenFOAM field name vs nastran field name //- Map of OpenFOAM field name vs nastran field name
HashTable<word> fieldMap_; HashTable<word> fieldMap_;
//- Scale to apply to values (default = 1.0)
scalar scale_;
// Private Member Functions // Private Member Functions

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) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,6 +46,8 @@ void Foam::nastranSurfaceWriter::writeFaceValue
label SID = 1; label SID = 1;
Type scaledValue = scale_*value;
switch (writeFormat_) switch (writeFormat_)
{ {
case wfShort: case wfShort:
@ -59,7 +61,7 @@ void Foam::nastranSurfaceWriter::writeFaceValue
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++) for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
{ {
os << setw(8) << component(value, dirI); os << setw(8) << component(scaledValue, dirI);
} }
os.unsetf(ios_base::right); os.unsetf(ios_base::right);
@ -77,7 +79,7 @@ void Foam::nastranSurfaceWriter::writeFaceValue
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++) for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
{ {
os << setw(16) << component(value, dirI); os << setw(16) << component(scaledValue, dirI);
} }
os.unsetf(ios_base::right); os.unsetf(ios_base::right);
@ -98,7 +100,7 @@ void Foam::nastranSurfaceWriter::writeFaceValue
for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++) for (direction dirI = 0; dirI < pTraits<Type>::nComponents; dirI++)
{ {
os << ',' << component(value, dirI); os << ',' << component(scaledValue, dirI);
} }
break; break;