Commit 6ba6d746 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: general consistency and documentation update for surface writers

parent d63b4cd4
......@@ -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();
}
// Create all write methods
defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
// Collated?
// ========
// geometry: rootdir/surfaceName/surfaceName.case
// geometry: rootdir/surfaceName/surfaceName.mesh
}
// ************************************************************************* //
......@@ -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
......