ENH: rework surface writers as non-templated classes

- easier (more logical) when adding a new writer

ENH: add surface field  writer for 'starcd' format

- creates *.usr files, which can be read in proSTAR with the 'getuser'
  command, but which can also be parsed directly since the format is
  extremely primitive
This commit is contained in:
Mark Olesen
2011-01-26 13:36:37 +01:00
parent 232c13eef0
commit 51df389de6
32 changed files with 1594 additions and 1543 deletions

View File

@ -46,14 +46,14 @@ sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C
surfWriters = sampledSurface/writers
$(surfWriters)/surfaceWriters.C
$(surfWriters)/dx/dxSurfaceWriterRunTime.C
$(surfWriters)/ensight/ensightSurfaceWriterRunTime.C
$(surfWriters)/foamFile/foamFileSurfaceWriterRunTime.C
$(surfWriters)/null/nullSurfaceWriterRunTime.C
$(surfWriters)/proxy/proxySurfaceWriterRunTime.C
$(surfWriters)/raw/rawSurfaceWriterRunTime.C
$(surfWriters)/vtk/vtkSurfaceWriterRunTime.C
$(surfWriters)/surfaceWriter.C
$(surfWriters)/dx/dxSurfaceWriter.C
$(surfWriters)/ensight/ensightSurfaceWriter.C
$(surfWriters)/foamFile/foamFileSurfaceWriter.C
$(surfWriters)/proxy/proxySurfaceWriter.C
$(surfWriters)/raw/rawSurfaceWriter.C
$(surfWriters)/starcd/starcdSurfaceWriter.C
$(surfWriters)/vtk/vtkSurfaceWriter.C
graphField/writePatchGraph.C
graphField/writeCellGraph.C

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -83,7 +83,7 @@ void Foam::sampledSurfaces::writeGeometry() const
{
if (Pstream::master() && mergeList_[surfI].faces.size())
{
genericFormatter_->write
formatter_->write
(
outputDir,
s.name(),
@ -94,7 +94,7 @@ void Foam::sampledSurfaces::writeGeometry() const
}
else if (s.faces().size())
{
genericFormatter_->write
formatter_->write
(
outputDir,
s.name(),
@ -123,9 +123,8 @@ Foam::sampledSurfaces::sampledSurfaces
outputPath_(fileName::null),
fieldSelection_(),
interpolationScheme_(word::null),
writeFormat_(word::null),
mergeList_(),
genericFormatter_(NULL),
formatter_(NULL),
scalarFields_(),
vectorFields_(),
sphericalTensorFields_(),
@ -201,7 +200,7 @@ void Foam::sampledSurfaces::write()
// write geometry first if required,
// or when no fields would otherwise be written
if (nFields == 0 || genericFormatter_->separateFiles())
if (nFields == 0 || formatter_->separateGeometry())
{
writeGeometry();
}
@ -221,11 +220,11 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
clearFieldGroups();
dict.lookup("interpolationScheme") >> interpolationScheme_;
dict.lookup("surfaceFormat") >> writeFormat_;
// define the generic (geometry) writer
genericFormatter_ = surfaceWriter<bool>::New(writeFormat_);
word writeFormat(dict.lookup("surfaceFormat"));
// define the surface formatter
formatter_ = surfaceWriter::New(writeFormat);
PtrList<sampledSurface> newList
(

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -68,36 +68,11 @@ class sampledSurfaces
{
public:
//- The surface formatter
autoPtr< surfaceWriter<Type> > formatter;
//- Construct null
fieldGroup()
:
DynamicList<word>(0),
formatter(NULL)
DynamicList<word>(0)
{}
//- Construct for a particular surface format
fieldGroup(const word& writeFormat)
:
DynamicList<word>(0),
formatter(surfaceWriter<Type>::New(writeFormat))
{}
//- Reset format and field list
void clear()
{
DynamicList<word>::clear();
formatter.clear();
}
//- Assign a new formatter
void operator=(const word& writeFormat)
{
formatter = surfaceWriter<Type>::New(writeFormat);
}
};
@ -151,10 +126,6 @@ class sampledSurfaces
//- Interpolation scheme to use
word interpolationScheme_;
//- Output format to use
word writeFormat_;
// surfaces
//- Information for merging surfaces
@ -163,8 +134,8 @@ class sampledSurfaces
// Calculated
//- Generic surface formatter
autoPtr< surfaceWriter<bool> > genericFormatter_;
//- Surface formatter
autoPtr<surfaceWriter> formatter_;
//- Categorized scalar/vector/tensor fields
fieldGroup<scalar> scalarFields_;
@ -190,14 +161,10 @@ class sampledSurfaces
//- Sample and write a particular volume field
template<class Type>
void sampleAndWrite
(
const GeometricField<Type, fvPatchField, volMesh>&,
const surfaceWriter<Type>& formatter
);
void sampleAndWrite(const GeometricField<Type, fvPatchField, volMesh>&);
//- Sample and write all the fields of the given type
template <class Type>
template<class Type>
void sampleAndWrite(fieldGroup<Type>&);
//- Disallow default bitwise copy construct and assignment

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -32,8 +32,7 @@ License
template<class Type>
void Foam::sampledSurfaces::sampleAndWrite
(
const GeometricField<Type, fvPatchField, volMesh>& vField,
const surfaceWriter<Type>& formatter
const GeometricField<Type, fvPatchField, volMesh>& vField
)
{
// interpolator for this field
@ -96,7 +95,7 @@ void Foam::sampledSurfaces::sampleAndWrite
// skip surface without faces (eg, a failed cut-plane)
if (mergeList_[surfI].faces.size())
{
formatter.write
formatter_->write
(
outputDir,
s.name(),
@ -115,7 +114,7 @@ void Foam::sampledSurfaces::sampleAndWrite
// skip surface without faces (eg, a failed cut-plane)
if (s.faces().size())
{
formatter.write
formatter_->write
(
outputDir,
s.name(),
@ -139,12 +138,6 @@ void Foam::sampledSurfaces::sampleAndWrite
{
if (fields.size())
{
// create or use existing surfaceWriter
if (fields.formatter.empty())
{
fields.formatter = surfaceWriter<Type>::New(writeFormat_);
}
forAll(fields, fieldI)
{
if (Pstream::master() && verbose_)
@ -168,8 +161,7 @@ void Foam::sampledSurfaces::sampleAndWrite
false
),
mesh_
),
fields.formatter()
)
);
}
else
@ -190,8 +182,7 @@ void Foam::sampledSurfaces::sampleAndWrite
<GeometricField<Type, fvPatchField, volMesh> >
(
fields[fieldI]
),
fields.formatter()
)
);
}
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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<class Type>
void Foam::dxSurfaceWriter<Type>::writeGeometry
void Foam::dxSurfaceWriter::writeGeometry
(
Ostream& os,
const pointField& points,
@ -54,7 +63,6 @@ void Foam::dxSurfaceWriter<Type>::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<Type>::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<Foam::scalar>::writeData
void Foam::dxSurfaceWriter::writeData
(
Ostream& os,
const Field<scalar>& 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<Foam::vector>::writeData
void Foam::dxSurfaceWriter::writeData
(
Ostream& os,
const Field<vector>& 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<Foam::sphericalTensor>::writeData
void Foam::dxSurfaceWriter::writeData
(
Ostream& os,
const Field<sphericalTensor>& 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<Foam::symmTensor>::writeData
void Foam::dxSurfaceWriter::writeData
(
Ostream& os,
const Field<symmTensor>& 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<tensor> in DX format
template<>
void Foam::dxSurfaceWriter<Foam::tensor>::writeData
inline void Foam::dxSurfaceWriter::writeData
(
Ostream& os,
const Field<tensor>& 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<class Type>
void Foam::dxSurfaceWriter<Type>::writeData
inline void Foam::dxSurfaceWriter::writeData
(
Ostream& os,
const Field<Type>& values
)
{
// Write data
os << "object 3 class array type float rank 0 items "
<< values.size() << " data follows" << nl;
@ -208,41 +233,8 @@ void Foam::dxSurfaceWriter<Type>::writeData
}
// Write trailer in DX format
template<class Type>
void Foam::dxSurfaceWriter<Type>::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<class Type>
Foam::dxSurfaceWriter<Type>::dxSurfaceWriter()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::dxSurfaceWriter<Type>::~dxSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::dxSurfaceWriter<Type>::write
void Foam::dxSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
@ -270,24 +262,29 @@ void Foam::dxSurfaceWriter<Type>::write
}
writeGeometry(os, points, faces);
writeData(os, values);
if (isNodeValues)
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;
}
else
{
os << nl << "attribute \"dep\" string \"connections\""
<< nl << nl;
}
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);
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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 Type>
class dxSurfaceWriter
:
public surfaceWriter<Type>
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<Type>& values);
template<class Type>
static void writeData(Ostream&, const Field<Type>&);
//- Templated write operation
template<class Type>
void writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const;
static void writeTrailer(Ostream&);
public:
@ -77,20 +92,76 @@ public:
// 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const word& fieldName, // name of field
const Field<scalar>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<vector>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<sphericalTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<symmTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<tensor>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};
@ -100,12 +171,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "dxSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,43 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "dxSurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriters(dxSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -31,6 +31,16 @@ License
#include "ensightGeoFile.H"
#include "ensightPartNonMeshFaces.H"
#include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makeSurfaceWriterType(ensightSurfaceWriter);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
namespace Foam
@ -38,30 +48,15 @@ namespace Foam
// Write scalarField in ensight format
template<>
void Foam::ensightSurfaceWriter<Foam::scalar>::writeData
inline void Foam::ensightSurfaceWriter::writeData
(
Ostream& os,
const Field<Foam::scalar>& values
const Field<scalar>& values
)
{
forAll(values, i)
{
os << values[i] << nl;
}
}
// Write booField in ensight format
template<>
void Foam::ensightSurfaceWriter<bool>::writeData
(
Ostream& os,
const Field<bool>& values
)
{
forAll(values, i)
{
os << values[i] << nl;
os << values[i] << nl;
}
}
}
@ -69,96 +64,25 @@ namespace Foam
// Write generic field in ensight format
template<class Type>
void Foam::ensightSurfaceWriter<Type>::writeData
inline void Foam::ensightSurfaceWriter::writeData
(
Ostream& os,
const Field<Type>& values
)
{
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt)
{
scalarField v(values.component(cmpt));
forAll(v, i)
{
os << v[i] << nl;
os << v[i] << nl;
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Type>
Foam::ensightSurfaceWriter<Type>::ensightSurfaceWriter()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::ensightSurfaceWriter<Type>::~ensightSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::ensightSurfaceWriter<Type>::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
{
if (!isDir(outputDir))
{
mkDir(outputDir);
}
//const scalar timeValue = Foam::name(this->mesh().time().timeValue());
const scalar timeValue = 0.0;
OFstream caseStr(outputDir/surfaceName + ".case");
ensightGeoFile geomStr
(
outputDir/surfaceName + ".000.mesh",
IOstream::ASCII
);
if (verbose)
{
Info<< "Writing case file to " << caseStr.name() << endl;
}
caseStr
<< "FORMAT" << nl
<< "type: ensight gold" << nl
<< nl
<< "GEOMETRY" << nl
<< "model: 1 " << geomStr.name().name() << nl
<< nl
<< "TIME" << nl
<< "time set: 1" << nl
<< "number of steps: 1" << nl
<< "filename start number: 0" << nl
<< "filename increment: 1" << nl
<< "time values:" << nl
<< timeValue << nl
<< nl;
ensightPartNonMeshFaces faceWriter(0, geomStr.name().name(), faces, points);
faceWriter.writeGeometry(geomStr);
}
template<class Type>
void Foam::ensightSurfaceWriter<Type>::write
void Foam::ensightSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
@ -175,10 +99,9 @@ void Foam::ensightSurfaceWriter<Type>::write
mkDir(outputDir/fieldName);
}
//const scalar timeValue = Foam::name(this->mesh().time().timeValue());
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
const scalar timeValue = 0.0;
OFstream caseStr(outputDir/fieldName/surfaceName + ".case");
ensightGeoFile geomStr
(
@ -230,8 +153,8 @@ void Foam::ensightSurfaceWriter<Type>::write
<< timeValue << nl
<< nl;
ensightPartNonMeshFaces faceWriter(0, geomStr.name().name(), faces, points);
faceWriter.writeGeometry(geomStr);
ensightPartNonMeshFaces ensPart(0, geomStr.name().name(), faces, points);
geomStr << ensPart;
// Write field
fieldStr
@ -246,19 +169,19 @@ void Foam::ensightSurfaceWriter<Type>::write
}
else
{
//faceWriter.writeField(fieldStr, values);
forAll(faceWriter.elementTypes(), elemI)
// ensPart.writeField(fieldStr, values);
forAll(ensPart.elementTypes(), elemI)
{
if (faceWriter.elemLists()[elemI].size())
if (ensPart.elemLists()[elemI].size())
{
fieldStr.writeKeyword(faceWriter.elementTypes()[elemI]);
fieldStr.writeKeyword(ensPart.elementTypes()[elemI]);
writeData
(
fieldStr,
Field<Type>
(
values,
faceWriter.elemLists()[elemI]
ensPart.elemLists()[elemI]
)
);
}
@ -267,4 +190,75 @@ void Foam::ensightSurfaceWriter<Type>::write
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::ensightSurfaceWriter::ensightSurfaceWriter()
:
surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::ensightSurfaceWriter::~ensightSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::ensightSurfaceWriter::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
{
if (!isDir(outputDir))
{
mkDir(outputDir);
}
//const scalar timeValue = Foam::name(this->mesh().time().timeValue());
const scalar timeValue = 0.0;
OFstream caseStr(outputDir/surfaceName + ".case");
ensightGeoFile geomStr
(
outputDir/surfaceName + ".000.mesh",
IOstream::ASCII
);
if (verbose)
{
Info<< "Writing case file to " << caseStr.name() << endl;
}
caseStr
<< "FORMAT" << nl
<< "type: ensight gold" << nl
<< nl
<< "GEOMETRY" << nl
<< "model: 1 " << geomStr.name().name() << nl
<< nl
<< "TIME" << nl
<< "time set: 1" << nl
<< "number of steps: 1" << nl
<< "filename start number: 0" << nl
<< "filename increment: 1" << nl
<< "time values:" << nl
<< timeValue << nl
<< nl;
ensightPartNonMeshFaces ensPart(0, geomStr.name().name(), faces, points);
geomStr << ensPart;
}
// create write methods
defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter);
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,7 @@ Class
Foam::ensightSurfaceWriter
Description
A surfaceWriter for Ensight format.
SourceFiles
ensightSurfaceWriter.C
@ -41,29 +42,41 @@ SourceFiles
namespace Foam
{
class ensightGeoFile;
/*---------------------------------------------------------------------------*\
Class ensightSurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class ensightSurfaceWriter
:
public surfaceWriter<Type>
public surfaceWriter
{
// Private data
fileName caseFileName_;
fileName surfaceName_;
fileName geomName_;
DynamicList<word> varNames_;
DynamicList<fileName> varFileNames_;
// fileName caseFileName_;
// fileName surfaceName_;
// fileName geomName_;
// DynamicList<word> varNames_;
// DynamicList<fileName> varFileNames_;
// Private Member Functions
static void writeData(Ostream&, const Field<Type>& values);
template<class Type>
static inline void writeData(Ostream&, const Field<Type>&);
//- Templated write operation
template<class Type>
void writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const;
public:
@ -84,9 +97,15 @@ public:
// Member Functions
// Write
//- 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,
@ -97,18 +116,76 @@ public:
) 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const word& fieldName, // name of field
const Field<scalar>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<vector>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<sphericalTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<symmTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<tensor>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};
@ -118,12 +195,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "ensightSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,44 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "ensightSurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(ensightSurfaceWriter, bool);
makeSurfaceWriters(ensightSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,67 +28,20 @@ License
#include "OFstream.H"
#include "OSspecific.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
#include "makeSurfaceWriterMethods.H"
template<class Type>
Foam::foamFileSurfaceWriter<Type>::foamFileSurfaceWriter()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::foamFileSurfaceWriter<Type>::~foamFileSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::foamFileSurfaceWriter<Type>::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
namespace Foam
{
fileName surfaceDir(outputDir/surfaceName);
if (!isDir(surfaceDir))
{
mkDir(surfaceDir);
}
if (verbose)
{
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;
makeSurfaceWriterType(foamFileSurfaceWriter);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::foamFileSurfaceWriter<Type>::write
void Foam::foamFileSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
@ -113,7 +66,6 @@ void Foam::foamFileSurfaceWriter<Type>::write
}
// geometry should already have been written
// Values to separate directory (e.g. "scalarField/p")
fileName foamName(pTraits<Type>::typeName);
@ -125,8 +77,69 @@ void Foam::foamFileSurfaceWriter<Type>::write
}
// values
OFstream(valuesDir/fieldName)() << values;
OFstream(valuesDir/fieldName)() << values;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::foamFileSurfaceWriter::foamFileSurfaceWriter()
:
surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::foamFileSurfaceWriter::~foamFileSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::foamFileSurfaceWriter::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
{
fileName surfaceDir(outputDir/surfaceName);
if (!isDir(surfaceDir))
{
mkDir(surfaceDir);
}
if (verbose)
{
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;
}
// create write methods
defineSurfaceWriterWriteFields(Foam::foamFileSurfaceWriter);
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -43,14 +43,29 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class foamFileSurfaceWriter Declaration
Class foamFileSurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class foamFileSurfaceWriter
:
public surfaceWriter<Type>
public surfaceWriter
{
// Private Member Functions
//- Templated write operation
template<class Type>
void writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const;
public:
@ -70,13 +85,14 @@ public:
// 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,77 @@ 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const word& fieldName, // name of field
const Field<scalar>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<vector>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<sphericalTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<symmTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<tensor>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};
@ -107,12 +182,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "foamFileSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,44 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "foamFileSurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(foamFileSurfaceWriter, bool);
makeSurfaceWriters(foamFileSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,92 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
InClass
Foam::makeSurfaceWriterMethods
Description
Convenience macros for instantiating writer methods for surfaceWriter
classes.
\*---------------------------------------------------------------------------*/
#ifndef makeSurfaceWriterMethods_H
#define makeSurfaceWriterMethods_H
#include "surfaceWriter.H"
#include "addToRunTimeSelectionTable.H"
namespace Foam
{
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#define makeSurfaceWriterType(ThisClass) \
defineTypeNameAndDebug(ThisClass, 0); \
addToRunTimeSelectionTable(surfaceWriter, ThisClass, word)
#define defineSurfaceWriterWriteField(ThisClass, FieldType) \
void ThisClass::write \
( \
const fileName& outputDir, \
const fileName& surfaceName, \
const pointField& points, \
const faceList& faces, \
const word& fieldName, \
const Field<FieldType>& values, \
const bool isNodeValues, \
const bool verbose \
) const \
{ \
writeTemplate \
( \
outputDir, \
surfaceName, \
points, \
faces, \
fieldName, \
values, \
isNodeValues, \
verbose \
); \
}
#define defineSurfaceWriterWriteFields(ThisClass) \
defineSurfaceWriterWriteField(ThisClass, scalar); \
defineSurfaceWriterWriteField(ThisClass, vector); \
defineSurfaceWriterWriteField(ThisClass, sphericalTensor); \
defineSurfaceWriterWriteField(ThisClass, symmTensor); \
defineSurfaceWriterWriteField(ThisClass, tensor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,63 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "nullSurfaceWriter.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::nullSurfaceWriter<Type>::nullSurfaceWriter()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::nullSurfaceWriter<Type>::~nullSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::nullSurfaceWriter<Type>::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{}
// ************************************************************************* //

View File

@ -1,103 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Class
Foam::nullSurfaceWriter
Description
SourceFiles
nullSurfaceWriter.C
\*---------------------------------------------------------------------------*/
#ifndef nullSurfaceWriter_H
#define nullSurfaceWriter_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class nullSurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class nullSurfaceWriter
:
public surfaceWriter<Type>
{
public:
//- Runtime type information
TypeName("null");
// Constructors
//- Construct null
nullSurfaceWriter();
//- Destructor
virtual ~nullSurfaceWriter();
// Member Functions
// Write
//- Writes single surface to file.
virtual void write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "nullSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,44 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "nullSurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(nullSurfaceWriter, bool);
makeSurfaceWriters(nullSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,27 +29,34 @@ License
#include "OFstream.H"
#include "OSspecific.H"
#include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTypeNameAndDebug(proxySurfaceWriter, 0);
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::proxySurfaceWriter<Type>::proxySurfaceWriter(const word& ext)
Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext)
:
surfaceWriter<Type>(),
surfaceWriter(),
ext_(ext)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::proxySurfaceWriter<Type>::~proxySurfaceWriter()
Foam::proxySurfaceWriter::~proxySurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::proxySurfaceWriter<Type>::write
void Foam::proxySurfaceWriter::write
(
const fileName& outputDir,
const fileName& surfaceName,
@ -69,19 +76,14 @@ void Foam::proxySurfaceWriter<Type>::write
mkDir(outputDir);
}
fileName fName(outputDir/surfaceName + "." + ext_);
fileName outName(outputDir/surfaceName + "." + ext_);
if (verbose)
{
Info<< "Writing geometry to " << fName << endl;
Info<< "Writing geometry to " << outName << endl;
}
MeshedSurfaceProxy<face>
(
points,
faces
).write(fName);
MeshedSurfaceProxy<face>(points, faces).write(outName);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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 Type>
class proxySurfaceWriter
:
public surfaceWriter<Type>
public surfaceWriter
{
// Private data
@ -74,15 +75,16 @@ 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.
//- Write single surface geometry to file.
virtual void write
(
const fileName& outputDir,
@ -92,20 +94,6 @@ public:
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 word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const
{}
};
@ -115,12 +103,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "proxySurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,45 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "proxySurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// create type names, but do not register with run-time tables
makeTypeSurfaceWritersTypeName(proxySurfaceWriter, bool);
makeSurfaceWritersTypeName(proxySurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,334 +29,187 @@ License
#include "OSspecific.H"
#include "IOmanip.H"
#include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makeSurfaceWriterType(rawSurfaceWriter);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeGeometry
inline void Foam::rawSurfaceWriter::writeLocation
(
Ostream& os,
const pointField& points,
const label pointI,
Ostream& os
const label pointI
)
{
const point& pt = points[pointI];
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' ';
}
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeGeometry
inline void Foam::rawSurfaceWriter::writeLocation
(
Ostream& os,
const pointField& points,
const faceList& faces,
const label faceI,
Ostream& os
const label faceI
)
{
const point& ct = faces[faceI].centre(points);
os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
}
// Write scalarField in raw format
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const scalarField& values,
const bool isNodeValues,
Ostream& os
)
{
// header
os << "# x y z " << fieldName << endl;
// Write data
if (isNodeValues)
{
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
os << values[elemI] << nl;
}
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
os << values[elemI] << nl;
}
}
os << nl;
}
// Write vectorField in raw format
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const vectorField& values,
const bool isNodeValues,
Ostream& os
)
{
// header
os << "# x y z "
<< fieldName << "_x "
<< fieldName << "_y "
<< fieldName << "_z "
<< endl;
// Write data
if (isNodeValues)
{
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const vector& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
}
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
const vector& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << nl;
}
}
}
// Write sphericalTensorField in raw format
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const sphericalTensorField& values,
const bool isNodeValues,
Ostream& os
)
{
// header
os << "# ii ";
os << fieldName << "_ii" << endl;
// Write data
if (isNodeValues)
{
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const sphericalTensor& v = values[elemI];
os << v[0] << nl;
}
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
const sphericalTensor& v = values[elemI];
os << v[0] << nl;
}
}
}
// Write symmTensorField in raw format
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const symmTensorField& values,
const bool isNodeValues,
Ostream& os
)
{
// header
os << "# xx xy xz yy yz ";
for (int i=0; i<6; i++)
{
os << fieldName << "_" << i << " ";
}
os << endl;
// Write data
if (isNodeValues)
{
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const symmTensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
<< v[3] << ' ' << v[4] << ' ' << v[5] << nl;
}
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
const symmTensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
<< v[3] << ' ' << v[4] << ' ' << v[5] << nl;
}
}
}
// Write tensorField in raw format
template<class Type>
void Foam::rawSurfaceWriter<Type>::writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const tensorField& values,
const bool isNodeValues,
Ostream& os
)
{
// header
os << "# xx xy xz yx yy yz zx zy zz";
for (int i=0; i<9; ++i)
{
os << fieldName << "_" << i << " ";
}
os << endl;
// Write data
if (isNodeValues)
{
forAll(values, elemI)
{
writeGeometry(points, elemI, os);
const tensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
<< v[3] << ' ' << v[4] << ' ' << v[5] << ' '
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
}
}
else
{
forAll(values, elemI)
{
writeGeometry(points, faces, elemI, os);
const tensor& v = values[elemI];
os << v[0] << ' ' << v[1] << ' ' << v[2] << ' '
<< v[3] << ' ' << v[4] << ' ' << v[5] << ' '
<< v[6] << ' ' << v[7] << ' ' << v[8] << nl;
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::rawSurfaceWriter<Type>::rawSurfaceWriter()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::rawSurfaceWriter<Type>::~rawSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::rawSurfaceWriter<Type>::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 + ".raw"
);
if (verbose)
{
Info<< "Writing geometry to " << os.name() << endl;
}
// header
os << "# geometry NO_DATA " << faces.size() << nl
<< "# x y z" << endl;
// Write faces
forAll(faces, elemI)
{
writeGeometry(points, faces, elemI, os);
os << nl;
}
os << nl;
os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' ';
}
namespace Foam
{
// bool fields aren't supported
template<>
void Foam::rawSurfaceWriter<bool>::write
void Foam::rawSurfaceWriter::writeHeader
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
Ostream& os,
const word& fieldName,
const Field<bool>& values,
const bool isNodeValues,
const bool verbose
) const
{}
const Field<scalar>& values
)
{
os << values.size() << nl
<< "# x y z " << fieldName << nl;
}
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;
}
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;
}
}
template<class Type>
void Foam::rawSurfaceWriter<Type>::write
void Foam::rawSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
@ -373,17 +226,13 @@ void Foam::rawSurfaceWriter<Type>::write
mkDir(outputDir);
}
OFstream os
(
outputDir/fieldName + '_' + surfaceName + ".raw"
);
OFstream os(outputDir/fieldName + '_' + surfaceName + ".raw");
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
}
// header
os << "# " << fieldName;
if (isNodeValues)
@ -395,10 +244,85 @@ void Foam::rawSurfaceWriter<Type>::write
os << " FACE_DATA ";
}
os << values.size() << nl;
// header
writeHeader(os, fieldName, values);
writeData(fieldName, points, faces, values, isNodeValues, os);
// 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]);
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::rawSurfaceWriter::rawSurfaceWriter()
:
surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::rawSurfaceWriter::~rawSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::rawSurfaceWriter::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 + ".raw");
if (verbose)
{
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)
{
writeLocation(os, points, faces, elemI);
os << nl;
}
os << nl;
}
// create write methods
defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter);
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -25,6 +25,7 @@ Class
Foam::rawSurfaceWriter
Description
A surfaceWriter for raw output.
SourceFiles
rawSurfaceWriter.C
@ -36,86 +37,62 @@ SourceFiles
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class raw Declaration
Class rawSurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class rawSurfaceWriter
:
public surfaceWriter<Type>
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<class Type>
static void writeHeader
(
Ostream&,
const word& fieldName,
const pointField& points,
const faceList& faces,
const scalarField& values,
const bool isNodeValues,
Ostream& os
const Field<Type>&
);
static void writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const vectorField& values,
const bool isNodeValues,
Ostream& os
);
template<class Type>
static inline void writeData(Ostream&, const Type&);
static void writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const sphericalTensorField& values,
const bool isNodeValues,
Ostream& os
);
static void writeData
//- Templated write operation
template<class Type>
void writeTemplate
(
const word& fieldName,
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const symmTensorField& values,
const bool isNodeValues,
Ostream& os
);
static void writeData
(
const word& fieldName,
const pointField& points,
const faceList& faces,
const tensorField& values,
const Field<Type>& values,
const bool isNodeValues,
Ostream& os
);
const bool verbose
) const;
public:
@ -136,9 +113,7 @@ public:
// Member Functions
// Write
//- Write geometry to file.
//- Write single surface geometry to file.
virtual void write
(
const fileName& outputDir,
@ -148,18 +123,77 @@ 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const word& fieldName, // name of field
const Field<scalar>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<vector>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<sphericalTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<symmTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<tensor>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};
@ -169,12 +203,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "rawSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,44 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "rawSurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(rawSurfaceWriter, bool);
makeSurfaceWriters(rawSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,172 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "starcdSurfaceWriter.H"
#include "MeshedSurfaceProxy.H"
#include "OFstream.H"
#include "OSspecific.H"
#include "makeSurfaceWriterMethods.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
makeSurfaceWriterType(starcdSurfaceWriter);
}
// * * * * * * * * * * * * * 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;
}
}
template<class Type>
inline void Foam::starcdSurfaceWriter::writeData
(
Ostream& os,
const Type& v
)
{}
template<class Type>
void Foam::starcdSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{
if (!isDir(outputDir))
{
mkDir(outputDir);
}
OFstream os(outputDir/fieldName + '_' + surfaceName + ".usr");
if (verbose)
{
Info<< "Writing field " << fieldName << " to " << os.name() << endl;
}
// no header, just write values
forAll(values, elemI)
{
os << elemI+1 << ' ';
writeData(os, values[elemI]);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::starcdSurfaceWriter::starcdSurfaceWriter()
:
surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::starcdSurfaceWriter::~starcdSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::starcdSurfaceWriter::write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose
) const
{
if (!isDir(outputDir))
{
mkDir(outputDir);
}
fileName outName(outputDir/surfaceName + ".inp");
if (verbose)
{
Info<< "Writing geometry to " << outName << endl;
}
MeshedSurfaceProxy<face>(points, faces).write(outName);
}
// create write methods
defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, scalar);
defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, vector);
defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, sphericalTensor);
// ************************************************************************* //

