From ee130abd3b6fa6ee9768805d2aa406492d4bc300 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 15 May 2018 16:32:42 +0100 Subject: [PATCH] MERGE: Merging surface writers --- .../sampledPatch/sampledPatch.C | 2 +- .../writers/dx/dxSurfaceWriter.C | 161 ++++++------ .../writers/dx/dxSurfaceWriter.H | 133 ++++++++-- .../writers/foamFile/foamFileSurfaceWriter.C | 118 +++++---- .../writers/foamFile/foamFileSurfaceWriter.H | 135 ++++++++-- .../writers/proxy/proxySurfaceWriter.H | 52 ++-- .../writers/raw/rawSurfaceWriter.C | 84 ------- .../writers/raw/rawSurfaceWriter.H | 233 +++++++++++------- .../sampledSurface/writers/surfaceWriter.C | 54 ---- .../sampledSurface/writers/surfaceWriter.H | 188 +++++++++----- .../writers/vtk/vtkSurfaceWriter.C | 223 ++++++++--------- .../writers/vtk/vtkSurfaceWriter.H | 160 +++++++++--- 12 files changed, 876 insertions(+), 667 deletions(-) diff --git a/src/sampling/sampledSurface/sampledPatch/sampledPatch.C b/src/sampling/sampledSurface/sampledPatch/sampledPatch.C index 217d191ff..c50315b2a 100644 --- a/src/sampling/sampledSurface/sampledPatch/sampledPatch.C +++ b/src/sampling/sampledSurface/sampledPatch/sampledPatch.C @@ -154,7 +154,7 @@ void Foam::sampledPatch::remapFaces ) { // recalculate the cells cut - if (!faceMap.empty()) + if (&faceMap && faceMap.size()) { MeshStorage::remapFaces(faceMap); } diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C index f70cc55c0..83bb49b20 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C @@ -28,10 +28,19 @@ License #include "OFstream.H" #include "OSspecific.H" +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(dxSurfaceWriter); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -void Foam::dxSurfaceWriter::writeGeometry +void Foam::dxSurfaceWriter::writeGeometry ( Ostream& os, const pointField& points, @@ -54,7 +63,6 @@ void Foam::dxSurfaceWriter::writeGeometry os << nl; // Write triangles - os << "# The irregular connections (triangles)" << nl << "object 2 class array type int rank 1 shape 3 items " << faces.size() << " data follows" << nl; @@ -80,17 +88,41 @@ void Foam::dxSurfaceWriter::writeGeometry } +void Foam::dxSurfaceWriter::writeTrailer(Ostream& os, const bool isNodeValues) +{ + if (isNodeValues) + { + os << nl << "attribute \"dep\" string \"positions\"" + << nl << nl; + } + else + { + os << nl << "attribute \"dep\" string \"connections\"" + << nl << nl; + } + + os << "# the field, with three components: \"positions\"," + << " \"connections\", and \"data\"" << nl + << "object \"irregular positions irregular " + << "connections\" class field" + << nl + << "component \"positions\" value 1" << nl + << "component \"connections\" value 2" << nl + << "component \"data\" value 3" << nl; + + os << "end" << endl; +} + + namespace Foam { - // Write scalarField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 0 items " << values.size() << " data follows" << nl; @@ -101,15 +133,13 @@ namespace Foam } - // Write vectorField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 1 shape 3 items " << values.size() << " data follows" << nl; @@ -122,15 +152,13 @@ namespace Foam } - // Write sphericalTensorField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 0 items " << values.size() << " data follows" << nl; @@ -141,15 +169,13 @@ namespace Foam } - // Write symmTensorField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 2 shape 3 items " << values.size() << " data follows" << nl; @@ -165,15 +191,14 @@ namespace Foam } - // Write tensorField in DX format + // Write Field in DX format template<> - void Foam::dxSurfaceWriter::writeData + inline void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 2 shape 3 items " << values.size() << " data follows" << nl; @@ -189,15 +214,15 @@ namespace Foam } } -// Write tensorField in DX format + +// arbitrary field template -void Foam::dxSurfaceWriter::writeData +inline void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 0 items " << values.size() << " data follows" << nl; @@ -208,49 +233,16 @@ void Foam::dxSurfaceWriter::writeData } -// Write trailer in DX format template -void Foam::dxSurfaceWriter::writeTrailer(Ostream& os) -{ - os << "# the field, with three components: \"positions\"," - << " \"connections\", and \"data\"" << nl - << "object \"irregular positions irregular " - << "connections\" class field" - << nl - << "component \"positions\" value 1" << nl - << "component \"connections\" value 2" << nl - << "component \"data\" value 3" << nl; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::dxSurfaceWriter::dxSurfaceWriter() -: - surfaceWriter() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::dxSurfaceWriter::~dxSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::dxSurfaceWriter::write +void Foam::dxSurfaceWriter::writeTemplate ( const fileName& outputDir, const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field& values, - const surfaceWriterBase::surfaceData sdType, + const bool isNodeValues, const bool verbose ) const { @@ -270,42 +262,29 @@ void Foam::dxSurfaceWriter::write } writeGeometry(os, points, faces); - writeData(os, values); - - switch (sdType) - { - case surfaceWriterBase::POINT_DATA: - // writing point data - if (values.size() != points.size()) - { - FatalErrorIn("void dxSurfaceWriter::write(...)") - << "Data size does not match the number of points. " - << "Points: " << points.size() << " data: " << values.size() - << abort(FatalError); - } - os << nl << "attribute \"dep\" string \"positions\"" - << nl << nl; - break; - - case surfaceWriterBase::FACE_DATA: - // writing face data - if (values.size() != faces.size()) - { - FatalErrorIn("void dxSurfaceWriter::write(...)") - << "Data size does not match the number of faces. " - << "Faces: " << faces.size() << " data: " << values.size() - << abort(FatalError); - } - os << nl << "attribute \"dep\" string \"connections\"" - << nl << nl; - break; - } - - writeTrailer(os); - - os << "end" << nl; + writeTrailer(os, isNodeValues); } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dxSurfaceWriter::dxSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::dxSurfaceWriter::~dxSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// create write methods +defineSurfaceWriterWriteFields(Foam::dxSurfaceWriter); + + // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H index a0842ee3a..3a7106c46 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H @@ -25,6 +25,7 @@ Class Foam::dxSurfaceWriter Description + A surfaceWriter for OpenDX format. SourceFiles dxSurfaceWriter.C @@ -42,22 +43,36 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class dxSurfaceWriter Declaration + Class dxSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class dxSurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private Member Functions static void writeGeometry(Ostream&, const pointField&, const faceList&); + static void writeTrailer(Ostream&, const bool isNodeValues); - static void writeData(Ostream&, const Field& values); + template + static void writeData(Ostream&, const Field&); + + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; - static void writeTrailer(Ostream&); public: @@ -71,26 +86,110 @@ public: dxSurfaceWriter(); - // Destructor + //- Destructor virtual ~dxSurfaceWriter(); // Member Functions - // Write - - //- Writes single surface to file. + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, - const fileName& surfaceName, + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, const bool verbose = false ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -100,12 +199,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "dxSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C index 13ca8f1f9..7b06bc020 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C @@ -28,26 +28,76 @@ License #include "OFstream.H" #include "OSspecific.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(foamFileSurfaceWriter); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template -Foam::foamFileSurfaceWriter::foamFileSurfaceWriter() +void Foam::foamFileSurfaceWriter::writeTemplate +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose +) const +{ + fileName surfaceDir(outputDir/surfaceName); + + if (!isDir(surfaceDir)) + { + mkDir(surfaceDir); + } + + if (verbose) + { + Info<< "Writing field " << fieldName << " to " << surfaceDir << endl; + } + + // geometry should already have been written + // Values to separate directory (e.g. "scalarField/p") + + fileName foamName(pTraits::typeName); + fileName valuesDir(surfaceDir / (foamName + Field::typeName)); + + if (!isDir(valuesDir)) + { + mkDir(valuesDir); + } + + // values + OFstream(valuesDir/fieldName)() << values; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::foamFileSurfaceWriter::foamFileSurfaceWriter() : - surfaceWriter() + surfaceWriter() {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::foamFileSurfaceWriter::~foamFileSurfaceWriter() +Foam::foamFileSurfaceWriter::~foamFileSurfaceWriter() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -void Foam::foamFileSurfaceWriter::write +void Foam::foamFileSurfaceWriter::write ( const fileName& outputDir, const fileName& surfaceName, @@ -68,54 +118,28 @@ void Foam::foamFileSurfaceWriter::write Info<< "Writing geometry to " << surfaceDir << endl; } + // Points OFstream(surfaceDir/"points")() << points; // Faces OFstream(surfaceDir/"faces")() << faces; + + // Face centers. Not really necessary but very handy when reusing as inputs + // for e.g. timeVaryingMapped bc. + pointField faceCentres(faces.size(),point::zero); + + forAll(faces, faceI) + { + faceCentres[faceI] = faces[faceI].centre(points); + } + + OFstream(surfaceDir/"faceCentres")() << faceCentres; } -template -void Foam::foamFileSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, - const bool verbose -) const -{ - fileName surfaceDir(outputDir/surfaceName); - - if (!isDir(surfaceDir)) - { - mkDir(surfaceDir); - } - - if (verbose) - { - Info<< "Writing field " << fieldName << " to " << surfaceDir << endl; - } - - // geometry should already have been written - - // Values to separate directory (e.g. "scalarField/p") - - fileName foamName(pTraits::typeName); - fileName valuesDir(surfaceDir / (foamName + Field::typeName)); - - if (!isDir(valuesDir)) - { - mkDir(valuesDir); - } - - // values - OFstream(valuesDir/fieldName)() << values; -} +// create write methods +defineSurfaceWriterWriteFields(Foam::foamFileSurfaceWriter); // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H index a15a8a283..3cefef8ca 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H @@ -43,14 +43,29 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class foamFileSurfaceWriter Declaration + Class foamFileSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class foamFileSurfaceWriter : - public surfaceWriter + public surfaceWriter { + // Private Member Functions + + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; + public: @@ -64,19 +79,20 @@ public: foamFileSurfaceWriter(); - // Destructor + //- Destructor virtual ~foamFileSurfaceWriter(); // Member Functions - //- Return true if the surface format supports separate files - virtual bool separateFiles() + //- True if the surface format supports geometry in a separate file. + // False if geometry and field must be in a single file + virtual bool separateGeometry() { return true; } - //- Write geometry to file. + //- Write single surface geometry to file. virtual void write ( const fileName& outputDir, @@ -86,18 +102,105 @@ public: const bool verbose = false ) const; - //- Writes single surface to file. + + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, - const fileName& surfaceName, + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, const bool verbose = false ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField4thOrder for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write diagTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -107,12 +210,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "foamFileSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H index f05ecd422..ae91599b5 100644 --- a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H @@ -25,6 +25,8 @@ Class Foam::proxySurfaceWriter Description + A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but + which does not support any fields. SourceFiles proxySurfaceWriter.C @@ -42,13 +44,12 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class proxySurfaceWriter Declaration + Class proxySurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class proxySurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private data @@ -74,38 +75,25 @@ public: // Member Functions - //- Always write separate geometry file - virtual bool separateFiles() + + //- True if the surface format supports geometry in a separate file. + // False if geometry and field must be in a single file + virtual bool separateGeometry() { return true; } - // Write - //- Write geometry to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const bool verbose = false - ) const; + //- Write single surface geometry to file. + virtual void write + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose = false + ) const; - - //- Writes single surface to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, - const bool verbose = false - ) const - {} }; @@ -115,12 +103,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "proxySurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C index 307d14f20..ed554f307 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C @@ -381,92 +381,8 @@ void Foam::rawSurfaceWriter::write } -<<<<<<< HEAD // create write methods defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter); -======= -namespace Foam -{ - // bool fields aren't supported - template<> - void Foam::rawSurfaceWriter::write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, - const bool verbose - ) const - {} -} - - -template -void Foam::rawSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, - const bool verbose -) const -{ - if (!isDir(outputDir)) - { - mkDir(outputDir); - } - - OFstream os - ( - outputDir/fieldName + '_' + surfaceName + ".raw" - ); - - if (verbose) - { - Info<< "Writing field " << fieldName << " to " << os.name() << endl; - } - - - // header - os << "# " << fieldName; - switch (sdType) - { - case surfaceWriterBase::POINT_DATA: - // writing point data - if (values.size() != points.size()) - { - FatalErrorIn("void rawSurfaceWriter::write(...)") - << "Data size does not match the number of points. " - << "Points: " << points.size() << " data: " << values.size() - << abort(FatalError); - } - os << "POINT_DATA "; - break; - - case surfaceWriterBase::FACE_DATA: - // writing face data - if (values.size() != faces.size()) - { - FatalErrorIn("void rawSurfaceWriter::write(...)") - << "Data size does not match the number of faces. " - << "Faces: " << faces.size() << " data: " << values.size() - << abort(FatalError); - } - os << "FACE_DATA "; - break; - } - - os << values.size() << nl; - - writeData(fieldName, points, faces, values, os); -} ->>>>>>> feature/JasakDevelopment // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H index c48c9c9f8..cc70bd398 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H @@ -25,6 +25,7 @@ Class Foam::rawSurfaceWriter Description + A surfaceWriter for raw output. SourceFiles rawSurfaceWriter.C @@ -36,99 +37,62 @@ SourceFiles #include "surfaceWriter.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ - Class rawSurfaceWriter Declaration + Class rawSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class rawSurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private Member Functions - static void writeGeometry + static inline void writeLocation ( - const pointField& points, - const label pointI, - Ostream& os + Ostream&, + const pointField&, + const label pointI ); - static void writeGeometry + static inline void writeLocation ( - const pointField& points, - const faceList& faces, - const label faceI, - Ostream& os + Ostream&, + const pointField&, + const faceList&, + const label faceI ); - static void writeData + template + static void writeHeader ( - const fileName& fieldName, - const pointField& points, - const faceList& faces, - const scalarField& values, - Ostream& os + Ostream&, + const word& fieldName, + const Field& ); - static void writeData - ( - const fileName& fieldName, - const pointField& points, - const faceList& faces, - const vectorField& values, - Ostream& os - ); + template + static inline void writeData(Ostream&, const Type&); - static void writeData - ( - const fileName& fieldName, - const pointField& points, - const faceList& faces, - const sphericalTensorField& values, - Ostream& os - ); - static void writeData + //- Templated write operation + template + void writeTemplate ( - const fileName& fieldName, + const fileName& outputDir, + const fileName& surfaceName, const pointField& points, const faceList& faces, - const diagTensorField& values, - Ostream& os - ); - - static void writeData - ( - const fileName& fieldName, - const pointField& points, - const faceList& faces, - const symmTensorField& values, - Ostream& os - ); - - static void writeData - ( - const fileName& fieldName, - const pointField& points, - const faceList& faces, - const symmTensor4thOrderField& values, - Ostream& os - ); - - static void writeData - ( - const fileName& fieldName, - const pointField& points, - const faceList& faces, - const tensorField& values, - Ostream& os - ); + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; public: @@ -143,36 +107,121 @@ public: rawSurfaceWriter(); - // Destructor + //- Destructor virtual ~rawSurfaceWriter(); // Member Functions - // Write + //- Write single surface geometry to file. + virtual void write + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose = false + ) const; - //- Write geometry to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const bool verbose = false - ) const; - //- Writes single surface to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, - const bool verbose = false - ) const; + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField4thOrder for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write diagTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -182,12 +231,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "rawSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.C b/src/sampling/sampledSurface/writers/surfaceWriter.C index 345460ff2..37b0a07b2 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.C +++ b/src/sampling/sampledSurface/writers/surfaceWriter.C @@ -113,58 +113,4 @@ Foam::surfaceWriter::~surfaceWriter() {} -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -template -void Foam::surfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, - const Field& values, - const bool verbose -) const -{ - if (points.size() == faces.size()) - { - WarningIn("void surfaceWriter::write(...)") - << "Writing unknown data type and the number of points " - << "and faces is the same. Defaulting to point data" << nl - << "Please specify data type in reader." - << endl; - } - - if (values.size() == points.size()) - { - this->write - ( - outputDir, - surfaceName, - points, - faces, - fieldName, - values, - surfaceWriterBase::POINT_DATA, - verbose - ); - } - else - { - this->write - ( - outputDir, - surfaceName, - points, - faces, - fieldName, - values, - surfaceWriterBase::FACE_DATA, - verbose - ); - } -} - - // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.H b/src/sampling/sampledSurface/writers/surfaceWriter.H index 43f8f9c5f..9a9ebcdfe 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.H +++ b/src/sampling/sampledSurface/writers/surfaceWriter.H @@ -35,7 +35,6 @@ SourceFiles #ifndef surfaceWriter_H #define surfaceWriter_H -#include "Field.H" #include "typeInfo.H" #include "autoPtr.H" #include "pointField.H" @@ -49,47 +48,12 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators - -template class surfaceWriter; -template class nullSurfaceWriter; -template class proxySurfaceWriter; - -class surfaceWriterBase -{ -public: - - // Public enumerations - - //- Surface data type - enum surfaceData - { - POINT_DATA, - FACE_DATA - }; - - - // Constructors - - //- Construct null - surfaceWriterBase() - {} -}; - - /*---------------------------------------------------------------------------*\ Class surfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class surfaceWriter -: - public surfaceWriterBase { - //- Friendship between writer data types - template friend class surfaceWriter; - - public: //- Runtime type information @@ -106,11 +70,30 @@ public: () ); + declareRunTimeSelectionTable + ( + autoPtr, + surfaceWriter, + wordDict, + ( + const dictionary& optDict + ), + (optDict) + ); + // Selectors //- Return a reference to the selected surfaceWriter - static autoPtr New(const word& writeFormat); + static autoPtr New(const word& writeType); + + //- Return a reference to the selected surfaceWriter + // Select with extra write option + static autoPtr New + ( + const word& writeType, + const dictionary& writeOptions + ); // Constructors @@ -126,16 +109,15 @@ public: // Member Functions //- Return true if the surface format supports separate files - virtual bool separateFiles() + virtual bool separateGeometry() { return false; } - - //- Writes single surface geometry to file. + //- Write single surface geometry to file. virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -143,32 +125,110 @@ public: ) const {} - //- Writes single surface to file. Either one value per vertex or - // one value per face (detected by values.size()==faces.size()) - void write - ( - const fileName& outputDir, // //surface/TIME - const fileName& surfaceName, // name of surface - const pointField& points, - const faceList& faces, - const fileName& fieldName, // name of field - const Field& values, - const bool verbose = false - ) const; - - //- Writes single surface to file. Either one value per vertex or - // one value per face, defined by type + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const fileName& fieldName, // name of field - const Field& values, - const surfaceWriterBase::surfaceData sdType, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, const bool verbose = false - ) const = 0; + ) const + {} + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write symmTensorField4thOrder for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write diagTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} }; @@ -178,12 +238,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "surfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C index 6490fd3e1..a36fcce2e 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C @@ -28,10 +28,19 @@ License #include "OFstream.H" #include "OSspecific.H" +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(vtkSurfaceWriter); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -void Foam::vtkSurfaceWriter::writeGeometry +void Foam::vtkSurfaceWriter::writeGeometry ( Ostream& os, const pointField& points, @@ -46,7 +55,7 @@ void Foam::vtkSurfaceWriter::writeGeometry << "DATASET POLYDATA" << nl; // Write vertex coords - os << "POINTS " << points.size() << " float" << nl; + os << "POINTS " << points.size() << " double" << nl; forAll(points, pointI) { const point& pt = points[pointI]; @@ -71,12 +80,12 @@ void Foam::vtkSurfaceWriter::writeGeometry { const face& f = faces[faceI]; - os << f.size(); + os << f.size(); forAll(f, fp) { - os << ' ' << f[fp]; + os << ' ' << f[fp]; } - os << nl; + os << nl; } } @@ -84,15 +93,14 @@ void Foam::vtkSurfaceWriter::writeGeometry namespace Foam { - // Write scalarField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, - const Field& values + const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " double" << nl; forAll(values, elemI) { @@ -100,29 +108,28 @@ namespace Foam { if (elemI % 10) { - os << ' '; + os << ' '; } else { - os << nl; + os << nl; } } - const scalar& v = values[elemI]; - os << float(v); + os << float(values[elemI]); } - os << nl; + os << nl; } - // Write vectorField in vtk format + template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, - const Field& values + const Field& values ) { - os << "3 " << values.size() << " float" << nl; + os << "3 " << values.size() << " double" << nl; forAll(values, elemI) { @@ -133,38 +140,37 @@ namespace Foam } - // Write sphericalTensorField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " double" << nl; forAll(values, elemI) { const sphericalTensor& v = values[elemI]; - os << float(v[0]) << nl; + os << float(v[0]) << nl; } } - // Write symmTensorField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "6 " << values.size() << " float" << nl; + os << "6 " << values.size() << " double" << nl; forAll(values, elemI) { const symmTensor& v = values[elemI]; os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2]) + << ' ' << float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5]) << nl; @@ -172,21 +178,22 @@ namespace Foam } - // Write tensorField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "9 " << values.size() << " float" << nl; + os << "9 " << values.size() << " double" << nl; forAll(values, elemI) { const tensor& v = values[elemI]; os << float(v[0]) << ' ' << float(v[1]) << ' ' << float(v[2]) + << ' ' << float(v[3]) << ' ' << float(v[4]) << ' ' << float(v[5]) + << ' ' << float(v[6]) << ' ' << float(v[7]) << ' ' << float(v[8]) << nl; } @@ -197,77 +204,31 @@ namespace Foam // Write generic field in vtk format template -void Foam::vtkSurfaceWriter::writeData +void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " double" << nl; forAll(values, elemI) { - os << float(0) << nl; + os << float(0) << nl; } } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components template -Foam::vtkSurfaceWriter::vtkSurfaceWriter() -: - surfaceWriter() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::vtkSurfaceWriter::~vtkSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::vtkSurfaceWriter::write +void Foam::vtkSurfaceWriter::writeTemplate ( const fileName& outputDir, const fileName& surfaceName, const pointField& points, const faceList& faces, - const bool verbose -) const -{ - if (!isDir(outputDir)) - { - mkDir(outputDir); - } - - fileName fName(outputDir/surfaceName + ".vtk"); - - if (verbose) - { - Info<< "Writing geometry to " << fName << endl; - } - - OFstream os(fName); - writeGeometry(os, points, faces); -} - - -template -void Foam::vtkSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field& values, - const surfaceWriterBase::surfaceData sdType, + const bool isNodeValues, const bool verbose ) const { @@ -276,10 +237,7 @@ void Foam::vtkSurfaceWriter::write mkDir(outputDir); } - OFstream os - ( - outputDir/fieldName + '_' + surfaceName + ".vtk" - ); + OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk"); if (verbose) { @@ -288,45 +246,68 @@ void Foam::vtkSurfaceWriter::write writeGeometry(os, points, faces); - switch (sdType) + // start writing data + if (isNodeValues) { - case surfaceWriterBase::POINT_DATA: - // writing point data - if (values.size() != points.size()) - { - FatalErrorIn("void vtkSurfaceWriter::write(...)") - << "Data size does not match the number of points. " - << "Points: " << points.size() << " data: " << values.size() - << abort(FatalError); - } - os << "POINT_DATA " - << values.size() << nl - << "FIELD attributes 1" << nl - << fieldName.c_str() << " "; - - // Write data - writeData(os, values); - break; - - case surfaceWriterBase::FACE_DATA: - // writing face data - if (values.size() != faces.size()) - { - FatalErrorIn("void vtkSurfaceWriter::write(...)") - << "Data size does not match the number of faces. " - << "Faces: " << faces.size() << " data: " << values.size() - << abort(FatalError); - } - os << "CELL_DATA " - << values.size() << nl - << "FIELD attributes 1" << nl - << fieldName.c_str() << " "; - - // Write data - writeData(os, values); - break; + os << "POINT_DATA "; } + else + { + os << "CELL_DATA "; + } + + os << values.size() << nl + << "FIELD attributes 1" << nl + << fieldName << " "; + + // Write data + writeData(os, values); } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::vtkSurfaceWriter::vtkSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::vtkSurfaceWriter::~vtkSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::vtkSurfaceWriter::write +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose +) const +{ + if (!isDir(outputDir)) + { + mkDir(outputDir); + } + + OFstream os(outputDir/surfaceName + ".vtk"); + + if (verbose) + { + Info<< "Writing geometry to " << os.name() << endl; + } + + writeGeometry(os, points, faces); +} + + +// create write methods +defineSurfaceWriterWriteFields(Foam::vtkSurfaceWriter); + + // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H index 4ef002856..be88fd6a8 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H @@ -25,6 +25,7 @@ Class Foam::vtkSurfaceWriter Description + A surfaceWriter for VTK legacy format. SourceFiles vtkSurfaceWriter.C @@ -42,21 +43,35 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class vtkSurfaceWriter Declaration + Class vtkSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class vtkSurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private Member Functions static void writeGeometry(Ostream&, const pointField&, const faceList&); - static void writeData(Ostream&, const Field& values); + template + static void writeData(Ostream&, const Field&); + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; + public: //- Runtime type information @@ -69,36 +84,121 @@ public: vtkSurfaceWriter(); - // Destructor + //- Destructor virtual ~vtkSurfaceWriter(); // Member Functions - // Write + //- Write single surface geometry to file. + virtual void write + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose = false + ) const; - //- Write geometry to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const bool verbose = false - ) const; - //- Writes single surface to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const fileName& fieldName, - const Field& values, - const surfaceWriterBase::surfaceData sdType, - const bool verbose = false - ) const; + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField4thOrder for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write diagTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // /surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -108,12 +208,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "vtkSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* //