mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
updated to incorporate particle post-processing
This commit is contained in:
@ -5,4 +5,3 @@ foamToEnsight.C
|
||||
ensightWriteBinary.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/foamToEnsight
|
||||
//EXE = $(FOAM_USER_APPBIN)/foamToEnsight
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
EXE_INC = \
|
||||
-DFULLDEBUG -g -O0 \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-llagrangian
|
||||
-llagrangian \
|
||||
|
||||
|
||||
@ -1,13 +0,0 @@
|
||||
forAll(Times, n1)
|
||||
{
|
||||
IOobject fieldObjectHeader
|
||||
(
|
||||
fieldName,
|
||||
Times[n1].name(),
|
||||
"lagrangian",
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
);
|
||||
|
||||
variableGood = variableGood && fieldObjectHeader.headerOk();
|
||||
}
|
||||
@ -24,7 +24,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "ensightSprayField.H"
|
||||
#include "ensightCloudField.H"
|
||||
#include "Time.H"
|
||||
#include "IOField.H"
|
||||
#include "OFstream.H"
|
||||
@ -35,39 +35,48 @@ using namespace Foam;
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void ensightSprayField
|
||||
void ensightCloudField
|
||||
(
|
||||
const Foam::IOobject& fieldObject,
|
||||
const Foam::fileName& postProcPath,
|
||||
const Foam::word& prepend,
|
||||
const Foam::label timeIndex,
|
||||
const Foam::word& sprayName,
|
||||
Foam::Ostream& ensightCaseFile
|
||||
const Foam::word& cloudName,
|
||||
Foam::Ostream& ensightCaseFile,
|
||||
const bool dataExists
|
||||
)
|
||||
{
|
||||
Info<< "Converting spray field " << fieldObject.name() << endl;
|
||||
if (dataExists)
|
||||
{
|
||||
Info<< "Converting cloud " << cloudName
|
||||
<< " field " << fieldObject.name() << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Creating empty cloud " << cloudName
|
||||
<< " field " << fieldObject.name() << endl;
|
||||
}
|
||||
|
||||
word timeFile = prepend + itoa(timeIndex);
|
||||
|
||||
const Time& runTime = fieldObject.time();
|
||||
|
||||
if (timeIndex == 0)
|
||||
if (timeIndex == 0 && Pstream::master())
|
||||
{
|
||||
ensightCaseFile
|
||||
<< pTraits<Type>::typeName << " per measured node: 1 ";
|
||||
ensightCaseFile.width(15);
|
||||
ensightCaseFile.setf(ios_base::left);
|
||||
ensightCaseFile
|
||||
<< ("s" + fieldObject.name()).c_str()
|
||||
<< (' ' + prepend + "***." + sprayName
|
||||
<< ("c" + fieldObject.name()).c_str()
|
||||
<< (' ' + prepend + "***." + cloudName
|
||||
+ "." + fieldObject.name()).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
// set the filename of the ensight file
|
||||
fileName ensightFileName
|
||||
(
|
||||
timeFile + "." + sprayName +"." + fieldObject.name()
|
||||
timeFile + "." + cloudName +"." + fieldObject.name()
|
||||
);
|
||||
|
||||
OFstream ensightFile
|
||||
@ -78,36 +87,39 @@ void ensightSprayField
|
||||
runTime.writeCompression()
|
||||
);
|
||||
|
||||
ensightFile << pTraits<Type>::typeName << " values" << nl;
|
||||
ensightFile<< pTraits<Type>::typeName << " values" << nl;
|
||||
|
||||
IOField<Type> vf(fieldObject);
|
||||
|
||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightFile.precision(5);
|
||||
|
||||
label count = 0;
|
||||
forAll(vf, i)
|
||||
if (dataExists)
|
||||
{
|
||||
Type v = vf[i];
|
||||
IOField<Type> vf(fieldObject);
|
||||
|
||||
if (mag(v) < 1.0e-90)
|
||||
{
|
||||
v = pTraits<Type>::zero;
|
||||
}
|
||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightFile.precision(5);
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
label count = 0;
|
||||
forAll(vf, i)
|
||||
{
|
||||
ensightFile << setw(12) << component(v, cmpt);
|
||||
if (++count % 6 == 0)
|
||||
Type v = vf[i];
|
||||
|
||||
if (mag(v) < 1.0e-90)
|
||||
{
|
||||
ensightFile << nl;
|
||||
v = pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
|
||||
{
|
||||
ensightFile << setw(12) << component(v, cmpt);
|
||||
if (++count % 6 == 0)
|
||||
{
|
||||
ensightFile << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( (count % 6 != 0) || (count==0) )
|
||||
{
|
||||
ensightFile << nl;
|
||||
if ((count % 6 != 0) || (count==0))
|
||||
{
|
||||
ensightFile << nl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,33 +28,34 @@ InApplication
|
||||
Description
|
||||
|
||||
SourceFiles
|
||||
ensightSprayField.C
|
||||
ensightCloudField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ensightSprayField_H
|
||||
#define ensightSprayField_H
|
||||
#ifndef ensightCloudField_H
|
||||
#define ensightCloudField_H
|
||||
|
||||
#include "IOobject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void ensightSprayField
|
||||
void ensightCloudField
|
||||
(
|
||||
const Foam::IOobject& fieldObject,
|
||||
const Foam::fileName& postProcPath,
|
||||
const Foam::word& prepend,
|
||||
const Foam::label timeIndex,
|
||||
const Foam::word& timeFile,
|
||||
const Foam::word& sprayName,
|
||||
Foam::Ostream& ensightCaseFile
|
||||
const Foam::word& cloudName,
|
||||
Foam::Ostream& ensightCaseFile,
|
||||
const bool dataExists
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "ensightSprayField.C"
|
||||
# include "ensightCloudField.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -278,7 +278,7 @@ bool writePatchField
|
||||
const Foam::label patchi,
|
||||
const Foam::label ensightPatchi,
|
||||
const Foam::faceSets& boundaryFaceSet,
|
||||
const Foam::ensightMesh::nFacePrims& nfp,
|
||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||
const Foam::labelList& patchProcessors,
|
||||
Foam::OFstream& ensightFile
|
||||
)
|
||||
@ -338,7 +338,7 @@ bool writePatchFieldBinary
|
||||
const Foam::label patchi,
|
||||
const Foam::label ensightPatchi,
|
||||
const Foam::faceSets& boundaryFaceSet,
|
||||
const Foam::ensightMesh::nFacePrims& nfp,
|
||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||
const Foam::labelList& patchProcessors,
|
||||
std::ofstream& ensightFile
|
||||
)
|
||||
@ -403,12 +403,13 @@ void writePatchField
|
||||
Foam::Ostream& ensightCaseFile
|
||||
)
|
||||
{
|
||||
const Time& runTime = eMesh.mesh.time();
|
||||
const Time& runTime = eMesh.mesh().time();
|
||||
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets;
|
||||
const HashTable<labelList>& allPatchNames = eMesh.allPatchNames;
|
||||
const HashTable<label>& patchIndices = eMesh.patchIndices;
|
||||
const HashTable<ensightMesh::nFacePrims>& nPatchPrims = eMesh.nPatchPrims;
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
|
||||
label patchi = -1;
|
||||
|
||||
@ -521,15 +522,16 @@ void ensightFieldAscii
|
||||
|
||||
word timeFile = prepend + itoa(timeIndex);
|
||||
|
||||
const fvMesh& mesh = eMesh.mesh;
|
||||
const fvMesh& mesh = eMesh.mesh();
|
||||
const Time& runTime = mesh.time();
|
||||
|
||||
const cellSets& meshCellSets = eMesh.meshCellSets;
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets;
|
||||
const HashTable<labelList>& allPatchNames = eMesh.allPatchNames;
|
||||
const HashTable<label>& patchIndices = eMesh.patchIndices;
|
||||
const wordHashSet& patchNames = eMesh.patchNames;
|
||||
const HashTable<ensightMesh::nFacePrims>& nPatchPrims = eMesh.nPatchPrims;
|
||||
const cellSets& meshCellSets = eMesh.meshCellSets();
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||
const HashTable<labelList>& allPatchNames = eMesh.allPatchNames();
|
||||
const HashTable<label>& patchIndices = eMesh.patchIndices();
|
||||
const wordHashSet& patchNames = eMesh.patchNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
|
||||
const labelList& tets = meshCellSets.tets;
|
||||
const labelList& pyrs = meshCellSets.pyrs;
|
||||
@ -701,15 +703,16 @@ void ensightFieldBinary
|
||||
|
||||
word timeFile = prepend + itoa(timeIndex);
|
||||
|
||||
const fvMesh& mesh = eMesh.mesh;
|
||||
const fvMesh& mesh = eMesh.mesh();
|
||||
//const Time& runTime = mesh.time();
|
||||
|
||||
const cellSets& meshCellSets = eMesh.meshCellSets;
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets;
|
||||
const HashTable<labelList>& allPatchNames = eMesh.allPatchNames;
|
||||
const HashTable<label>& patchIndices = eMesh.patchIndices;
|
||||
const wordHashSet& patchNames = eMesh.patchNames;
|
||||
const HashTable<ensightMesh::nFacePrims>& nPatchPrims = eMesh.nPatchPrims;
|
||||
const cellSets& meshCellSets = eMesh.meshCellSets();
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||
const HashTable<labelList>& allPatchNames = eMesh.allPatchNames();
|
||||
const HashTable<label>& patchIndices = eMesh.patchIndices();
|
||||
const wordHashSet& patchNames = eMesh.patchNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
|
||||
const labelList& tets = meshCellSets.tets;
|
||||
const labelList& pyrs = meshCellSets.pyrs;
|
||||
|
||||
@ -52,12 +52,7 @@ public:
|
||||
const HashTable<labelList>& y
|
||||
) const
|
||||
{
|
||||
for
|
||||
(
|
||||
HashTable<labelList>::const_iterator iter = y.begin();
|
||||
iter != y.end();
|
||||
++iter
|
||||
)
|
||||
forAllConstIter(HashTable<labelList>, y, iter)
|
||||
{
|
||||
HashTable<labelList>::iterator xiter = x.find(iter.key());
|
||||
|
||||
@ -89,38 +84,46 @@ public:
|
||||
|
||||
Foam::ensightMesh::ensightMesh
|
||||
(
|
||||
const fvMesh& fMesh,
|
||||
const fvMesh& mesh,
|
||||
const argList& args,
|
||||
const bool binary
|
||||
)
|
||||
:
|
||||
binary_(binary),
|
||||
mesh(fMesh),
|
||||
meshCellSets(mesh.nCells()),
|
||||
boundaryFaceSets(mesh.boundary().size())
|
||||
mesh_(mesh),
|
||||
meshCellSets_(mesh_.nCells()),
|
||||
boundaryFaceSets_(mesh_.boundary().size()),
|
||||
allPatchNames_(0),
|
||||
patchIndices_(0),
|
||||
patchNames_(0),
|
||||
nPatchPrims_(0)
|
||||
{
|
||||
forAll (mesh.boundaryMesh(), patchi)
|
||||
forAll (mesh_.boundaryMesh(), patchi)
|
||||
{
|
||||
if (typeid(mesh.boundaryMesh()[patchi]) != typeid(processorPolyPatch))
|
||||
if
|
||||
(
|
||||
typeid(mesh_.boundaryMesh()[patchi])
|
||||
!= typeid(processorPolyPatch)
|
||||
)
|
||||
{
|
||||
if (!allPatchNames.found(mesh.boundaryMesh()[patchi].name()))
|
||||
if (!allPatchNames_.found(mesh_.boundaryMesh()[patchi].name()))
|
||||
{
|
||||
allPatchNames.insert
|
||||
allPatchNames_.insert
|
||||
(
|
||||
mesh.boundaryMesh()[patchi].name(),
|
||||
mesh_.boundaryMesh()[patchi].name(),
|
||||
labelList(1, Pstream::myProcNo())
|
||||
);
|
||||
|
||||
patchIndices.insert
|
||||
patchIndices_.insert
|
||||
(
|
||||
mesh.boundaryMesh()[patchi].name(),
|
||||
mesh_.boundaryMesh()[patchi].name(),
|
||||
patchi
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
combineReduce(allPatchNames, concatPatchNames());
|
||||
combineReduce(allPatchNames_, concatPatchNames());
|
||||
|
||||
if (args.options().found("patches"))
|
||||
{
|
||||
@ -128,12 +131,12 @@ Foam::ensightMesh::ensightMesh
|
||||
|
||||
if (!patchNameList.size())
|
||||
{
|
||||
patchNameList = allPatchNames.toc();
|
||||
patchNameList = allPatchNames_.toc();
|
||||
}
|
||||
|
||||
forAll (patchNameList, i)
|
||||
{
|
||||
patchNames.insert(patchNameList[i]);
|
||||
patchNames_.insert(patchNameList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,12 +148,12 @@ Foam::ensightMesh::ensightMesh
|
||||
const cellModel& wedge = *(cellModeller::lookup("wedge"));
|
||||
const cellModel& hex = *(cellModeller::lookup("hex"));
|
||||
|
||||
labelList& tets = meshCellSets.tets;
|
||||
labelList& pyrs = meshCellSets.pyrs;
|
||||
labelList& prisms = meshCellSets.prisms;
|
||||
labelList& wedges = meshCellSets.wedges;
|
||||
labelList& hexes = meshCellSets.hexes;
|
||||
labelList& polys = meshCellSets.polys;
|
||||
labelList& tets = meshCellSets_.tets;
|
||||
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;
|
||||
@ -160,7 +163,7 @@ Foam::ensightMesh::ensightMesh
|
||||
label nHexes = 0;
|
||||
label nPolys = 0;
|
||||
|
||||
if (!patchNames.size())
|
||||
if (!patchNames_.size())
|
||||
{
|
||||
forAll(cellShapes, celli)
|
||||
{
|
||||
@ -200,20 +203,20 @@ Foam::ensightMesh::ensightMesh
|
||||
hexes.setSize(nHexes);
|
||||
polys.setSize(nPolys);
|
||||
|
||||
meshCellSets.nTets = nTets;
|
||||
reduce(meshCellSets.nTets, sumOp<label>());
|
||||
meshCellSets_.nTets = nTets;
|
||||
reduce(meshCellSets_.nTets, sumOp<label>());
|
||||
|
||||
meshCellSets.nPyrs = nPyrs;
|
||||
reduce(meshCellSets.nPyrs, sumOp<label>());
|
||||
meshCellSets_.nPyrs = nPyrs;
|
||||
reduce(meshCellSets_.nPyrs, sumOp<label>());
|
||||
|
||||
meshCellSets.nPrisms = nPrisms;
|
||||
reduce(meshCellSets.nPrisms, sumOp<label>());
|
||||
meshCellSets_.nPrisms = nPrisms;
|
||||
reduce(meshCellSets_.nPrisms, sumOp<label>());
|
||||
|
||||
meshCellSets.nHexesWedges = nHexes + nWedges;
|
||||
reduce(meshCellSets.nHexesWedges, sumOp<label>());
|
||||
meshCellSets_.nHexesWedges = nHexes + nWedges;
|
||||
reduce(meshCellSets_.nHexesWedges, sumOp<label>());
|
||||
|
||||
meshCellSets.nPolys = nPolys;
|
||||
reduce(meshCellSets.nPolys, sumOp<label>());
|
||||
meshCellSets_.nPolys = nPolys;
|
||||
reduce(meshCellSets_.nPolys, sumOp<label>());
|
||||
}
|
||||
|
||||
|
||||
@ -223,9 +226,9 @@ Foam::ensightMesh::ensightMesh
|
||||
{
|
||||
const polyPatch& p = mesh.boundaryMesh()[patchi];
|
||||
|
||||
labelList& tris = boundaryFaceSets[patchi].tris;
|
||||
labelList& quads = boundaryFaceSets[patchi].quads;
|
||||
labelList& polys = boundaryFaceSets[patchi].polys;
|
||||
labelList& tris = boundaryFaceSets_[patchi].tris;
|
||||
labelList& quads = boundaryFaceSets_[patchi].quads;
|
||||
labelList& polys = boundaryFaceSets_[patchi].polys;
|
||||
|
||||
tris.setSize(p.size());
|
||||
quads.setSize(p.size());
|
||||
@ -259,26 +262,21 @@ Foam::ensightMesh::ensightMesh
|
||||
}
|
||||
}
|
||||
|
||||
for
|
||||
(
|
||||
HashTable<labelList>::const_iterator iter = allPatchNames.begin();
|
||||
iter != allPatchNames.end();
|
||||
++iter
|
||||
)
|
||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
nFacePrims nfp;
|
||||
nFacePrimitives nfp;
|
||||
|
||||
if (!patchNames.size() || patchNames.found(patchName))
|
||||
if (!patchNames_.size() || patchNames_.found(patchName))
|
||||
{
|
||||
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.nTris = boundaryFaceSets[patchi].tris.size();
|
||||
nfp.nQuads = boundaryFaceSets[patchi].quads.size();
|
||||
nfp.nPolys = boundaryFaceSets[patchi].polys.size();
|
||||
nfp.nTris = boundaryFaceSets_[patchi].tris.size();
|
||||
nfp.nQuads = boundaryFaceSets_[patchi].quads.size();
|
||||
nfp.nPolys = boundaryFaceSets_[patchi].polys.size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,7 +285,7 @@ Foam::ensightMesh::ensightMesh
|
||||
reduce(nfp.nQuads, sumOp<label>());
|
||||
reduce(nfp.nPolys, sumOp<label>());
|
||||
|
||||
nPatchPrims.insert(patchName, nfp);
|
||||
nPatchPrims_.insert(patchName, nfp);
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,7 +306,7 @@ void Foam::ensightMesh::writePoints
|
||||
{
|
||||
forAll(pointsComponent, pointi)
|
||||
{
|
||||
ensightGeometryFile << setw(12) << float(pointsComponent[pointi]) << nl;
|
||||
ensightGeometryFile<< setw(12) << float(pointsComponent[pointi]) << nl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,7 +406,7 @@ void Foam::ensightMesh::writePrimsBinary
|
||||
if (cellShapes.size() > 0)
|
||||
{
|
||||
// All the cellShapes have the same number of elements!
|
||||
int numIntElem = cellShapes.size() * cellShapes[0].size();
|
||||
int numIntElem = cellShapes.size()*cellShapes[0].size();
|
||||
List<int> temp(numIntElem);
|
||||
|
||||
int n = 0;
|
||||
@ -866,11 +864,11 @@ void Foam::ensightMesh::writeAscii
|
||||
Ostream& ensightCaseFile
|
||||
) const
|
||||
{
|
||||
const Time& runTime = mesh.time();
|
||||
const pointField& points = mesh.points();
|
||||
const cellList& cellFaces = mesh.cells();
|
||||
const faceList& faces = mesh.faces();
|
||||
const cellShapeList& cellShapes = mesh.cellShapes();
|
||||
const Time& runTime = mesh_.time();
|
||||
const pointField& points = mesh_.points();
|
||||
const cellList& cellFaces = mesh_.cells();
|
||||
const faceList& faces = mesh_.faces();
|
||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||
|
||||
word timeFile = prepend;
|
||||
|
||||
@ -878,7 +876,7 @@ void Foam::ensightMesh::writeAscii
|
||||
{
|
||||
timeFile += "000.";
|
||||
}
|
||||
else if (mesh.moving())
|
||||
else if (mesh_.moving())
|
||||
{
|
||||
timeFile += itoa(timeIndex) + '.';
|
||||
}
|
||||
@ -919,7 +917,7 @@ void Foam::ensightMesh::writeAscii
|
||||
|
||||
labelList pointOffsets(Pstream::nProcs(), 0);
|
||||
|
||||
if (!patchNames.size())
|
||||
if (!patchNames_.size())
|
||||
{
|
||||
label nPoints = points.size();
|
||||
Pstream::gather(nPoints, sumOp<label>());
|
||||
@ -962,8 +960,8 @@ void Foam::ensightMesh::writeAscii
|
||||
writeAllPrims
|
||||
(
|
||||
"hexa8",
|
||||
meshCellSets.nHexesWedges,
|
||||
map(cellShapes, meshCellSets.hexes, meshCellSets.wedges),
|
||||
meshCellSets_.nHexesWedges,
|
||||
map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
@ -971,8 +969,8 @@ void Foam::ensightMesh::writeAscii
|
||||
writeAllPrims
|
||||
(
|
||||
"penta6",
|
||||
meshCellSets.nPrisms,
|
||||
map(cellShapes, meshCellSets.prisms),
|
||||
meshCellSets_.nPrisms,
|
||||
map(cellShapes, meshCellSets_.prisms),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
@ -980,8 +978,8 @@ void Foam::ensightMesh::writeAscii
|
||||
writeAllPrims
|
||||
(
|
||||
"pyramid5",
|
||||
meshCellSets.nPyrs,
|
||||
map(cellShapes, meshCellSets.pyrs),
|
||||
meshCellSets_.nPyrs,
|
||||
map(cellShapes, meshCellSets_.pyrs),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
@ -989,25 +987,25 @@ void Foam::ensightMesh::writeAscii
|
||||
writeAllPrims
|
||||
(
|
||||
"tetra4",
|
||||
meshCellSets.nTets,
|
||||
map(cellShapes, meshCellSets.tets),
|
||||
meshCellSets_.nTets,
|
||||
map(cellShapes, meshCellSets_.tets),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
|
||||
|
||||
if (meshCellSets.nPolys)
|
||||
if (meshCellSets_.nPolys)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
/*
|
||||
ensightGeometryFile
|
||||
<< "nfaced" << nl
|
||||
<< setw(10) << meshCellSets.nPolys << nl;
|
||||
<< setw(10) << meshCellSets_.nPolys << nl;
|
||||
*/
|
||||
writePolys
|
||||
(
|
||||
meshCellSets.polys,
|
||||
meshCellSets_.polys,
|
||||
cellFaces,
|
||||
faces,
|
||||
0,
|
||||
@ -1034,7 +1032,7 @@ void Foam::ensightMesh::writeAscii
|
||||
else
|
||||
{
|
||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||
toMaster<< meshCellSets.polys << cellFaces << faces;
|
||||
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1042,19 +1040,14 @@ void Foam::ensightMesh::writeAscii
|
||||
|
||||
label ensightPatchi = 2;
|
||||
|
||||
for
|
||||
(
|
||||
HashTable<labelList>::const_iterator iter = allPatchNames.begin();
|
||||
iter != allPatchNames.end();
|
||||
++iter
|
||||
)
|
||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||
{
|
||||
const labelList& patchProcessors = iter();
|
||||
|
||||
if (!patchNames.size() || patchNames.found(iter.key()))
|
||||
if (!patchNames_.size() || patchNames_.found(iter.key()))
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const nFacePrims& nfp = nPatchPrims.find(patchName)();
|
||||
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
|
||||
|
||||
const labelList *trisPtr = NULL;
|
||||
const labelList *quadsPtr = NULL;
|
||||
@ -1063,14 +1056,14 @@ void Foam::ensightMesh::writeAscii
|
||||
const pointField *patchPointsPtr = NULL;
|
||||
const faceList *patchFacesPtr = NULL;
|
||||
|
||||
if (patchIndices.found(iter.key()))
|
||||
if (patchIndices_.found(iter.key()))
|
||||
{
|
||||
label patchi = patchIndices.find(iter.key())();
|
||||
const polyPatch& p = mesh.boundaryMesh()[patchi];
|
||||
label patchi = patchIndices_.find(iter.key())();
|
||||
const polyPatch& p = mesh_.boundaryMesh()[patchi];
|
||||
|
||||
trisPtr = &boundaryFaceSets[patchi].tris;
|
||||
quadsPtr = &boundaryFaceSets[patchi].quads;
|
||||
polysPtr = &boundaryFaceSets[patchi].polys;
|
||||
trisPtr = &boundaryFaceSets_[patchi].tris;
|
||||
quadsPtr = &boundaryFaceSets_[patchi].quads;
|
||||
polysPtr = &boundaryFaceSets_[patchi].polys;
|
||||
|
||||
patchPointsPtr = &(p.localPoints());
|
||||
patchFacesPtr = &(p.localFaces());
|
||||
@ -1207,10 +1200,10 @@ void Foam::ensightMesh::writeBinary
|
||||
) const
|
||||
{
|
||||
//const Time& runTime = mesh.time();
|
||||
const pointField& points = mesh.points();
|
||||
const cellList& cellFaces = mesh.cells();
|
||||
const faceList& faces = mesh.faces();
|
||||
const cellShapeList& cellShapes = mesh.cellShapes();
|
||||
const pointField& points = mesh_.points();
|
||||
const cellList& cellFaces = mesh_.cells();
|
||||
const faceList& faces = mesh_.faces();
|
||||
const cellShapeList& cellShapes = mesh_.cellShapes();
|
||||
|
||||
word timeFile = prepend;
|
||||
|
||||
@ -1218,7 +1211,7 @@ void Foam::ensightMesh::writeBinary
|
||||
{
|
||||
timeFile += "000.";
|
||||
}
|
||||
else if (mesh.moving())
|
||||
else if (mesh_.moving())
|
||||
{
|
||||
timeFile += itoa(timeIndex) + '.';
|
||||
}
|
||||
@ -1230,7 +1223,11 @@ void Foam::ensightMesh::writeBinary
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightGeometryFilePtr = new std::ofstream((postProcPath/ensightGeometryFileName).c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||
ensightGeometryFilePtr = new std::ofstream
|
||||
(
|
||||
(postProcPath/ensightGeometryFileName).c_str(),
|
||||
ios_base::out | ios_base::binary | ios_base::trunc
|
||||
);
|
||||
// Check on file opened?
|
||||
}
|
||||
|
||||
@ -1247,7 +1244,7 @@ void Foam::ensightMesh::writeBinary
|
||||
|
||||
labelList pointOffsets(Pstream::nProcs(), 0);
|
||||
|
||||
if (!patchNames.size())
|
||||
if (!patchNames_.size())
|
||||
{
|
||||
label nPoints = points.size();
|
||||
Pstream::gather(nPoints, sumOp<label>());
|
||||
@ -1290,8 +1287,8 @@ void Foam::ensightMesh::writeBinary
|
||||
writeAllPrimsBinary
|
||||
(
|
||||
"hexa8",
|
||||
meshCellSets.nHexesWedges,
|
||||
map(cellShapes, meshCellSets.hexes, meshCellSets.wedges),
|
||||
meshCellSets_.nHexesWedges,
|
||||
map(cellShapes, meshCellSets_.hexes, meshCellSets_.wedges),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
@ -1299,8 +1296,8 @@ void Foam::ensightMesh::writeBinary
|
||||
writeAllPrimsBinary
|
||||
(
|
||||
"penta6",
|
||||
meshCellSets.nPrisms,
|
||||
map(cellShapes, meshCellSets.prisms),
|
||||
meshCellSets_.nPrisms,
|
||||
map(cellShapes, meshCellSets_.prisms),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
@ -1308,8 +1305,8 @@ void Foam::ensightMesh::writeBinary
|
||||
writeAllPrimsBinary
|
||||
(
|
||||
"pyramid5",
|
||||
meshCellSets.nPyrs,
|
||||
map(cellShapes, meshCellSets.pyrs),
|
||||
meshCellSets_.nPyrs,
|
||||
map(cellShapes, meshCellSets_.pyrs),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
@ -1317,24 +1314,24 @@ void Foam::ensightMesh::writeBinary
|
||||
writeAllPrimsBinary
|
||||
(
|
||||
"tetra4",
|
||||
meshCellSets.nTets,
|
||||
map(cellShapes, meshCellSets.tets),
|
||||
meshCellSets_.nTets,
|
||||
map(cellShapes, meshCellSets_.tets),
|
||||
pointOffsets,
|
||||
ensightGeometryFile
|
||||
);
|
||||
|
||||
if (meshCellSets.nPolys)
|
||||
if (meshCellSets_.nPolys)
|
||||
{
|
||||
if (Pstream::master())
|
||||
{
|
||||
/*
|
||||
ensightGeometryFile
|
||||
<< "nfaced" << nl
|
||||
<< setw(10) << meshCellSets.nPolys << nl;
|
||||
<< setw(10) << meshCellSets_.nPolys << nl;
|
||||
*/
|
||||
writePolysBinary
|
||||
(
|
||||
meshCellSets.polys,
|
||||
meshCellSets_.polys,
|
||||
cellFaces,
|
||||
faces,
|
||||
0,
|
||||
@ -1361,7 +1358,7 @@ void Foam::ensightMesh::writeBinary
|
||||
else
|
||||
{
|
||||
OPstream toMaster(Pstream::scheduled, Pstream::masterNo());
|
||||
toMaster<< meshCellSets.polys << cellFaces << faces;
|
||||
toMaster<< meshCellSets_.polys << cellFaces << faces;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1371,20 +1368,15 @@ void Foam::ensightMesh::writeBinary
|
||||
|
||||
label iCount = 0;
|
||||
|
||||
for
|
||||
(
|
||||
HashTable<labelList>::const_iterator iter = allPatchNames.begin();
|
||||
iter != allPatchNames.end();
|
||||
++iter
|
||||
)
|
||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||
{
|
||||
iCount ++;
|
||||
const labelList& patchProcessors = iter();
|
||||
|
||||
if (!patchNames.size() || patchNames.found(iter.key()))
|
||||
if (!patchNames_.size() || patchNames_.found(iter.key()))
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const nFacePrims& nfp = nPatchPrims.find(patchName)();
|
||||
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
|
||||
|
||||
const labelList *trisPtr = NULL;
|
||||
const labelList *quadsPtr = NULL;
|
||||
@ -1393,14 +1385,14 @@ void Foam::ensightMesh::writeBinary
|
||||
const pointField *patchPointsPtr = NULL;
|
||||
const faceList *patchFacesPtr = NULL;
|
||||
|
||||
if (patchIndices.found(iter.key()))
|
||||
if (patchIndices_.found(iter.key()))
|
||||
{
|
||||
label patchi = patchIndices.find(iter.key())();
|
||||
const polyPatch& p = mesh.boundaryMesh()[patchi];
|
||||
label patchi = patchIndices_.find(iter.key())();
|
||||
const polyPatch& p = mesh_.boundaryMesh()[patchi];
|
||||
|
||||
trisPtr = &boundaryFaceSets[patchi].tris;
|
||||
quadsPtr = &boundaryFaceSets[patchi].quads;
|
||||
polysPtr = &boundaryFaceSets[patchi].polys;
|
||||
trisPtr = &boundaryFaceSets_[patchi].tris;
|
||||
quadsPtr = &boundaryFaceSets_[patchi].quads;
|
||||
polysPtr = &boundaryFaceSets_[patchi].polys;
|
||||
|
||||
patchPointsPtr = &(p.localPoints());
|
||||
patchFacesPtr = &(p.localFaces());
|
||||
|
||||
@ -57,11 +57,48 @@ class argList;
|
||||
|
||||
class ensightMesh
|
||||
{
|
||||
class nFacePrimitives
|
||||
{
|
||||
public:
|
||||
|
||||
label nPoints;
|
||||
label nTris;
|
||||
label nQuads;
|
||||
label nPolys;
|
||||
|
||||
nFacePrimitives()
|
||||
:
|
||||
nPoints(0),
|
||||
nTris(0),
|
||||
nQuads(0),
|
||||
nPolys(0)
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
// Private data
|
||||
|
||||
//- Set binary file output
|
||||
bool binary_;
|
||||
|
||||
//- Reference to the OpenFOAM mesh
|
||||
const fvMesh& mesh_;
|
||||
|
||||
cellSets meshCellSets_;
|
||||
|
||||
List<faceSets> boundaryFaceSets_;
|
||||
|
||||
|
||||
|
||||
|
||||
HashTable<labelList> allPatchNames_;
|
||||
|
||||
HashTable<label> patchIndices_;
|
||||
|
||||
wordHashSet patchNames_;
|
||||
|
||||
HashTable<nFacePrimitives> nPatchPrims_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -203,37 +240,6 @@ class ensightMesh
|
||||
|
||||
public:
|
||||
|
||||
// Public data
|
||||
|
||||
const fvMesh& mesh;
|
||||
cellSets meshCellSets;
|
||||
List<faceSets> boundaryFaceSets;
|
||||
|
||||
HashTable<labelList> allPatchNames;
|
||||
HashTable<label> patchIndices;
|
||||
wordHashSet patchNames;
|
||||
|
||||
class nFacePrims
|
||||
{
|
||||
public:
|
||||
|
||||
label nPoints;
|
||||
label nTris;
|
||||
label nQuads;
|
||||
label nPolys;
|
||||
|
||||
nFacePrims()
|
||||
:
|
||||
nPoints(0),
|
||||
nTris(0),
|
||||
nQuads(0),
|
||||
nPolys(0)
|
||||
{}
|
||||
};
|
||||
|
||||
HashTable<nFacePrims> nPatchPrims;
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from fvMesh
|
||||
@ -247,6 +253,46 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
|
||||
const fvMesh& mesh() const
|
||||
{
|
||||
return mesh_;
|
||||
}
|
||||
|
||||
const cellSets& meshCellSets() const
|
||||
{
|
||||
return meshCellSets_;
|
||||
}
|
||||
|
||||
const List<faceSets>& boundaryFaceSets() const
|
||||
{
|
||||
return boundaryFaceSets_;
|
||||
}
|
||||
|
||||
const HashTable<labelList>& allPatchNames() const
|
||||
{
|
||||
return allPatchNames_;
|
||||
}
|
||||
|
||||
const HashTable<label>& patchIndices() const
|
||||
{
|
||||
return patchIndices_;
|
||||
}
|
||||
|
||||
const wordHashSet& patchNames() const
|
||||
{
|
||||
return patchNames_;
|
||||
}
|
||||
|
||||
const HashTable<nFacePrimitives>& nPatchPrims() const
|
||||
{
|
||||
return nPatchPrims_;
|
||||
}
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
void write
|
||||
(
|
||||
const fileName& postProcPath,
|
||||
|
||||
@ -41,14 +41,22 @@ void ensightParticlePositions
|
||||
const Foam::fvMesh& mesh,
|
||||
const Foam::fileName& postProcPath,
|
||||
const Foam::word& timeFile,
|
||||
const Foam::word& sprayName
|
||||
const Foam::word& cloudName,
|
||||
const bool dataExists
|
||||
)
|
||||
{
|
||||
if (dataExists)
|
||||
{
|
||||
Info<< "Converting cloud " << cloudName << " positions" << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Creating empty cloud " << cloudName << " positions" << endl;
|
||||
}
|
||||
|
||||
const Time& runTime = mesh.time();
|
||||
|
||||
Cloud<passiveParticle> parcels(mesh);
|
||||
|
||||
fileName ensightFileName(timeFile + "."+ sprayName);
|
||||
fileName ensightFileName(timeFile + "." + cloudName);
|
||||
OFstream ensightFile
|
||||
(
|
||||
postProcPath/ensightFileName,
|
||||
@ -59,31 +67,36 @@ void ensightParticlePositions
|
||||
|
||||
// Output header
|
||||
ensightFile
|
||||
<< "lagrangian " << nl
|
||||
<< cloudName.c_str() << nl
|
||||
<< "particle coordinates" << nl;
|
||||
|
||||
// Set Format
|
||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightFile.precision(5);
|
||||
|
||||
ensightFile << setw(8) << parcels.size() << nl;
|
||||
|
||||
label nParcels = 0;
|
||||
|
||||
// Output position
|
||||
for
|
||||
(
|
||||
Cloud<passiveParticle>::iterator elmnt = parcels.begin();
|
||||
elmnt != parcels.end();
|
||||
++elmnt
|
||||
)
|
||||
if (dataExists)
|
||||
{
|
||||
const vector& p = elmnt().position();
|
||||
Cloud<passiveParticle> parcels(mesh, cloudName, false);
|
||||
|
||||
ensightFile
|
||||
<< setw(8) << ++nParcels
|
||||
<< setw(12) << p.x() << setw(12) << p.y() << setw(12) << p.z()
|
||||
<< nl;
|
||||
// Set Format
|
||||
ensightFile.setf(ios_base::scientific, ios_base::floatfield);
|
||||
ensightFile.precision(5);
|
||||
|
||||
ensightFile<< setw(8) << parcels.size() << nl;
|
||||
|
||||
label nParcels = 0;
|
||||
|
||||
// Output positions
|
||||
forAllConstIter(Cloud<passiveParticle>, parcels, elmnt)
|
||||
{
|
||||
const vector& p = elmnt().position();
|
||||
|
||||
ensightFile
|
||||
<< setw(8) << ++nParcels
|
||||
<< setw(12) << p.x() << setw(12) << p.y() << setw(12) << p.z()
|
||||
<< nl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label nParcels = 0;
|
||||
ensightFile<< setw(8) << nParcels << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,8 @@ void ensightParticlePositions
|
||||
const Foam::fvMesh& mesh,
|
||||
const Foam::fileName& postProcPath,
|
||||
const Foam::word& timeFile,
|
||||
const Foam::word& sprayName
|
||||
const Foam::word& CloudName,
|
||||
const bool dataExists
|
||||
);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -24,22 +24,26 @@ License
|
||||
|
||||
Description
|
||||
Translates FOAM data to EnSight format
|
||||
Parallel support for cloud data is not supported
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "volFields.H"
|
||||
#include "tensorIOField.H"
|
||||
#include "IOobjectList.H"
|
||||
#include "OFstream.H"
|
||||
#include "IOmanip.H"
|
||||
#include "OFstream.H"
|
||||
|
||||
#include "volFields.H"
|
||||
|
||||
#include "labelIOField.H"
|
||||
#include "scalarIOField.H"
|
||||
#include "tensorIOField.H"
|
||||
|
||||
#include "ensightMesh.H"
|
||||
#include "ensightField.H"
|
||||
|
||||
#include "ensightParticlePositions.H"
|
||||
#include "ensightSprayField.H"
|
||||
#include "ensightCloudField.H"
|
||||
|
||||
#include "fvc.H"
|
||||
|
||||
@ -47,6 +51,24 @@ using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool inFileNameList
|
||||
(
|
||||
const fileNameList& nameList,
|
||||
const word& name
|
||||
)
|
||||
{
|
||||
forAll(nameList, i)
|
||||
{
|
||||
if (nameList[i] == name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
@ -55,21 +77,15 @@ int main(int argc, char *argv[])
|
||||
argList::validOptions.insert("binary", "" );
|
||||
# include "addTimeOptions.H"
|
||||
|
||||
const label nTypes = 2;
|
||||
const word fieldTypes[] =
|
||||
{
|
||||
volScalarField::typeName,
|
||||
volVectorField::typeName
|
||||
};
|
||||
|
||||
const label nSprayFieldTypes = 2;
|
||||
const word sprayFieldTypes[] =
|
||||
{
|
||||
scalarIOField::typeName,
|
||||
vectorIOField::typeName
|
||||
};
|
||||
|
||||
# include "setRootCase.H"
|
||||
|
||||
// Check options
|
||||
bool binary = false;
|
||||
if (args.options().found("binary"))
|
||||
{
|
||||
binary = true;
|
||||
}
|
||||
|
||||
# include "createTime.H"
|
||||
|
||||
// get the available time-steps
|
||||
@ -79,12 +95,29 @@ int main(int argc, char *argv[])
|
||||
|
||||
runTime.setTime(Times[startTime], startTime);
|
||||
|
||||
# include "createMesh.H"
|
||||
# include "createNamedMesh.H"
|
||||
|
||||
// Mesh instance (region0 gets filtered out)
|
||||
fileName regionPrefix = "";
|
||||
|
||||
if (regionName != polyMesh::defaultRegion)
|
||||
{
|
||||
regionPrefix = regionName;
|
||||
}
|
||||
|
||||
const label nTypes = 2;
|
||||
const word fieldTypes[] =
|
||||
{
|
||||
volScalarField::typeName,
|
||||
volVectorField::typeName
|
||||
};
|
||||
|
||||
// Create the output folder
|
||||
const word postProcDir = "EnSight";
|
||||
const word prepend = args.globalCaseName() + '.';
|
||||
const word sprayName = "lagrangian";
|
||||
|
||||
// Path to EnSight folder at case level only
|
||||
// - For parallel cases, data only written from master
|
||||
// fileName postProcPath = runTime.path()/postProcDir;
|
||||
fileName postProcPath = args.rootPath()/args.globalCaseName()/postProcDir;
|
||||
|
||||
if (Pstream::master())
|
||||
@ -97,18 +130,14 @@ int main(int argc, char *argv[])
|
||||
mkDir(postProcPath);
|
||||
}
|
||||
|
||||
// Start of case file header output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
const word prepend = args.globalCaseName() + '.';
|
||||
|
||||
OFstream *ensightCaseFilePtr = NULL;
|
||||
|
||||
// Check options
|
||||
bool binary = false;
|
||||
if (args.options().found("binary"))
|
||||
{
|
||||
binary = true;
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
// Open the Case file
|
||||
fileName ensightCaseFileName = prepend + "case";
|
||||
|
||||
if (!binary)
|
||||
@ -137,49 +166,117 @@ int main(int argc, char *argv[])
|
||||
|
||||
OFstream& ensightCaseFile = *ensightCaseFilePtr;
|
||||
|
||||
# include "ensightCaseHeader.H"
|
||||
|
||||
// Construct the EnSight mesh
|
||||
ensightMesh eMesh(mesh, args, binary);
|
||||
|
||||
// Set Time to the last time before looking for the spray objects
|
||||
// Set Time to the last time before looking for the lagrangian objects
|
||||
runTime.setTime(Times[Times.size()-1], Times.size()-1);
|
||||
|
||||
IOobjectList objects(mesh, runTime.timeName());
|
||||
IOobjectList sprayObjects(mesh, runTime.timeName(), "lagrangian");
|
||||
|
||||
bool lagrangianExist = false;
|
||||
|
||||
if (!eMesh.patchNames.size())
|
||||
{
|
||||
IOobject lagrangianHeader
|
||||
(
|
||||
"positions",
|
||||
runTime.timeName(),
|
||||
"lagrangian",
|
||||
mesh,
|
||||
IOobject::NO_READ
|
||||
);
|
||||
|
||||
if (lagrangianHeader.headerOk())
|
||||
{
|
||||
lagrangianExist = true;
|
||||
}
|
||||
}
|
||||
|
||||
# include "ensightCaseHeader.H"
|
||||
|
||||
# include "checkMeshMoving.H"
|
||||
|
||||
wordHashSet allCloudNames;
|
||||
word geomCaseFileName = prepend + "000";
|
||||
if (Pstream::master())
|
||||
{
|
||||
// test pre check variable if there is a moving mesh
|
||||
if (meshMoving == true) geomCaseFileName = prepend + "***";
|
||||
if (meshMoving == true)
|
||||
{
|
||||
geomCaseFileName = prepend + "***";
|
||||
}
|
||||
|
||||
ensightCaseFile
|
||||
<< "GEOMETRY" << nl
|
||||
<< "model: 1 "
|
||||
<< (geomCaseFileName + ".mesh").c_str() << nl;
|
||||
}
|
||||
|
||||
// Identify if lagrangian data exists at each time, and add clouds
|
||||
// to the 'allCloudNames' hash set
|
||||
for (label n=startTime; n<endTime; n++)
|
||||
{
|
||||
runTime.setTime(Times[n], n);
|
||||
|
||||
fileNameList cloudDirs = readDir
|
||||
(
|
||||
runTime.timePath()/regionPrefix/"lagrangian",
|
||||
fileName::DIRECTORY
|
||||
);
|
||||
|
||||
forAll(cloudDirs, cloudI)
|
||||
{
|
||||
IOobjectList cloudObjs
|
||||
(
|
||||
mesh,
|
||||
runTime.timeName(),
|
||||
"lagrangian"/cloudDirs[cloudI]
|
||||
);
|
||||
|
||||
IOobject* positionsPtr = cloudObjs.lookup("positions");
|
||||
|
||||
if (positionsPtr)
|
||||
{
|
||||
allCloudNames.insert(cloudDirs[cloudI]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashTable<HashTable<word> > allCloudFields;
|
||||
forAllConstIter(wordHashSet, allCloudNames, cloudIter)
|
||||
{
|
||||
// Add the name of the cloud(s) to the case file header
|
||||
if (Pstream::master())
|
||||
{
|
||||
ensightCaseFile
|
||||
<< (
|
||||
"measured: 1 "
|
||||
+ prepend
|
||||
+ "***."
|
||||
+ cloudIter.key()
|
||||
).c_str()
|
||||
<< nl;
|
||||
}
|
||||
|
||||
// Create a new hash table for each cloud
|
||||
allCloudFields.insert(cloudIter.key(), HashTable<word>());
|
||||
|
||||
// Identify the new cloud in the hash table
|
||||
HashTable<HashTable<word> >::iterator newCloudIter =
|
||||
allCloudFields.find(cloudIter.key());
|
||||
|
||||
// Loop over all times to build list of fields and field types
|
||||
// for each cloud
|
||||
for (label n=startTime; n<endTime; n++)
|
||||
{
|
||||
runTime.setTime(Times[n], n);
|
||||
|
||||
IOobjectList cloudObjs
|
||||
(
|
||||
mesh,
|
||||
runTime.timeName(),
|
||||
"lagrangian"/cloudIter.key()
|
||||
);
|
||||
|
||||
forAllConstIter(IOobjectList, cloudObjs, fieldIter)
|
||||
{
|
||||
const IOobject obj = *fieldIter();
|
||||
|
||||
if (obj.name() != "positions")
|
||||
{
|
||||
// Add field and field type
|
||||
newCloudIter().insert
|
||||
(
|
||||
obj.name(),
|
||||
obj.headerClassName()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label nTimeSteps = 0;
|
||||
for (label n=startTime; n<endTime; n++)
|
||||
{
|
||||
@ -190,7 +287,7 @@ int main(int argc, char *argv[])
|
||||
word timeName = itoa(timeIndex);
|
||||
word timeFile = prepend + timeName;
|
||||
|
||||
Info << "Translating time = " << runTime.timeName() << nl;
|
||||
Info<< "Translating time = " << runTime.timeName() << nl;
|
||||
|
||||
# include "moveMesh.H"
|
||||
|
||||
@ -205,22 +302,19 @@ int main(int argc, char *argv[])
|
||||
);
|
||||
}
|
||||
|
||||
if (Pstream::master() && timeIndex == 0)
|
||||
|
||||
// Start of field data output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
if (timeIndex == 0 && Pstream::master())
|
||||
{
|
||||
if (lagrangianExist)
|
||||
{
|
||||
ensightCaseFile
|
||||
<< (
|
||||
"measured: 1 "
|
||||
+ prepend
|
||||
+ "***."
|
||||
+ sprayName
|
||||
).c_str()
|
||||
<< nl;
|
||||
}
|
||||
ensightCaseFile << nl << "VARIABLE" << nl;
|
||||
ensightCaseFile<< nl << "VARIABLE" << nl;
|
||||
}
|
||||
|
||||
|
||||
// Cell field data output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
for (label i=0; i<nTypes; i++)
|
||||
{
|
||||
wordList fieldNames = objects.names(fieldTypes[i]);
|
||||
@ -313,70 +407,75 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
if (lagrangianExist)
|
||||
|
||||
// Cloud field data output
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
forAllConstIter(HashTable<HashTable<word> >, allCloudFields, cloudIter)
|
||||
{
|
||||
const word& cloudName = cloudIter.key();
|
||||
|
||||
fileNameList currentCloudDirs = readDir
|
||||
(
|
||||
runTime.timePath()/regionPrefix/"lagrangian",
|
||||
fileName::DIRECTORY
|
||||
);
|
||||
|
||||
bool cloudExists = inFileNameList(currentCloudDirs, cloudName);
|
||||
ensightParticlePositions
|
||||
(
|
||||
mesh,
|
||||
postProcPath,
|
||||
timeFile,
|
||||
sprayName
|
||||
cloudName,
|
||||
cloudExists
|
||||
);
|
||||
|
||||
for (label i=0; i<nSprayFieldTypes; i++)
|
||||
forAllConstIter(HashTable<word>, cloudIter(), fieldIter)
|
||||
{
|
||||
wordList fieldNames = sprayObjects.names(sprayFieldTypes[i]);
|
||||
const word& fieldName = fieldIter.key();
|
||||
const word& fieldType = fieldIter();
|
||||
|
||||
for (label j=0; j<fieldNames.size(); j++)
|
||||
IOobject fieldObject
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
"lagrangian"/cloudName,
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
|
||||
bool fieldExists = fieldObject.headerOk();
|
||||
if (fieldType == scalarIOField::typeName)
|
||||
{
|
||||
word fieldName = fieldNames[j];
|
||||
|
||||
IOobject fieldObject
|
||||
ensightCloudField<scalar>
|
||||
(
|
||||
fieldName,
|
||||
mesh.time().timeName(),
|
||||
"lagrangian",
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
fieldObject,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
cloudName,
|
||||
ensightCaseFile,
|
||||
fieldExists
|
||||
);
|
||||
|
||||
if (sprayFieldTypes[i] == scalarIOField::typeName)
|
||||
{
|
||||
ensightSprayField<scalar>
|
||||
(
|
||||
fieldObject,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
sprayName,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else if (sprayFieldTypes[i] == vectorIOField::typeName)
|
||||
{
|
||||
ensightSprayField<vector>
|
||||
(
|
||||
fieldObject,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
sprayName,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
else if (sprayFieldTypes[i] == tensorIOField::typeName)
|
||||
{
|
||||
ensightSprayField<tensor>
|
||||
(
|
||||
fieldObject,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
sprayName,
|
||||
ensightCaseFile
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (fieldType == vectorIOField::typeName)
|
||||
{
|
||||
ensightCloudField<vector>
|
||||
(
|
||||
fieldObject,
|
||||
postProcPath,
|
||||
prepend,
|
||||
timeIndex,
|
||||
cloudName,
|
||||
ensightCaseFile,
|
||||
fieldExists
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< "Unable to convert field type " << fieldType
|
||||
<< " for field " << fieldName << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user