mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: foamToEnsight: cellZone support
This commit is contained in:
@ -356,25 +356,29 @@ void ensightField
|
||||
|
||||
ensightStream& ensightFile = *ensightFilePtr;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (timeIndex == 0)
|
||||
{
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
|
||||
ensightCaseFile
|
||||
<< ensightPTraits<Type>::typeName
|
||||
<< " per element: 1 "
|
||||
<< setw(15) << vf.name()
|
||||
<< (' ' + prepend + "****." + vf.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
||||
}
|
||||
|
||||
if (patchNames.empty())
|
||||
{
|
||||
eMesh.barrier();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (timeIndex == 0)
|
||||
{
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
|
||||
ensightCaseFile
|
||||
<< ensightPTraits<Type>::typeName
|
||||
<< " per element: 1 "
|
||||
<< setw(15) << vf.name()
|
||||
<< (' ' + prepend + "****." + vf.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
||||
ensightFile.writePartHeader(1);
|
||||
}
|
||||
|
||||
@ -570,25 +574,29 @@ void ensightPointField
|
||||
|
||||
ensightStream& ensightFile = *ensightFilePtr;
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (timeIndex == 0)
|
||||
{
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
|
||||
ensightCaseFile
|
||||
<< ensightPTraits<Type>::typeName
|
||||
<< " per node: 1 "
|
||||
<< setw(15) << pf.name()
|
||||
<< (' ' + prepend + "****." + pf.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
||||
}
|
||||
|
||||
if (eMesh.patchNames().empty())
|
||||
{
|
||||
eMesh.barrier();
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
if (timeIndex == 0)
|
||||
{
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
|
||||
ensightCaseFile
|
||||
<< ensightPTraits<Type>::typeName
|
||||
<< " per node: 1 "
|
||||
<< setw(15) << pf.name()
|
||||
<< (' ' + prepend + "****." + pf.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
ensightFile.write(ensightPTraits<Type>::typeName);
|
||||
ensightFile.writePartHeader(1);
|
||||
}
|
||||
|
||||
|
||||
@ -260,7 +260,10 @@ void Foam::ensightMesh::correct()
|
||||
// faceZones
|
||||
if (faceZones_)
|
||||
{
|
||||
const wordList faceZoneNamesAll = mesh_.faceZones().names();
|
||||
wordList faceZoneNamesAll = mesh_.faceZones().names();
|
||||
// Need to sort the list of all face zones since the index may vary
|
||||
// from processor to processor...
|
||||
sort(faceZoneNamesAll);
|
||||
|
||||
// Find faceZone names which match that requested at command-line
|
||||
forAll(faceZoneNamesAll, nameI)
|
||||
@ -300,15 +303,16 @@ void Foam::ensightMesh::correct()
|
||||
// Count face types in each faceZone
|
||||
forAll(faceZoneNamesAll, zoneI)
|
||||
{
|
||||
//const word& zoneName = faceZoneNamesAll[zoneI];
|
||||
const word& zoneName = faceZoneNamesAll[zoneI];
|
||||
const label faceZoneId = mesh_.faceZones().findZoneID(zoneName);
|
||||
|
||||
const faceZone& fz = mesh_.faceZones()[zoneI];
|
||||
const faceZone& fz = mesh_.faceZones()[faceZoneId];
|
||||
|
||||
if (fz.size())
|
||||
{
|
||||
labelList& tris = faceZoneFaceSets_[zoneI].tris;
|
||||
labelList& quads = faceZoneFaceSets_[zoneI].quads;
|
||||
labelList& polys = faceZoneFaceSets_[zoneI].polys;
|
||||
labelList& tris = faceZoneFaceSets_[faceZoneId].tris;
|
||||
labelList& quads = faceZoneFaceSets_[faceZoneId].quads;
|
||||
labelList& polys = faceZoneFaceSets_[faceZoneId].polys;
|
||||
|
||||
tris.setSize(fz.size());
|
||||
quads.setSize(fz.size());
|
||||
@ -356,19 +360,20 @@ void Foam::ensightMesh::correct()
|
||||
{
|
||||
const word& zoneName = faceZoneNamesAll[zoneI];
|
||||
nFacePrimitives nfp;
|
||||
const label faceZoneId = mesh_.faceZones().findZoneID(zoneName);
|
||||
|
||||
if (faceZoneNames_.found(zoneName))
|
||||
{
|
||||
if
|
||||
(
|
||||
faceZoneFaceSets_[zoneI].tris.size()
|
||||
|| faceZoneFaceSets_[zoneI].quads.size()
|
||||
|| faceZoneFaceSets_[zoneI].polys.size()
|
||||
faceZoneFaceSets_[faceZoneId].tris.size()
|
||||
|| faceZoneFaceSets_[faceZoneId].quads.size()
|
||||
|| faceZoneFaceSets_[faceZoneId].polys.size()
|
||||
)
|
||||
{
|
||||
nfp.nTris = faceZoneFaceSets_[zoneI].tris.size();
|
||||
nfp.nQuads = faceZoneFaceSets_[zoneI].quads.size();
|
||||
nfp.nPolys = faceZoneFaceSets_[zoneI].polys.size();
|
||||
nfp.nTris = faceZoneFaceSets_[faceZoneId].tris.size();
|
||||
nfp.nQuads = faceZoneFaceSets_[faceZoneId].quads.size();
|
||||
nfp.nPolys = faceZoneFaceSets_[faceZoneId].polys.size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -593,6 +598,7 @@ void Foam::ensightMesh::writePolysPoints
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
const labelList& faceOwner,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const
|
||||
{
|
||||
@ -602,12 +608,46 @@ void Foam::ensightMesh::writePolysPoints
|
||||
|
||||
forAll(cf, faceI)
|
||||
{
|
||||
const face& f = faces[cf[faceI]];
|
||||
const label faceId = cf[faceI];
|
||||
const face& f = faces[faceId]; // points of face (in global points)
|
||||
const label np = f.size();
|
||||
bool reverseOrder = false;
|
||||
if (faceId >= faceOwner.size())
|
||||
{
|
||||
// Boundary face.
|
||||
// Nothing should be done for processor boundary.
|
||||
// The current cell always owns them. Given that we
|
||||
// are reverting the
|
||||
// order when the cell is the neighbour to the face,
|
||||
// the orientation of
|
||||
// all the boundaries, no matter if they are "real"
|
||||
// or processorBoundaries, is consistent.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (faceOwner[faceId] != polys[i])
|
||||
{
|
||||
reverseOrder = true;
|
||||
}
|
||||
}
|
||||
|
||||
List<int> temp(f.size());
|
||||
// If the face owner is the current cell, write the points
|
||||
// in the standard order.
|
||||
// If the face owner is not the current cell, write the points
|
||||
// in reverse order.
|
||||
// EnSight prefers to have all the faces of an nfaced cell
|
||||
// oriented in the same way.
|
||||
List<int> temp(np);
|
||||
forAll(f, pointI)
|
||||
{
|
||||
temp[pointI] = f[pointI] + 1;
|
||||
if (reverseOrder)
|
||||
{
|
||||
temp[np-1-pointI] = f[pointI] + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
temp[pointI] = f[pointI] + 1;
|
||||
}
|
||||
}
|
||||
ensightGeometryFile.write(temp);
|
||||
}
|
||||
@ -624,6 +664,8 @@ void Foam::ensightMesh::writeAllPolys
|
||||
if (meshCellSets_.nPolys)
|
||||
{
|
||||
const cellList& cellFaces = mesh_.cells();
|
||||
const labelList& faceOwner = mesh_.faceOwner();
|
||||
|
||||
// Renumber faces to use global point numbers
|
||||
faceList faces(mesh_.faces());
|
||||
forAll(faces, i)
|
||||
@ -714,6 +756,7 @@ void Foam::ensightMesh::writeAllPolys
|
||||
meshCellSets_.polys,
|
||||
cellFaces,
|
||||
faces,
|
||||
faceOwner,
|
||||
ensightGeometryFile
|
||||
);
|
||||
// Slaves
|
||||
@ -723,12 +766,14 @@ void Foam::ensightMesh::writeAllPolys
|
||||
labelList polys(fromSlave);
|
||||
cellList cellFaces(fromSlave);
|
||||
faceList faces(fromSlave);
|
||||
labelList faceOwner(fromSlave);
|
||||
|
||||
writePolysPoints
|
||||
(
|
||||
polys,
|
||||
cellFaces,
|
||||
faces,
|
||||
faceOwner,
|
||||
ensightGeometryFile
|
||||
);
|
||||
}
|
||||
@ -736,7 +781,7 @@ void Foam::ensightMesh::writeAllPolys
|
||||
else
|
||||
{
|
||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
||||
toMaster<< meshCellSets_.polys << cellFaces << faces << faceOwner;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1197,7 +1242,7 @@ void Foam::ensightMesh::write
|
||||
pointField uniquePoints(mesh_.points(), uniqueMeshPointLabels);
|
||||
|
||||
// Find the list of master faces belonging to the faceZone,
|
||||
// in loacal numbering
|
||||
// in local numbering
|
||||
faceList faceZoneFaces(fz().localFaces());
|
||||
|
||||
// Count how many master faces belong to the faceZone. Is there
|
||||
|
||||
@ -192,6 +192,7 @@ private:
|
||||
const labelList& polys,
|
||||
const cellList& cellFaces,
|
||||
const faceList& faces,
|
||||
const labelList& faceOwner,
|
||||
ensightStream& ensightGeometryFile
|
||||
) const;
|
||||
|
||||
|
||||
@ -135,6 +135,12 @@ int main(int argc, char *argv[])
|
||||
"specify faceZones to write - eg '( slice \"mfp-.*\" )'."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"fields",
|
||||
"wordReList",
|
||||
"specify fields to export (all by default) - eg '( \"U.*\" )'."
|
||||
);
|
||||
argList::addOption
|
||||
(
|
||||
"cellZone",
|
||||
"word",
|
||||
@ -224,6 +230,13 @@ int main(int argc, char *argv[])
|
||||
zonePatterns = wordReList(args.optionLookup("faceZones")());
|
||||
}
|
||||
|
||||
const bool selectedFields = args.optionFound("fields");
|
||||
wordReList fieldPatterns;
|
||||
if (selectedFields)
|
||||
{
|
||||
fieldPatterns = wordReList(args.optionLookup("fields")());
|
||||
}
|
||||
|
||||
word cellZoneName;
|
||||
const bool doCellZone = args.optionReadIfPresent("cellZone", cellZoneName);
|
||||
|
||||
@ -430,6 +443,15 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
const word& fieldName = fieldNames[j];
|
||||
|
||||
// Check if the field has to be exported
|
||||
if (selectedFields)
|
||||
{
|
||||
if (!findStrings(fieldPatterns, fieldName))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
#include "checkData.H"
|
||||
|
||||
if (!variableGood)
|
||||
|
||||
Reference in New Issue
Block a user