mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
foamToEnsight* fixes and tweaks
foamToEnsight:
- add -noPatches option
- had incorrect part# when the internalMesh was not output
- case file is always ascii
foamToEnsightParts:
- fixed field selection bug,
no fields were selected when a single time-step was selected
This commit is contained in:
@ -1,18 +1,21 @@
|
|||||||
for (int n1=startTime; n1<endTime; n1++)
|
// ignore special fields or fields that we don't handle
|
||||||
|
//
|
||||||
|
bool variableGood = true;
|
||||||
|
for (label n1=startTime; n1<endTime && variableGood; ++n1)
|
||||||
{
|
{
|
||||||
|
// ignore _0 fields
|
||||||
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
|
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
|
||||||
{
|
{
|
||||||
variableGood = false;
|
variableGood = false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
IOobject fieldObjectHeader
|
{
|
||||||
(
|
variableGood = IOobject
|
||||||
fieldName,
|
(
|
||||||
Times[n1].name(),
|
fieldName,
|
||||||
mesh,
|
Times[n1].name(),
|
||||||
IOobject::NO_READ
|
mesh,
|
||||||
);
|
IOobject::NO_READ
|
||||||
|
).headerOk();
|
||||||
variableGood = variableGood && fieldObjectHeader.headerOk();
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,19 +1,19 @@
|
|||||||
bool meshMoving = true;
|
// check for "points" in all of the result directories
|
||||||
|
|
||||||
|
bool meshMoving = true;
|
||||||
if (Times.size() > 2)
|
if (Times.size() > 2)
|
||||||
{
|
{
|
||||||
for(label n2=2; n2<Times.size(); n2++)
|
for (label n1=2; n1<Times.size() && meshMoving; ++n1)
|
||||||
{
|
{
|
||||||
IOobject tmpPoints
|
meshMoving = IOobject
|
||||||
(
|
(
|
||||||
"points",
|
"points",
|
||||||
Times[n2].name(),
|
Times[n1].name(),
|
||||||
polyMesh::meshSubDir,
|
polyMesh::meshSubDir,
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ
|
IOobject::NO_READ
|
||||||
);
|
).headerOk();
|
||||||
meshMoving = meshMoving && tmpPoints.headerOk();
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,5 +0,0 @@
|
|||||||
if (Pstream::master())
|
|
||||||
{
|
|
||||||
ensightCaseFile << "FORMAT" << nl;
|
|
||||||
ensightCaseFile << "type: ensight gold" << nl << nl;
|
|
||||||
}
|
|
||||||
@ -275,8 +275,8 @@ template<class Type>
|
|||||||
bool writePatchField
|
bool writePatchField
|
||||||
(
|
(
|
||||||
const Foam::Field<Type>& pf,
|
const Foam::Field<Type>& pf,
|
||||||
const Foam::label patchi,
|
const Foam::label patchI,
|
||||||
const Foam::label ensightPatchi,
|
const Foam::label ensightPatchI,
|
||||||
const Foam::faceSets& boundaryFaceSet,
|
const Foam::faceSets& boundaryFaceSet,
|
||||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||||
const Foam::labelList& patchProcessors,
|
const Foam::labelList& patchProcessors,
|
||||||
@ -289,7 +289,7 @@ bool writePatchField
|
|||||||
{
|
{
|
||||||
ensightFile
|
ensightFile
|
||||||
<< "part" << nl
|
<< "part" << nl
|
||||||
<< setw(10) << ensightPatchi << nl;
|
<< setw(10) << ensightPatchI << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeAllFaceData
|
writeAllFaceData
|
||||||
@ -335,8 +335,8 @@ template<class Type>
|
|||||||
bool writePatchFieldBinary
|
bool writePatchFieldBinary
|
||||||
(
|
(
|
||||||
const Foam::Field<Type>& pf,
|
const Foam::Field<Type>& pf,
|
||||||
const Foam::label patchi,
|
const Foam::label patchI,
|
||||||
const Foam::label ensightPatchi,
|
const Foam::label ensightPatchI,
|
||||||
const Foam::faceSets& boundaryFaceSet,
|
const Foam::faceSets& boundaryFaceSet,
|
||||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||||
const Foam::labelList& patchProcessors,
|
const Foam::labelList& patchProcessors,
|
||||||
@ -348,7 +348,7 @@ bool writePatchFieldBinary
|
|||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
writeEnsDataBinary("part",ensightFile);
|
writeEnsDataBinary("part",ensightFile);
|
||||||
writeEnsDataBinary(ensightPatchi,ensightFile);
|
writeEnsDataBinary(ensightPatchI,ensightFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeAllFaceDataBinary
|
writeAllFaceDataBinary
|
||||||
@ -411,14 +411,14 @@ void writePatchField
|
|||||||
const HashTable<ensightMesh::nFacePrimitives>&
|
const HashTable<ensightMesh::nFacePrimitives>&
|
||||||
nPatchPrims = eMesh.nPatchPrims();
|
nPatchPrims = eMesh.nPatchPrims();
|
||||||
|
|
||||||
label patchi = -1;
|
label patchI = -1;
|
||||||
|
|
||||||
if (patchIndices.found(patchName))
|
if (patchIndices.found(patchName))
|
||||||
{
|
{
|
||||||
patchi = patchIndices.find(patchName)();
|
patchI = patchIndices.find(patchName)();
|
||||||
}
|
}
|
||||||
|
|
||||||
label ensightPatchi = 2;
|
label ensightPatchI = eMesh.patchPartOffset();
|
||||||
|
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
@ -429,7 +429,7 @@ void writePatchField
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (iter.key() == patchName) break;
|
if (iter.key() == patchName) break;
|
||||||
ensightPatchi++;
|
ensightPatchI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -472,14 +472,14 @@ void writePatchField
|
|||||||
ensightFile << pTraits<Type>::typeName << nl;
|
ensightFile << pTraits<Type>::typeName << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (patchi >= 0)
|
if (patchI >= 0)
|
||||||
{
|
{
|
||||||
writePatchField
|
writePatchField
|
||||||
(
|
(
|
||||||
pf,
|
pf,
|
||||||
patchi,
|
patchI,
|
||||||
ensightPatchi,
|
ensightPatchI,
|
||||||
boundaryFaceSets[patchi],
|
boundaryFaceSets[patchI],
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
patchProcessors,
|
patchProcessors,
|
||||||
ensightFile
|
ensightFile
|
||||||
@ -493,7 +493,7 @@ void writePatchField
|
|||||||
(
|
(
|
||||||
Field<Type>(),
|
Field<Type>(),
|
||||||
-1,
|
-1,
|
||||||
ensightPatchi,
|
ensightPatchI,
|
||||||
nullFaceSets,
|
nullFaceSets,
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
patchProcessors,
|
patchProcessors,
|
||||||
@ -621,7 +621,7 @@ void ensightFieldAscii
|
|||||||
writeAllData("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
|
writeAllData("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
label ensightPatchi = 2;
|
label ensightPatchI = eMesh.patchPartOffset();
|
||||||
|
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
@ -637,23 +637,23 @@ void ensightFieldAscii
|
|||||||
{
|
{
|
||||||
if (patchIndices.found(patchName))
|
if (patchIndices.found(patchName))
|
||||||
{
|
{
|
||||||
label patchi = patchIndices.find(patchName)();
|
label patchI = patchIndices.find(patchName)();
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
writePatchField
|
writePatchField
|
||||||
(
|
(
|
||||||
vf.boundaryField()[patchi],
|
vf.boundaryField()[patchI],
|
||||||
patchi,
|
patchI,
|
||||||
ensightPatchi,
|
ensightPatchI,
|
||||||
boundaryFaceSets[patchi],
|
boundaryFaceSets[patchI],
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
patchProcessors,
|
patchProcessors,
|
||||||
ensightFile
|
ensightFile
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ensightPatchi++;
|
ensightPatchI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -667,7 +667,7 @@ void ensightFieldAscii
|
|||||||
(
|
(
|
||||||
Field<Type>(),
|
Field<Type>(),
|
||||||
-1,
|
-1,
|
||||||
ensightPatchi,
|
ensightPatchI,
|
||||||
nullFaceSet,
|
nullFaceSet,
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
patchProcessors,
|
patchProcessors,
|
||||||
@ -675,7 +675,7 @@ void ensightFieldAscii
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ensightPatchi++;
|
ensightPatchI++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -793,7 +793,7 @@ void ensightFieldBinary
|
|||||||
writeAllDataBinary("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
|
writeAllDataBinary("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
label ensightPatchi = 2;
|
label ensightPatchI = eMesh.patchPartOffset();
|
||||||
|
|
||||||
for
|
for
|
||||||
(
|
(
|
||||||
@ -809,23 +809,23 @@ void ensightFieldBinary
|
|||||||
{
|
{
|
||||||
if (patchIndices.found(patchName))
|
if (patchIndices.found(patchName))
|
||||||
{
|
{
|
||||||
label patchi = patchIndices.find(patchName)();
|
label patchI = patchIndices.find(patchName)();
|
||||||
|
|
||||||
if
|
if
|
||||||
(
|
(
|
||||||
writePatchFieldBinary
|
writePatchFieldBinary
|
||||||
(
|
(
|
||||||
vf.boundaryField()[patchi],
|
vf.boundaryField()[patchI],
|
||||||
patchi,
|
patchI,
|
||||||
ensightPatchi,
|
ensightPatchI,
|
||||||
boundaryFaceSets[patchi],
|
boundaryFaceSets[patchI],
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
patchProcessors,
|
patchProcessors,
|
||||||
ensightFile
|
ensightFile
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ensightPatchi++;
|
ensightPatchI++;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -839,7 +839,7 @@ void ensightFieldBinary
|
|||||||
(
|
(
|
||||||
Field<Type>(),
|
Field<Type>(),
|
||||||
-1,
|
-1,
|
||||||
ensightPatchi,
|
ensightPatchI,
|
||||||
nullFaceSet,
|
nullFaceSet,
|
||||||
nPatchPrims.find(patchName)(),
|
nPatchPrims.find(patchName)(),
|
||||||
patchProcessors,
|
patchProcessors,
|
||||||
@ -847,7 +847,7 @@ void ensightFieldBinary
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
ensightPatchi++;
|
ensightPatchI++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,8 +89,9 @@ Foam::ensightMesh::ensightMesh
|
|||||||
const bool binary
|
const bool binary
|
||||||
)
|
)
|
||||||
:
|
:
|
||||||
binary_(binary),
|
|
||||||
mesh_(mesh),
|
mesh_(mesh),
|
||||||
|
binary_(binary),
|
||||||
|
patchPartOffset_(2),
|
||||||
meshCellSets_(mesh_.nCells()),
|
meshCellSets_(mesh_.nCells()),
|
||||||
boundaryFaceSets_(mesh_.boundary().size()),
|
boundaryFaceSets_(mesh_.boundary().size()),
|
||||||
allPatchNames_(0),
|
allPatchNames_(0),
|
||||||
@ -98,48 +99,6 @@ Foam::ensightMesh::ensightMesh
|
|||||||
patchNames_(0),
|
patchNames_(0),
|
||||||
nPatchPrims_(0)
|
nPatchPrims_(0)
|
||||||
{
|
{
|
||||||
forAll (mesh_.boundaryMesh(), patchi)
|
|
||||||
{
|
|
||||||
if
|
|
||||||
(
|
|
||||||
typeid(mesh_.boundaryMesh()[patchi])
|
|
||||||
!= typeid(processorPolyPatch)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (!allPatchNames_.found(mesh_.boundaryMesh()[patchi].name()))
|
|
||||||
{
|
|
||||||
allPatchNames_.insert
|
|
||||||
(
|
|
||||||
mesh_.boundaryMesh()[patchi].name(),
|
|
||||||
labelList(1, Pstream::myProcNo())
|
|
||||||
);
|
|
||||||
|
|
||||||
patchIndices_.insert
|
|
||||||
(
|
|
||||||
mesh_.boundaryMesh()[patchi].name(),
|
|
||||||
patchi
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
combineReduce(allPatchNames_, concatPatchNames());
|
|
||||||
|
|
||||||
if (args.options().found("patches"))
|
|
||||||
{
|
|
||||||
wordList patchNameList(IStringStream(args.options()["patches"])());
|
|
||||||
|
|
||||||
if (patchNameList.empty())
|
|
||||||
{
|
|
||||||
patchNameList = allPatchNames_.toc();
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll (patchNameList, i)
|
|
||||||
{
|
|
||||||
patchNames_.insert(patchNameList[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const cellShapeList& cellShapes = mesh.cellShapes();
|
const cellShapeList& cellShapes = mesh.cellShapes();
|
||||||
|
|
||||||
const cellModel& tet = *(cellModeller::lookup("tet"));
|
const cellModel& tet = *(cellModeller::lookup("tet"));
|
||||||
@ -148,51 +107,101 @@ Foam::ensightMesh::ensightMesh
|
|||||||
const cellModel& wedge = *(cellModeller::lookup("wedge"));
|
const cellModel& wedge = *(cellModeller::lookup("wedge"));
|
||||||
const cellModel& hex = *(cellModeller::lookup("hex"));
|
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||||
|
|
||||||
labelList& tets = meshCellSets_.tets;
|
if (!args.options().found("noPatches"))
|
||||||
labelList& pyrs = meshCellSets_.pyrs;
|
|
||||||
labelList& prisms = meshCellSets_.prisms;
|
|
||||||
labelList& wedges = meshCellSets_.wedges;
|
|
||||||
labelList& hexes = meshCellSets_.hexes;
|
|
||||||
labelList& polys = meshCellSets_.polys;
|
|
||||||
|
|
||||||
// Count the shapes
|
|
||||||
label nTets = 0;
|
|
||||||
label nPyrs = 0;
|
|
||||||
label nPrisms = 0;
|
|
||||||
label nWedges = 0;
|
|
||||||
label nHexes = 0;
|
|
||||||
label nPolys = 0;
|
|
||||||
|
|
||||||
if (patchNames_.empty())
|
|
||||||
{
|
{
|
||||||
forAll(cellShapes, celli)
|
forAll (mesh_.boundaryMesh(), patchI)
|
||||||
{
|
{
|
||||||
const cellShape& cellShape = cellShapes[celli];
|
if
|
||||||
|
(
|
||||||
|
typeid(mesh_.boundaryMesh()[patchI])
|
||||||
|
!= typeid(processorPolyPatch)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!allPatchNames_.found(mesh_.boundaryMesh()[patchI].name()))
|
||||||
|
{
|
||||||
|
allPatchNames_.insert
|
||||||
|
(
|
||||||
|
mesh_.boundaryMesh()[patchI].name(),
|
||||||
|
labelList(1, Pstream::myProcNo())
|
||||||
|
);
|
||||||
|
|
||||||
|
patchIndices_.insert
|
||||||
|
(
|
||||||
|
mesh_.boundaryMesh()[patchI].name(),
|
||||||
|
patchI
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
combineReduce(allPatchNames_, concatPatchNames());
|
||||||
|
|
||||||
|
if (args.options().found("patches"))
|
||||||
|
{
|
||||||
|
wordList patchNameList(IStringStream(args.options()["patches"])());
|
||||||
|
|
||||||
|
if (patchNameList.empty())
|
||||||
|
{
|
||||||
|
patchNameList = allPatchNames_.toc();
|
||||||
|
}
|
||||||
|
|
||||||
|
forAll (patchNameList, i)
|
||||||
|
{
|
||||||
|
patchNames_.insert(patchNameList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (patchNames_.size())
|
||||||
|
{
|
||||||
|
// no internalMesh
|
||||||
|
patchPartOffset_ = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Count the shapes
|
||||||
|
labelList& tets = meshCellSets_.tets;
|
||||||
|
labelList& pyrs = meshCellSets_.pyrs;
|
||||||
|
labelList& prisms = meshCellSets_.prisms;
|
||||||
|
labelList& wedges = meshCellSets_.wedges;
|
||||||
|
labelList& hexes = meshCellSets_.hexes;
|
||||||
|
labelList& polys = meshCellSets_.polys;
|
||||||
|
|
||||||
|
label nTets = 0;
|
||||||
|
label nPyrs = 0;
|
||||||
|
label nPrisms = 0;
|
||||||
|
label nWedges = 0;
|
||||||
|
label nHexes = 0;
|
||||||
|
label nPolys = 0;
|
||||||
|
|
||||||
|
forAll(cellShapes, cellI)
|
||||||
|
{
|
||||||
|
const cellShape& cellShape = cellShapes[cellI];
|
||||||
const cellModel& cellModel = cellShape.model();
|
const cellModel& cellModel = cellShape.model();
|
||||||
|
|
||||||
if (cellModel == tet)
|
if (cellModel == tet)
|
||||||
{
|
{
|
||||||
tets[nTets++] = celli;
|
tets[nTets++] = cellI;
|
||||||
}
|
}
|
||||||
else if (cellModel == pyr)
|
else if (cellModel == pyr)
|
||||||
{
|
{
|
||||||
pyrs[nPyrs++] = celli;
|
pyrs[nPyrs++] = cellI;
|
||||||
}
|
}
|
||||||
else if (cellModel == prism)
|
else if (cellModel == prism)
|
||||||
{
|
{
|
||||||
prisms[nPrisms++] = celli;
|
prisms[nPrisms++] = cellI;
|
||||||
}
|
}
|
||||||
else if (cellModel == wedge)
|
else if (cellModel == wedge)
|
||||||
{
|
{
|
||||||
wedges[nWedges++] = celli;
|
wedges[nWedges++] = cellI;
|
||||||
}
|
}
|
||||||
else if (cellModel == hex)
|
else if (cellModel == hex)
|
||||||
{
|
{
|
||||||
hexes[nHexes++] = celli;
|
hexes[nHexes++] = cellI;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
polys[nPolys++] = celli;
|
polys[nPolys++] = cellI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,49 +228,52 @@ Foam::ensightMesh::ensightMesh
|
|||||||
reduce(meshCellSets_.nPolys, sumOp<label>());
|
reduce(meshCellSets_.nPolys, sumOp<label>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!args.options().found("noPatches"))
|
||||||
forAll (mesh.boundary(), patchi)
|
|
||||||
{
|
{
|
||||||
if (mesh.boundary()[patchi].size())
|
forAll (mesh.boundary(), patchI)
|
||||||
{
|
{
|
||||||
const polyPatch& p = mesh.boundaryMesh()[patchi];
|
if (mesh.boundary()[patchI].size())
|
||||||
|
|
||||||
labelList& tris = boundaryFaceSets_[patchi].tris;
|
|
||||||
labelList& quads = boundaryFaceSets_[patchi].quads;
|
|
||||||
labelList& polys = boundaryFaceSets_[patchi].polys;
|
|
||||||
|
|
||||||
tris.setSize(p.size());
|
|
||||||
quads.setSize(p.size());
|
|
||||||
polys.setSize(p.size());
|
|
||||||
|
|
||||||
label nTris = 0;
|
|
||||||
label nQuads = 0;
|
|
||||||
label nPolys = 0;
|
|
||||||
|
|
||||||
forAll(p, facei)
|
|
||||||
{
|
{
|
||||||
const face& f = p[facei];
|
const polyPatch& p = mesh.boundaryMesh()[patchI];
|
||||||
|
|
||||||
if (f.size() == 3)
|
labelList& tris = boundaryFaceSets_[patchI].tris;
|
||||||
|
labelList& quads = boundaryFaceSets_[patchI].quads;
|
||||||
|
labelList& polys = boundaryFaceSets_[patchI].polys;
|
||||||
|
|
||||||
|
tris.setSize(p.size());
|
||||||
|
quads.setSize(p.size());
|
||||||
|
polys.setSize(p.size());
|
||||||
|
|
||||||
|
label nTris = 0;
|
||||||
|
label nQuads = 0;
|
||||||
|
label nPolys = 0;
|
||||||
|
|
||||||
|
forAll(p, faceI)
|
||||||
{
|
{
|
||||||
tris[nTris++] = facei;
|
const face& f = p[faceI];
|
||||||
}
|
|
||||||
else if (f.size() == 4)
|
if (f.size() == 3)
|
||||||
{
|
{
|
||||||
quads[nQuads++] = facei;
|
tris[nTris++] = faceI;
|
||||||
}
|
}
|
||||||
else
|
else if (f.size() == 4)
|
||||||
{
|
{
|
||||||
polys[nPolys++] = facei;
|
quads[nQuads++] = faceI;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
polys[nPolys++] = faceI;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tris.setSize(nTris);
|
||||||
|
quads.setSize(nQuads);
|
||||||
|
polys.setSize(nPolys);
|
||||||
}
|
}
|
||||||
|
|
||||||
tris.setSize(nTris);
|
|
||||||
quads.setSize(nQuads);
|
|
||||||
polys.setSize(nPolys);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||||
{
|
{
|
||||||
const word& patchName = iter.key();
|
const word& patchName = iter.key();
|
||||||
@ -271,12 +283,12 @@ Foam::ensightMesh::ensightMesh
|
|||||||
{
|
{
|
||||||
if (patchIndices_.found(patchName))
|
if (patchIndices_.found(patchName))
|
||||||
{
|
{
|
||||||
label patchi = patchIndices_.find(patchName)();
|
label patchI = patchIndices_.find(patchName)();
|
||||||
|
|
||||||
nfp.nPoints = mesh.boundaryMesh()[patchi].localPoints().size();
|
nfp.nPoints = mesh.boundaryMesh()[patchI].localPoints().size();
|
||||||
nfp.nTris = boundaryFaceSets_[patchi].tris.size();
|
nfp.nTris = boundaryFaceSets_[patchI].tris.size();
|
||||||
nfp.nQuads = boundaryFaceSets_[patchi].quads.size();
|
nfp.nQuads = boundaryFaceSets_[patchI].quads.size();
|
||||||
nfp.nPolys = boundaryFaceSets_[patchi].polys.size();
|
nfp.nPolys = boundaryFaceSets_[patchI].polys.size();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,9 +316,9 @@ void Foam::ensightMesh::writePoints
|
|||||||
OFstream& ensightGeometryFile
|
OFstream& ensightGeometryFile
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
forAll(pointsComponent, pointi)
|
forAll(pointsComponent, pointI)
|
||||||
{
|
{
|
||||||
ensightGeometryFile<< setw(12) << float(pointsComponent[pointi]) << nl;
|
ensightGeometryFile<< setw(12) << float(pointsComponent[pointI]) << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,9 +392,9 @@ void Foam::ensightMesh::writePrims
|
|||||||
{
|
{
|
||||||
const cellShape& cellPoints = cellShapes[i];
|
const cellShape& cellPoints = cellShapes[i];
|
||||||
|
|
||||||
forAll(cellPoints, pointi)
|
forAll(cellPoints, pointI)
|
||||||
{
|
{
|
||||||
ensightGeometryFile<< setw(10) << cellPoints[pointi] + po;
|
ensightGeometryFile<< setw(10) << cellPoints[pointI] + po;
|
||||||
}
|
}
|
||||||
ensightGeometryFile << nl;
|
ensightGeometryFile << nl;
|
||||||
}
|
}
|
||||||
@ -415,9 +427,9 @@ void Foam::ensightMesh::writePrimsBinary
|
|||||||
{
|
{
|
||||||
const cellShape& cellPoints = cellShapes[i];
|
const cellShape& cellPoints = cellShapes[i];
|
||||||
|
|
||||||
forAll(cellPoints, pointi)
|
forAll(cellPoints, pointI)
|
||||||
{
|
{
|
||||||
temp[n] = cellPoints[pointi] + po;
|
temp[n] = cellPoints[pointI] + po;
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -457,10 +469,10 @@ void Foam::ensightMesh::writePolys
|
|||||||
{
|
{
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
|
|
||||||
forAll(cf, facei)
|
forAll(cf, faceI)
|
||||||
{
|
{
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
<< setw(10) << faces[cf[facei]].size() << nl;
|
<< setw(10) << faces[cf[faceI]].size() << nl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,13 +480,13 @@ void Foam::ensightMesh::writePolys
|
|||||||
{
|
{
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
|
|
||||||
forAll(cf, facei)
|
forAll(cf, faceI)
|
||||||
{
|
{
|
||||||
const face& f = faces[cf[facei]];
|
const face& f = faces[cf[faceI]];
|
||||||
|
|
||||||
forAll(f, pointi)
|
forAll(f, pointI)
|
||||||
{
|
{
|
||||||
ensightGeometryFile << setw(10) << f[pointi] + po;
|
ensightGeometryFile << setw(10) << f[pointI] + po;
|
||||||
}
|
}
|
||||||
ensightGeometryFile << nl;
|
ensightGeometryFile << nl;
|
||||||
}
|
}
|
||||||
@ -513,11 +525,11 @@ void Foam::ensightMesh::writePolysBinary
|
|||||||
{
|
{
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
|
|
||||||
forAll(cf, facei)
|
forAll(cf, faceI)
|
||||||
{
|
{
|
||||||
writeEnsDataBinary
|
writeEnsDataBinary
|
||||||
(
|
(
|
||||||
faces[cf[facei]].size(),
|
faces[cf[faceI]].size(),
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -527,13 +539,13 @@ void Foam::ensightMesh::writePolysBinary
|
|||||||
{
|
{
|
||||||
const labelList& cf = cellFaces[polys[i]];
|
const labelList& cf = cellFaces[polys[i]];
|
||||||
|
|
||||||
forAll(cf, facei)
|
forAll(cf, faceI)
|
||||||
{
|
{
|
||||||
const face& f = faces[cf[facei]];
|
const face& f = faces[cf[faceI]];
|
||||||
|
|
||||||
forAll(f, pointi)
|
forAll(f, pointI)
|
||||||
{
|
{
|
||||||
writeEnsDataBinary(f[pointi] + po,ensightGeometryFile);
|
writeEnsDataBinary(f[pointI] + po,ensightGeometryFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -648,9 +660,9 @@ void Foam::ensightMesh::writeFacePrims
|
|||||||
{
|
{
|
||||||
const face& patchFace = patchFaces[i];
|
const face& patchFace = patchFaces[i];
|
||||||
|
|
||||||
forAll(patchFace, pointi)
|
forAll(patchFace, pointI)
|
||||||
{
|
{
|
||||||
ensightGeometryFile << setw(10) << patchFace[pointi] + po;
|
ensightGeometryFile << setw(10) << patchFace[pointI] + po;
|
||||||
}
|
}
|
||||||
ensightGeometryFile << nl;
|
ensightGeometryFile << nl;
|
||||||
}
|
}
|
||||||
@ -690,11 +702,11 @@ void Foam::ensightMesh::writeFacePrimsBinary
|
|||||||
{
|
{
|
||||||
const face& patchFace = patchFaces[i];
|
const face& patchFace = patchFaces[i];
|
||||||
|
|
||||||
forAll(patchFace, pointi)
|
forAll(patchFace, pointI)
|
||||||
{
|
{
|
||||||
writeEnsDataBinary
|
writeEnsDataBinary
|
||||||
(
|
(
|
||||||
patchFace[pointi] + po,
|
patchFace[pointI] + po,
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -892,7 +904,7 @@ void Foam::ensightMesh::writeAscii
|
|||||||
postProcPath/ensightGeometryFileName,
|
postProcPath/ensightGeometryFileName,
|
||||||
runTime.writeFormat(),
|
runTime.writeFormat(),
|
||||||
runTime.writeVersion(),
|
runTime.writeVersion(),
|
||||||
runTime.writeCompression()
|
IOstream::UNCOMPRESSED
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -909,8 +921,8 @@ void Foam::ensightMesh::writeAscii
|
|||||||
ensightGeometryFile.precision(5);
|
ensightGeometryFile.precision(5);
|
||||||
|
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
<< "OpenFOAM Geometry File " << nl
|
<< "EnSight Geometry File" << nl
|
||||||
<< "OpenFOAM version " << Foam::FOAMversion << nl
|
<< "written from OpenFOAM-" << Foam::FOAMversion << nl
|
||||||
<< "node id assign" << nl
|
<< "node id assign" << nl
|
||||||
<< "element id assign" << nl;
|
<< "element id assign" << nl;
|
||||||
}
|
}
|
||||||
@ -927,7 +939,7 @@ void Foam::ensightMesh::writeAscii
|
|||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
<< "part" << nl
|
<< "part" << nl
|
||||||
<< setw(10) << 1 << nl
|
<< setw(10) << 1 << nl
|
||||||
<< "FOAM cells" << nl
|
<< "internalMesh" << nl
|
||||||
<< "coordinates" << nl
|
<< "coordinates" << nl
|
||||||
<< setw(10) << nPoints
|
<< setw(10) << nPoints
|
||||||
<< endl;
|
<< endl;
|
||||||
@ -1038,7 +1050,7 @@ void Foam::ensightMesh::writeAscii
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
label ensightPatchi = 2;
|
label ensightPatchI = patchPartOffset_;
|
||||||
|
|
||||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||||
{
|
{
|
||||||
@ -1049,7 +1061,7 @@ void Foam::ensightMesh::writeAscii
|
|||||||
const word& patchName = iter.key();
|
const word& patchName = iter.key();
|
||||||
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
|
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
|
||||||
|
|
||||||
const labelList *trisPtr = NULL;
|
const labelList *trisPtr = NULL;
|
||||||
const labelList *quadsPtr = NULL;
|
const labelList *quadsPtr = NULL;
|
||||||
const labelList *polysPtr = NULL;
|
const labelList *polysPtr = NULL;
|
||||||
|
|
||||||
@ -1058,15 +1070,15 @@ void Foam::ensightMesh::writeAscii
|
|||||||
|
|
||||||
if (patchIndices_.found(iter.key()))
|
if (patchIndices_.found(iter.key()))
|
||||||
{
|
{
|
||||||
label patchi = patchIndices_.find(iter.key())();
|
label patchI = patchIndices_.find(iter.key())();
|
||||||
const polyPatch& p = mesh_.boundaryMesh()[patchi];
|
const polyPatch& p = mesh_.boundaryMesh()[patchI];
|
||||||
|
|
||||||
trisPtr = &boundaryFaceSets_[patchi].tris;
|
trisPtr = &boundaryFaceSets_[patchI].tris;
|
||||||
quadsPtr = &boundaryFaceSets_[patchi].quads;
|
quadsPtr = &boundaryFaceSets_[patchI].quads;
|
||||||
polysPtr = &boundaryFaceSets_[patchi].polys;
|
polysPtr = &boundaryFaceSets_[patchI].polys;
|
||||||
|
|
||||||
patchPointsPtr = &(p.localPoints());
|
patchPointsPtr = &(p.localPoints());
|
||||||
patchFacesPtr = &(p.localFaces());
|
patchFacesPtr = &(p.localFaces());
|
||||||
}
|
}
|
||||||
|
|
||||||
const labelList& tris = *trisPtr;
|
const labelList& tris = *trisPtr;
|
||||||
@ -1083,7 +1095,7 @@ void Foam::ensightMesh::writeAscii
|
|||||||
{
|
{
|
||||||
ensightGeometryFile
|
ensightGeometryFile
|
||||||
<< "part" << nl
|
<< "part" << nl
|
||||||
<< setw(10) << ensightPatchi++ << nl
|
<< setw(10) << ensightPatchI++ << nl
|
||||||
<< patchName << nl
|
<< patchName << nl
|
||||||
<< "coordinates" << nl
|
<< "coordinates" << nl
|
||||||
<< setw(10) << nfp.nPoints
|
<< setw(10) << nfp.nPoints
|
||||||
@ -1235,11 +1247,11 @@ void Foam::ensightMesh::writeBinary
|
|||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
writeEnsDataBinary("C binary",ensightGeometryFile);
|
writeEnsDataBinary("C binary", ensightGeometryFile);
|
||||||
writeEnsDataBinary("OpenFOAM Geometry File",ensightGeometryFile);
|
writeEnsDataBinary("EnSight Geometry File", ensightGeometryFile);
|
||||||
writeEnsDataBinary("Binary format",ensightGeometryFile);
|
writeEnsDataBinary("written from OpenFOAM", ensightGeometryFile);
|
||||||
writeEnsDataBinary("node id assign",ensightGeometryFile);
|
writeEnsDataBinary("node id assign", ensightGeometryFile);
|
||||||
writeEnsDataBinary("element id assign",ensightGeometryFile);
|
writeEnsDataBinary("element id assign", ensightGeometryFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
labelList pointOffsets(Pstream::nProcs(), 0);
|
labelList pointOffsets(Pstream::nProcs(), 0);
|
||||||
@ -1364,8 +1376,7 @@ void Foam::ensightMesh::writeBinary
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
label ensightPatchi = 2;
|
label ensightPatchI = patchPartOffset_;
|
||||||
|
|
||||||
label iCount = 0;
|
label iCount = 0;
|
||||||
|
|
||||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||||
@ -1387,12 +1398,12 @@ void Foam::ensightMesh::writeBinary
|
|||||||
|
|
||||||
if (patchIndices_.found(iter.key()))
|
if (patchIndices_.found(iter.key()))
|
||||||
{
|
{
|
||||||
label patchi = patchIndices_.find(iter.key())();
|
label patchI = patchIndices_.find(iter.key())();
|
||||||
const polyPatch& p = mesh_.boundaryMesh()[patchi];
|
const polyPatch& p = mesh_.boundaryMesh()[patchI];
|
||||||
|
|
||||||
trisPtr = &boundaryFaceSets_[patchi].tris;
|
trisPtr = &boundaryFaceSets_[patchI].tris;
|
||||||
quadsPtr = &boundaryFaceSets_[patchi].quads;
|
quadsPtr = &boundaryFaceSets_[patchI].quads;
|
||||||
polysPtr = &boundaryFaceSets_[patchi].polys;
|
polysPtr = &boundaryFaceSets_[patchI].polys;
|
||||||
|
|
||||||
patchPointsPtr = &(p.localPoints());
|
patchPointsPtr = &(p.localPoints());
|
||||||
patchFacesPtr = &(p.localFaces());
|
patchFacesPtr = &(p.localFaces());
|
||||||
@ -1411,7 +1422,7 @@ void Foam::ensightMesh::writeBinary
|
|||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
writeEnsDataBinary("part",ensightGeometryFile);
|
writeEnsDataBinary("part",ensightGeometryFile);
|
||||||
writeEnsDataBinary(ensightPatchi++,ensightGeometryFile);
|
writeEnsDataBinary(ensightPatchI++,ensightGeometryFile);
|
||||||
//writeEnsDataBinary(patchName.c_str(),ensightGeometryFile);
|
//writeEnsDataBinary(patchName.c_str(),ensightGeometryFile);
|
||||||
writeEnsDataBinary(iter.key().c_str(),ensightGeometryFile);
|
writeEnsDataBinary(iter.key().c_str(),ensightGeometryFile);
|
||||||
writeEnsDataBinary("coordinates",ensightGeometryFile);
|
writeEnsDataBinary("coordinates",ensightGeometryFile);
|
||||||
|
|||||||
@ -78,11 +78,14 @@ class ensightMesh
|
|||||||
|
|
||||||
// Private data
|
// Private data
|
||||||
|
|
||||||
|
//- Reference to the OpenFOAM mesh
|
||||||
|
const fvMesh& mesh_;
|
||||||
|
|
||||||
//- Set binary file output
|
//- Set binary file output
|
||||||
bool binary_;
|
bool binary_;
|
||||||
|
|
||||||
//- Reference to the OpenFOAM mesh
|
//- The ensight part id for the first patch
|
||||||
const fvMesh& mesh_;
|
label patchPartOffset_;
|
||||||
|
|
||||||
cellSets meshCellSets_;
|
cellSets meshCellSets_;
|
||||||
|
|
||||||
@ -286,6 +289,12 @@ public:
|
|||||||
return nPatchPrims_;
|
return nPatchPrims_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//- The ensight part id for the first patch
|
||||||
|
label patchPartOffset() const
|
||||||
|
{
|
||||||
|
return patchPartOffset_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// I-O
|
// I-O
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,9 @@ License
|
|||||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
Description
|
Description
|
||||||
Translates FOAM data to EnSight format
|
Translates FOAM data to EnSight format.
|
||||||
|
|
||||||
|
An Ensight part is created for the internalMesh and for each patch.
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
- foamToEnsight [OPTION] \n
|
- foamToEnsight [OPTION] \n
|
||||||
@ -32,8 +34,16 @@ Usage
|
|||||||
@param -ascii \n
|
@param -ascii \n
|
||||||
Write Ensight data in ASCII format instead of "C Binary"
|
Write Ensight data in ASCII format instead of "C Binary"
|
||||||
|
|
||||||
|
@param -patches patchList \n
|
||||||
|
Specify particular patches to write.
|
||||||
|
Specifying an empty list suppresses writing the internalMesh.
|
||||||
|
|
||||||
|
@param -noPatches \n
|
||||||
|
Suppress writing any patches.
|
||||||
|
|
||||||
Note
|
Note
|
||||||
Parallel support for cloud data is not supported
|
Parallel support for cloud data is not supported
|
||||||
|
- writes to @a EnSight directory to avoid collisions with foamToEnsightParts
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
@ -82,10 +92,11 @@ bool inFileNameList
|
|||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
argList::validOptions.insert("patches", "patch list");
|
|
||||||
argList::validOptions.insert("ascii", "" );
|
argList::validOptions.insert("ascii", "" );
|
||||||
# include "addTimeOptions.H"
|
argList::validOptions.insert("patches", "patchList");
|
||||||
|
argList::validOptions.insert("noPatches", "");
|
||||||
|
|
||||||
|
# include "addTimeOptions.H"
|
||||||
# include "setRootCase.H"
|
# include "setRootCase.H"
|
||||||
|
|
||||||
// Check options
|
// Check options
|
||||||
@ -114,29 +125,28 @@ int main(int argc, char *argv[])
|
|||||||
regionPrefix = regionName;
|
regionPrefix = regionName;
|
||||||
}
|
}
|
||||||
|
|
||||||
const label nTypes = 2;
|
const label nVolFieldTypes = 5;
|
||||||
const word fieldTypes[] =
|
const word volFieldTypes[] =
|
||||||
{
|
{
|
||||||
volScalarField::typeName,
|
volScalarField::typeName,
|
||||||
volVectorField::typeName
|
volVectorField::typeName,
|
||||||
|
volSphericalTensorField::typeName,
|
||||||
|
volSymmTensorField::typeName,
|
||||||
|
volTensorField::typeName
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create the output folder
|
|
||||||
const word postProcDir = "EnSight";
|
|
||||||
|
|
||||||
// Path to EnSight folder at case level only
|
// Path to EnSight folder at case level only
|
||||||
// - For parallel cases, data only written from master
|
// - For parallel cases, data only written from master
|
||||||
// fileName postProcPath = runTime.path()/postProcDir;
|
fileName ensightDir = args.rootPath()/args.globalCaseName()/"EnSight";
|
||||||
fileName postProcPath = args.rootPath()/args.globalCaseName()/postProcDir;
|
|
||||||
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
if (isDir(postProcPath))
|
if (isDir(ensightDir))
|
||||||
{
|
{
|
||||||
rmDir(postProcPath);
|
rmDir(ensightDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
mkDir(postProcPath);
|
mkDir(ensightDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start of case file header output
|
// Start of case file header output
|
||||||
@ -147,36 +157,23 @@ int main(int argc, char *argv[])
|
|||||||
OFstream *ensightCaseFilePtr = NULL;
|
OFstream *ensightCaseFilePtr = NULL;
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
fileName ensightCaseFileName = prepend + "case";
|
fileName caseFileName = prepend + "case";
|
||||||
|
Info<< nl << "write case: " << caseFileName.c_str() << endl;
|
||||||
|
|
||||||
if (!binary)
|
// the case file is always ASCII
|
||||||
{
|
ensightCaseFilePtr = new OFstream
|
||||||
ensightCaseFilePtr = new OFstream
|
(
|
||||||
(
|
ensightDir/caseFileName,
|
||||||
postProcPath/ensightCaseFileName,
|
IOstream::ASCII
|
||||||
runTime.writeFormat(),
|
);
|
||||||
runTime.writeVersion(),
|
|
||||||
runTime.writeCompression()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ensightCaseFilePtr = new OFstream
|
|
||||||
(
|
|
||||||
postProcPath/ensightCaseFileName,
|
|
||||||
runTime.writeFormat(),
|
|
||||||
runTime.writeVersion(),
|
|
||||||
IOstream::UNCOMPRESSED
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
Info<< nl << "Case file is " << ensightCaseFileName << endl;
|
*ensightCaseFilePtr
|
||||||
|
<< "FORMAT" << nl
|
||||||
|
<< "type: ensight gold" << nl << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
OFstream& ensightCaseFile = *ensightCaseFilePtr;
|
OFstream& ensightCaseFile = *ensightCaseFilePtr;
|
||||||
|
|
||||||
# include "ensightCaseHeader.H"
|
|
||||||
|
|
||||||
// Construct the EnSight mesh
|
// Construct the EnSight mesh
|
||||||
ensightMesh eMesh(mesh, args, binary);
|
ensightMesh eMesh(mesh, args, binary);
|
||||||
|
|
||||||
@ -188,19 +185,20 @@ int main(int argc, char *argv[])
|
|||||||
# include "checkMeshMoving.H"
|
# include "checkMeshMoving.H"
|
||||||
|
|
||||||
wordHashSet allCloudNames;
|
wordHashSet allCloudNames;
|
||||||
word geomCaseFileName = prepend + "000";
|
|
||||||
if (Pstream::master())
|
if (Pstream::master())
|
||||||
{
|
{
|
||||||
|
word geomFileName = prepend + "000";
|
||||||
|
|
||||||
// test pre check variable if there is a moving mesh
|
// test pre check variable if there is a moving mesh
|
||||||
if (meshMoving == true)
|
if (meshMoving)
|
||||||
{
|
{
|
||||||
geomCaseFileName = prepend + "***";
|
geomFileName = prepend + "***";
|
||||||
}
|
}
|
||||||
|
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
<< "GEOMETRY" << nl
|
<< "GEOMETRY" << nl
|
||||||
<< "model: 1 "
|
<< "model: 1 "
|
||||||
<< (geomCaseFileName + ".mesh").c_str() << nl;
|
<< (geomFileName + ".mesh").c_str() << nl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Identify if lagrangian data exists at each time, and add clouds
|
// Identify if lagrangian data exists at each time, and add clouds
|
||||||
@ -304,7 +302,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
eMesh.write
|
eMesh.write
|
||||||
(
|
(
|
||||||
postProcPath,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
ensightCaseFile
|
ensightCaseFile
|
||||||
@ -324,94 +322,94 @@ int main(int argc, char *argv[])
|
|||||||
// Cell field data output
|
// Cell field data output
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
for (label i=0; i<nTypes; i++)
|
for (label i=0; i<nVolFieldTypes; i++)
|
||||||
{
|
{
|
||||||
wordList fieldNames = objects.names(fieldTypes[i]);
|
wordList fieldNames = objects.names(volFieldTypes[i]);
|
||||||
|
|
||||||
for (label j=0; j<fieldNames.size(); j++)
|
for (label j=0; j<fieldNames.size(); j++)
|
||||||
{
|
{
|
||||||
word fieldName = fieldNames[j];
|
word fieldName = fieldNames[j];
|
||||||
|
|
||||||
bool variableGood = true;
|
|
||||||
|
|
||||||
# include "checkData.H"
|
# include "checkData.H"
|
||||||
|
|
||||||
if (variableGood)
|
if (!variableGood)
|
||||||
{
|
{
|
||||||
IOobject fieldObject
|
continue;
|
||||||
(
|
}
|
||||||
fieldName,
|
|
||||||
mesh.time().timeName(),
|
|
||||||
mesh,
|
|
||||||
IOobject::MUST_READ,
|
|
||||||
IOobject::NO_WRITE
|
|
||||||
);
|
|
||||||
|
|
||||||
if (fieldTypes[i] == volScalarField::typeName)
|
IOobject fieldObject
|
||||||
{
|
(
|
||||||
ensightField<scalar>
|
fieldName,
|
||||||
(
|
mesh.time().timeName(),
|
||||||
fieldObject,
|
mesh,
|
||||||
eMesh,
|
IOobject::MUST_READ,
|
||||||
postProcPath,
|
IOobject::NO_WRITE
|
||||||
prepend,
|
);
|
||||||
timeIndex,
|
|
||||||
binary,
|
if (volFieldTypes[i] == volScalarField::typeName)
|
||||||
ensightCaseFile
|
{
|
||||||
);
|
ensightField<scalar>
|
||||||
}
|
(
|
||||||
else if (fieldTypes[i] == volVectorField::typeName)
|
fieldObject,
|
||||||
{
|
eMesh,
|
||||||
ensightField<vector>
|
ensightDir,
|
||||||
(
|
prepend,
|
||||||
fieldObject,
|
timeIndex,
|
||||||
eMesh,
|
binary,
|
||||||
postProcPath,
|
ensightCaseFile
|
||||||
prepend,
|
);
|
||||||
timeIndex,
|
}
|
||||||
binary,
|
else if (volFieldTypes[i] == volVectorField::typeName)
|
||||||
ensightCaseFile
|
{
|
||||||
);
|
ensightField<vector>
|
||||||
}
|
(
|
||||||
else if (fieldTypes[i] == volSphericalTensorField::typeName)
|
fieldObject,
|
||||||
{
|
eMesh,
|
||||||
ensightField<sphericalTensor>
|
ensightDir,
|
||||||
(
|
prepend,
|
||||||
fieldObject,
|
timeIndex,
|
||||||
eMesh,
|
binary,
|
||||||
postProcPath,
|
ensightCaseFile
|
||||||
prepend,
|
);
|
||||||
timeIndex,
|
}
|
||||||
binary,
|
else if (volFieldTypes[i] == volSphericalTensorField::typeName)
|
||||||
ensightCaseFile
|
{
|
||||||
);
|
ensightField<sphericalTensor>
|
||||||
}
|
(
|
||||||
else if (fieldTypes[i] == volSymmTensorField::typeName)
|
fieldObject,
|
||||||
{
|
eMesh,
|
||||||
ensightField<symmTensor>
|
ensightDir,
|
||||||
(
|
prepend,
|
||||||
fieldObject,
|
timeIndex,
|
||||||
eMesh,
|
binary,
|
||||||
postProcPath,
|
ensightCaseFile
|
||||||
prepend,
|
);
|
||||||
timeIndex,
|
}
|
||||||
binary,
|
else if (volFieldTypes[i] == volSymmTensorField::typeName)
|
||||||
ensightCaseFile
|
{
|
||||||
);
|
ensightField<symmTensor>
|
||||||
}
|
(
|
||||||
else if (fieldTypes[i] == volTensorField::typeName)
|
fieldObject,
|
||||||
{
|
eMesh,
|
||||||
ensightField<tensor>
|
ensightDir,
|
||||||
(
|
prepend,
|
||||||
fieldObject,
|
timeIndex,
|
||||||
eMesh,
|
binary,
|
||||||
postProcPath,
|
ensightCaseFile
|
||||||
prepend,
|
);
|
||||||
timeIndex,
|
}
|
||||||
binary,
|
else if (volFieldTypes[i] == volTensorField::typeName)
|
||||||
ensightCaseFile
|
{
|
||||||
);
|
ensightField<tensor>
|
||||||
}
|
(
|
||||||
|
fieldObject,
|
||||||
|
eMesh,
|
||||||
|
ensightDir,
|
||||||
|
prepend,
|
||||||
|
timeIndex,
|
||||||
|
binary,
|
||||||
|
ensightCaseFile
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -434,7 +432,7 @@ int main(int argc, char *argv[])
|
|||||||
ensightParticlePositions
|
ensightParticlePositions
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
postProcPath,
|
ensightDir,
|
||||||
timeFile,
|
timeFile,
|
||||||
cloudName,
|
cloudName,
|
||||||
cloudExists
|
cloudExists
|
||||||
@ -460,7 +458,7 @@ int main(int argc, char *argv[])
|
|||||||
ensightCloudField<scalar>
|
ensightCloudField<scalar>
|
||||||
(
|
(
|
||||||
fieldObject,
|
fieldObject,
|
||||||
postProcPath,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
cloudName,
|
cloudName,
|
||||||
@ -473,7 +471,7 @@ int main(int argc, char *argv[])
|
|||||||
ensightCloudField<vector>
|
ensightCloudField<vector>
|
||||||
(
|
(
|
||||||
fieldObject,
|
fieldObject,
|
||||||
postProcPath,
|
ensightDir,
|
||||||
prepend,
|
prepend,
|
||||||
timeIndex,
|
timeIndex,
|
||||||
cloudName,
|
cloudName,
|
||||||
|
|||||||
@ -6,15 +6,13 @@ if (timeDirs.size() > 1)
|
|||||||
hasMovingMesh = true;
|
hasMovingMesh = true;
|
||||||
for (label i=0; i < timeDirs.size() && hasMovingMesh; ++i)
|
for (label i=0; i < timeDirs.size() && hasMovingMesh; ++i)
|
||||||
{
|
{
|
||||||
IOobject io
|
hasMovingMesh = IOobject
|
||||||
(
|
(
|
||||||
"points",
|
"points",
|
||||||
timeDirs[i].name(),
|
timeDirs[i].name(),
|
||||||
polyMesh::meshSubDir,
|
polyMesh::meshSubDir,
|
||||||
mesh,
|
mesh,
|
||||||
IOobject::NO_READ
|
IOobject::NO_READ
|
||||||
);
|
).headerOk();
|
||||||
|
|
||||||
hasMovingMesh = io.headerOk();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,40 +1,40 @@
|
|||||||
// check the final time directory for
|
// check the final time directory for the following:
|
||||||
|
|
||||||
// 1. volume fields
|
// 1. volume fields
|
||||||
HashTable<word> volumeFields;
|
HashTable<word> volumeFields;
|
||||||
|
|
||||||
// 2. the fields for each cloud:
|
// 2. the fields for each cloud:
|
||||||
HashTable<HashTable<word> > cloudFields;
|
HashTable< HashTable<word> > cloudFields;
|
||||||
|
|
||||||
if (timeDirs.size() > 1)
|
if (timeDirs.size())
|
||||||
{
|
{
|
||||||
IOobjectList objs(mesh, timeDirs[timeDirs.size()-1].name());
|
IOobjectList objs(mesh, timeDirs[timeDirs.size()-1].name());
|
||||||
|
|
||||||
forAllConstIter(IOobjectList, objs, fieldIter)
|
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||||
{
|
{
|
||||||
const IOobject& obj = *fieldIter();
|
const IOobject& obj = *fieldIter();
|
||||||
|
const word& fieldName = obj.name();
|
||||||
|
const word& fieldType = obj.headerClassName();
|
||||||
|
|
||||||
if
|
if (fieldName.size() > 2 && fieldName(fieldName.size()-2, 2) == "_0")
|
||||||
(
|
|
||||||
obj.headerClassName() == volScalarField::typeName
|
|
||||||
|| obj.headerClassName() == volVectorField::typeName
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
// Add field and field type
|
// ignore _0 fields
|
||||||
volumeFields.insert
|
}
|
||||||
(
|
else if (volFieldTypes.found(fieldType))
|
||||||
obj.name(),
|
{
|
||||||
obj.headerClassName()
|
// simply ignore types that we don't handle
|
||||||
);
|
volumeFields.insert(fieldName, fieldType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// now check for lagrangian/<cloudName>
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// now check for lagrangian/<cloudName>
|
||||||
|
//
|
||||||
fileNameList cloudDirs = readDir
|
fileNameList cloudDirs = readDir
|
||||||
(
|
(
|
||||||
runTime.path()
|
runTime.path()
|
||||||
/ timeDirs[timeDirs.size() - 1].name()
|
/ timeDirs[timeDirs.size()-1].name()
|
||||||
/ regionPrefix
|
/ regionPrefix
|
||||||
/ cloud::prefix,
|
/ cloud::prefix,
|
||||||
fileName::DIRECTORY
|
fileName::DIRECTORY
|
||||||
@ -47,42 +47,59 @@ if (timeDirs.size() > 1)
|
|||||||
// Create a new hash table for each cloud
|
// Create a new hash table for each cloud
|
||||||
cloudFields.insert(cloudName, HashTable<word>());
|
cloudFields.insert(cloudName, HashTable<word>());
|
||||||
|
|
||||||
// Identify the new cloud in the hash table
|
// Identify the new cloud within the hash table
|
||||||
HashTable<HashTable<word> >::iterator cloudIter =
|
HashTable<HashTable<word> >::iterator cloudIter =
|
||||||
cloudFields.find(cloudName);
|
cloudFields.find(cloudName);
|
||||||
|
|
||||||
IOobjectList cloudObjs
|
IOobjectList objs
|
||||||
(
|
(
|
||||||
mesh,
|
mesh,
|
||||||
timeDirs[timeDirs.size() - 1].name(),
|
timeDirs[timeDirs.size()-1].name(),
|
||||||
cloud::prefix/cloudName
|
cloud::prefix/cloudName
|
||||||
);
|
);
|
||||||
|
|
||||||
bool hasPositions = false;
|
bool hasPositions = false;
|
||||||
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
|
forAllConstIter(IOobjectList, objs, fieldIter)
|
||||||
{
|
{
|
||||||
const IOobject obj = *fieldIter();
|
const IOobject obj = *fieldIter();
|
||||||
|
const word& fieldName = obj.name();
|
||||||
|
const word& fieldType = obj.headerClassName();
|
||||||
|
|
||||||
if (obj.name() == "positions")
|
if (fieldName == "positions")
|
||||||
{
|
{
|
||||||
hasPositions = true;
|
hasPositions = true;
|
||||||
}
|
}
|
||||||
else
|
else if (cloudFieldTypes.found(fieldType))
|
||||||
{
|
{
|
||||||
// Add field and field type
|
// simply ignore types that we don't handle
|
||||||
cloudIter().insert
|
cloudIter().insert(fieldName, fieldType);
|
||||||
(
|
|
||||||
obj.name(),
|
|
||||||
obj.headerClassName()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop this cloud if it has no positions
|
// drop this cloud if it has no positions or is otherwise empty
|
||||||
if (!hasPositions)
|
if (!hasPositions || cloudIter().empty())
|
||||||
{
|
{
|
||||||
|
Info<< "removing cloud " << cloudName << endl;
|
||||||
cloudFields.erase(cloudIter);
|
cloudFields.erase(cloudIter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// verify that the variable is present for all times
|
||||||
|
//
|
||||||
|
for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
|
||||||
|
{
|
||||||
|
IOobjectList objs(mesh, timeDirs[i].name());
|
||||||
|
|
||||||
|
forAllIter(HashTable<word>, volumeFields, fieldIter)
|
||||||
|
{
|
||||||
|
const word& fieldName = fieldIter.key();
|
||||||
|
|
||||||
|
if (!objs.found(fieldName))
|
||||||
|
{
|
||||||
|
volumeFields.erase(fieldIter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -83,23 +83,19 @@ int main(int argc, char *argv[])
|
|||||||
argList::validOptions.insert("index", "start");
|
argList::validOptions.insert("index", "start");
|
||||||
argList::validOptions.insert("noMesh", "");
|
argList::validOptions.insert("noMesh", "");
|
||||||
|
|
||||||
const word volFieldTypes[] =
|
// the volume field types that we handle
|
||||||
{
|
wordHashSet volFieldTypes;
|
||||||
volScalarField::typeName,
|
volFieldTypes.insert(volScalarField::typeName);
|
||||||
volVectorField::typeName,
|
volFieldTypes.insert(volVectorField::typeName);
|
||||||
volSphericalTensorField::typeName,
|
volFieldTypes.insert(volSphericalTensorField::typeName);
|
||||||
volSymmTensorField::typeName,
|
volFieldTypes.insert(volSymmTensorField::typeName);
|
||||||
volTensorField::typeName,
|
volFieldTypes.insert(volTensorField::typeName);
|
||||||
word::null
|
|
||||||
};
|
|
||||||
|
|
||||||
const word sprayFieldTypes[] =
|
// the lagrangian field types that we handle
|
||||||
{
|
wordHashSet cloudFieldTypes;
|
||||||
scalarIOField::typeName,
|
cloudFieldTypes.insert(scalarIOField::typeName);
|
||||||
vectorIOField::typeName,
|
cloudFieldTypes.insert(vectorIOField::typeName);
|
||||||
tensorIOField::typeName,
|
cloudFieldTypes.insert(tensorIOField::typeName);
|
||||||
word::null
|
|
||||||
};
|
|
||||||
|
|
||||||
const char* geometryName = "geometry";
|
const char* geometryName = "geometry";
|
||||||
|
|
||||||
@ -168,7 +164,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
# include "checkHasMovingMesh.H"
|
# include "checkHasMovingMesh.H"
|
||||||
# include "findFields.H"
|
# include "findFields.H"
|
||||||
# include "validateFields.H"
|
|
||||||
|
|
||||||
if (hasMovingMesh && optNoMesh)
|
if (hasMovingMesh && optNoMesh)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -11,8 +11,6 @@
|
|||||||
{
|
{
|
||||||
// Read new points
|
// Read new points
|
||||||
io.readOpt() = IOobject::MUST_READ;
|
io.readOpt() = IOobject::MUST_READ;
|
||||||
pointIOField newPoints(io);
|
mesh.movePoints(pointIOField(io));
|
||||||
|
|
||||||
mesh.movePoints(newPoints);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,105 +0,0 @@
|
|||||||
// ignore special fields or fields that we don't handle
|
|
||||||
//
|
|
||||||
forAllIter(HashTable<word>, volumeFields, fieldIter)
|
|
||||||
{
|
|
||||||
const word& fieldName = fieldIter.key();
|
|
||||||
const word& fieldType = fieldIter();
|
|
||||||
|
|
||||||
// ignore _0 fields
|
|
||||||
if (fieldName.size() > 2 && fieldName(fieldName.size() - 2, 2) == "_0")
|
|
||||||
{
|
|
||||||
volumeFields.erase(fieldIter);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// remove types that we don't handle:
|
|
||||||
bool invalid = true;
|
|
||||||
for (label typeI=0; invalid && volFieldTypes[typeI].size(); ++typeI)
|
|
||||||
{
|
|
||||||
if (fieldType == volFieldTypes[typeI])
|
|
||||||
{
|
|
||||||
invalid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (invalid)
|
|
||||||
{
|
|
||||||
Info<< "ignoring " << fieldType << ": " << fieldName << endl;
|
|
||||||
volumeFields.erase(fieldIter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// verify that the variable is present for all times
|
|
||||||
//
|
|
||||||
for (label i=0; volumeFields.size() && i < timeDirs.size(); ++i)
|
|
||||||
{
|
|
||||||
IOobjectList objs(mesh, timeDirs[i].name());
|
|
||||||
|
|
||||||
forAllIter(HashTable<word>, volumeFields, fieldIter)
|
|
||||||
{
|
|
||||||
const word& fieldName = fieldIter.key();
|
|
||||||
|
|
||||||
if (!objs.found(fieldName))
|
|
||||||
{
|
|
||||||
volumeFields.erase(fieldIter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ignore fields that we don't handle
|
|
||||||
//
|
|
||||||
forAllIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
|
||||||
{
|
|
||||||
const word& cloudName = cloudIter.key();
|
|
||||||
|
|
||||||
forAllIter(HashTable<word>, cloudIter(), fieldIter)
|
|
||||||
{
|
|
||||||
const word& fieldName = fieldIter.key();
|
|
||||||
const word& fieldType = fieldIter();
|
|
||||||
|
|
||||||
// remove types that we don't handle:
|
|
||||||
bool invalid = true;
|
|
||||||
for (label typeI=0; invalid && sprayFieldTypes[typeI].size(); ++typeI)
|
|
||||||
{
|
|
||||||
if (fieldType == sprayFieldTypes[typeI])
|
|
||||||
{
|
|
||||||
invalid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (invalid)
|
|
||||||
{
|
|
||||||
Info<< "ignoring " << fieldType << ": " << fieldName << endl;
|
|
||||||
cloudIter().erase(fieldIter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cloudIter().empty())
|
|
||||||
{
|
|
||||||
Info<< "removing cloud " << cloudName << endl;
|
|
||||||
cloudFields.erase(cloudIter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// DEBUGGING
|
|
||||||
// Info<<"final fields (";
|
|
||||||
// forAllConstIter(HashTable<word>, volumeFields, fieldIter)
|
|
||||||
// {
|
|
||||||
// Info<< " " << fieldIter.key();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// Info<< " )\n";
|
|
||||||
//
|
|
||||||
// forAllConstIter(HashTable<HashTable<word> >, cloudFields, cloudIter)
|
|
||||||
// {
|
|
||||||
// Info<<"final fields for lagrangian/" << cloudIter.key() << " (";
|
|
||||||
// forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
|
|
||||||
// {
|
|
||||||
// Info<< " " << fieldIter.key();
|
|
||||||
// }
|
|
||||||
// Info<< " )\n";
|
|
||||||
// }
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user