View File

@ -0,0 +1,181 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
Class
Foam::starcdSurfaceWriter
Description
A surfaceWriter for STARCD files.
The geometry is written via the MeshedSurfaceProxy, the fields
are written in a trivial ASCII format with ID and VALUE as
so-called user data. These @c .usr files can be read into proSTAR
with these types of commands. For element data:
@verbatim
getuser FILENAME.usr cell scalar free
getuser FILENAME.usr cell vector free
@endverbatim
and for vertex data:
@verbatim
getuser FILENAME.usr vertex scalar free
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.
SourceFiles
starcdSurfaceWriter.C
\*---------------------------------------------------------------------------*/
#ifndef starcdSurfaceWriter_H
#define starcdSurfaceWriter_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class starcdSurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
class starcdSurfaceWriter
:
public surfaceWriter
{
// Private Member Functions
template<class Type>
static inline void writeData(Ostream&, const Type&);
//- Templated write operation
template<class Type>
void writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const;
public:
//- Runtime type information
TypeName("starcd");
// Constructors
//- Construct null
starcdSurfaceWriter();
//- Destructor
virtual ~starcdSurfaceWriter();
// Member Functions
//- 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 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 scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true)
virtual void write
(
const fileName& outputDir, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<scalar>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<vector>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<sphericalTensor>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,47 +26,43 @@ License
#include "surfaceWriter.H"
#include "MeshedSurfaceProxy.H"
#include "nullSurfaceWriter.H"
#include "proxySurfaceWriter.H"
#include "HashTable.H"
#include "word.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
template<class Type>
Foam::autoPtr< Foam::surfaceWriter<Type> >
Foam::surfaceWriter<Type>::New(const word& writeType)
namespace Foam
{
typename wordConstructorTable::iterator cstrIter =
defineTypeNameAndDebug(surfaceWriter, 0);
defineRunTimeSelectionTable(surfaceWriter, word);
addNamedToRunTimeSelectionTable
(
surfaceWriter,
surfaceWriter,
word,
null
);
}
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
Foam::autoPtr<Foam::surfaceWriter>
Foam::surfaceWriter::New(const word& writeType)
{
wordConstructorTable::iterator cstrIter =
wordConstructorTablePtr_->find(writeType);
if (cstrIter == wordConstructorTablePtr_->end())
{
// not supported for this data type, but it generally does work
// (it handles the 'bool' specialization - ie, geometry write)
if
(
Foam::surfaceWriter<bool>::wordConstructorTablePtr_->found
(
writeType
)
)
{
// use 'null' handler instead
return autoPtr< surfaceWriter<Type> >
(
new nullSurfaceWriter<Type>()
);
}
else if (MeshedSurfaceProxy<face>::canWriteType(writeType))
if (MeshedSurfaceProxy<face>::canWriteType(writeType))
{
// generally unknown, but can be written via MeshedSurfaceProxy
// use 'proxy' handler instead
return autoPtr< surfaceWriter<Type> >
(
new proxySurfaceWriter<Type>(writeType)
);
return autoPtr<surfaceWriter>(new proxySurfaceWriter(writeType));
}
if (cstrIter == wordConstructorTablePtr_->end())
@ -83,24 +79,20 @@ Foam::surfaceWriter<Type>::New(const word& writeType)
}
}
return autoPtr< surfaceWriter<Type> >(cstrIter()());
return autoPtr<surfaceWriter>(cstrIter()());
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::surfaceWriter<Type>::surfaceWriter()
Foam::surfaceWriter::surfaceWriter()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::surfaceWriter<Type>::~surfaceWriter()
Foam::surfaceWriter::~surfaceWriter()
{}
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -34,7 +34,7 @@ SourceFiles
#ifndef surfaceWriter_H
#define surfaceWriter_H
#include "Field.H"
#include "volFields.H"
#include "typeInfo.H"
#include "autoPtr.H"
#include "pointField.H"
@ -48,22 +48,12 @@ SourceFiles
namespace Foam
{
// Forward declaration of friend functions and operators
template<class Type> class surfaceWriter;
template<class Type> class nullSurfaceWriter;
template<class Type> class proxySurfaceWriter;
/*---------------------------------------------------------------------------*\
Class surfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class surfaceWriter
{
//- friendship between writer data types
template<class Type2> friend class surfaceWriter;
public:
//- Runtime type information
@ -99,14 +89,15 @@ public:
// 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 false;
}
//- Writes single surface geometry to file.
//- Write single surface geometry to file.
virtual void write
(
const fileName& outputDir, // <root>/<case>/surface/TIME
@ -118,8 +109,8 @@ public:
{}
//- Writes single surface to file. Either one value per vertex or
// one value per face (isNodeValues = false)
//- Write scalarField for a single surface to file.
// One value per face or vertex (isNodeValues = true)
virtual void write
(
const fileName& outputDir, // <root>/<case>/surface/TIME
@ -127,10 +118,73 @@ public:
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<Type>& values,
const Field<scalar>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<vector>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<sphericalTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<symmTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<tensor>& values,
const bool isNodeValues,
const bool verbose = false
) const
{}
};
@ -140,12 +194,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "surfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,50 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "surfaceWriters.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
#define defineSurfaceWriterType(dataType) \
defineNamedTemplateTypeNameAndDebug(surfaceWriter< dataType >, 0); \
defineTemplatedRunTimeSelectionTable(surfaceWriter, word, dataType)
defineSurfaceWriterType(bool);
defineSurfaceWriterType(scalar);
defineSurfaceWriterType(vector);
defineSurfaceWriterType(sphericalTensor);
defineSurfaceWriterType(symmTensor);
defineSurfaceWriterType(tensor);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,76 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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/>.
InClass
Foam::surfaceWriters
Description
\*---------------------------------------------------------------------------*/
#ifndef surfaceWriters_H
#define surfaceWriters_H
#include "surfaceWriter.H"
#include "fieldTypes.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Only used internally
#define makeTypeSurfaceWritersTypeName(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0)
// Sometimes used externally
#define makeSurfaceWritersTypeName(typeWriter) \
\
makeTypeSurfaceWritersTypeName(typeWriter, scalar); \
makeTypeSurfaceWritersTypeName(typeWriter, vector); \
makeTypeSurfaceWritersTypeName(typeWriter, sphericalTensor); \
makeTypeSurfaceWritersTypeName(typeWriter, symmTensor); \
makeTypeSurfaceWritersTypeName(typeWriter, tensor)
// Define type info for single dataType template instantiation (eg, vector)
#define makeSurfaceWriterType(typeWriter, dataType) \
\
defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0); \
addTemplatedToRunTimeSelectionTable \
( \
surfaceWriter, typeWriter, dataType, word \
)
// Define type info for scalar, vector etc. instantiations
#define makeSurfaceWriters(typeWriter) \
\
makeSurfaceWriterType(typeWriter, scalar); \
makeSurfaceWriterType(typeWriter, vector); \
makeSurfaceWriterType(typeWriter, sphericalTensor); \
makeSurfaceWriterType(typeWriter, symmTensor); \
makeSurfaceWriterType(typeWriter, tensor)
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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<class Type>
void Foam::vtkSurfaceWriter<Type>::writeGeometry
void Foam::vtkSurfaceWriter::writeGeometry
(
Ostream& os,
const pointField& points,
@ -71,12 +80,12 @@ void Foam::vtkSurfaceWriter<Type>::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<Type>::writeGeometry
namespace Foam
{
// Write scalarField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::scalar>::writeData
void Foam::vtkSurfaceWriter::writeData
(
Ostream& os,
const Field<Foam::scalar>& values
const Field<scalar>& values
)
{
os << "1 " << values.size() << " float" << nl;
os << "1 " << values.size() << " float" << 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<Foam::vector>::writeData
void Foam::vtkSurfaceWriter::writeData
(
Ostream& os,
const Field<Foam::vector>& values
const Field<vector>& values
)
{
os << "3 " << values.size() << " float" << nl;
os << "3 " << values.size() << " float" << nl;
forAll(values, elemI)
{
@ -133,33 +140,31 @@ namespace Foam
}
// Write sphericalTensorField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::sphericalTensor>::writeData
void Foam::vtkSurfaceWriter::writeData
(
Ostream& os,
const Field<sphericalTensor>& values
)
{
os << "1 " << values.size() << " float" << nl;
os << "1 " << values.size() << " float" << 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<Foam::symmTensor>::writeData
void Foam::vtkSurfaceWriter::writeData
(
Ostream& os,
const Field<symmTensor>& values
)
{
os << "6 " << values.size() << " float" << nl;
os << "6 " << values.size() << " float" << nl;
forAll(values, elemI)
{
@ -172,15 +177,14 @@ namespace Foam
}
// Write tensorField in vtk format
template<>
void Foam::vtkSurfaceWriter<Foam::tensor>::writeData
void Foam::vtkSurfaceWriter::writeData
(
Ostream& os,
const Field<tensor>& values
)
{
os << "9 " << values.size() << " float" << nl;
os << "9 " << values.size() << " float" << nl;
forAll(values, elemI)
{
@ -197,69 +201,23 @@ namespace Foam
// Write generic field in vtk format
template<class Type>
void Foam::vtkSurfaceWriter<Type>::writeData
void Foam::vtkSurfaceWriter::writeData
(
Ostream& os,
const Field<Type>& values
)
{
os << "1 " << values.size() << " float" << nl;
os << "1 " << values.size() << " float" << nl;
forAll(values, elemI)
{
os << float(0) << nl;
os << float(0) << nl;
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class Type>
Foam::vtkSurfaceWriter<Type>::vtkSurfaceWriter()
:
surfaceWriter<Type>()
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::vtkSurfaceWriter<Type>::~vtkSurfaceWriter()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::vtkSurfaceWriter<Type>::write
(
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<class Type>
void Foam::vtkSurfaceWriter<Type>::write
void Foam::vtkSurfaceWriter::writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
@ -276,10 +234,7 @@ void Foam::vtkSurfaceWriter<Type>::write
mkDir(outputDir);
}
OFstream os
(
outputDir/fieldName + '_' + surfaceName + ".vtk"
);
OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk");
if (verbose)
{
@ -304,8 +259,52 @@ void Foam::vtkSurfaceWriter<Type>::write
// 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);
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -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 Type>
class vtkSurfaceWriter
:
public surfaceWriter<Type>
public surfaceWriter
{
// Private Member Functions
static void writeGeometry(Ostream&, const pointField&, const faceList&);
static void writeData(Ostream&, const Field<Type>& values);
template<class Type>
static void writeData(Ostream&, const Field<Type>&);
//- Templated write operation
template<class Type>
void writeTemplate
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const;
public:
//- Runtime type information
@ -75,9 +90,7 @@ public:
// Member Functions
// Write
//- Write geometry to file.
//- Write single surface geometry to file.
virtual void write
(
const fileName& outputDir,
@ -88,18 +101,76 @@ public:
) 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const word& fieldName, // name of field
const Field<scalar>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<vector>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<sphericalTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<symmTensor>& 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, // <root>/<case>/surface/TIME
const fileName& surfaceName, // name of surface
const pointField& points,
const faceList& faces,
const word& fieldName, // name of field
const Field<tensor>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};
@ -109,12 +180,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "vtkSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,44 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
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 "vtkSurfaceWriter.H"
#include "surfaceWriters.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
makeSurfaceWriterType(vtkSurfaceWriter, bool);
makeSurfaceWriters(vtkSurfaceWriter);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //