Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
andy
2010-11-10 09:35:58 +00:00
27 changed files with 762 additions and 66 deletions

View File

@ -27,6 +27,7 @@ setFormat raw;
// Surface output format. Choice of
// null : suppress output
// ensight : Ensight Gold format, one field per case file
// foamFile : separate points, faces and values file
// dx : DX scalar or vector format
// vtk : VTK ascii format

View File

@ -20,4 +20,7 @@ streamLine/streamLineParticle.C
streamLine/streamLineParticleCloud.C
streamLine/streamLineFunctionObject.C
surfaceInterpolateFields/surfaceInterpolateFields.C
surfaceInterpolateFields/surfaceInterpolateFieldsFunctionObject.C
LIB = $(FOAM_LIBBIN)/libfieldFunctionObjects

View File

@ -198,11 +198,10 @@ void Foam::fieldValues::cellSource::write()
if (active_)
{
scalar totalVolume = gSum(filterField(mesh().V()));
if (Pstream::master())
{
outputFilePtr_()
<< obr_.time().value() << tab
<< sum(filterField(mesh().V()));
outputFilePtr_() << obr_.time().value() << tab << totalVolume;
}
forAll(fields_, i)

View File

@ -61,11 +61,25 @@ functions
// Output field values as well
valueOutput true;
// Patch or faceZone to sample
// Type of source: patch/faceZone/sampledSurface
source patch;
// if patch or faceZone: name of patch or faceZone
sourceName movingWall;
// source faceZone;
// sourceName f0;
//// if sampledSurface: dictionary with a sampledSurface
//// Note: the sampledSurfaces will have cell-values, i.e.
//// non-interpolated. Also will not sample surface fields.
//sampledSurfaceDict
//{
// type cuttingPlane;
// planeType pointAndNormal;
// pointAndNormalDict
// {
// basePoint (0 0.099 0);
// normalVector (0 1 0);
// }
//}
// Operation: areaAverage/sum/weightedAverage ...
operation areaAverage;
@ -73,7 +87,7 @@ functions
fields
(
p
phi
phi // surface fields not supported for sampledSurface
U
);
}

View File

