Commit 750a8c78 authored by Andrew Heather's avatar Andrew Heather
Browse files

updated to incorporate particle post-processing

parent 9bd3861c
......@@ -5,4 +5,3 @@ foamToEnsight.C
ensightWriteBinary.C
EXE = $(FOAM_APPBIN)/foamToEnsight
//EXE = $(FOAM_USER_APPBIN)/foamToEnsight
EXE_INC = \
-DFULLDEBUG -g -O0 \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-llagrangian
-llagrangian \
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)
{
v = pTraits<Type>::zero;
}
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
{
ensightFile << nl;
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)