ENH: general consistency and documentation update for surface writers

This commit is contained in:
Mark Olesen
2018-10-19 19:26:05 +02:00
parent d63b4cd4f4
commit 6ba6d7466d
26 changed files with 1073 additions and 920 deletions

View File

@ -34,6 +34,15 @@ namespace Foam
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing implementation
#include "boundaryDataSurfaceWriterImpl.C"
// Field writing methods
defineSurfaceWriterWriteFields(Foam::boundaryDataSurfaceWriter);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::boundaryDataSurfaceWriter::write Foam::fileName Foam::boundaryDataSurfaceWriter::write
@ -44,20 +53,24 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
// geometry: rootdir/surfaceName/"points"
// field: rootdir/surfaceName/time/field
const fileName baseDir(outputDir.path()/surfaceName); const fileName baseDir(outputDir.path()/surfaceName);
const fileName timeName(outputDir.name()); const fileName timeName(outputDir.name());
const pointField& points = surf.points(); const pointField& points = surf.points();
// Construct dummy time to use as an objectRegistry // Dummy time to use as an objectRegistry
const fileName caseDir(getEnv("FOAM_CASE")); const fileName caseDir(getEnv("FOAM_CASE"));
Time dummyTime Time dummyTime
( (
caseDir.path(), //rootPath, caseDir.path(), // root-path,
caseDir.name(), //caseName, caseDir.name(), // case-name,
"system", //systemName, "system", //
"constant", //constantName, "constant", //
false //enableFunctionObjects false // no function objects
); );
@ -97,10 +110,4 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::write
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// create write methods
defineSurfaceWriterWriteFields(Foam::boundaryDataSurfaceWriter);
// ************************************************************************* // // ************************************************************************* //

View File

