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