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;
|
||||
|
||||
|
||||
|
||||
@ -59,22 +59,43 @@ void Foam::ensightPart::writeFieldList
|
||||
const labelUList& idList
|
||||
) const
|
||||
{
|
||||
forAll(idList, i)
|
||||
if (&idList)
|
||||
{
|
||||
if (idList[i] >= field.size() || isnan(field[idList[i]]))
|
||||
forAll(idList, i)
|
||||
{
|
||||
os.writeUndef();
|
||||
}
|
||||
else
|
||||
{
|
||||
os.write(field[idList[i]]);
|
||||
}
|
||||
if (idList[i] >= field.size() || isnan(field[idList[i]]))
|
||||
{
|
||||
os.writeUndef();
|
||||
}
|
||||
else
|
||||
{
|
||||
os.write(field[idList[i]]);
|
||||
}
|
||||
|
||||
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 * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::ensightPart::reconstruct(Istream& is)
|
||||
@ -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,21 +216,30 @@ 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);
|
||||
|
||||
forAll(elementTypes(), elemI)
|
||||
if (perNode)
|
||||
{
|
||||
const labelList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
os.writeKeyword("coordinates");
|
||||
writeFieldList(os, field, labelUList::null());
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(elementTypes(), elemI)
|
||||
{
|
||||
os.writeKeyword(elementTypes()[elemI]);
|
||||
writeFieldList(os, field, idList);
|
||||
const labelUList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
{
|
||||
os.writeKeyword(elementTypes()[elemI]);
|
||||
writeFieldList(os, field, idList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -221,23 +251,34 @@ 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);
|
||||
|
||||
forAll(elementTypes(), elemI)
|
||||
if (perNode)
|
||||
{
|
||||
const labelList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
os.writeKeyword("coordinates");
|
||||
writeFieldList(os, field0, labelUList::null());
|
||||
writeFieldList(os, field1, labelUList::null());
|
||||
writeFieldList(os, field2, labelUList::null());
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(elementTypes(), elemI)
|
||||
{
|
||||
os.writeKeyword(elementTypes()[elemI]);
|
||||
writeFieldList(os, field0, idList);
|
||||
writeFieldList(os, field1, idList);
|
||||
writeFieldList(os, field2, idList);
|
||||
const labelUList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
{
|
||||
os.writeKeyword(elementTypes()[elemI]);
|
||||
writeFieldList(os, field0, idList);
|
||||
writeFieldList(os, field1, idList);
|
||||
writeFieldList(os, field2, idList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,29 +34,46 @@ 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);
|
||||
|
||||
forAll(elementTypes(), elemI)
|
||||
if (perNode)
|
||||
{
|
||||
const labelList& idList = elemLists_[elemI];
|
||||
|
||||
if (idList.size())
|
||||
os.writeKeyword("coordinates");
|
||||
for
|
||||
(
|
||||
direction cmpt=0;
|
||||
cmpt < pTraits<Type>::nComponents;
|
||||
++cmpt
|
||||
)
|
||||
{
|
||||
os.writeKeyword(elementTypes()[elemI]);
|
||||
writeFieldList(os, field.component(cmpt), labelUList::null());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(elementTypes(), elemI)
|
||||
{
|
||||
const labelUList& idList = elemLists_[elemI];
|
||||
|
||||
for
|
||||
(
|
||||
direction cmpt=0;
|
||||
cmpt < pTraits<Type>::nComponents;
|
||||
++cmpt
|
||||
)
|
||||
if (idList.size())
|
||||
{
|
||||
writeFieldList(os, field.component(cmpt), idList);
|
||||
os.writeKeyword(elementTypes()[elemI]);
|
||||
|
||||
for
|
||||
(
|
||||
direction cmpt=0;
|
||||
cmpt < pTraits<Type>::nComponents;
|
||||
++cmpt
|
||||
)
|
||||
{
|
||||
writeFieldList(os, field.component(cmpt), idList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
Reference in New Issue
Block a user