@ -28,21 +28,20 @@ License
#include "cyclicPolyPatch.H"
#include "emptyPolyPatch.H"
#include "coupledPolyPatch.H"
#include "surfaceFields.H"
#include "volFields.H"
#include "sampledSurface.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::fieldValues::faceSource, 0);
template<>
const char* Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 2>::
const char* Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>::
names[] =
{
"faceZone", "patch"
"faceZone", "patch", "sampledSurface"
};
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 2>
const Foam::NamedEnum<Foam::fieldValues::faceSource::sourceType, 3>
Foam::fieldValues::faceSource::sourceTypeNames_;
@ -188,6 +187,19 @@ void Foam::fieldValues::faceSource::setPatchFaces()
}
void Foam::fieldValues::faceSource::sampledSurfaceFaces(const dictionary& dict)
{
surfacePtr_ = sampledSurface::New
(
name_,
mesh(),
dict.subDict("sampledSurfaceDict")
);
surfacePtr_().update();
nFaces_ = returnReduce(surfacePtr_().faces().size(), sumOp<label>());
}
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
@ -204,20 +216,37 @@ void Foam::fieldValues::faceSource::initialise(const dictionary& dict)
setPatchFaces();
break;
}
case stSampledSurface:
{
sampledSurfaceFaces(dict);
break;
}
default:
{
FatalErrorIn("faceSource::initialise()")
<< type() << " " << name_ << ": "
<< sourceTypeNames_[source_] << "(" << sourceName_ << "):"
<< nl << " Unknown source type. Valid source types are:"
<< sourceTypeNames_ << nl << exit(FatalError);
<< sourceTypeNames_.sortedToc() << nl << exit(FatalError);
}
}
scalar totalArea;
if (surfacePtr_.valid())
{
surfacePtr_().update();
totalArea = gSum(surfacePtr_().magSf());
}
else
{
totalArea = gSum(filterField(mesh().magSf(), false));
}
Info<< type() << " " << name_ << ":" << nl
<< " total faces = " << nFaces_
<< nl
<< " total area = " << gSum(filterField(mesh().magSf(), false))
<< " total area = " << totalArea
<< nl;
if (operation_ == opWeightedAverage)
@ -280,11 +309,11 @@ Foam::fieldValues::faceSource::faceSource
fieldValue(name, obr, dict, loadFromFiles),
source_(sourceTypeNames_.read(dict.lookup("source"))),
operation_(operationTypeNames_.read(dict.lookup("operation"))),
weightFieldName_("undefinedWeightedFieldName"),
nFaces_(0),
faceId_(),
facePatchId_(),
faceSign_(),
weightFieldName_("undefinedWeightedFieldName")
faceSign_()
{
read(dict);
}
@ -315,11 +344,22 @@ void Foam::fieldValues::faceSource::write()
if (active_)
{
scalar totalArea;
if (surfacePtr_.valid())
{
surfacePtr_().update();
totalArea = gSum(surfacePtr_().magSf());
}
else
{
totalArea = gSum(filterField(mesh().magSf(), false));
}
if (Pstream::master())
{
outputFilePtr_()
<< obr_.time().value() << tab
<< sum(filterField(mesh().magSf(), false));
outputFilePtr_() << obr_.time().value() << tab << totalArea;
}
forAll(fields_, i)

View File

@ -36,8 +36,9 @@ Description
outputControl outputTime;
log true; // log to screen?
valueOutput true; // Write values at run-time output times?
source faceZone; // Type of face source: faceZone, patch
sourceName f0;
source faceZone; // Type of face source:
// faceZone,patch,sampledSurface
sourceName f0; // faceZone name, see below
operation sum;
fields
(
@ -47,7 +48,13 @@ Description
);
}
where operation is one of:
source:
- faceZone : requires a 'sourceName' entry to specify the faceZone
- patch : "" patch
- sampledSurface : requires a 'sampledSurfaceDict' subdictionary. See e.g.
sampleDict.
operation is one of:
- none
- sum
- areaAverage
@ -62,6 +69,11 @@ Description
faces.
- all fields get oriented according to the faceZone (so you might e.g. see
negative pressure)
- using sampledSurfaces:
- they do not do surface fields
- they use cell values - they do not do any interpolation.
- take care when using isoSurfaces - these might have duplicate
triangles so integration might be wrong
SourceFiles
faceSource.C
@ -80,6 +92,9 @@ SourceFiles
namespace Foam
{
class sampledSurface;
namespace fieldValues
{
@ -100,11 +115,12 @@ public:
enum sourceType
{
stFaceZone,
stPatch
stPatch,
stSampledSurface
};
//- Source type names
static const NamedEnum<sourceType, 2> sourceTypeNames_;
static const NamedEnum<sourceType, 3> sourceTypeNames_;
//- Operation type enumeration
@ -133,6 +149,9 @@ private:
//- Set faces to evaluate based on a patch
void setPatchFaces();
//- Set faces according to sampledSurface
void sampledSurfaceFaces(const dictionary&);
protected:
@ -144,20 +163,30 @@ protected:
//- Operation to apply to values
operationType operation_;
//- Weight field name - only used for opWeightedAverage mode
word weightFieldName_;
//- Global number of faces
label nFaces_;
//- Local list of face IDs
labelList faceId_;
//- Local list of patch ID per face
labelList facePatchId_;
// If operating on mesh faces (faceZone,patch)
//- List of +1/-1 representing face flip map (1 use as is, -1 negate)
labelList faceSign_;
//- Local list of face IDs
labelList faceId_;
//- Local list of patch ID per face
labelList facePatchId_;
//- List of +1/-1 representing face flip map
// (1 use as is, -1 negate)
labelList faceSign_;
// If operating on sampledSurface
//- underlying sampledSurface
autoPtr<sampledSurface> surfacePtr_;
//- Weight field name - only used for opWeightedAverage mode
word weightFieldName_;
// Protected Member Functions
@ -171,7 +200,7 @@ protected:
//- Return field values by looking up field name
template<class Type>
tmp<Field<Type> > setFieldValues(const word& fieldName) const;
tmp<Field<Type> > getFieldValues(const word& fieldName) const;
//- Apply the 'operation' to the values
template<class Type>

View File

@ -26,7 +26,7 @@ License
#include "faceSource.H"
#include "surfaceFields.H"
#include "volFields.H"
#include "ListListOps.H"
#include "sampledSurface.H"
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
@ -36,7 +36,7 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf;
if (obr_.foundObject<sf>(fieldName))
if (source_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
{
return true;
}
@ -50,7 +50,7 @@ bool Foam::fieldValues::faceSource::validField(const word& fieldName) const
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues
Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::getFieldValues
(
const word& fieldName
) const
@ -58,13 +58,20 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValues::faceSource::setFieldValues
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sf;
typedef GeometricField<Type, fvPatchField, volMesh> vf;
if (obr_.foundObject<sf>(fieldName))
if (source_ != stSampledSurface && obr_.foundObject<sf>(fieldName))
{
return filterField(obr_.lookupObject<sf>(fieldName), true);
}
else if (obr_.foundObject<vf>(fieldName))
{
return filterField(obr_.lookupObject<vf>(fieldName), true);
if (surfacePtr_.valid())
{
return surfacePtr_().sample(obr_.lookupObject<vf>(fieldName));
}
else
{
return filterField(obr_.lookupObject<vf>(fieldName), true);
}
}
return tmp<Field<Type> >(new Field<Type>(0));
@ -131,15 +138,26 @@ bool Foam::fieldValues::faceSource::writeValues(const word& fieldName)
if (ok)
{
// Get (correctly oriented) field
Field<Type> values = combineFields(setFieldValues<Type>(fieldName));
Field<Type> values = getFieldValues<Type>(fieldName);
scalarField weightField = getFieldValues<scalar>(weightFieldName_);
scalarField magSf;
// Get unoriented magSf
scalarField magSf = combineFields(filterField(mesh().magSf(), false));
if (surfacePtr_.valid())
{
// Get unoriented magSf
magSf = surfacePtr_().magSf();
}
else
{
// Get unoriented magSf
magSf = combineFields(filterField(mesh().magSf(), false));
}
// Combine onto master
values = combineFields(values);
magSf = combineFields(magSf);
weightField = combineFields(weightField);
// Get (correctly oriented) weighting field
scalarField weightField =
combineFields(setFieldValues<scalar>(weightFieldName_));
if (Pstream::master())
{

View File

@ -130,7 +130,7 @@ Foam::fieldValue::fieldValue
obr_(obr),
active_(true),
log_(false),
sourceName_(dict.lookup("sourceName")),
sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
fields_(dict.lookup("fields")),
valueOutput_(dict.lookup("valueOutput")),
outputFilePtr_(NULL)

View File

@ -164,12 +164,14 @@ public:
//- Execute the at the final time-loop, currently does nothing
virtual void end();
//- Comnbine fields from all processor domains into single field
//- Combine fields from all processor domains into single field
template<class Type>
tmp<Field<Type> > combineFields
(
const tmp<Field<Type> >& field
) const;
tmp<Field<Type> > combineFields(const Field<Type>& field) const;
//- Combine fields from all processor domains into single field
template<class Type>
tmp<Field<Type> > combineFields(const tmp<Field<Type> >&) const;
};

View File

@ -32,12 +32,12 @@ License
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields
(
const tmp<Field<Type> >& field
const Field<Type>& field
) const
{
List<Field<Type> > allValues(Pstream::nProcs());
allValues[Pstream::myProcNo()] = field();
allValues[Pstream::myProcNo()] = field;
Pstream::gatherList(allValues);
@ -57,9 +57,19 @@ Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields
}
else
{
return field();
return field;
}
}
template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::fieldValue::combineFields
(
const tmp<Field<Type> >& field
) const
{
return combineFields(field());
}
// ************************************************************************* //

View File

@ -46,6 +46,7 @@ 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

View File

@ -103,7 +103,8 @@ void Foam::sampledSurfaces::sampleAndWrite
mergeList_[surfI].points,
mergeList_[surfI].faces,
fieldName,
allValues
allValues,
s.interpolate()
);
}
}
@ -121,7 +122,8 @@ void Foam::sampledSurfaces::sampleAndWrite
s.points(),
s.faces(),
fieldName,
values
values,
s.interpolate()
);
}
}

