mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'master' of ssh://noisy/home/noisy3/OpenFOAM/OpenFOAM-dev
This commit is contained in:
@ -178,7 +178,6 @@ void writeAllDataBinary
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
void writeAllFaceData
|
||||
(
|
||||
@ -275,7 +274,7 @@ template<class Type>
|
||||
bool writePatchField
|
||||
(
|
||||
const Foam::Field<Type>& pf,
|
||||
const Foam::label patchI,
|
||||
const Foam::label patchi,
|
||||
const Foam::label ensightPatchI,
|
||||
const Foam::faceSets& boundaryFaceSet,
|
||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||
@ -335,7 +334,7 @@ template<class Type>
|
||||
bool writePatchFieldBinary
|
||||
(
|
||||
const Foam::Field<Type>& pf,
|
||||
const Foam::label patchI,
|
||||
const Foam::label patchi,
|
||||
const Foam::label ensightPatchI,
|
||||
const Foam::faceSets& boundaryFaceSet,
|
||||
const Foam::ensightMesh::nFacePrimitives& nfp,
|
||||
@ -406,34 +405,27 @@ void writePatchField
|
||||
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 wordList& allPatchNames = eMesh.allPatchNames();
|
||||
const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
|
||||
label patchI = -1;
|
||||
|
||||
if (patchIndices.found(patchName))
|
||||
{
|
||||
patchI = patchIndices.find(patchName)();
|
||||
}
|
||||
|
||||
label ensightPatchI = eMesh.patchPartOffset();
|
||||
|
||||
for
|
||||
(
|
||||
HashTable<labelList>::const_iterator iter =
|
||||
allPatchNames.begin();
|
||||
iter != allPatchNames.end();
|
||||
++iter
|
||||
)
|
||||
label patchi = -1;
|
||||
|
||||
forAll(allPatchNames, i)
|
||||
{
|
||||
if (iter.key() == patchName) break;
|
||||
if (allPatchNames[i] == patchName)
|
||||
{
|
||||
patchi = i;
|
||||
break;
|
||||
}
|
||||
ensightPatchI++;
|
||||
}
|
||||
|
||||
|
||||
const labelList& patchProcessors = allPatchNames.find(patchName)();
|
||||
const labelList& patchProcessors = allPatchProcs[patchi];
|
||||
|
||||
word pfName = patchName + '.' + fieldName;
|
||||
|
||||
@ -472,14 +464,14 @@ void writePatchField
|
||||
ensightFile << pTraits<Type>::typeName << nl;
|
||||
}
|
||||
|
||||
if (patchI >= 0)
|
||||
if (patchi >= 0)
|
||||
{
|
||||
writePatchField
|
||||
(
|
||||
pf,
|
||||
patchI,
|
||||
patchi,
|
||||
ensightPatchI,
|
||||
boundaryFaceSets[patchI],
|
||||
boundaryFaceSets[patchi],
|
||||
nPatchPrims.find(patchName)(),
|
||||
patchProcessors,
|
||||
ensightFile
|
||||
@ -507,6 +499,7 @@ void writePatchField
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightFieldAscii
|
||||
(
|
||||
@ -527,8 +520,8 @@ void ensightFieldAscii
|
||||
|
||||
const cellSets& meshCellSets = eMesh.meshCellSets();
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||
const HashTable<labelList>& allPatchNames = eMesh.allPatchNames();
|
||||
const HashTable<label>& patchIndices = eMesh.patchIndices();
|
||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||
const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
|
||||
const wordHashSet& patchNames = eMesh.patchNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
@ -623,30 +616,23 @@ void ensightFieldAscii
|
||||
|
||||
label ensightPatchI = eMesh.patchPartOffset();
|
||||
|
||||
for
|
||||
(
|
||||
HashTable<labelList>::const_iterator iter = allPatchNames.begin();
|
||||
iter != allPatchNames.end();
|
||||
++iter
|
||||
)
|
||||
forAll(allPatchNames, patchi)
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const labelList& patchProcessors = iter();
|
||||
const word& patchName = allPatchNames[patchi];
|
||||
const labelList& patchProcessors = allPatchProcs[patchi];
|
||||
|
||||
if (patchNames.empty() || patchNames.found(patchName))
|
||||
{
|
||||
if (patchIndices.found(patchName))
|
||||
if (mesh.boundary()[patchi].size())
|
||||
{
|
||||
label patchI = patchIndices.find(patchName)();
|
||||
|
||||
if
|
||||
(
|
||||
writePatchField
|
||||
(
|
||||
vf.boundaryField()[patchI],
|
||||
patchI,
|
||||
vf.boundaryField()[patchi],
|
||||
patchi,
|
||||
ensightPatchI,
|
||||
boundaryFaceSets[patchI],
|
||||
boundaryFaceSets[patchi],
|
||||
nPatchPrims.find(patchName)(),
|
||||
patchProcessors,
|
||||
ensightFile
|
||||
@ -708,8 +694,8 @@ void ensightFieldBinary
|
||||
|
||||
const cellSets& meshCellSets = eMesh.meshCellSets();
|
||||
const List<faceSets>& boundaryFaceSets = eMesh.boundaryFaceSets();
|
||||
const HashTable<labelList>& allPatchNames = eMesh.allPatchNames();
|
||||
const HashTable<label>& patchIndices = eMesh.patchIndices();
|
||||
const wordList& allPatchNames = eMesh.allPatchNames();
|
||||
const List<labelList>& allPatchProcs = eMesh.allPatchProcs();
|
||||
const wordHashSet& patchNames = eMesh.patchNames();
|
||||
const HashTable<ensightMesh::nFacePrimitives>&
|
||||
nPatchPrims = eMesh.nPatchPrims();
|
||||
@ -726,7 +712,11 @@ void ensightFieldBinary
|
||||
{
|
||||
// set the filename of the ensight file
|
||||
fileName ensightFileName(timeFile + "." + fieldObject.name());
|
||||
ensightFilePtr = new std::ofstream((postProcPath/ensightFileName).c_str(), ios_base::out | ios_base::binary | ios_base::trunc);
|
||||
ensightFilePtr = new std::ofstream
|
||||
(
|
||||
(postProcPath/ensightFileName).c_str(),
|
||||
ios_base::out | ios_base::binary | ios_base::trunc
|
||||
);
|
||||
// Check on file opened?
|
||||
}
|
||||
|
||||
@ -787,38 +777,62 @@ void ensightFieldBinary
|
||||
}
|
||||
}
|
||||
|
||||
writeAllDataBinary("penta6", vf, prisms, meshCellSets.nPrisms, ensightFile);
|
||||
writeAllDataBinary("pyramid5", vf, pyrs, meshCellSets.nPyrs, ensightFile);
|
||||
writeAllDataBinary("tetra4", vf, tets, meshCellSets.nTets, ensightFile);
|
||||
writeAllDataBinary("nfaced", vf, polys, meshCellSets.nPolys, ensightFile);
|
||||
writeAllDataBinary
|
||||
(
|
||||
"penta6",
|
||||
vf,
|
||||
prisms,
|
||||
meshCellSets.nPrisms,
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeAllDataBinary
|
||||
(
|
||||
"pyramid5",
|
||||
vf,
|
||||
pyrs,
|
||||
meshCellSets.nPyrs,
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeAllDataBinary
|
||||
(
|
||||
"tetra4",
|
||||
vf,
|
||||
tets,
|
||||
meshCellSets.nTets,
|
||||
ensightFile
|
||||
);
|
||||
|
||||
writeAllDataBinary
|
||||
(
|
||||
"nfaced",
|
||||
vf,
|
||||
polys,
|
||||
meshCellSets.nPolys,
|
||||
ensightFile
|
||||
);
|
||||
}
|
||||
|
||||
label ensightPatchI = eMesh.patchPartOffset();
|
||||
|
||||
for
|
||||
(
|
||||
HashTable<labelList>::const_iterator iter = allPatchNames.begin();
|
||||
iter != allPatchNames.end();
|
||||
++iter
|
||||
)
|
||||
forAll(allPatchNames, patchi)
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const labelList& patchProcessors = iter();
|
||||
const word& patchName = allPatchNames[patchi];
|
||||
const labelList& patchProcessors = allPatchProcs[patchi];
|
||||
|
||||
if (patchNames.empty() || patchNames.found(patchName))
|
||||
{
|
||||
if (patchIndices.found(patchName))
|
||||
if (mesh.boundary()[patchi].size())
|
||||
{
|
||||
label patchI = patchIndices.find(patchName)();
|
||||
|
||||
if
|
||||
(
|
||||
writePatchFieldBinary
|
||||
(
|
||||
vf.boundaryField()[patchI],
|
||||
patchI,
|
||||
vf.boundaryField()[patchi],
|
||||
patchi,
|
||||
ensightPatchI,
|
||||
boundaryFaceSets[patchI],
|
||||
boundaryFaceSets[patchi],
|
||||
nPatchPrims.find(patchName)(),
|
||||
patchProcessors,
|
||||
ensightFile
|
||||
@ -859,6 +873,7 @@ void ensightFieldBinary
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void ensightField
|
||||
(
|
||||
|
||||
@ -28,6 +28,7 @@ License
|
||||
#include "Time.H"
|
||||
#include "ensightMesh.H"
|
||||
#include "fvMesh.H"
|
||||
#include "globalMeshData.H"
|
||||
#include "PstreamCombineReduceOps.H"
|
||||
#include "processorPolyPatch.H"
|
||||
#include "cellModeller.H"
|
||||
@ -40,43 +41,37 @@ License
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class concatPatchNames
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
void operator()
|
||||
(
|
||||
HashTable<labelList>& x,
|
||||
const HashTable<labelList>& y
|
||||
) const
|
||||
//- Proxy-class to hold the patch processor list combination operator
|
||||
class concatPatchProcs
|
||||
{
|
||||
forAllConstIter(HashTable<labelList>, y, iter)
|
||||
|
||||
public:
|
||||
|
||||
void operator()
|
||||
(
|
||||
List<labelList>& x,
|
||||
const List<labelList>& y
|
||||
) const
|
||||
{
|
||||
HashTable<labelList>::iterator xiter = x.find(iter.key());
|
||||
|
||||
if (xiter == x.end())
|
||||
forAll(y, i)
|
||||
{
|
||||
x.insert(iter.key(), iter());
|
||||
}
|
||||
else
|
||||
{
|
||||
labelList& xPatches = xiter();
|
||||
const labelList& yPatches = iter();
|
||||
const labelList& yPatches = y[i];
|
||||
|
||||
label offset = xPatches.size();
|
||||
xPatches.setSize(offset + yPatches.size());
|
||||
|
||||
forAll(yPatches, i)
|
||||
if (yPatches.size())
|
||||
{
|
||||
xPatches[i + offset] = yPatches[i];
|
||||
labelList& xPatches = x[i];
|
||||
|
||||
label offset = xPatches.size();
|
||||
xPatches.setSize(offset + yPatches.size());
|
||||
|
||||
forAll(yPatches, i)
|
||||
{
|
||||
xPatches[i + offset] = yPatches[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
@ -95,7 +90,7 @@ Foam::ensightMesh::ensightMesh
|
||||
meshCellSets_(mesh_.nCells()),
|
||||
boundaryFaceSets_(mesh_.boundary().size()),
|
||||
allPatchNames_(0),
|
||||
patchIndices_(0),
|
||||
allPatchProcs_(0),
|
||||
patchNames_(0),
|
||||
nPatchPrims_(0)
|
||||
{
|
||||
@ -109,32 +104,24 @@ Foam::ensightMesh::ensightMesh
|
||||
|
||||
if (!args.optionFound("noPatches"))
|
||||
{
|
||||
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())
|
||||
);
|
||||
allPatchNames_ = wordList::subList
|
||||
(
|
||||
mesh_.boundaryMesh().names(), mesh_.boundary().size()
|
||||
- mesh_.globalData().processorPatches().size()
|
||||
);
|
||||
|
||||
patchIndices_.insert
|
||||
(
|
||||
mesh_.boundaryMesh()[patchI].name(),
|
||||
patchI
|
||||
);
|
||||
}
|
||||
allPatchProcs_.setSize(allPatchNames_.size());
|
||||
|
||||
forAll (allPatchProcs_, patchi)
|
||||
{
|
||||
if (mesh_.boundary()[patchi].size())
|
||||
{
|
||||
allPatchProcs_[patchi].setSize(1);
|
||||
allPatchProcs_[patchi][0] = Pstream::myProcNo();
|
||||
}
|
||||
}
|
||||
|
||||
combineReduce(allPatchNames_, concatPatchNames());
|
||||
combineReduce(allPatchProcs_, concatPatchProcs());
|
||||
|
||||
if (args.optionFound("patches"))
|
||||
{
|
||||
@ -142,7 +129,7 @@ Foam::ensightMesh::ensightMesh
|
||||
|
||||
if (patchNameList.empty())
|
||||
{
|
||||
patchNameList = allPatchNames_.toc();
|
||||
patchNameList = allPatchNames_;
|
||||
}
|
||||
|
||||
forAll (patchNameList, i)
|
||||
@ -230,15 +217,15 @@ Foam::ensightMesh::ensightMesh
|
||||
|
||||
if (!args.optionFound("noPatches"))
|
||||
{
|
||||
forAll (mesh.boundary(), patchI)
|
||||
forAll (mesh.boundary(), patchi)
|
||||
{
|
||||
if (mesh.boundary()[patchI].size())
|
||||
if (mesh.boundary()[patchi].size())
|
||||
{
|
||||
const polyPatch& p = mesh.boundaryMesh()[patchI];
|
||||
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());
|
||||
@ -274,21 +261,19 @@ Foam::ensightMesh::ensightMesh
|
||||
}
|
||||
|
||||
|
||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||
forAll(allPatchNames_, patchi)
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const word& patchName = allPatchNames_[patchi];
|
||||
nFacePrimitives nfp;
|
||||
|
||||
if (patchNames_.empty() || patchNames_.found(patchName))
|
||||
{
|
||||
if (patchIndices_.found(patchName))
|
||||
if (mesh.boundary()[patchi].size())
|
||||
{
|
||||
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.nPoints = mesh.boundaryMesh()[patchi].localPoints().size();
|
||||
nfp.nTris = boundaryFaceSets_[patchi].tris.size();
|
||||
nfp.nQuads = boundaryFaceSets_[patchi].quads.size();
|
||||
nfp.nPolys = boundaryFaceSets_[patchi].polys.size();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1052,13 +1037,13 @@ void Foam::ensightMesh::writeAscii
|
||||
|
||||
label ensightPatchI = patchPartOffset_;
|
||||
|
||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||
forAll(allPatchNames_, patchi)
|
||||
{
|
||||
const labelList& patchProcessors = iter();
|
||||
const word& patchName = allPatchNames_[patchi];
|
||||
const labelList& patchProcessors = allPatchProcs_[patchi];
|
||||
|
||||
if (patchNames_.empty() || patchNames_.found(iter.key()))
|
||||
if (patchNames_.empty() || patchNames_.found(patchName))
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
|
||||
|
||||
const labelList *trisPtr = NULL;
|
||||
@ -1068,14 +1053,13 @@ void Foam::ensightMesh::writeAscii
|
||||
const pointField *patchPointsPtr = NULL;
|
||||
const faceList *patchFacesPtr = NULL;
|
||||
|
||||
if (patchIndices_.found(iter.key()))
|
||||
if (mesh_.boundary()[patchi].size())
|
||||
{
|
||||
label patchI = patchIndices_.find(iter.key())();
|
||||
const polyPatch& p = mesh_.boundaryMesh()[patchI];
|
||||
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());
|
||||
@ -1265,7 +1249,7 @@ void Foam::ensightMesh::writeBinary
|
||||
{
|
||||
writeEnsDataBinary("part",ensightGeometryFile);
|
||||
writeEnsDataBinary(1,ensightGeometryFile);
|
||||
writeEnsDataBinary("FOAM cells",ensightGeometryFile);
|
||||
writeEnsDataBinary("internalMesh",ensightGeometryFile);
|
||||
writeEnsDataBinary("coordinates",ensightGeometryFile);
|
||||
writeEnsDataBinary(nPoints,ensightGeometryFile);
|
||||
|
||||
@ -1379,14 +1363,14 @@ void Foam::ensightMesh::writeBinary
|
||||
label ensightPatchI = patchPartOffset_;
|
||||
label iCount = 0;
|
||||
|
||||
forAllConstIter(HashTable<labelList>, allPatchNames_, iter)
|
||||
forAll(allPatchNames_, patchi)
|
||||
{
|
||||
iCount ++;
|
||||
const labelList& patchProcessors = iter();
|
||||
const word& patchName = allPatchNames_[patchi];
|
||||
const labelList& patchProcessors = allPatchProcs_[patchi];
|
||||
|
||||
if (patchNames_.empty() || patchNames_.found(iter.key()))
|
||||
if (patchNames_.empty() || patchNames_.found(patchName))
|
||||
{
|
||||
const word& patchName = iter.key();
|
||||
const nFacePrimitives& nfp = nPatchPrims_.find(patchName)();
|
||||
|
||||
const labelList *trisPtr = NULL;
|
||||
@ -1396,14 +1380,13 @@ void Foam::ensightMesh::writeBinary
|
||||
const pointField *patchPointsPtr = NULL;
|
||||
const faceList *patchFacesPtr = NULL;
|
||||
|
||||
if (patchIndices_.found(iter.key()))
|
||||
if (mesh_.boundary()[patchi].size())
|
||||
{
|
||||
label patchI = patchIndices_.find(iter.key())();
|
||||
const polyPatch& p = mesh_.boundaryMesh()[patchI];
|
||||
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());
|
||||
@ -1424,7 +1407,7 @@ void Foam::ensightMesh::writeBinary
|
||||
writeEnsDataBinary("part",ensightGeometryFile);
|
||||
writeEnsDataBinary(ensightPatchI++,ensightGeometryFile);
|
||||
//writeEnsDataBinary(patchName.c_str(),ensightGeometryFile);
|
||||
writeEnsDataBinary(iter.key().c_str(),ensightGeometryFile);
|
||||
writeEnsDataBinary(patchName.c_str(),ensightGeometryFile);
|
||||
writeEnsDataBinary("coordinates",ensightGeometryFile);
|
||||
writeEnsDataBinary(nfp.nPoints,ensightGeometryFile);
|
||||
|
||||
|
||||
@ -91,9 +91,9 @@ class ensightMesh
|
||||
|
||||
List<faceSets> boundaryFaceSets_;
|
||||
|
||||
HashTable<labelList> allPatchNames_;
|
||||
wordList allPatchNames_;
|
||||
|
||||
HashTable<label> patchIndices_;
|
||||
List<labelList> allPatchProcs_;
|
||||
|
||||
wordHashSet patchNames_;
|
||||
|
||||
@ -269,14 +269,14 @@ public:
|
||||
return boundaryFaceSets_;
|
||||
}
|
||||
|
||||
const HashTable<labelList>& allPatchNames() const
|
||||
const wordList& allPatchNames() const
|
||||
{
|
||||
return allPatchNames_;
|
||||
}
|
||||
|
||||
const HashTable<label>& patchIndices() const
|
||||
const List<labelList>& allPatchProcs() const
|
||||
{
|
||||
return patchIndices_;
|
||||
return allPatchProcs_;
|
||||
}
|
||||
|
||||
const wordHashSet& patchNames() const
|
||||
|
||||
@ -0,0 +1,3 @@
|
||||
particleTracks.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/particleTracks
|
||||
@ -0,0 +1,7 @@
|
||||
EXE_INC = \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude
|
||||
|
||||
EXE_LIBS = \
|
||||
-lfiniteVolume \
|
||||
-llagrangian
|
||||
@ -0,0 +1,22 @@
|
||||
IOdictionary propsDict
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"particleTrackProperties",
|
||||
runTime.constant(),
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
)
|
||||
);
|
||||
|
||||
word cloudName(propsDict.lookup("cloudName"));
|
||||
|
||||
label sampleFrequency(readLabel(propsDict.lookup("sampleFrequency")));
|
||||
|
||||
// outputMode: compositeFile, filePerTrack
|
||||
//word outputmode(propsDict.lookup("outputMode"))
|
||||
|
||||
label maxPositions(readLabel(propsDict.lookup("maxPositions")));
|
||||
|
||||
// outputFormat: raw, vtk
|
||||
//word outputFormat(propsDict.lookup("outputFormat"));
|
||||
@ -0,0 +1,270 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Application
|
||||
particleTracks
|
||||
|
||||
Description
|
||||
Generates a VTK file of particle tracks for cases that were computed using
|
||||
a tracked-parcel-type cloud
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "argList.H"
|
||||
#include "Cloud.H"
|
||||
#include "IOdictionary.H"
|
||||
#include "fvMesh.H"
|
||||
#include "Time.H"
|
||||
#include "timeSelector.H"
|
||||
#include "OFstream.H"
|
||||
#include "passiveParticle.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
# include "setRootCase.H"
|
||||
|
||||
# include "createTime.H"
|
||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||
# include "createMesh.H"
|
||||
# include "createFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Info<< "Scanning times to determine track data" << nl << endl;
|
||||
|
||||
labelList maxIds(Pstream::nProcs(), -1);
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
IOobject origProcHeader
|
||||
(
|
||||
"origProc",
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
IOobject idHeader
|
||||
(
|
||||
"id",
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
mesh,
|
||||
IOobject::MUST_READ
|
||||
);
|
||||
if (idHeader.headerOk() && origProcHeader.headerOk())
|
||||
{
|
||||
IOField<label> origProc(origProcHeader);
|
||||
IOField<label> id(idHeader);
|
||||
forAll(id, i)
|
||||
{
|
||||
maxIds[origProc[i]] = max(maxIds[origProc[i]], id[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
Pstream::listCombineGather(maxIds, maxOp<label>());
|
||||
Pstream::listCombineScatter(maxIds);
|
||||
labelList numIds = maxIds + 1;
|
||||
|
||||
// calc starting ids for particles on each processor
|
||||
List<label> startIds(numIds.size(), 0);
|
||||
for (label i = 0; i < numIds.size()-1; i++)
|
||||
{
|
||||
startIds[i+1] += startIds[i] + numIds[i];
|
||||
}
|
||||
label nParticle = startIds[startIds.size()-1] + numIds[startIds.size()-1];
|
||||
|
||||
// number of tracks to generate
|
||||
label nTracks = nParticle/sampleFrequency;
|
||||
|
||||
// storage for all particle tracks
|
||||
List<DynamicList<vector> > allTracks(nTracks);
|
||||
|
||||
Info<< "\nGenerating " << nTracks << " particle tracks" << nl << endl;
|
||||
forAll(timeDirs, timeI)
|
||||
{
|
||||
runTime.setTime(timeDirs[timeI], timeI);
|
||||
Info<< "Time = " << runTime.timeName() << endl;
|
||||
|
||||
IOobject positionsHeader
|
||||
(
|
||||
"positions",
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
IOobject origProcHeader
|
||||
(
|
||||
"origProc",
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
IOobject idHeader
|
||||
(
|
||||
"id",
|
||||
runTime.timeName(),
|
||||
cloud::prefix/cloudName,
|
||||
mesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE,
|
||||
false
|
||||
);
|
||||
|
||||
if
|
||||
(
|
||||
positionsHeader.headerOk()
|
||||
&& origProcHeader.headerOk()
|
||||
&& idHeader.headerOk()
|
||||
)
|
||||
{
|
||||
Info<< " Reading particle positions" << endl;
|
||||
Cloud<passiveParticle> myCloud(mesh, cloudName, false);
|
||||
|
||||
Info<< " Reading particle id" << endl;
|
||||
IOField<label> id(idHeader);
|
||||
|
||||
Info<< " Reading particle origProc" << endl;
|
||||
IOField<label> origProc(origProcHeader);
|
||||
|
||||
// collect the track data on the master processor
|
||||
label i = 0;
|
||||
List<pointField> allPositions(Pstream::nProcs());
|
||||
allPositions[Pstream::myProcNo()].setSize(myCloud.size());
|
||||
forAllConstIter(Cloud<passiveParticle>, myCloud, iter)
|
||||
{
|
||||
allPositions[Pstream::myProcNo()][i++] = iter().position();
|
||||
}
|
||||
Pstream::gatherList(allPositions);
|
||||
|
||||
List<labelList> allIds(Pstream::nProcs());
|
||||
allIds[Pstream::myProcNo()] = id;
|
||||
Pstream::gatherList(allIds);
|
||||
|
||||
List<labelList> allOrigProcs(Pstream::nProcs());
|
||||
allOrigProcs[Pstream::myProcNo()] = origProc;
|
||||
Pstream::gatherList(allOrigProcs);
|
||||
|
||||
Info<< " Constructing tracks" << nl << endl;
|
||||
if (Pstream::master())
|
||||
{
|
||||
forAll(allPositions, procI)
|
||||
{
|
||||
forAll(allPositions[procI], i)
|
||||
{
|
||||
label globalId =
|
||||
startIds[allOrigProcs[procI][i]]
|
||||
+ allIds[procI][i];
|
||||
|
||||
if (globalId % sampleFrequency == 0)
|
||||
{
|
||||
label trackId = globalId/sampleFrequency;
|
||||
if (allTracks[trackId].size() < maxPositions)
|
||||
{
|
||||
allTracks[trackId].append
|
||||
(
|
||||
allPositions[procI][i]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Info<< " No particles read" << nl << endl;
|
||||
}
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
Info<< "\nWriting particle tracks" << nl << endl;
|
||||
|
||||
OFstream vtkTracks("particleTracks.vtk");
|
||||
|
||||
// Total number of points in tracks + 1 per track
|
||||
label nPoints = 0;
|
||||
forAll(allTracks, trackI)
|
||||
{
|
||||
nPoints += allTracks[trackI].size();
|
||||
}
|
||||
|
||||
vtkTracks
|
||||
<< "# vtk DataFile Version 2.0" << nl
|
||||
<< "particleTracks" << nl
|
||||
<< "ASCII" << nl
|
||||
<< "DATASET POLYDATA" << nl
|
||||
<< "POINTS " << nPoints << " float" << nl;
|
||||
|
||||
// Write track points to file
|
||||
forAll(allTracks, trackI)
|
||||
{
|
||||
forAll(allTracks[trackI], i)
|
||||
{
|
||||
const vector& pt = allTracks[trackI][i];
|
||||
vtkTracks << pt.x() << ' ' << pt.y() << ' ' << pt.z() << nl;
|
||||
}
|
||||
}
|
||||
|
||||
// write track (line) connectivity to file
|
||||
vtkTracks << "LINES " << nTracks << ' ' << nPoints+nTracks << nl;
|
||||
|
||||
// Write ids of track points to file
|
||||
label globalPtI = 0;
|
||||
forAll(allTracks, trackI)
|
||||
{
|
||||
vtkTracks << allTracks[trackI].size();
|
||||
|
||||
forAll(allTracks[trackI], i)
|
||||
{
|
||||
vtkTracks << ' ' << globalPtI;
|
||||
globalPtI++;
|
||||
}
|
||||
|
||||
vtkTracks << nl;
|
||||
}
|
||||
|
||||
Info<< "end" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user