mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: general consistency and documentation update for surface writers
This commit is contained in:
@ -34,6 +34,15 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Field writing implementation
|
||||
#include "boundaryDataSurfaceWriterImpl.C"
|
||||
|
||||
// Field writing methods
|
||||
defineSurfaceWriterWriteFields(Foam::boundaryDataSurfaceWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::boundaryDataSurfaceWriter::write
|
||||
@ -44,20 +53,24 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// geometry: rootdir/surfaceName/"points"
|
||||
// field: rootdir/surfaceName/time/field
|
||||
|
||||
const fileName baseDir(outputDir.path()/surfaceName);
|
||||
const fileName timeName(outputDir.name());
|
||||
|
||||
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"));
|
||||
|
||||
Time dummyTime
|
||||
(
|
||||
caseDir.path(), //rootPath,
|
||||
caseDir.name(), //caseName,
|
||||
"system", //systemName,
|
||||
"constant", //constantName,
|
||||
false //enableFunctionObjects
|
||||
caseDir.path(), // root-path,
|
||||
caseDir.name(), // case-name,
|
||||
"system", //
|
||||
"constant", //
|
||||
false // no function objects
|
||||
);
|
||||
|
||||
|
||||
@ -97,10 +110,4 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::write
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// create write methods
|
||||
defineSurfaceWriterWriteFields(Foam::boundaryDataSurfaceWriter);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -65,6 +65,26 @@ Description
|
||||
(this is what timeVaryingMappedFixedValue uses to do interpolation)
|
||||
(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
|
||||
boundaryDataSurfaceWriter.C
|
||||
@ -96,16 +116,15 @@ class boundaryDataSurfaceWriter
|
||||
template<class Type>
|
||||
fileName writeTemplate
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -127,76 +146,76 @@ public:
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<symmTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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 (isNodeValues = true)
|
||||
// One value per face or vertex.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
};
|
||||
|
||||
@ -207,12 +226,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "boundaryDataSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -44,22 +44,25 @@ Foam::fileName Foam::boundaryDataSurfaceWriter::writeTemplate
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// geometry: rootdir/surfaceName/"points"
|
||||
// field: rootdir/surfaceName/time/field
|
||||
|
||||
const fileName baseDir(outputDir.path()/surfaceName);
|
||||
const fileName timeName(outputDir.name());
|
||||
|
||||
const pointField& points = surf.points();
|
||||
const faceList& faces = surf.faces();
|
||||
|
||||
|
||||
// Construct dummy time to use as an objectRegistry
|
||||
// Dummy time to use as an objectRegistry
|
||||
const fileName caseDir(getEnv("FOAM_CASE"));
|
||||
|
||||
Time dummyTime
|
||||
(
|
||||
caseDir.path(), //rootPath,
|
||||
caseDir.name(), //caseName,
|
||||
"system", //systemName,
|
||||
"constant", //constantName,
|
||||
false //enableFunctionObjects
|
||||
caseDir.path(), // root-path
|
||||
caseDir.name(), // case-name
|
||||
"system", //
|
||||
"constant", //
|
||||
false // no function objects
|
||||
);
|
||||
|
||||
|
||||
@ -35,6 +35,14 @@ namespace Foam
|
||||
addToRunTimeSelectionTable(surfaceWriter, ensightSurfaceWriter, wordDict);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Field writing implementation
|
||||
#include "ensightSurfaceWriterImpl.C"
|
||||
|
||||
// Field writing methods
|
||||
defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||
|
||||
@ -183,10 +191,13 @@ Foam::fileName Foam::ensightSurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
const pointField& points = surf.points();
|
||||
const faceList& faces = surf.faces();
|
||||
const ensight::FileName surfName(surfaceName);
|
||||
|
||||
// Uncollated
|
||||
// ==========
|
||||
// geometry: rootdir/time/surfaceName.case
|
||||
// geometry: rootdir/time/surfaceName.00000000.mesh
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
@ -205,6 +216,9 @@ Foam::fileName Foam::ensightSurfaceWriter::write
|
||||
Info<< "Writing case file to " << osCase.name() << endl;
|
||||
}
|
||||
|
||||
const pointField& points = surf.points();
|
||||
const faceList& faces = surf.faces();
|
||||
|
||||
osCase
|
||||
<< "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl
|
||||
@ -220,11 +234,13 @@ Foam::fileName Foam::ensightSurfaceWriter::write
|
||||
osGeom << ensPart;
|
||||
|
||||
return osCase.name();
|
||||
|
||||
|
||||
// Collated?
|
||||
// ========
|
||||
// geometry: rootdir/surfaceName/surfaceName.case
|
||||
// geometry: rootdir/surfaceName/surfaceName.mesh
|
||||
}
|
||||
|
||||
|
||||
// Create all write methods
|
||||
defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -100,42 +100,41 @@ class ensightSurfaceWriter
|
||||
template<class Type>
|
||||
fileName writeCollated
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
//- Templated write operation - all time steps in single file
|
||||
template<class Type>
|
||||
fileName writeUncollated
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
//- Templated write operation
|
||||
template<class Type>
|
||||
fileName writeTemplate
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
@ -165,83 +164,84 @@ public:
|
||||
// \note this is a stop-gap solution
|
||||
virtual void updateMesh
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName //!< Name of surface
|
||||
) const; // override
|
||||
|
||||
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<symmTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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 (isNodeValues = true)
|
||||
// One value per face or vertex.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
};
|
||||
|
||||
@ -252,12 +252,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "ensightSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -48,7 +48,11 @@ Foam::fileName Foam::ensightSurfaceWriter::writeUncollated
|
||||
const ensight::FileName surfName(surfaceName);
|
||||
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:
|
||||
// - VAR1/SURF1.case
|
||||
// - VAR1/SURF1.0000.mesh
|
||||
@ -163,7 +167,11 @@ Foam::fileName Foam::ensightSurfaceWriter::writeCollated
|
||||
const ensight::FileName surfName(surfaceName);
|
||||
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:
|
||||
// - SURF1/SURF1.case
|
||||
// - SURF1/SURF1/data/00000000/geometry
|
||||
@ -35,6 +35,15 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Field writing implementation
|
||||
#include "foamSurfaceWriterImpl.C"
|
||||
|
||||
// Field writing methods
|
||||
defineSurfaceWriterWriteFields(Foam::foamSurfaceWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileName Foam::foamSurfaceWriter::write
|
||||
@ -45,8 +54,8 @@ Foam::fileName Foam::foamSurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
const pointField& points = surf.points();
|
||||
const faceList& faces = surf.faces();
|
||||
// Output:
|
||||
// - rootdir/time/surfaceName/{points,faces}
|
||||
|
||||
fileName surfaceDir(outputDir/surfaceName);
|
||||
|
||||
@ -60,6 +69,8 @@ Foam::fileName Foam::foamSurfaceWriter::write
|
||||
Info<< "Writing geometry to " << surfaceDir << endl;
|
||||
}
|
||||
|
||||
const pointField& points = surf.points();
|
||||
const faceList& faces = surf.faces();
|
||||
|
||||
// Points
|
||||
OFstream(surfaceDir/"points")() << points;
|
||||
@ -82,8 +93,4 @@ Foam::fileName Foam::foamSurfaceWriter::write
|
||||
}
|
||||
|
||||
|
||||
// Create write methods
|
||||
defineSurfaceWriterWriteFields(Foam::foamSurfaceWriter);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / 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
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,6 +27,34 @@ Class
|
||||
Description
|
||||
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
|
||||
foamSurfaceWriter.C
|
||||
|
||||
@ -56,13 +84,13 @@ class foamSurfaceWriter
|
||||
template<class Type>
|
||||
fileName writeTemplate
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
|
||||
@ -94,76 +122,76 @@ public:
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<symmTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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 (isNodeValues = true)
|
||||
// One value per face or vertex.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
};
|
||||
|
||||
@ -174,12 +202,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "foamSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / 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.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -40,33 +40,35 @@ Foam::fileName Foam::foamSurfaceWriter::writeTemplate
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
fileName surfaceDir(outputDir/surfaceName);
|
||||
// Geometry should already have been written
|
||||
// Values to separate directory (e.g. "scalarField/p")
|
||||
|
||||
if (!isDir(surfaceDir))
|
||||
{
|
||||
mkDir(surfaceDir);
|
||||
}
|
||||
// field: rootdir/time/surfaceName/fieldType/field
|
||||
|
||||
const word fieldTypeName
|
||||
(
|
||||
word(pTraits<Type>::typeName) + FieldBase::typeName
|
||||
);
|
||||
|
||||
const fileName base(outputDir/surfaceName);
|
||||
const fileName outputFile(base / fieldTypeName / fieldName);
|
||||
|
||||
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);
|
||||
fileName valuesDir(surfaceDir/(foamName + Field<Type>::typeName));
|
||||
|
||||
if (!isDir(valuesDir))
|
||||
if (!isDir(outputFile.path()))
|
||||
{
|
||||
mkDir(valuesDir);
|
||||
mkDir(outputFile.path());
|
||||
}
|
||||
|
||||
// values
|
||||
OFstream(valuesDir/fieldName)() << values;
|
||||
// Write field
|
||||
OFstream os(outputFile);
|
||||
os << values;
|
||||
|
||||
return valuesDir/fieldName;
|
||||
return os.name();
|
||||
}
|
||||
|
||||
|
||||
@ -35,9 +35,6 @@ namespace Foam
|
||||
{
|
||||
makeSurfaceWriterType(nastranSurfaceWriter);
|
||||
addToRunTimeSelectionTable(surfaceWriter, nastranSurfaceWriter, wordDict);
|
||||
|
||||
// Create write methods
|
||||
defineSurfaceWriterWriteFields(nastranSurfaceWriter);
|
||||
}
|
||||
|
||||
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 * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::nastranSurfaceWriter::writeKeyword
|
||||
@ -334,7 +339,7 @@ Foam::nastranSurfaceWriter::nastranSurfaceWriter(const dictionary& options)
|
||||
)
|
||||
),
|
||||
fieldMap_(),
|
||||
scale_(options.lookupOrDefault<scalar>("scale", 1.0)),
|
||||
scale_(options.lookupOrDefault<scalar>("scale", 1)),
|
||||
separator_()
|
||||
{
|
||||
if (writeFormat_ == fieldFormat::FREE)
|
||||
@ -367,6 +372,8 @@ Foam::fileName Foam::nastranSurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// geometry: rootdir/time/surfaceName.nas
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
|
||||
@ -27,25 +27,57 @@ Class
|
||||
Description
|
||||
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
|
||||
formatOptions
|
||||
{
|
||||
nastran
|
||||
{
|
||||
// From OpenFOAM field name to NASTRAN field name
|
||||
// OpenFOAM field name to NASTRAN field name
|
||||
fields
|
||||
(
|
||||
(pMean PLOAD2)
|
||||
(p PLOAD4)
|
||||
);
|
||||
// Optional scale
|
||||
scale 2.0;
|
||||
// Optional format
|
||||
format free; // short, long, free
|
||||
format free; // format type
|
||||
scale 2.0; // output scaling
|
||||
}
|
||||
}
|
||||
\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
|
||||
nastranSurfaceWriter.C
|
||||
nastranSurfaceWriterTemplates.C
|
||||
@ -57,7 +89,6 @@ SourceFiles
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
#include "NASCore.H"
|
||||
#include "OFstream.H"
|
||||
#include "HashTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -162,13 +193,13 @@ private:
|
||||
template<class Type>
|
||||
fileName writeTemplate
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
|
||||
@ -203,75 +234,76 @@ public:
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<symmTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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 (isNodeValues = true)
|
||||
// One value per face or vertex.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
};
|
||||
|
||||
@ -282,12 +314,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "nastranSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -164,6 +164,9 @@ Foam::fileName Foam::nastranSurfaceWriter::writeTemplate
|
||||
|
||||
const loadFormat& format(fieldMap_[fieldName]);
|
||||
|
||||
// field: rootdir/time/field/surfaceName.nas
|
||||
|
||||
|
||||
if (!isDir(outputDir/fieldName))
|
||||
{
|
||||
mkDir(outputDir/fieldName);
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -24,11 +24,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "proxySurfaceWriter.H"
|
||||
|
||||
#include "MeshedSurfaceProxy.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
#include "makeSurfaceWriterMethods.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -41,10 +38,10 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext)
|
||||
Foam::proxySurfaceWriter::proxySurfaceWriter(const word& fileExt)
|
||||
:
|
||||
surfaceWriter(),
|
||||
ext_(ext)
|
||||
fileExtension_(fileExt)
|
||||
{}
|
||||
|
||||
|
||||
@ -58,27 +55,28 @@ Foam::fileName Foam::proxySurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// avoid bad values
|
||||
if (ext_.empty())
|
||||
// Avoid bad values
|
||||
if (fileExtension_.empty())
|
||||
{
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
}
|
||||
fileName outputFile(outputDir/surfaceName + '.' + fileExtension_);
|
||||
|
||||
fileName outName(outputDir/surfaceName + "." + ext_);
|
||||
if (!isDir(outputFile.path()))
|
||||
{
|
||||
mkDir(outputFile.path());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -28,6 +28,18 @@ Description
|
||||
A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but
|
||||
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
|
||||
proxySurfaceWriter.C
|
||||
|
||||
@ -54,8 +66,9 @@ class proxySurfaceWriter
|
||||
|
||||
// Private data
|
||||
|
||||
//- The associated file extension
|
||||
word ext_;
|
||||
//- The file extension associated with the proxy
|
||||
word fileExtension_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -66,7 +79,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct for a given extension
|
||||
proxySurfaceWriter(const word& ext);
|
||||
proxySurfaceWriter(const word& fileExt);
|
||||
|
||||
|
||||
//- Destructor
|
||||
@ -87,10 +100,10 @@ public:
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
};
|
||||
|
||||
|
||||
@ -24,6 +24,8 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "rawSurfaceWriter.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "makeSurfaceWriterMethods.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -35,169 +37,25 @@ namespace Foam
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member 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));
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
template<>
|
||||
void Foam::rawSurfaceWriter::writeHeader
|
||||
(
|
||||
Ostream& os,
|
||||
const word& fieldName,
|
||||
const Field<scalar>& values
|
||||
)
|
||||
// Emit x,y,z
|
||||
static inline void writePoint(Ostream& os, const point& p)
|
||||
{
|
||||
os << values.size() << nl
|
||||
<< "# x y z " << fieldName << nl;
|
||||
os << p.x() << ' ' << p.y() << ' ' << p.z();
|
||||
}
|
||||
} // 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<>
|
||||
void Foam::rawSurfaceWriter::writeHeader
|
||||
(
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
// Field writing methods
|
||||
defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
@ -232,9 +90,12 @@ Foam::fileName Foam::rawSurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// geometry: rootdir/time/surfaceName.raw
|
||||
|
||||
const pointField& points = surf.points();
|
||||
const faceList& faces = surf.faces();
|
||||
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
@ -253,16 +114,15 @@ Foam::fileName Foam::rawSurfaceWriter::write
|
||||
Info<< "Writing geometry to " << os.name() << endl;
|
||||
}
|
||||
|
||||
|
||||
// Header
|
||||
os << "# geometry NO_DATA " << faces.size() << nl
|
||||
<< "# x y z" << nl;
|
||||
|
||||
// Write faces centres
|
||||
forAll(faces, elemI)
|
||||
for (const face& f : faces)
|
||||
{
|
||||
writeLocation(os, points, faces[elemI]);
|
||||
os << nl;
|
||||
writePoint(os, f.centre(points));
|
||||
os << nl;
|
||||
}
|
||||
|
||||
os << nl;
|
||||
@ -271,10 +131,4 @@ Foam::fileName Foam::rawSurfaceWriter::write
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Create write methods
|
||||
defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / 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
|
||||
This file is part of OpenFOAM.
|
||||
@ -27,6 +27,43 @@ Class
|
||||
Description
|
||||
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
|
||||
rawSurfaceWriter.C
|
||||
|
||||
@ -37,7 +74,6 @@ SourceFiles
|
||||
|
||||
#include "surfaceWriter.H"
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -53,44 +89,23 @@ class rawSurfaceWriter
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Output compression, defaults to uncompressed
|
||||
//- Output compression (default: uncompressed)
|
||||
IOstream::compressionType writeCompression_;
|
||||
|
||||
|
||||
// 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
|
||||
template<class Type>
|
||||
fileName writeTemplate
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
|
||||
@ -118,76 +133,76 @@ public:
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<symmTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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 (isNodeValues = true)
|
||||
// One value per face or vertex.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
};
|
||||
|
||||
@ -198,12 +213,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "rawSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
168
src/sampling/sampledSurface/writers/raw/rawSurfaceWriterImpl.C
Normal file
168
src/sampling/sampledSurface/writers/raw/rawSurfaceWriterImpl.C
Normal 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();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -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();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -25,6 +25,8 @@ License
|
||||
|
||||
#include "starcdSurfaceWriter.H"
|
||||
#include "MeshedSurfaceProxy.H"
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "makeSurfaceWriterMethods.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -34,44 +36,11 @@ namespace Foam
|
||||
makeSurfaceWriterType(starcdSurfaceWriter);
|
||||
}
|
||||
|
||||
// Field writing implementation
|
||||
#include "starcdSurfaceWriterImpl.C"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
// Field writing methods
|
||||
defineSurfaceWriterWriteFields(Foam::starcdSurfaceWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -84,28 +53,27 @@ Foam::fileName Foam::starcdSurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
}
|
||||
// geometry: rootdir/time/surfaceName.{raw,vrt,inp}
|
||||
|
||||
fileName outName(outputDir/surfaceName + ".inp");
|
||||
fileName outputFile(outputDir/surfaceName + ".inp");
|
||||
|
||||
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);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -41,10 +41,25 @@ Description
|
||||
getuser FILENAME.usr vertex vector free
|
||||
\endverbatim
|
||||
|
||||
Note
|
||||
Only scalar and vector fields are supported directly.
|
||||
A sphericalTensor is written as a scalar.
|
||||
Other field types are not written.
|
||||
\heading Output file locations
|
||||
|
||||
The \c rootdir normally corresponds to something like
|
||||
\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
|
||||
starcdSurfaceWriter.C
|
||||
@ -71,21 +86,17 @@ class starcdSurfaceWriter
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
template<class Type>
|
||||
static inline void writeData(Ostream&, const Type&);
|
||||
|
||||
|
||||
//- Templated write operation
|
||||
template<class Type>
|
||||
fileName writeTemplate
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
|
||||
@ -117,49 +128,76 @@ public:
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
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
|
||||
};
|
||||
|
||||
@ -170,12 +208,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "starcdSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / 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.
|
||||
\\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -26,17 +26,27 @@ License
|
||||
#include "OFstream.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 * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
inline void Foam::starcdSurfaceWriter::writeData
|
||||
(
|
||||
Ostream& os,
|
||||
const Type& v
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::fileName Foam::starcdSurfaceWriter::writeTemplate
|
||||
(
|
||||
@ -49,6 +59,8 @@ Foam::fileName Foam::starcdSurfaceWriter::writeTemplate
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// field: rootdir/time/<field>_surfaceName.usr
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
@ -61,11 +73,16 @@ Foam::fileName Foam::starcdSurfaceWriter::writeTemplate
|
||||
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
|
||||
}
|
||||
|
||||
// no header, just write values
|
||||
forAll(values, elemI)
|
||||
// 1-based ids
|
||||
label elemId = 1;
|
||||
|
||||
// No header, just write values
|
||||
for (const Type& val : values)
|
||||
{
|
||||
os << elemI+1 << ' ';
|
||||
writeData(os, values[elemI]);
|
||||
os << elemId;
|
||||
writeData(os, val);
|
||||
|
||||
++elemId;
|
||||
}
|
||||
|
||||
return os.name();
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -69,7 +69,7 @@ Foam::surfaceWriter::New(const word& writeType)
|
||||
{
|
||||
FatalErrorInFunction
|
||||
<< "Unknown write type \"" << writeType << "\"\n\n"
|
||||
<< "Valid write types : "
|
||||
<< "Valid types : "
|
||||
<< wordConstructorTablePtr_->sortedToc() << nl
|
||||
<< "Valid proxy types : "
|
||||
<< MeshedSurfaceProxy<face>::writeTypes() << endl
|
||||
@ -82,18 +82,18 @@ Foam::surfaceWriter::New(const word& writeType)
|
||||
|
||||
|
||||
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);
|
||||
|
||||
if (!cstrIter.found())
|
||||
{
|
||||
// revert to versions without options
|
||||
// Revert to version without options
|
||||
return Foam::surfaceWriter::New(writeType);
|
||||
}
|
||||
|
||||
return autoPtr<surfaceWriter>(cstrIter()(optDict));
|
||||
return autoPtr<surfaceWriter>(cstrIter()(options));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / 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
|
||||
This file is part of OpenFOAM.
|
||||
@ -74,9 +74,9 @@ public:
|
||||
surfaceWriter,
|
||||
wordDict,
|
||||
(
|
||||
const dictionary& optDict
|
||||
const dictionary& options
|
||||
),
|
||||
(optDict)
|
||||
(options)
|
||||
);
|
||||
|
||||
|
||||
@ -118,98 +118,98 @@ public:
|
||||
// is improved.
|
||||
virtual void updateMesh
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName //!< Name of surface
|
||||
) const
|
||||
{}
|
||||
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const
|
||||
{
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const
|
||||
{
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const
|
||||
{
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const
|
||||
{
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<symmTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
{
|
||||
return fileName::null;
|
||||
}
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
{
|
||||
return fileName::null;
|
||||
|
||||
@ -24,6 +24,10 @@ License
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "vtkSurfaceWriter.H"
|
||||
#include "foamVtkOutputOptions.H"
|
||||
|
||||
#include "OFstream.H"
|
||||
#include "OSspecific.H"
|
||||
#include "makeSurfaceWriterMethods.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
@ -34,22 +38,34 @@ namespace Foam
|
||||
addToRunTimeSelectionTable(surfaceWriter, vtkSurfaceWriter, wordDict);
|
||||
}
|
||||
|
||||
// Field writing implementation
|
||||
#include "vtkSurfaceWriterImpl.C"
|
||||
|
||||
// Field writing methods
|
||||
defineSurfaceWriterWriteFields(Foam::vtkSurfaceWriter);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::vtkSurfaceWriter::writeGeometry
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurf& surf
|
||||
const meshedSurf& surf,
|
||||
std::string title
|
||||
)
|
||||
{
|
||||
const pointField& points = surf.points();
|
||||
const faceList& faces = surf.faces();
|
||||
|
||||
if (title.empty())
|
||||
{
|
||||
title = "sampleSurface";
|
||||
}
|
||||
|
||||
// header
|
||||
os
|
||||
<< "# vtk DataFile Version 2.0" << nl
|
||||
<< "sampleSurface" << nl
|
||||
<< title.c_str() << nl
|
||||
<< "ASCII" << nl
|
||||
<< "DATASET POLYDATA" << nl;
|
||||
|
||||
@ -193,7 +209,6 @@ namespace Foam
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -202,22 +217,47 @@ namespace Foam
|
||||
Foam::vtkSurfaceWriter::vtkSurfaceWriter()
|
||||
:
|
||||
surfaceWriter(),
|
||||
writePrecision_(IOstream::defaultPrecision())
|
||||
fmtType_(unsigned(vtk::formatType::LEGACY_ASCII)),
|
||||
precision_(IOstream::defaultPrecision())
|
||||
{}
|
||||
|
||||
|
||||
Foam::vtkSurfaceWriter::vtkSurfaceWriter(const dictionary& options)
|
||||
:
|
||||
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()
|
||||
)
|
||||
)
|
||||
{}
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -230,27 +270,25 @@ Foam::fileName Foam::vtkSurfaceWriter::write
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// geometry: rootdir/time/surfaceName.{vtk|vtp}
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
}
|
||||
|
||||
OFstream os(outputDir/surfaceName + ".vtk");
|
||||
os.precision(writePrecision_);
|
||||
os.precision(precision_);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing geometry to " << os.name() << endl;
|
||||
}
|
||||
|
||||
writeGeometry(os, surf);
|
||||
writeGeometry(os, surf, surfaceName);
|
||||
|
||||
return os.name();
|
||||
}
|
||||
|
||||
|
||||
// Create write methods
|
||||
defineSurfaceWriterWriteFields(Foam::vtkSurfaceWriter);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,6 +27,44 @@ Class
|
||||
Description
|
||||
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
|
||||
Uses ASCII-only output.
|
||||
All data are written as \c double due to portability issues
|
||||
@ -57,12 +95,22 @@ class vtkSurfaceWriter
|
||||
{
|
||||
// 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
|
||||
|
||||
static void writeGeometry(Ostream&, const meshedSurf&);
|
||||
static void writeGeometry
|
||||
(
|
||||
Ostream& os,
|
||||
const meshedSurf& surf,
|
||||
std::string title = ""
|
||||
);
|
||||
|
||||
template<class Type>
|
||||
static void writeData(Ostream&, const Field<Type>&);
|
||||
@ -72,13 +120,13 @@ class vtkSurfaceWriter
|
||||
template<class Type>
|
||||
fileName writeTemplate
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName,
|
||||
const Field<Type>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<Type>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const;
|
||||
|
||||
|
||||
@ -106,78 +154,77 @@ public:
|
||||
//- Write single surface geometry to file.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir,
|
||||
const fileName& surfaceName,
|
||||
const meshedSurf& surf,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<scalar>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<scalar>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<vector>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<vector>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<sphericalTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
const fileName& outputDir, //!< output-dir
|
||||
const fileName& surfaceName, //!< Name of surface
|
||||
const meshedSurf& surf, //!< Surface geometry
|
||||
const word& fieldName, //!< Name of field
|
||||
const Field<sphericalTensor>& values, //!< Field values to write
|
||||
const bool isNodeValues = false,//!< Values are per-vertex
|
||||
const bool verbose = false //!< Additional verbosity
|
||||
) const; // override
|
||||
|
||||
//- 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
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<symmTensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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 (isNodeValues = true)
|
||||
// One value per face or vertex.
|
||||
virtual fileName write
|
||||
(
|
||||
const fileName& outputDir, // <case>/surface/TIME
|
||||
const fileName& surfaceName, // name of surface
|
||||
const meshedSurf& surf,
|
||||
const word& fieldName, // name of field
|
||||
const Field<tensor>& values,
|
||||
const bool isNodeValues,
|
||||
const bool verbose = false
|
||||
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
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -187,12 +234,6 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
#include "vtkSurfaceWriterTemplates.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -60,13 +60,15 @@ Foam::fileName Foam::vtkSurfaceWriter::writeTemplate
|
||||
const bool verbose
|
||||
) const
|
||||
{
|
||||
// field: rootdir/time/<field>_surfaceName.{vtk|vtp}
|
||||
|
||||
if (!isDir(outputDir))
|
||||
{
|
||||
mkDir(outputDir);
|
||||
}
|
||||
|
||||
OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk");
|
||||
os.precision(writePrecision_);
|
||||
os.precision(precision_);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Reference in New Issue
Block a user