View File

@ -250,6 +250,7 @@ void Foam::dxSurfaceWriter<Type>::write
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{
@ -272,7 +273,7 @@ void Foam::dxSurfaceWriter<Type>::write
writeData(os, values);
if (values.size() == points.size())
if (isNodeValues)
{
os << nl << "attribute \"dep\" string \"positions\""
<< nl << nl;

View File

@ -88,6 +88,7 @@ public:
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};

View File

@ -0,0 +1,372 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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 "OFstream.H"
#include "OSspecific.H"
#include "IOmanip.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type>
void Foam::ensightSurfaceWriter<Type>::binShapes
(
const pointField& points,
const faceList& faces,
DynamicList<label>& tris,
DynamicList<label>& quads,
DynamicList<label>& polys
)
{
tris.setCapacity(faces.size());
quads.setCapacity(faces.size());
polys.setCapacity(faces.size());
forAll(faces, i)
{
const face& f = faces[i];
if (f.size() == 3)
{
tris.append(i);
}
else if (f.size() == 4)
{
quads.append(i);
}
else
{
polys.append(i);
}
}
}
template<class Type>
void Foam::ensightSurfaceWriter<Type>::writeGeometry
(
const fileName& surfaceName,
Ostream& os,
const pointField& points,
const faceList& faces,
const DynamicList<label>& tris,
const DynamicList<label>& quads,
const DynamicList<label>& polys
)
{
os << "EnSight Geometry File" << nl
<< (string("written by OpenFOAM-") + Foam::FOAMversion).c_str() << nl
<< "node id assign" << nl
<< "element id assign" << nl
<< "part" << nl
<< setw(10) << 1 << nl
<< surfaceName.c_str() << nl;
os << "coordinates" << nl
<< setw(10) << points.size() << nl;
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
{
scalarField v = points.component(cmpt);
forAll(v, i)
{
os << v[i] << nl;
}
}
if (tris.size())
{
os << "tria3" << nl
<< setw(10) << tris.size() << nl;
forAll(tris, i)
{
const face& f = faces[tris[i]];
forAll(f, fp)
{
os << setw(10) << f[fp]+1;
}
os << nl;
}
}
if (quads.size())
{
os << "quad4" << nl
<< setw(10) << quads.size() << nl;
forAll(quads, i)
{
const face& f = faces[quads[i]];
forAll(f, fp)
{
os << setw(10) << f[fp]+1;
}
os << nl;
}
}
if (polys.size())
{
os << "nsided" << nl
<< setw(10) << polys.size() << nl;
forAll(polys, i)
{
const face& f = faces[polys[i]];
forAll(f, fp)
{
os << setw(10) << f[fp]+1;
}
os << nl;
}
}
}
namespace Foam
{
// Write scalarField in ensight format
template<>
void Foam::ensightSurfaceWriter<Foam::scalar>::writeData
(
Ostream& os,
const Field<Foam::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;
}
}
}
// Write generic field in ensight format
template<class Type>
void Foam::ensightSurfaceWriter<Type>::writeData
(
Ostream& os,
const Field<Type>& values
)
{
for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++)
{
scalarField v = values.component(cmpt);
forAll(v, i)
{
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");
OFstream geomStr(outputDir/surfaceName + ".***.mesh");
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;
DynamicList<label> tris;
DynamicList<label> quads;
DynamicList<label> polys;
binShapes(points, faces, tris, quads, polys);
writeGeometry(surfaceName, geomStr, points, faces, tris, quads, polys);
}
template<class Type>
void Foam::ensightSurfaceWriter<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
{
if (!isDir(outputDir/fieldName))
{
mkDir(outputDir/fieldName);
}
//const scalar timeValue = Foam::name(this->mesh().time().timeValue());
const scalar timeValue = 0.0;
OFstream caseStr(outputDir/fieldName/surfaceName + ".case");
OFstream geomStr(outputDir/fieldName/surfaceName + ".000.mesh");
OFstream fieldStr(outputDir/fieldName/surfaceName + ".000." + fieldName);
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
<< "VARIABLE" << nl;
if (isNodeValues)
{
caseStr
<< pTraits<Type>::typeName << " per node:" << setw(10) << 1
<< " " << fieldName
<< " " << surfaceName.c_str() << ".***." << fieldName << nl;
}
else
{
caseStr
<< pTraits<Type>::typeName << " per element:" << setw(10) << 1
<< " " << fieldName
<< " " << surfaceName.c_str() << ".***." << fieldName << nl;
}
caseStr
<< 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;
DynamicList<label> tris;
DynamicList<label> quads;
DynamicList<label> polys;
binShapes(points, faces, tris, quads, polys);
writeGeometry(surfaceName, geomStr, points, faces, tris, quads, polys);
// Write field
fieldStr
<< pTraits<Type>::typeName << nl
<< "part" << nl
<< setw(10) << 1 << nl;
if (isNodeValues)
{
fieldStr << "coordinates" << nl;
writeData(fieldStr, values);
}
else
{
if (tris.size())
{
fieldStr << "tria3" << nl;
writeData(fieldStr, Field<Type>(values, tris));
}
if (quads.size())
{
fieldStr << "quad4" << nl;
writeData(fieldStr, Field<Type>(values, quads));
}
if (polys.size())
{
fieldStr << "nsided" << nl;
writeData(fieldStr, Field<Type>(values, polys));
}
}
}
// ************************************************************************* //

View File

@ -0,0 +1,138 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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/>.
Class
Foam::ensightSurfaceWriter
Description
SourceFiles
ensightSurfaceWriter.C
\*---------------------------------------------------------------------------*/
#ifndef ensightSurfaceWriter_H
#define ensightSurfaceWriter_H
#include "surfaceWriter.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class ensightSurfaceWriter Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class ensightSurfaceWriter
:
public surfaceWriter<Type>
{
// Private Member Functions
static void binShapes
(
const pointField& points,
const faceList& faces,
DynamicList<label>& tris,
DynamicList<label>& quads,
DynamicList<label>& polys
);
static void writeGeometry
(
const fileName&,
Ostream&,
const pointField&,
const faceList&,
const DynamicList<label>&,
const DynamicList<label>&,
const DynamicList<label>&
);
static void writeData(Ostream&, const Field<Type>& values);
public:
//- Runtime type information
TypeName("ensight");
// Constructors
//- Construct null
ensightSurfaceWriter();
//- Destructor
virtual ~ensightSurfaceWriter();
// Member Functions
// Write
//- Write geometry to file.
virtual void write
(
const fileName& outputDir,
const fileName& surfaceName,
const pointField& points,
const faceList& faces,
const bool verbose = false
) const;
//- 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 "ensightSurfaceWriter.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,44 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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

@ -96,6 +96,7 @@ void Foam::foamFileSurfaceWriter<Type>::write
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{

View File

@ -95,6 +95,7 @@ public:
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};

View File

@ -54,6 +54,7 @@ void Foam::nullSurfaceWriter<Type>::write
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{}

View File

@ -80,6 +80,7 @@ public:
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};

View File

@ -102,6 +102,7 @@ public:
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const
{}

View File

@ -68,6 +68,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
const pointField& points,
const faceList& faces,
const scalarField& values,
const bool isNodeValues,
Ostream& os
)
{
@ -75,7 +76,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
os << "# x y z " << fieldName << endl;
// Write data
if (values.size() == points.size())
if (isNodeValues)
{
forAll(values, elemI)
{
@ -104,6 +105,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
const pointField& points,
const faceList& faces,
const vectorField& values,
const bool isNodeValues,
Ostream& os
)
{
@ -115,7 +117,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
<< endl;
// Write data
if (values.size() == points.size())
if (isNodeValues)
{
forAll(values, elemI)
{
@ -147,6 +149,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
const pointField& points,
const faceList& faces,
const sphericalTensorField& values,
const bool isNodeValues,
Ostream& os
)
{
@ -155,7 +158,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
os << fieldName << "_ii" << endl;
// Write data
if (values.size() == points.size())
if (isNodeValues)
{
forAll(values, elemI)
{
@ -186,6 +189,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
const pointField& points,
const faceList& faces,
const symmTensorField& values,
const bool isNodeValues,
Ostream& os
)
{
@ -198,7 +202,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
os << endl;
// Write data
if (values.size() == points.size())
if (isNodeValues)
{
forAll(values, elemI)
{
@ -233,6 +237,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
const pointField& points,
const faceList& faces,
const tensorField& values,
const bool isNodeValues,
Ostream& os
)
{
@ -245,7 +250,7 @@ void Foam::rawSurfaceWriter<Type>::writeData
os << endl;
// Write data
if (values.size() == points.size())
if (isNodeValues)
{
forAll(values, elemI)
{
@ -343,6 +348,7 @@ namespace Foam
const faceList& faces,
const word& fieldName,
const Field<bool>& values,
const bool isNodeValues,
const bool verbose
) const
{}
@ -358,6 +364,7 @@ void Foam::rawSurfaceWriter<Type>::write
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{
@ -379,7 +386,7 @@ void Foam::rawSurfaceWriter<Type>::write
// header
os << "# " << fieldName;
if (values.size() == points.size())
if (isNodeValues)
{
os << " POINT_DATA ";
}
@ -390,7 +397,7 @@ void Foam::rawSurfaceWriter<Type>::write
os << values.size() << nl;
writeData(fieldName, points, faces, values, os);
writeData(fieldName, points, faces, values, isNodeValues, os);
}

View File

@ -73,6 +73,7 @@ class rawSurfaceWriter
const pointField& points,
const faceList& faces,
const scalarField& values,
const bool isNodeValues,
Ostream& os
);
@ -82,6 +83,7 @@ class rawSurfaceWriter
const pointField& points,
const faceList& faces,
const vectorField& values,
const bool isNodeValues,
Ostream& os
);
@ -91,6 +93,7 @@ class rawSurfaceWriter
const pointField& points,
const faceList& faces,
const sphericalTensorField& values,
const bool isNodeValues,
Ostream& os
);
@ -100,6 +103,7 @@ class rawSurfaceWriter
const pointField& points,
const faceList& faces,
const symmTensorField& values,
const bool isNodeValues,
Ostream& os
);
@ -109,6 +113,7 @@ class rawSurfaceWriter
const pointField& points,
const faceList& faces,
const tensorField& values,
const bool isNodeValues,
Ostream& os
);
@ -152,6 +157,7 @@ public:
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};

View File

@ -119,7 +119,7 @@ public:
//- Writes single surface to file. Either one value per vertex or
// one value per face (detected by values.size()==faces.size())
// one value per face (isNodeValues = false)
virtual void write
(
const fileName& outputDir, // <root>/<case>/surface/TIME
@ -128,6 +128,7 @@ public:
const faceList& faces,
const word& fieldName, // name of field
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const = 0;
};

View File

@ -267,6 +267,7 @@ void Foam::vtkSurfaceWriter<Type>::write
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose
) const
{
@ -288,7 +289,7 @@ void Foam::vtkSurfaceWriter<Type>::write
writeGeometry(os, points, faces);
// start writing data
if (values.size() == points.size())
if (isNodeValues)
{
os << "POINT_DATA ";
}

View File

@ -97,6 +97,7 @@ public:
const faceList& faces,
const word& fieldName,
const Field<Type>& values,
const bool isNodeValues,
const bool verbose = false
) const;
};