@ -65,6 +65,26 @@ Description
(this is what timeVaryingMappedFixedValue uses to do interpolation) (this is what timeVaryingMappedFixedValue uses to do interpolation)
(Alternatively use timeVaryingMappedFixedValue with mapMethod 'nearest') (Alternatively use timeVaryingMappedFixedValue with mapMethod 'nearest')
\heading Output file locations
The \c rootdir normally corresponds to something like
\c postProcessing/\<name\>
\subheading Geometry
\verbatim
rootdir
`-- surfaceName
`-- "points"
\endverbatim
\subheading Fields
\verbatim
rootdir
`-- surfaceName
|-- "points"
`-- timeName
`-- field
\endverbatim
SourceFiles SourceFiles
boundaryDataSurfaceWriter.C boundaryDataSurfaceWriter.C
@ -96,16 +116,15 @@ class boundaryDataSurfaceWriter
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
public: public:
//- Runtime type information //- Runtime type information
@ -127,76 +146,76 @@ public:
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write symmTensorField for a single surface to file. //- Write symmTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<symmTensor>& values, const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write tensorField for a single surface to file. //- Write tensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<tensor>& values, const Field<tensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };
@ -207,12 +226,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "boundaryDataSurfaceWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,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) 2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -44,22 +44,25 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::writeTemplate
const bool verbose const bool verbose
) const ) const
{ {
// geometry: rootdir/surfaceName/"points"
// field: rootdir/surfaceName/time/field
const fileName baseDir(outputDir.path()/surfaceName); const fileName baseDir(outputDir.path()/surfaceName);
const fileName timeName(outputDir.name()); const fileName timeName(outputDir.name());
const pointField& points = surf.points(); const pointField& points = surf.points();
const faceList& faces = surf.faces(); const faceList& faces = surf.faces();
// Dummy time to use as an objectRegistry
// Construct dummy time to use as an objectRegistry
const fileName caseDir(getEnv("FOAM_CASE")); const fileName caseDir(getEnv("FOAM_CASE"));
Time dummyTime Time dummyTime
( (
caseDir.path(), //rootPath, caseDir.path(), // root-path
caseDir.name(), //caseName, caseDir.name(), // case-name
"system", //systemName, "system", //
"constant", //constantName, "constant", //
false //enableFunctionObjects false // no function objects
); );

View File

@ -35,6 +35,14 @@ namespace Foam
addToRunTimeSelectionTable(surfaceWriter, ensightSurfaceWriter, wordDict); addToRunTimeSelectionTable(surfaceWriter, ensightSurfaceWriter, wordDict);
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing implementation
#include "ensightSurfaceWriterImpl.C"
// Field writing methods
defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -183,10 +191,13 @@ Foam::fileName Foam::ensightSurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
const pointField& points = surf.points();
const faceList& faces = surf.faces();
const ensight::FileName surfName(surfaceName); const ensight::FileName surfName(surfaceName);
// Uncollated
// ==========
// geometry: rootdir/time/surfaceName.case
// geometry: rootdir/time/surfaceName.00000000.mesh
if (!isDir(outputDir)) if (!isDir(outputDir))
{ {
mkDir(outputDir); mkDir(outputDir);
@ -205,6 +216,9 @@ Foam::fileName Foam::ensightSurfaceWriter::write
Info<< "Writing case file to " << osCase.name() << endl; Info<< "Writing case file to " << osCase.name() << endl;
} }
const pointField& points = surf.points();
const faceList& faces = surf.faces();
osCase osCase
<< "FORMAT" << nl << "FORMAT" << nl
<< "type: ensight gold" << nl << "type: ensight gold" << nl
@ -220,11 +234,13 @@ Foam::fileName Foam::ensightSurfaceWriter::write
osGeom << ensPart; osGeom << ensPart;
return osCase.name(); return osCase.name();
// Collated?
// ========
// geometry: rootdir/surfaceName/surfaceName.case
// geometry: rootdir/surfaceName/surfaceName.mesh
} }
// Create all write methods
defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
// ************************************************************************* // // ************************************************************************* //

View File

@ -100,42 +100,41 @@ class ensightSurfaceWriter
template<class Type> template<class Type>
fileName writeCollated fileName writeCollated
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
//- Templated write operation - all time steps in single file //- Templated write operation - all time steps in single file
template<class Type> template<class Type>
fileName writeUncollated fileName writeUncollated
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
//- Templated write operation //- Templated write operation
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
public: public:
//- Runtime type information //- Runtime type information
@ -165,83 +164,84 @@ public:
// \note this is a stop-gap solution // \note this is a stop-gap solution
virtual void updateMesh virtual void updateMesh
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName const fileName& surfaceName //!< Name of surface
) const; // override ) const; // override
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write symmTensorField for a single surface to file. //- Write symmTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<symmTensor>& values, const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write tensorField for a single surface to file. //- Write tensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<tensor>& values, const Field<tensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };
@ -252,12 +252,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "ensightSurfaceWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -48,7 +48,11 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
const ensight::FileName surfName(surfaceName); const ensight::FileName surfName(surfaceName);
const ensight::VarName varName(fieldName); const ensight::VarName varName(fieldName);
// use variable name as sub-directory for results // geometry: rootdir/time/<field>/surfaceName.case
// geometry: rootdir/time/<field>/surfaceName.<index>.mesh
// field: rootdir/time/<field>/surfaceName.<index>.field
// Variable name as sub-directory for results
// eg, something like this: // eg, something like this:
// - VAR1/SURF1.case // - VAR1/SURF1.case
// - VAR1/SURF1.0000.mesh // - VAR1/SURF1.0000.mesh
@ -163,7 +167,11 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
const ensight::FileName surfName(surfaceName); const ensight::FileName surfName(surfaceName);
const ensight::VarName varName(fieldName); const ensight::VarName varName(fieldName);
// use surface name as sub-directory for results // geometry: rootdir/surfaceName/surfaceName.case
// geometry: rootdir/surfaceName/surfaceName/data/<index>/geometry
// field: rootdir/surfaceName/surfaceName/data/<index>/field
// Use surface name as sub-directory for results
// eg, something like this: // eg, something like this:
// - SURF1/SURF1.case // - SURF1/SURF1.case
// - SURF1/SURF1/data/00000000/geometry // - SURF1/SURF1/data/00000000/geometry

View File

@ -35,6 +35,15 @@ namespace Foam
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing implementation
#include "foamSurfaceWriterImpl.C"
// Field writing methods
defineSurfaceWriterWriteFields(Foam::foamSurfaceWriter);
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::fileName Foam::foamSurfaceWriter::write Foam::fileName Foam::foamSurfaceWriter::write
@ -45,8 +54,8 @@ Foam::fileName Foam::foamSurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
const pointField& points = surf.points(); // Output:
const faceList& faces = surf.faces(); // - rootdir/time/surfaceName/{points,faces}
fileName surfaceDir(outputDir/surfaceName); fileName surfaceDir(outputDir/surfaceName);
@ -60,6 +69,8 @@ Foam::fileName Foam::foamSurfaceWriter::write
Info<< "Writing geometry to " << surfaceDir << endl; Info<< "Writing geometry to " << surfaceDir << endl;
} }
const pointField& points = surf.points();
const faceList& faces = surf.faces();
// Points // Points
OFstream(surfaceDir/"points")() << points; OFstream(surfaceDir/"points")() << points;
@ -82,8 +93,4 @@ Foam::fileName Foam::foamSurfaceWriter::write
} }
// Create write methods
defineSurfaceWriterWriteFields(Foam::foamSurfaceWriter);
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,6 +27,34 @@ Class
Description Description
A surfaceWriter for OpenFOAM surfaces A surfaceWriter for OpenFOAM surfaces
\heading Output file locations
The \c rootdir normally corresponds to something like
\c postProcessing/\<name\>
\subheading Geometry
\verbatim
rootdir
`-- timeName
`-- surfaceName
|-- "points"
|-- "faceCentres"
`-- "faces"
\endverbatim
\subheading Fields
\verbatim
rootdir
`-- timeName
`-- surfaceName
|-- scalarField
| |-- field
| `-- field
|-- vectorField
|-- field
`-- field
\endverbatim
SourceFiles SourceFiles
foamSurfaceWriter.C foamSurfaceWriter.C
@ -56,13 +84,13 @@ class foamSurfaceWriter
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
@ -94,76 +122,76 @@ public:
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write symmTensorField for a single surface to file. //- Write symmTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<symmTensor>& values, const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write tensorField for a single surface to file. //- Write tensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<tensor>& values, const Field<tensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };
@ -174,12 +202,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "foamSurfaceWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,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) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,33 +40,35 @@ Foam::fileName Foam::foamSurfaceWriter::writeTemplate
const bool verbose const bool verbose
) const ) const
{ {
fileName surfaceDir(outputDir/surfaceName); // Geometry should already have been written
// Values to separate directory (e.g. "scalarField/p")
if (!isDir(surfaceDir)) // field: rootdir/time/surfaceName/fieldType/field
{
mkDir(surfaceDir); const word fieldTypeName
} (
word(pTraits<Type>::typeName) + FieldBase::typeName
);
const fileName base(outputDir/surfaceName);
const fileName outputFile(base / fieldTypeName / fieldName);
if (verbose) if (verbose)
{ {
Info<< "Writing field " << fieldName << " to " << surfaceDir << endl; Info<< "Writing field " << fieldName << " to " << base << endl;
} }
// geometry should already have been written
// Values to separate directory (e.g. "scalarField/p")
fileName foamName(pTraits<Type>::typeName); if (!isDir(outputFile.path()))
fileName valuesDir(surfaceDir/(foamName + Field<Type>::typeName));
if (!isDir(valuesDir))
{ {
mkDir(valuesDir); mkDir(outputFile.path());
} }
// values // Write field
OFstream(valuesDir/fieldName)() << values; OFstream os(outputFile);
os << values;
return valuesDir/fieldName; return os.name();
} }

View File

@ -35,9 +35,6 @@ namespace Foam
{ {
makeSurfaceWriterType(nastranSurfaceWriter); makeSurfaceWriterType(nastranSurfaceWriter);
addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict); addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict);
// Create write methods
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
} }
const Foam::Enum const Foam::Enum
@ -51,6 +48,14 @@ Foam::nastranSurfaceWriter::loadFormatNames_
}); });
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Field writing implementation
#include "nastranSurfaceWriterImpl.C"
// Field writing methods
defineSurfaceWriterWriteFields(Foam::nastranSurfaceWriter);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::Ostream& Foam::nastranSurfaceWriter::writeKeyword Foam::Ostream& Foam::nastranSurfaceWriter::writeKeyword
@ -334,7 +339,7 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
) )
), ),
fieldMap_(), fieldMap_(),
scale_(options.lookupOrDefault<scalar>("scale", 1.0)), scale_(options.lookupOrDefault<scalar>("scale", 1)),
separator_() separator_()
{ {
if (writeFormat_ == fieldFormat::FREE) if (writeFormat_ == fieldFormat::FREE)
@ -367,6 +372,8 @@ Foam::fileName Foam::nastranSurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
// geometry: rootdir/time/surfaceName.nas
if (!isDir(outputDir)) if (!isDir(outputDir))
{ {
mkDir(outputDir); mkDir(outputDir);

View File

@ -27,25 +27,57 @@ Class
Description Description
A surface writer for the Nastran file format - both surface mesh and fields A surface writer for the Nastran file format - both surface mesh and fields
The formatOptions for nastran:
\table
Property | Description | Required | Default
fields | field pairs for PLOAD2, PLOAD4 | yes |
format | short / long / free | no | long
scale | output scaling | no | 1
\endtable
For example,
\verbatim \verbatim
formatOptions formatOptions
{ {
nastran nastran
{ {
// From OpenFOAM field name to NASTRAN field name // OpenFOAM field name to NASTRAN field name
fields fields
( (
(pMean PLOAD2) (pMean PLOAD2)
(p PLOAD4) (p PLOAD4)
); );
// Optional scale format free; // format type
scale 2.0; scale 2.0; // output scaling
// Optional format
format free; // short, long, free
} }
} }
\endverbatim \endverbatim
\heading Output file locations
The \c rootdir normally corresponds to something like
\c postProcessing/\<name\>
\subheading Geometry
\verbatim
rootdir
`-- timeName
|-- surfaceName0.{nas}
`-- surfaceName1.{nas}
\endverbatim
\subheading Fields
\verbatim
rootdir
`-- timeName
`-- field0
| |-- surfaceName0.{nas}
| `-- surfaceName1.{nas}
`-- field1
|-- surfaceName0.{nas}
`-- surfaceName1.{nas}
\endverbatim
SourceFiles SourceFiles
nastranSurfaceWriter.C nastranSurfaceWriter.C
nastranSurfaceWriterTemplates.C nastranSurfaceWriterTemplates.C
@ -57,7 +89,6 @@ SourceFiles
#include "surfaceWriter.H" #include "surfaceWriter.H"
#include "NASCore.H" #include "NASCore.H"
#include "OFstream.H"
#include "HashTable.H" #include "HashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -162,13 +193,13 @@ private:
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
@ -203,75 +234,76 @@ public:
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write symmTensorField for a single surface to file. //- Write symmTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<symmTensor>& values, const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write tensorField for a single surface to file. //- Write tensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<tensor>& values, const Field<tensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };
@ -282,12 +314,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "nastranSurfaceWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -164,6 +164,9 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
const loadFormat& format(fieldMap_[fieldName]); const loadFormat& format(fieldMap_[fieldName]);
// field: rootdir/time/field/surfaceName.nas
if (!isDir(outputDir/fieldName)) if (!isDir(outputDir/fieldName))
{ {
mkDir(outputDir/fieldName); mkDir(outputDir/fieldName);

View File

@ -3,7 +3,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) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -24,11 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "proxySurfaceWriter.H" #include "proxySurfaceWriter.H"
#include "MeshedSurfaceProxy.H" #include "MeshedSurfaceProxy.H"
#include "OFstream.H"
#include "OSspecific.H" #include "OSspecific.H"
#include "makeSurfaceWriterMethods.H" #include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -41,10 +38,10 @@ namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext) Foam::proxySurfaceWriter::proxySurfaceWriter(const word& fileExt)
: :
surfaceWriter(), surfaceWriter(),
ext_(ext) fileExtension_(fileExt)
{} {}
@ -58,27 +55,28 @@ Foam::fileName Foam::proxySurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
// avoid bad values // Avoid bad values
if (ext_.empty()) if (fileExtension_.empty())
{ {
return fileName::null; return fileName::null;
} }
if (!isDir(outputDir)) fileName outputFile(outputDir/surfaceName + '.' + fileExtension_);
{
mkDir(outputDir);
}
fileName outName(outputDir/surfaceName + "." + ext_); if (!isDir(outputFile.path()))
{
mkDir(outputFile.path());
}
if (verbose) if (verbose)
{ {
Info<< "Writing geometry to " << outName << endl; Info<< "Writing geometry to " << outputFile << endl;
} }
MeshedSurfaceProxy<face>(surf.points(), surf.faces()).write(outName); MeshedSurfaceProxy<face>(surf.points(), surf.faces())
.write(outputFile, fileExtension_);
return outName; return outputFile;
} }

View File

@ -3,7 +3,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) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -28,6 +28,18 @@ Description
A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but
which does not support any fields. which does not support any fields.
\heading Output file locations
The \c rootdir normally corresponds to something like
\c postProcessing/\<name\>
\subheading Geometry
\verbatim
rootdir
`-- timeName
`-- surfaceName.{obj|stl|..}
\endverbatim
SourceFiles SourceFiles
proxySurfaceWriter.C proxySurfaceWriter.C
@ -54,8 +66,9 @@ class proxySurfaceWriter
// Private data // Private data
//- The associated file extension //- The file extension associated with the proxy
word ext_; word fileExtension_;
public: public:
@ -66,7 +79,7 @@ public:
// Constructors // Constructors
//- Construct for a given extension //- Construct for a given extension
proxySurfaceWriter(const word& ext); proxySurfaceWriter(const word& fileExt);
//- Destructor //- Destructor
@ -87,10 +100,10 @@ public:
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };

View File

@ -24,6 +24,8 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "rawSurfaceWriter.H" #include "rawSurfaceWriter.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "makeSurfaceWriterMethods.H" #include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -35,169 +37,25 @@ namespace Foam
} }
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
inline void Foam::rawSurfaceWriter::writeLocation
(
Ostream& os,
const point& pt
)
{
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
}
inline void Foam::rawSurfaceWriter::writeLocation
(
Ostream& os,
const pointField& points,
const face& f
)
{
writeLocation(os, f.centre(points));
}
namespace Foam namespace Foam
{ {
template<> // Emit x,y,z
void Foam::rawSurfaceWriter::writeHeader static inline void writePoint(Ostream& os, const point& p)
(
Ostream& os,
const word& fieldName,
const Field<scalar>& values
)
{ {
os << values.size() << nl os << p.x() << ' ' << p.y() << ' ' << p.z();
<< "# x y z " << fieldName << nl;
} }
} // End namespace Foam
template<> // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void Foam::rawSurfaceWriter::writeHeader
(
Ostream& os,
const word& fieldName,
const Field<vector>& values
)
{
os << values.size() << nl
<< "# x y z "
<< fieldName << "_x "
<< fieldName << "_y "
<< fieldName << "_z "
<< endl;
}
// Field writing implementation
#include "rawSurfaceWriterImpl.C"
template<> // Field writing methods
void Foam::rawSurfaceWriter::writeHeader defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter);
(
Ostream& os,
const word& fieldName,
const Field<sphericalTensor>& values
)
{
os << values.size() << nl
<< "# ii "
<< fieldName << "_ii" << nl;
}
template<>
void Foam::rawSurfaceWriter::writeHeader
(
Ostream& os,
const word& fieldName,
const Field<symmTensor>& values
)
{
os << values.size() << nl
<< "# xx xy xz yy yz ";
for (int i=0; i<6; ++i)
{
os << fieldName << "_" << i << " ";
}
os << endl;
}
template<>
void Foam::rawSurfaceWriter::writeHeader
(
Ostream& os,
const word& fieldName,
const Field<tensor>& values
)
{
os << values.size() << nl
<< "# xx xy xz yx yy yz zx zy zz";
for (int i=0; i<9; ++i)
{
os << fieldName << "_" << i << " ";
}
os << nl;
}
template<>
inline void Foam::rawSurfaceWriter::writeData
(
Ostream& os,
const scalar& v
)
{
os << v << nl;
}
template<>
inline void Foam::rawSurfaceWriter::writeData
(
Ostream& os,
const vector& v
)
{
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
}
template<>
inline void Foam::rawSurfaceWriter::writeData
(
Ostream& os,
const sphericalTensor& v
)
{
os << v[0] << nl;
}
template<>
inline void Foam::rawSurfaceWriter::writeData
(
Ostream& os,
const symmTensor& v
)
{
os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
<< v[3] << ' ' << v[4] << ' ' << v[5] << nl;
}
template<>
inline void Foam::rawSurfaceWriter::writeData
(
Ostream& os,
const tensor& v
)
{
os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
<< v[3] << ' ' << v[4] << ' ' << v[5] << ' '
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -232,9 +90,12 @@ Foam::fileName Foam::rawSurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
// geometry: rootdir/time/surfaceName.raw
const pointField& points = surf.points(); const pointField& points = surf.points();
const faceList& faces = surf.faces(); const faceList& faces = surf.faces();
if (!isDir(outputDir)) if (!isDir(outputDir))
{ {
mkDir(outputDir); mkDir(outputDir);
@ -253,16 +114,15 @@ Foam::fileName Foam::rawSurfaceWriter::write
Info<< "Writing geometry to " << os.name() << endl; Info<< "Writing geometry to " << os.name() << endl;
} }
// Header // Header
os << "# geometry NO_DATA " << faces.size() << nl os << "# geometry NO_DATA " << faces.size() << nl
<< "# x y z" << nl; << "# x y z" << nl;
// Write faces centres // Write faces centres
forAll(faces, elemI) for (const face& f : faces)
{ {
writeLocation(os, points, faces[elemI]); writePoint(os, f.centre(points));
os << nl; os << nl;
} }
os << nl; os << nl;
@ -271,10 +131,4 @@ Foam::fileName Foam::rawSurfaceWriter::write
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Create write methods
defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter);
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,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) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -27,6 +27,43 @@ Class
Description Description
A surfaceWriter for raw output. A surfaceWriter for raw output.
The formatOptions for raw:
\table
Property | Description | Required | Default
compression | on / off | no | off
\endtable
For example,
\verbatim
formatOptions
{
raw
{
compression on;
}
}
\endverbatim
\heading Output file locations
The \c rootdir normally corresponds to something like
\c postProcessing/\<name\>
\subheading Geometry
\verbatim
rootdir
`-- timeName
`-- surfaceName.{raw}
\endverbatim
\subheading Fields
\verbatim
rootdir
`-- timeName
|-- <field0>_surfaceName.{raw}
`-- <field1>_surfaceName.{raw}
\endverbatim
SourceFiles SourceFiles
rawSurfaceWriter.C rawSurfaceWriter.C
@ -37,7 +74,6 @@ SourceFiles
#include "surfaceWriter.H" #include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
@ -53,44 +89,23 @@ class rawSurfaceWriter
{ {
// Private data // Private data
//- Output compression, defaults to uncompressed //- Output compression (default: uncompressed)
IOstream::compressionType writeCompression_; IOstream::compressionType writeCompression_;
// Private Member Functions // Private Member Functions
static inline void writeLocation(Ostream&, const point&);
static inline void writeLocation
(
Ostream&,
const pointField&,
const face&
);
template<class Type>
static void writeHeader
(
Ostream&,
const word& fieldName,
const Field<Type>&
);
template<class Type>
static inline void writeData(Ostream&, const Type&);
//- Templated write operation //- Templated write operation
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
@ -118,76 +133,76 @@ public:
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write symmTensorField for a single surface to file. //- Write symmTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<symmTensor>& values, const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write tensorField for a single surface to file. //- Write tensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<tensor>& values, const Field<tensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };
@ -198,12 +213,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "rawSurfaceWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,168 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "OFstream.H"
#include "OSspecific.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Emit each component
template<class Type>
static inline void writeData(Ostream& os, const Type& val)
{
for (direction i=0; i < pTraits<Type>::nComponents; ++i)
{
os << ' ' << component(val, i);
}
os << nl;
}
template<class Type>
static inline void writeHeader(Ostream& os, const word& fieldName) {}
template<>
void writeHeader<scalar>(Ostream& os, const word& fieldName)
{
os << "# x y z"
<< " " << fieldName << nl;
}
template<>
void writeHeader<vector>(Ostream& os, const word& fieldName)
{
os << "# x y z"
<< " " << fieldName << "_x"
<< " " << fieldName << "_y"
<< " " << fieldName << "_z"
<< nl;
}
template<>
void writeHeader<sphericalTensor>(Ostream& os, const word& fieldName)
{
os << "# x y z"
<< " " << fieldName << "_ii" << nl;
}
template<>
void writeHeader<symmTensor>(Ostream& os, const word& fieldName)
{
// This may not be quite right (not sure what people might need)
os << "# xx xy xz yy yz zz";
for (direction i=0; i < pTraits<symmTensor>::nComponents; ++i)
{
os << " " << fieldName << '_' << int(i);
}
os << nl;
}
template<>
void writeHeader<tensor>(Ostream& os, const word& fieldName)
{
// This may not be quite right (not sure what people might need)
os << "# xx xy xz yx yy yz zx zy zz";
for (direction i=0; i < pTraits<tensor>::nComponents; ++i)
{
os << " " << fieldName << '_' << int(i);
}
os << nl;
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::rawSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const meshedSurf& surf,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{
// field: rootdir/time/<field>_surfaceName.raw
const pointField& points = surf.points();
const faceList& faces = surf.faces();
if (!isDir(outputDir))
{
mkDir(outputDir);
}
OFstream os(outputDir/fieldName + '_' + surfaceName + ".raw");
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
}
// Header
os << "# " << fieldName;
if (isNodeValues)
{
os << " POINT_DATA " << values.size() << nl;
}
else
{
os << " FACE_DATA " << values.size() << nl;
}
// Header
// # x y z field
writeHeader<Type>(os, fieldName);
if (isNodeValues)
{
// Node values
forAll(values, elemi)
{
writePoint(os, points[elemi]);
writeData(os, values[elemi]);
}
}
else
{
// Face values
forAll(values, elemi)
{
writePoint(os, faces[elemi].centre(points));
writeData(os, values[elemi]);
}
}
return os.name();
}
// ************************************************************************* //

View File

@ -1,95 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "OFstream.H"
#include "OSspecific.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
Foam::fileName Foam::rawSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const meshedSurf& surf,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{
const pointField& points = surf.points();
const faceList& faces = surf.faces();
if (!isDir(outputDir))
{
mkDir(outputDir);
}
OFstream os(outputDir/fieldName + '_' + surfaceName + ".raw");
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
}
// header
os << "# " << fieldName;
if (isNodeValues)
{
os << " POINT_DATA ";
}
else
{
os << " FACE_DATA ";
}
// header
writeHeader(os, fieldName, values);
// values
if (isNodeValues)
{
forAll(values, elemI)
{
writeLocation(os, points[elemI]);
writeData(os, values[elemI]);
}
}
else
{
forAll(values, elemI)
{
writeLocation(os, points, faces[elemI]);
writeData(os, values[elemI]);
}
}
return os.name();
}
// ************************************************************************* //

View File

@ -3,7 +3,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) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -25,6 +25,8 @@ License
#include "starcdSurfaceWriter.H" #include "starcdSurfaceWriter.H"
#include "MeshedSurfaceProxy.H" #include "MeshedSurfaceProxy.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "makeSurfaceWriterMethods.H" #include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -34,44 +36,11 @@ namespace Foam
makeSurfaceWriterType(starcdSurfaceWriter); makeSurfaceWriterType(starcdSurfaceWriter);
} }
// Field writing implementation
#include "starcdSurfaceWriterImpl.C"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // Field writing methods
defineSurfaceWriterWriteFields(Foam::starcdSurfaceWriter);
namespace Foam
{
template<>
inline void Foam::starcdSurfaceWriter::writeData
(
Ostream& os,
const scalar& v
)
{
os << v << nl;
}
template<>
inline void Foam::starcdSurfaceWriter::writeData
(
Ostream& os,
const vector& v
)
{
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
}
template<>
inline void Foam::starcdSurfaceWriter::writeData
(
Ostream& os,
const sphericalTensor& v
)
{
os << v[0] << nl;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -84,28 +53,27 @@ Foam::fileName Foam::starcdSurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
if (!isDir(outputDir)) // geometry: rootdir/time/surfaceName.{raw,vrt,inp}
{
mkDir(outputDir);
}
fileName outName(outputDir/surfaceName + ".inp"); fileName outputFile(outputDir/surfaceName + ".inp");
if (verbose) if (verbose)
{ {
Info<< "Writing geometry to " << outName << endl; Info<< "Writing geometry to " << outputFile << endl;
} }
MeshedSurfaceProxy<face>(surf.points(), surf.faces()).write(outName); if (!isDir(outputFile.path()))
{
mkDir(outputFile.path());
}
return outName; MeshedSurfaceProxy<face>(surf.points(), surf.faces()).write
(
outputFile
);
return outputFile;
} }
// create write methods
defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, scalar);
defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, vector);
defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, sphericalTensor);
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,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) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -41,10 +41,25 @@ Description
getuser FILENAME.usr vertex vector free getuser FILENAME.usr vertex vector free
\endverbatim \endverbatim
Note \heading Output file locations
Only scalar and vector fields are supported directly.
A sphericalTensor is written as a scalar. The \c rootdir normally corresponds to something like
Other field types are not written. \c postProcessing/\<name\>
\subheading Geometry
\verbatim
rootdir
`-- timeName
`-- surfaceName.{cel,vrt,inp}
\endverbatim
\subheading Fields
\verbatim
rootdir
`-- timeName
|-- <field0>_surfaceName.{usr}
`-- <field1>_surfaceName.{usr}
\endverbatim
SourceFiles SourceFiles
starcdSurfaceWriter.C starcdSurfaceWriter.C
@ -71,21 +86,17 @@ class starcdSurfaceWriter
{ {
// Private Member Functions // Private Member Functions
template<class Type>
static inline void writeData(Ostream&, const Type&);
//- Templated write operation //- Templated write operation
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
@ -117,49 +128,76 @@ public:
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override
//- Write symmTensorField for a single surface to file.
// One value per face or vertex.
virtual fileName write
(
const fileName& outputDir, //!< output-dir
const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, //!< Surface geometry
const word& fieldName, //!< Name of field
const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false //!< Additional verbosity
) const; // override
//- Write tensorField for a single surface to file.
// One value per face or vertex.
virtual fileName write
(
const fileName& outputDir, //!< output-dir
const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, //!< Surface geometry
const word& fieldName, //!< Name of field
const Field<tensor>& values, //!< Field values to write
const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };
@ -170,12 +208,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "starcdSurfaceWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,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) 2011-2014 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -26,17 +26,27 @@ License
#include "OFstream.H" #include "OFstream.H"
#include "OSspecific.H" #include "OSspecific.H"
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
// Emit each component
template<class Type>
static inline void writeData(Ostream& os, const Type& val)
{
const direction ncmpt = pTraits<Type>::nComponents;
for (direction cmpt=0; cmpt < ncmpt; ++cmpt)
{
os << ' ' << component(val, cmpt);
}
os << nl;
}
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
inline void Foam::starcdSurfaceWriter::writeData
(
Ostream& os,
const Type& v
)
{}
template<class Type> template<class Type>
Foam::fileName Foam::starcdSurfaceWriter::writeTemplate Foam::fileName Foam::starcdSurfaceWriter::writeTemplate
( (
@ -49,6 +59,8 @@ Foam::fileName Foam::starcdSurfaceWriter::writeTemplate
const bool verbose const bool verbose
) const ) const
{ {
// field: rootdir/time/<field>_surfaceName.usr
if (!isDir(outputDir)) if (!isDir(outputDir))
{ {
mkDir(outputDir); mkDir(outputDir);
@ -61,11 +73,16 @@ Foam::fileName Foam::starcdSurfaceWriter::writeTemplate
Info<< "Writing field " << fieldName << " to " << os.name() << endl; Info<< "Writing field " << fieldName << " to " << os.name() << endl;
} }
// no header, just write values // 1-based ids
forAll(values, elemI) label elemId = 1;
// No header, just write values
for (const Type& val : values)
{ {
os << elemI+1 << ' '; os << elemId;
writeData(os, values[elemI]); writeData(os, val);
++elemId;
} }
return os.name(); return os.name();

View File

@ -3,7 +3,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) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -69,7 +69,7 @@ Foam::surfaceWriter::New(const word& writeType)
{ {
FatalErrorInFunction FatalErrorInFunction
<< "Unknown write type \"" << writeType << "\"\n\n" << "Unknown write type \"" << writeType << "\"\n\n"
<< "Valid write types : " << "Valid types : "
<< wordConstructorTablePtr_->sortedToc() << nl << wordConstructorTablePtr_->sortedToc() << nl
<< "Valid proxy types : " << "Valid proxy types : "
<< MeshedSurfaceProxy<face>::writeTypes() << endl << MeshedSurfaceProxy<face>::writeTypes() << endl
@ -82,18 +82,18 @@ Foam::surfaceWriter::New(const word& writeType)
Foam::autoPtr<Foam::surfaceWriter> Foam::autoPtr<Foam::surfaceWriter>
Foam::surfaceWriter::New(const word& writeType, const dictionary& optDict) Foam::surfaceWriter::New(const word& writeType, const dictionary& options)
{ {
// find constructors with dictionary options // Constructors with dictionary options
auto cstrIter = wordDictConstructorTablePtr_->cfind(writeType); auto cstrIter = wordDictConstructorTablePtr_->cfind(writeType);
if (!cstrIter.found()) if (!cstrIter.found())
{ {
// revert to versions without options // Revert to version without options
return Foam::surfaceWriter::New(writeType); return Foam::surfaceWriter::New(writeType);
} }
return autoPtr<surfaceWriter>(cstrIter()(optDict)); return autoPtr<surfaceWriter>(cstrIter()(options));
} }

View File

@ -3,7 +3,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) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -74,9 +74,9 @@ public:
surfaceWriter, surfaceWriter,
wordDict, wordDict,
( (
const dictionary& optDict const dictionary& options
), ),
(optDict) (options)
); );
@ -118,98 +118,98 @@ public:
// is improved. // is improved.
virtual void updateMesh virtual void updateMesh
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName const fileName& surfaceName //!< Name of surface
) const ) const
{} {}
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const ) const
{ {
return fileName::null; return fileName::null;
} }
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const ) const
{ {
return fileName::null; return fileName::null;
} }
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const ) const
{ {
return fileName::null; return fileName::null;
} }
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const ) const
{ {
return fileName::null; return fileName::null;
} }
//- Write symmTensorField for a single surface to file. //- Write symmTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<symmTensor>& values, const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const ) const
{ {
return fileName::null; return fileName::null;
} }
//- Write tensorField for a single surface to file. //- Write tensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<tensor>& values, const Field<tensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const ) const
{ {
return fileName::null; return fileName::null;

View File

@ -24,6 +24,10 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "vtkSurfaceWriter.H" #include "vtkSurfaceWriter.H"
#include "foamVtkOutputOptions.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "makeSurfaceWriterMethods.H" #include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -34,22 +38,34 @@ namespace Foam
addToRunTimeSelectionTable(surfaceWriter, vtkSurfaceWriter, wordDict); addToRunTimeSelectionTable(surfaceWriter, vtkSurfaceWriter, wordDict);
} }
// Field writing implementation
#include "vtkSurfaceWriterImpl.C"
// Field writing methods
defineSurfaceWriterWriteFields(Foam::vtkSurfaceWriter);
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::vtkSurfaceWriter::writeGeometry void Foam::vtkSurfaceWriter::writeGeometry
( (
Ostream& os, Ostream& os,
const meshedSurf& surf const meshedSurf& surf,
std::string title
) )
{ {
const pointField& points = surf.points(); const pointField& points = surf.points();
const faceList& faces = surf.faces(); const faceList& faces = surf.faces();
if (title.empty())
{
title = "sampleSurface";
}
// header // header
os os
<< "# vtk DataFile Version 2.0" << nl << "# vtk DataFile Version 2.0" << nl
<< "sampleSurface" << nl << title.c_str() << nl
<< "ASCII" << nl << "ASCII" << nl
<< "DATASET POLYDATA" << nl; << "DATASET POLYDATA" << nl;
@ -193,7 +209,6 @@ namespace Foam
<< nl; << nl;
} }
} }
} }
@ -202,22 +217,47 @@ namespace Foam
Foam::vtkSurfaceWriter::vtkSurfaceWriter() Foam::vtkSurfaceWriter::vtkSurfaceWriter()
: :
surfaceWriter(), surfaceWriter(),
writePrecision_(IOstream::defaultPrecision()) fmtType_(unsigned(vtk::formatType::LEGACY_ASCII)),
precision_(IOstream::defaultPrecision())
{} {}
Foam::vtkSurfaceWriter::vtkSurfaceWriter(const dictionary& options) Foam::vtkSurfaceWriter::vtkSurfaceWriter(const dictionary& options)
: :
surfaceWriter(), surfaceWriter(),
writePrecision_ fmtType_(static_cast<unsigned>(vtk::formatType::LEGACY_ASCII)),
precision_(IOstream::defaultPrecision())
{
#if 0
// Future
// format: ascii | binary
// legacy true | false
vtk::outputOptions opts(static_cast<vtk::formatType>(fmtType_));
opts.ascii
( (
options.lookupOrDefault options.found("format")
&& (IOstream::formatEnum(options.get<word>("format")) == IOstream::ASCII)
);
if (options.lookupOrDefault("legacy", false))
{
opts.legacy(true);
}
// Convert back to raw data type
fmtType_ = static_cast<unsigned>(opts.fmt());
#endif
// The write precision for ASCII formatters
precision_ =
options.lookupOrDefaultCompat
( (
"writePrecision", "precision", {{"writePrecision", -1806}},
IOstream::defaultPrecision() IOstream::defaultPrecision()
) );
) }
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
@ -230,27 +270,25 @@ Foam::fileName Foam::vtkSurfaceWriter::write
const bool verbose const bool verbose
) const ) const
{ {
// geometry: rootdir/time/surfaceName.{vtk|vtp}
if (!isDir(outputDir)) if (!isDir(outputDir))
{ {
mkDir(outputDir); mkDir(outputDir);
} }
OFstream os(outputDir/surfaceName + ".vtk"); OFstream os(outputDir/surfaceName + ".vtk");
os.precision(writePrecision_); os.precision(precision_);
if (verbose) if (verbose)
{ {
Info<< "Writing geometry to " << os.name() << endl; Info<< "Writing geometry to " << os.name() << endl;
} }
writeGeometry(os, surf); writeGeometry(os, surf, surfaceName);
return os.name(); return os.name();
} }
// Create write methods
defineSurfaceWriterWriteFields(Foam::vtkSurfaceWriter);
// ************************************************************************* // // ************************************************************************* //

View File

@ -27,6 +27,44 @@ Class
Description Description
A surfaceWriter for VTK legacy format. A surfaceWriter for VTK legacy format.
The formatOptions for vtk:
\table
Property | Description | Required | Default
format | [FUTURE] ascii or binary format | no | ascii
legacy | [FUTURE] Legacy VTK output | no | true
precision | Write precision in ascii | no | same as IOstream
\endtable
For example,
\verbatim
formatOptions
{
vtk
{
precision 10;
}
}
\endverbatim
\heading Output file locations
The \c rootdir normally corresponds to something like
\c postProcessing/\<name\>
\subheading Geometry
\verbatim
rootdir
`-- timeName
`-- surfaceName.{vtk}
\endverbatim
\subheading Fields
\verbatim
rootdir
`-- timeName
`-- <field>_surfaceName.{vtk}
\endverbatim
Note Note
Uses ASCII-only output. Uses ASCII-only output.
All data are written as \c double due to portability issues All data are written as \c double due to portability issues
@ -57,12 +95,22 @@ class vtkSurfaceWriter
{ {
// Private data // Private data
const unsigned int writePrecision_; //- The VTK output format type.
// Stored as a raw value to avoid a dependency on fileFormats
unsigned fmtType_;
//- ASCII write precision
unsigned precision_;
// Private Member Functions // Private Member Functions
static void writeGeometry(Ostream&, const meshedSurf&); static void writeGeometry
(
Ostream& os,
const meshedSurf& surf,
std::string title = ""
);
template<class Type> template<class Type>
static void writeData(Ostream&, const Field<Type>&); static void writeData(Ostream&, const Field<Type>&);
@ -72,13 +120,13 @@ class vtkSurfaceWriter
template<class Type> template<class Type>
fileName writeTemplate fileName writeTemplate
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, const word& fieldName, //!< Name of field
const Field<Type>& values, const Field<Type>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose const bool verbose = false //!< Additional verbosity
) const; ) const;
@ -106,78 +154,77 @@ public:
//- Write single surface geometry to file. //- Write single surface geometry to file.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, const fileName& outputDir, //!< output-dir
const fileName& surfaceName, const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write scalarField for a single surface to file. //- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<scalar>& values, const Field<scalar>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write vectorField for a single surface to file. //- Write vectorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<vector>& values, const Field<vector>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write sphericalTensorField for a single surface to file. //- Write sphericalTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<sphericalTensor>& values, const Field<sphericalTensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write symmTensorField for a single surface to file. //- Write symmTensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<symmTensor>& values, const Field<symmTensor>& values,//!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
//- Write tensorField for a single surface to file. //- Write tensorField for a single surface to file.
// One value per face or vertex (isNodeValues = true) // One value per face or vertex.
virtual fileName write virtual fileName write
( (
const fileName& outputDir, // <case>/surface/TIME const fileName& outputDir, //!< output-dir
const fileName& surfaceName, // name of surface const fileName& surfaceName, //!< Name of surface
const meshedSurf& surf, const meshedSurf& surf, //!< Surface geometry
const word& fieldName, // name of field const word& fieldName, //!< Name of field
const Field<tensor>& values, const Field<tensor>& values, //!< Field values to write
const bool isNodeValues, const bool isNodeValues = false,//!< Values are per-vertex
const bool verbose = false const bool verbose = false //!< Additional verbosity
) const; // override ) const; // override
}; };
@ -187,12 +234,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "vtkSurfaceWriterTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif #endif
// ************************************************************************* // // ************************************************************************* //

View File

@ -60,13 +60,15 @@ Foam::fileName Foam::vtkSurfaceWriter::writeTemplate
const bool verbose const bool verbose
) const ) const
{ {
// field: rootdir/time/<field>_surfaceName.{vtk|vtp}
if (!isDir(outputDir)) if (!isDir(outputDir))
{ {
mkDir(outputDir); mkDir(outputDir);
} }
OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk"); OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk");
os.precision(writePrecision_); os.precision(precision_);
if (verbose) if (verbose)
{ {