mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: add perNode field writing to ensight/part/ensightPart*
- simplify the ensightSurfaceWriter accordingly
This commit is contained in:
@ -45,11 +45,11 @@ bool Foam::ensightPart::isFieldDefined(const List<scalar>& field) const
|
||||
{
|
||||
forAll(elemLists_, elemI)
|
||||
{
|
||||
const labelList& idList = elemLists_[elemI];
|
||||
const labelUList& idList = elemLists_[elemI];
|
||||
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i];
|
||||
const label id = idList[i];
|
||||
|
||||
if (id >= field.size() || isnan(field[id]))
|
||||
{
|
||||
@ -159,7 +159,7 @@ Foam::ensightPart::~ensightPart()
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ensightPart::renumber(const labelList& origId)
|
||||
void Foam::ensightPart::renumber(const labelUList& origId)
|
||||
{
|
||||
// transform to global values first
|
||||
if (offset_)
|
||||
|
||||
@ -134,6 +134,7 @@ protected:
|
||||
void writeHeader(ensightFile&, bool withDescription=false) const;
|
||||
|
||||
//- write a scalar field for idList
|
||||
// A null reference for idList writes the perNode values
|
||||
void writeFieldList
|
||||
(
|
||||
ensightFile& os,
|
||||
@ -150,10 +151,10 @@ protected:
|
||||
//- write connectivities
|
||||
virtual void writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
ensightGeoFile&,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
const labelUList& idList,
|
||||
const labelUList& pointMap
|
||||
) const
|
||||
{}
|
||||
|
||||
@ -287,7 +288,7 @@ public:
|
||||
// Edit
|
||||
|
||||
//- renumber elements
|
||||
void renumber(const labelList&);
|
||||
void renumber(const labelUList&);
|
||||
|
||||
//- write summary information about the object
|
||||
bool writeSummary(Ostream&) const;
|
||||
@ -303,28 +304,34 @@ public:
|
||||
void writeGeometry(ensightGeoFile&, const pointField&) const;
|
||||
|
||||
//- write scalar field
|
||||
// optionally write data per node
|
||||
void writeScalarField
|
||||
(
|
||||
ensightFile&,
|
||||
const List<scalar>& field
|
||||
const List<scalar>& field,
|
||||
const bool perNode = false
|
||||
) const;
|
||||
|
||||
//- write vector field components
|
||||
// optionally write data per node
|
||||
void writeVectorField
|
||||
(
|
||||
ensightFile&,
|
||||
const List<scalar>& field0,
|
||||
const List<scalar>& field1,
|
||||
const List<scalar>& field2
|
||||
const List<scalar>& field2,
|
||||
const bool perNode = false
|
||||
) const;
|
||||
|
||||
|
||||
//- write generalized field components
|
||||
// optionally write data per node
|
||||
template<class Type>
|
||||
void writeField
|
||||
(
|
||||
ensightFile&,
|
||||
const Field<Type>&
|
||||
const Field<Type>&,
|
||||
const bool perNode = false
|
||||
) const;
|
||||
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ const Foam::List<Foam::word> Foam::ensightPartCells::elemTypes_
|
||||
void Foam::ensightPartCells::classify
|
||||
(
|
||||
const polyMesh& mesh,
|
||||
const labelList& idList
|
||||
const labelUList& idList
|
||||
)
|
||||
{
|
||||
// References to cell shape models
|
||||
@ -203,7 +203,7 @@ Foam::ensightPartCells::ensightPartCells
|
||||
(
|
||||
label partNumber,
|
||||
const polyMesh& mesh,
|
||||
const labelList& idList
|
||||
const labelUList& idList
|
||||
)
|
||||
:
|
||||
ensightPart(partNumber, "cells", mesh.points()),
|
||||
@ -259,13 +259,13 @@ Foam::ensightPart::localPoints Foam::ensightPartCells::calcLocalPoints() const
|
||||
|
||||
forAll(elemLists_, typeI)
|
||||
{
|
||||
const labelList& idList = elemLists_[typeI];
|
||||
const labelUList& idList = elemLists_[typeI];
|
||||
|
||||
// add all points from cells
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const labelList& cFaces = mesh_.cells()[id];
|
||||
const label id = idList[i] + offset_;
|
||||
const labelUList& cFaces = mesh_.cells()[id];
|
||||
|
||||
forAll(cFaces, cFaceI)
|
||||
{
|
||||
@ -301,8 +301,8 @@ void Foam::ensightPartCells::writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
const labelUList& idList,
|
||||
const labelUList& pointMap
|
||||
) const
|
||||
{
|
||||
os.writeKeyword(key);
|
||||
@ -317,8 +317,8 @@ void Foam::ensightPartCells::writeConnectivity
|
||||
// write the number of faces per element
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const labelList& cFace = mesh_.cells()[id];
|
||||
const label id = idList[i] + offset_;
|
||||
const labelUList& cFace = mesh_.cells()[id];
|
||||
|
||||
os.write(cFace.size());
|
||||
os.newline();
|
||||
@ -327,8 +327,8 @@ void Foam::ensightPartCells::writeConnectivity
|
||||
// write the number of points per element face
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const labelList& cFace = mesh_.cells()[id];
|
||||
const label id = idList[i] + offset_;
|
||||
const labelUList& cFace = mesh_.cells()[id];
|
||||
|
||||
forAll(cFace, faceI)
|
||||
{
|
||||
@ -342,8 +342,8 @@ void Foam::ensightPartCells::writeConnectivity
|
||||
// write the points describing each element face
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const labelList& cFace = mesh_.cells()[id];
|
||||
const label id = idList[i] + offset_;
|
||||
const labelUList& cFace = mesh_.cells()[id];
|
||||
|
||||
forAll(cFace, faceI)
|
||||
{
|
||||
@ -366,7 +366,7 @@ void Foam::ensightPartCells::writeConnectivity
|
||||
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const label id = idList[i] + offset_;
|
||||
const cellShape& cellPoints = cellShapes[id];
|
||||
|
||||
// convert global -> local index
|
||||
|
||||
@ -60,7 +60,7 @@ class ensightPartCells
|
||||
void classify
|
||||
(
|
||||
const polyMesh&,
|
||||
const labelList& idLabels = labelList::null()
|
||||
const labelUList& idLabels = labelUList::null()
|
||||
);
|
||||
|
||||
//- track points used
|
||||
@ -72,10 +72,10 @@ class ensightPartCells
|
||||
//- element connectivity
|
||||
virtual void writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
ensightGeoFile&,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
const labelUList& idList,
|
||||
const labelUList& pointMap
|
||||
) const;
|
||||
|
||||
|
||||
@ -121,7 +121,7 @@ public:
|
||||
(
|
||||
label partNumber,
|
||||
const polyMesh&,
|
||||
const labelList&
|
||||
const labelUList&
|
||||
);
|
||||
|
||||
//- Construct from polyMesh and cellZone
|
||||
|
||||
@ -217,12 +217,12 @@ Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const
|
||||
|
||||
forAll(elemLists_, typeI)
|
||||
{
|
||||
const labelList& idList = elemLists_[typeI];
|
||||
const labelUList& idList = elemLists_[typeI];
|
||||
|
||||
// add all points from faces
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const label id = idList[i] + offset_;
|
||||
const face& f = faces_[id];
|
||||
|
||||
forAll(f, fp)
|
||||
@ -255,8 +255,8 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const faceList& faces,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
const labelUList& idList,
|
||||
const labelUList& pointMap
|
||||
) const
|
||||
{
|
||||
os.writeKeyword(key);
|
||||
@ -269,7 +269,7 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
// write the number of points per face
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const label id = idList[i] + offset_;
|
||||
const face& f = faces[id];
|
||||
|
||||
os.write(f.size());
|
||||
@ -280,7 +280,7 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
// write the points describing the face
|
||||
forAll(idList, i)
|
||||
{
|
||||
label id = idList[i] + offset_;
|
||||
const label id = idList[i] + offset_;
|
||||
const face& f = faces[id];
|
||||
|
||||
// convert global -> local index
|
||||
@ -298,8 +298,8 @@ void Foam::ensightPartFaces::writeConnectivity
|
||||
(
|
||||
ensightGeoFile& os,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
const labelUList& idList,
|
||||
const labelUList& pointMap
|
||||
) const
|
||||
{
|
||||
writeConnectivity
|
||||
|
||||
@ -63,8 +63,8 @@ class ensightPartFaces
|
||||
(
|
||||
ensightGeoFile&,
|
||||
const word& key,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
const labelUList& idList,
|
||||
const labelUList& pointMap
|
||||
) const;
|
||||
|
||||
|
||||
@ -104,8 +104,8 @@ protected:
|
||||
ensightGeoFile&,
|
||||
const word& key,
|
||||
const faceList&,
|
||||
const labelList& idList,
|
||||
const labelList& pointMap
|
||||
const labelUList& idList,
|
||||
const labelUList& pointMap
|
||||
) const;
|
||||
|
||||
|
||||
|
||||
@ -58,6 +58,8 @@ void Foam::ensightPart::writeFieldList
|
||||
const List<scalar>& field,
|
||||
const labelUList& idList
|
||||
) const
|
||||
{
|
||||
if (&idList)
|
||||
{
|
||||
forAll(idList, i)
|
||||
{
|
||||
@ -73,6 +75,25 @@ void Foam::ensightPart::writeFieldList
|
||||
os.newline();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// no idList => perNode
|
||||
forAll(field, i)
|
||||
{
|
||||
if (isnan(field[i]))
|
||||
{
|
||||
os.writeUndef();
|
||||
}
|
||||
else
|
||||
{
|
||||
os.write(field[i]);
|
||||
}
|
||||
|
||||
os.newline();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
@ -153,7 +174,7 @@ void Foam::ensightPart::writeGeometry
|
||||
if (size())
|
||||
{
|
||||
const localPoints ptList = calcLocalPoints();
|
||||
const labelList& pointMap = ptList.list;
|
||||
const labelUList& pointMap = ptList.list;
|
||||
|
||||
writeHeader(os, true);
|
||||
|
||||
@ -195,16 +216,24 @@ void Foam::ensightPart::writeGeometry
|
||||
void Foam::ensightPart::writeScalarField
|
||||
(
|
||||
ensightFile& os,
|
||||
const List<scalar>& field
|
||||
const List<scalar>& field,
|
||||
const bool perNode
|
||||
) const
|
||||
{
|
||||
if (size() && field.size() && (os.allowUndef() || isFieldDefined(field)))
|
||||
{
|
||||
writeHeader(os);
|
||||
|
||||
if (perNode)
|
||||
{
|
||||
os.writeKeyword("coordinates");
|
||||
writeFieldList(os, field, labelUList::null());
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(elementTypes(), elemI)
|
||||
{
|
||||
const labelList& idList = elemLists_[elemI];
|
||||
const labelUList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
{
|
||||
@ -214,6 +243,7 @@ void Foam::ensightPart::writeScalarField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::ensightPart::writeVectorField
|
||||
@ -221,16 +251,26 @@ void Foam::ensightPart::writeVectorField
|
||||
ensightFile& os,
|
||||
const List<scalar>& field0,
|
||||
const List<scalar>& field1,
|
||||
const List<scalar>& field2
|
||||
const List<scalar>& field2,
|
||||
const bool perNode
|
||||
) const
|
||||
{
|
||||
if (size() && field0.size() && (os.allowUndef() || isFieldDefined(field0)))
|
||||
{
|
||||
writeHeader(os);
|
||||
|
||||
if (perNode)
|
||||
{
|
||||
os.writeKeyword("coordinates");
|
||||
writeFieldList(os, field0, labelUList::null());
|
||||
writeFieldList(os, field1, labelUList::null());
|
||||
writeFieldList(os, field2, labelUList::null());
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(elementTypes(), elemI)
|
||||
{
|
||||
const labelList& idList = elemLists_[elemI];
|
||||
const labelUList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
{
|
||||
@ -242,6 +282,7 @@ void Foam::ensightPart::writeVectorField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
@ -34,16 +34,32 @@ template<class Type>
|
||||
void Foam::ensightPart::writeField
|
||||
(
|
||||
ensightFile& os,
|
||||
const Field<Type>& field
|
||||
const Field<Type>& field,
|
||||
const bool perNode
|
||||
) const
|
||||
{
|
||||
if (this->size() && field.size())
|
||||
{
|
||||
writeHeader(os);
|
||||
|
||||
if (perNode)
|
||||
{
|
||||
os.writeKeyword("coordinates");
|
||||
for
|
||||
(
|
||||
direction cmpt=0;
|
||||
cmpt < pTraits<Type>::nComponents;
|
||||
++cmpt
|
||||
)
|
||||
{
|
||||
writeFieldList(os, field.component(cmpt), labelUList::null());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(elementTypes(), elemI)
|
||||
{
|
||||
const labelList& idList = elemLists_[elemI];
|
||||
const labelUList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
{
|
||||
@ -62,6 +78,7 @@ void Foam::ensightPart::writeField
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -107,7 +107,7 @@ void Foam::ensightParts::recalculate(const polyMesh& mesh)
|
||||
|
||||
forAll(mesh.cellZones(), zoneI)
|
||||
{
|
||||
const labelList& idList = mesh.cellZones()[zoneI];
|
||||
const labelUList& idList = mesh.cellZones()[zoneI];
|
||||
|
||||
forAll(idList, i)
|
||||
{
|
||||
@ -162,8 +162,8 @@ void Foam::ensightParts::recalculate(const polyMesh& mesh)
|
||||
|
||||
void Foam::ensightParts::renumber
|
||||
(
|
||||
const labelList& origCellId,
|
||||
const labelList& origFaceId
|
||||
const labelUList& origCellId,
|
||||
const labelUList& origFaceId
|
||||
)
|
||||
{
|
||||
forAll(partsList_, partI)
|
||||
@ -228,7 +228,8 @@ void Foam::ensightParts::writeScalarField
|
||||
(
|
||||
ensightFile& os,
|
||||
const List<scalar>& field,
|
||||
bool useFaceData
|
||||
const bool useFaceData,
|
||||
const bool perNode
|
||||
) const
|
||||
{
|
||||
forAll(partsList_, partI)
|
||||
@ -240,7 +241,7 @@ void Foam::ensightParts::writeScalarField
|
||||
: partsList_[partI].isCellData()
|
||||
)
|
||||
{
|
||||
partsList_[partI].writeScalarField(os,field);
|
||||
partsList_[partI].writeScalarField(os, field, perNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -252,7 +253,8 @@ void Foam::ensightParts::writeVectorField
|
||||
const List<scalar>& field0,
|
||||
const List<scalar>& field1,
|
||||
const List<scalar>& field2,
|
||||
bool useFaceData
|
||||
const bool useFaceData,
|
||||
const bool perNode
|
||||
) const
|
||||
{
|
||||
forAll(partsList_, partI)
|
||||
@ -264,7 +266,12 @@ void Foam::ensightParts::writeVectorField
|
||||
: partsList_[partI].isCellData()
|
||||
)
|
||||
{
|
||||
partsList_[partI].writeVectorField(os, field0, field1, field2);
|
||||
partsList_[partI].writeVectorField
|
||||
(
|
||||
os,
|
||||
field0, field1, field2,
|
||||
perNode
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -89,8 +89,8 @@ public:
|
||||
//- renumber elements
|
||||
void renumber
|
||||
(
|
||||
const labelList& origCellId,
|
||||
const labelList& origFaceId
|
||||
const labelUList& origCellId,
|
||||
const labelUList& origFaceId
|
||||
);
|
||||
|
||||
//- number of parts
|
||||
@ -108,26 +108,32 @@ public:
|
||||
//- write the lists
|
||||
void writeData(Ostream&) const;
|
||||
|
||||
//- write scalar field
|
||||
//- write (volume) scalar field
|
||||
// optionally write data for face parts
|
||||
// optionally write data per node
|
||||
void writeScalarField
|
||||
(
|
||||
ensightFile&,
|
||||
const List<scalar>& field,
|
||||
bool useFaceData = false
|
||||
const bool useFaceData = false,
|
||||
const bool perNode = false
|
||||
) const;
|
||||
|
||||
//- write vector field components
|
||||
//- write (volume) vector field components
|
||||
// optionally write data for face parts
|
||||
// optionally write data per node
|
||||
void writeVectorField
|
||||
(
|
||||
ensightFile&,
|
||||
const List<scalar>& field0,
|
||||
const List<scalar>& field1,
|
||||
const List<scalar>& field2,
|
||||
bool useFaceData = false
|
||||
const bool useFaceData = false,
|
||||
const bool perNode = false
|
||||
) const;
|
||||
|
||||
|
||||
//- write generalized field components
|
||||
//- write generalized volume field components
|
||||
template<class Type>
|
||||
void writeField
|
||||
(
|
||||
|
||||
@ -221,10 +221,10 @@ void Foam::sampledSurfaces::read(const dictionary& dict)
|
||||
|
||||
dict.lookup("interpolationScheme") >> interpolationScheme_;
|
||||
|
||||
word writeFormat(dict.lookup("surfaceFormat"));
|
||||
word writeType(dict.lookup("surfaceFormat"));
|
||||
|
||||
// define the surface formatter
|
||||
formatter_ = surfaceWriter::New(writeFormat);
|
||||
formatter_ = surfaceWriter::New(writeType);
|
||||
|
||||
PtrList<sampledSurface> newList
|
||||
(
|
||||
|
||||
@ -42,44 +42,6 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Write scalarField in ensight format
|
||||
template<>
|
||||
inline void Foam::ensightSurfaceWriter::writeData
|
||||
(
|
||||
Ostream& os,
|
||||
const Field<scalar>& values
|
||||
)
|
||||
{
|
||||
forAll(values, i)
|
||||
{
|
||||
os << values[i] << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Write generic field in ensight format
|
||||
template<class Type>
|
||||
inline void Foam::ensightSurfaceWriter::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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::ensightSurfaceWriter::writeTemplate
|
||||
(
|
||||
@ -101,47 +63,35 @@ void Foam::ensightSurfaceWriter::writeTemplate
|
||||
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
||||
const scalar timeValue = 0.0;
|
||||
|
||||
OFstream caseStr(outputDir/fieldName/surfaceName + ".case");
|
||||
ensightGeoFile geomStr
|
||||
OFstream osCase(outputDir/fieldName/surfaceName + ".case");
|
||||
ensightGeoFile osGeom
|
||||
(
|
||||
outputDir/fieldName/surfaceName + ".000.mesh",
|
||||
IOstream::ASCII
|
||||
writeFormat_
|
||||
);
|
||||
ensightFile fieldStr
|
||||
ensightFile osField
|
||||
(
|
||||
outputDir/fieldName/surfaceName + ".000." + fieldName,
|
||||
IOstream::ASCII
|
||||
writeFormat_
|
||||
);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing case file to " << caseStr.name() << endl;
|
||||
Info<< "Writing case file to " << osCase.name() << endl;
|
||||
}
|
||||
|
||||
caseStr
|
||||
osCase
|
||||
<< "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << geomStr.name().name() << nl
|
||||
<< "model: 1 " << osGeom.name().name() << nl
|
||||
<< nl
|
||||
<< "VARIABLE" << nl;
|
||||
if (isNodeValues)
|
||||
{
|
||||
caseStr
|
||||
<< pTraits<Type>::typeName << " per node:" << setw(10) << 1
|
||||
<< "VARIABLE" << nl
|
||||
<< pTraits<Type>::typeName << " per "
|
||||
<< word(isNodeValues ? "node:" : "element:") << 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
|
||||
<< " " << surfaceName.c_str() << ".***." << fieldName << nl
|
||||
<< nl
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
@ -152,40 +102,12 @@ void Foam::ensightSurfaceWriter::writeTemplate
|
||||
<< timeValue << nl
|
||||
<< nl;
|
||||
|
||||
ensightPartFaces ensPart(0, geomStr.name().name(), points, faces, true);
|
||||
geomStr << ensPart;
|
||||
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
||||
osGeom << ensPart;
|
||||
|
||||
// Write field
|
||||
fieldStr
|
||||
<< pTraits<Type>::typeName << nl
|
||||
<< "part" << nl
|
||||
<< setw(10) << 1 << nl;
|
||||
|
||||
if (isNodeValues)
|
||||
{
|
||||
fieldStr << "coordinates" << nl;
|
||||
writeData(fieldStr, values);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ensPart.writeField(fieldStr, values);
|
||||
forAll(ensPart.elementTypes(), elemI)
|
||||
{
|
||||
if (ensPart.elemLists()[elemI].size())
|
||||
{
|
||||
fieldStr.writeKeyword(ensPart.elementTypes()[elemI]);
|
||||
writeData
|
||||
(
|
||||
fieldStr,
|
||||
Field<Type>
|
||||
(
|
||||
values,
|
||||
ensPart.elemLists()[elemI]
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
osField.writeKeyword(pTraits<Type>::typeName);
|
||||
ensPart.writeField(osField, values, isNodeValues);
|
||||
}
|
||||
|
||||
|
||||
@ -193,7 +115,8 @@ void Foam::ensightSurfaceWriter::writeTemplate
|
||||
|
||||
Foam::ensightSurfaceWriter::ensightSurfaceWriter()
|
||||
:
|
||||
surfaceWriter()
|
||||
surfaceWriter(),
|
||||
writeFormat_(IOstream::ASCII)
|
||||
{}
|
||||
|
||||
|
||||
@ -222,25 +145,24 @@ void Foam::ensightSurfaceWriter::write
|
||||
// const scalar timeValue = Foam::name(this->mesh().time().timeValue());
|
||||
const scalar timeValue = 0.0;
|
||||
|
||||
|
||||
OFstream caseStr(outputDir/surfaceName + ".case");
|
||||
ensightGeoFile geomStr
|
||||
OFstream osCase(outputDir/surfaceName + ".case");
|
||||
ensightGeoFile osGeom
|
||||
(
|
||||
outputDir/surfaceName + ".000.mesh",
|
||||
IOstream::ASCII
|
||||
writeFormat_
|
||||
);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
Info<< "Writing case file to " << caseStr.name() << endl;
|
||||
Info<< "Writing case file to " << osCase.name() << endl;
|
||||
}
|
||||
|
||||
caseStr
|
||||
osCase
|
||||
<< "FORMAT" << nl
|
||||
<< "type: ensight gold" << nl
|
||||
<< nl
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 " << geomStr.name().name() << nl
|
||||
<< "model: 1 " << osGeom.name().name() << nl
|
||||
<< nl
|
||||
<< "TIME" << nl
|
||||
<< "time set: 1" << nl
|
||||
@ -251,8 +173,8 @@ void Foam::ensightSurfaceWriter::write
|
||||
<< timeValue << nl
|
||||
<< nl;
|
||||
|
||||
ensightPartFaces ensPart(0, geomStr.name().name(), points, faces, true);
|
||||
geomStr << ensPart;
|
||||
ensightPartFaces ensPart(0, osGeom.name().name(), points, faces, true);
|
||||
osGeom << ensPart;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -52,18 +52,12 @@ class ensightSurfaceWriter
|
||||
{
|
||||
// Private data
|
||||
|
||||
// fileName caseFileName_;
|
||||
// fileName surfaceName_;
|
||||
// fileName geomName_;
|
||||
// DynamicList<word> varNames_;
|
||||
// DynamicList<fileName> varFileNames_;
|
||||
//- Write option (default is IOstream::ASCII
|
||||
IOstream::streamFormat writeFormat_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
template<class Type>
|
||||
static inline void writeData(Ostream&, const Field<Type>&);
|
||||
|
||||
//- Templated write operation
|
||||
template<class Type>
|
||||
void writeTemplate
|
||||
|
||||
@ -74,7 +74,7 @@ public:
|
||||
// Selectors
|
||||
|
||||
//- Return a reference to the selected surfaceWriter
|
||||
static autoPtr<surfaceWriter> New(const word& writeFormat);
|
||||
static autoPtr<surfaceWriter> New(const word& writeType);
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
Reference in New Issue
Block a user