sampledSurface::writers: Added writeFormat option to select ascii or binary
e.g. in tutorials/incompressible/pisoFoam/LES/motorBike/motorBike/system/cuttingPlane
surfaceFormat vtk;
writeFormat binary;
fields (p U);
selects writing the VTK surface files in binary format which significantly
speeds-up reading of the files in paraview.
Currently binary writing is supported in VTK and EnSight formats.
This commit is contained in:
@ -525,12 +525,7 @@ void Foam::functionObjects::fieldValues::surfaceFieldValue::initialise
|
||||
|
||||
surfaceWriterPtr_.reset
|
||||
(
|
||||
surfaceWriter::New
|
||||
(
|
||||
surfaceFormat,
|
||||
dict.subOrEmptyDict("formatOptions").
|
||||
subOrEmptyDict(surfaceFormat)
|
||||
).ptr()
|
||||
surfaceWriter::New(surfaceFormat, dict).ptr()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -194,12 +194,7 @@ void Foam::FacePostProcessing<CloudType>::write()
|
||||
|
||||
autoPtr<surfaceWriter> writer
|
||||
(
|
||||
surfaceWriter::New
|
||||
(
|
||||
surfaceFormat_,
|
||||
this->coeffDict().subOrEmptyDict("formatOptions").
|
||||
subOrEmptyDict(surfaceFormat_)
|
||||
)
|
||||
surfaceWriter::New(surfaceFormat_, this->coeffDict())
|
||||
);
|
||||
|
||||
writer->write
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -241,12 +241,7 @@ bool Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
const word writeType(dict.lookup("surfaceFormat"));
|
||||
|
||||
// Define the surface formatter
|
||||
// Optionally defined extra controls for the output formats
|
||||
formatter_ = surfaceWriter::New
|
||||
(
|
||||
writeType,
|
||||
dict.subOrEmptyDict("formatOptions").subOrEmptyDict(writeType)
|
||||
);
|
||||
formatter_ = surfaceWriter::New(writeType, dict);
|
||||
|
||||
PtrList<sampledSurface> newList
|
||||
(
|
||||
|
||||
@ -37,15 +37,15 @@ namespace Foam
|
||||
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
|
||||
|
||||
template<>
|
||||
const char* NamedEnum<nastranSurfaceWriter::writeFormat, 3>::names[] =
|
||||
const char* NamedEnum<nastranSurfaceWriter::format, 3>::names[] =
|
||||
{
|
||||
"short",
|
||||
"long",
|
||||
"free"
|
||||
};
|
||||
|
||||
const NamedEnum<nastranSurfaceWriter::writeFormat, 3>
|
||||
nastranSurfaceWriter::writeFormatNames_;
|
||||
const NamedEnum<nastranSurfaceWriter::format, 3>
|
||||
nastranSurfaceWriter::formatNames_;
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ void Foam::nastranSurfaceWriter::formatOS(OFstream& os) const
|
||||
|
||||
label prec = 0;
|
||||
label offset = 7;
|
||||
switch (writeFormat_)
|
||||
switch (format_)
|
||||
{
|
||||
case (wfShort):
|
||||
case (wfFree):
|
||||
@ -100,7 +100,7 @@ void Foam::nastranSurfaceWriter::writeCoord
|
||||
// 8 PS : single point constraints (blank)
|
||||
// 9 SEID : super-element ID
|
||||
|
||||
switch (writeFormat_)
|
||||
switch (format_)
|
||||
{
|
||||
case wfShort:
|
||||
{
|
||||
@ -155,7 +155,7 @@ void Foam::nastranSurfaceWriter::writeCoord
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown writeFormat enumeration" << abort(FatalError);
|
||||
<< "Unknown format enumeration" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,7 +182,7 @@ void Foam::nastranSurfaceWriter::writeFace
|
||||
|
||||
// For CTRIA3 elements, cols 7 onwards are not used
|
||||
|
||||
switch (writeFormat_)
|
||||
switch (format_)
|
||||
{
|
||||
case wfShort:
|
||||
{
|
||||
@ -248,7 +248,7 @@ void Foam::nastranSurfaceWriter::writeFace
|
||||
default:
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown writeFormat enumeration" << abort(FatalError);
|
||||
<< "Unknown format enumeration" << abort(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
@ -322,7 +322,7 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter
|
||||
)
|
||||
:
|
||||
surfaceWriter(writeFormat),
|
||||
writeFormat_(wfShort),
|
||||
format_(wfShort),
|
||||
fieldMap_(),
|
||||
scale_(1.0)
|
||||
{}
|
||||
@ -331,21 +331,28 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter
|
||||
Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& optDict)
|
||||
:
|
||||
surfaceWriter(optDict),
|
||||
writeFormat_(wfLong),
|
||||
format_(wfLong),
|
||||
fieldMap_(),
|
||||
scale_(optDict.lookupOrDefault("scale", 1.0))
|
||||
scale_(1.0)
|
||||
{
|
||||
if (optDict.found("format"))
|
||||
const dictionary& nastranDict(optDict.lookup("nastranOptions"));
|
||||
|
||||
if (nastranDict.found("format"))
|
||||
{
|
||||
writeFormat_ = writeFormatNames_.read(optDict.lookup("format"));
|
||||
format_ = formatNames_.read(nastranDict.lookup("format"));
|
||||
}
|
||||
|
||||
List<Tuple2<word, word>> fieldSet(optDict.lookup("fields"));
|
||||
List<Tuple2<word, word>> fieldSet(nastranDict.lookup("fields"));
|
||||
|
||||
forAll(fieldSet, i)
|
||||
{
|
||||
fieldMap_.insert(fieldSet[i].first(), fieldSet[i].second());
|
||||
}
|
||||
|
||||
if (nastranDict.found("scale"))
|
||||
{
|
||||
nastranDict.lookup("scale") >> scale_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -27,18 +27,17 @@ Class
|
||||
Description
|
||||
A surface writer for the Nastran file format - both surface mesh and fields
|
||||
|
||||
formatOptions
|
||||
{
|
||||
nastran
|
||||
nastranOptions
|
||||
{
|
||||
// From OpenFOAM field name to Nastran field name
|
||||
fields ((pMean PLOAD2));
|
||||
|
||||
// Optional scale
|
||||
scale 2.0;
|
||||
|
||||
// Optional format
|
||||
format free; // short, long, free
|
||||
}
|
||||
};
|
||||
|
||||
SourceFiles
|
||||
nastranSurfaceWriter.C
|
||||
@ -68,14 +67,14 @@ class nastranSurfaceWriter
|
||||
{
|
||||
public:
|
||||
|
||||
enum writeFormat
|
||||
enum format
|
||||
{
|
||||
wfShort,
|
||||
wfLong,
|
||||
wfFree
|
||||
};
|
||||
|
||||
static const NamedEnum<writeFormat, 3> writeFormatNames_;
|
||||
static const NamedEnum<format, 3> formatNames_;
|
||||
|
||||
|
||||
private:
|
||||
@ -83,7 +82,7 @@ private:
|
||||
// Private Data
|
||||
|
||||
//- Write option
|
||||
writeFormat writeFormat_;
|
||||
format format_;
|
||||
|
||||
//- Map of OpenFOAM field name vs nastran field name
|
||||
HashTable<word> fieldMap_;
|
||||
|
||||
@ -48,7 +48,7 @@ void Foam::nastranSurfaceWriter::writeFaceValue
|
||||
|
||||
Type scaledValue = scale_*value;
|
||||
|
||||
switch (writeFormat_)
|
||||
switch (format_)
|
||||
{
|
||||
case wfShort:
|
||||
{
|
||||
|
||||
@ -36,7 +36,6 @@ namespace Foam
|
||||
makeSurfaceWriterType(vtkSurfaceWriter);
|
||||
}
|
||||
|
||||
static bool binary = false;
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -45,8 +44,10 @@ void Foam::vtkSurfaceWriter::writeGeometry
|
||||
std::ostream& os,
|
||||
const pointField& points,
|
||||
const faceList& faces
|
||||
)
|
||||
) const
|
||||
{
|
||||
const bool binary = (writeFormat_ == IOstream::BINARY);
|
||||
|
||||
// VTK header
|
||||
vtkWriteOps::writeHeader(os, binary, "sampleSurface");
|
||||
os << "DATASET POLYDATA" << nl;
|
||||
@ -103,6 +104,8 @@ void Foam::vtkSurfaceWriter::Write
|
||||
const bool isNodeValues
|
||||
) const
|
||||
{
|
||||
const bool binary = (writeFormat_ == IOstream::BINARY);
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
|
||||
@ -25,7 +25,8 @@ Class
|
||||
Foam::vtkSurfaceWriter
|
||||
|
||||
Description
|
||||
A surfaceWriter for VTK legacy format.
|
||||
A surfaceWriter for VTK legacy format
|
||||
with support for writing ASCII or binary.
|
||||
|
||||
SourceFiles
|
||||
vtkSurfaceWriter.C
|
||||
@ -52,12 +53,12 @@ class vtkSurfaceWriter
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
static void writeGeometry
|
||||
void writeGeometry
|
||||
(
|
||||
std::ostream&,
|
||||
const pointField&,
|
||||
const faceList&
|
||||
);
|
||||
) const;
|
||||
|
||||
//- Templated write operation
|
||||
template<class Type>
|
||||
|
||||
@ -13,6 +13,7 @@ surfaces
|
||||
writeControl writeTime;
|
||||
|
||||
surfaceFormat vtk;
|
||||
writeFormat binary;
|
||||
fields (p U Q);
|
||||
|
||||
interpolationScheme cellPoint;
|
||||
|
||||
@ -14,6 +14,7 @@ cuttingPlane
|
||||
writeControl writeTime;
|
||||
|
||||
surfaceFormat vtk;
|
||||
|
||||
fields ( p U );
|
||||
|
||||
interpolationScheme cellPoint;
|
||||
|
||||
@ -13,6 +13,7 @@ cuttingPlane
|
||||
writeControl writeTime;
|
||||
|
||||
surfaceFormat vtk;
|
||||
writeFormat binary;
|
||||
fields (p U);
|
||||
|
||||
interpolationScheme cellPoint;
|
||||
|
||||
@ -66,6 +66,7 @@ functions
|
||||
startTime 10;
|
||||
|
||||
surfaceFormat vtk;
|
||||
writeFormat binary;
|
||||
fields (p_rgh U);
|
||||
|
||||
interpolationScheme cellPoint;
|
||||
|
||||
Reference in New Issue
Block a user