From 4c2adfe276ec9f64ce188fb24de80ae77736fdd0 Mon Sep 17 00:00:00 2001 From: henry <Henry Weller h.weller@opencfd.co.uk> Date: Thu, 11 Jun 2009 16:18:19 +0100 Subject: [PATCH] Fixed!!! --- .../foamToEnsight/ensightField.C | 137 ++++++++------- .../foamToEnsight/ensightMesh.C | 159 ++++++++---------- .../foamToEnsight/ensightMesh.H | 10 +- 3 files changed, 152 insertions(+), 154 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C index 64452a05f70..90a597e5788 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightField.C @@ -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 ( diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C index 079145a0c56..c3262e6b9c4 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.C @@ -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 { + //- Proxy-class to hold the patch processor list combination operator + class concatPatchProcs + { -class concatPatchNames -{ - -public: + public: - void operator() - ( - HashTable<labelList>& x, - const HashTable<labelList>& y - ) const - { - forAllConstIter(HashTable<labelList>, y, iter) + void operator() + ( + List<labelList>& x, + const List<labelList>& y + ) const { - HashTable<labelList>::iterator xiter = x.find(iter.key()); - - if (xiter == x.end()) - { - x.insert(iter.key(), iter()); - } - else + forAll(y, i) { - labelList& xPatches = xiter(); - const labelList& yPatches = iter(); - - label offset = xPatches.size(); - xPatches.setSize(offset + yPatches.size()); + const labelList& yPatches = y[i]; - 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) + allPatchNames_ = wordList::subList + ( + mesh_.boundaryMesh().names(), mesh_.boundary().size() + - mesh_.globalData().processorPatches().size() + ); + + allPatchProcs_.setSize(allPatchNames_.size()); + + forAll (allPatchProcs_, patchi) { - if - ( - typeid(mesh_.boundaryMesh()[patchI]) - != typeid(processorPolyPatch) - ) + if (mesh_.boundary()[patchi].size()) { - if (!allPatchNames_.found(mesh_.boundaryMesh()[patchI].name())) - { - allPatchNames_.insert - ( - mesh_.boundaryMesh()[patchI].name(), - labelList(1, Pstream::myProcNo()) - ); - - patchIndices_.insert - ( - mesh_.boundaryMesh()[patchI].name(), - patchI - ); - } + 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); diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H index 6a3cb824708..4ddb084d3d0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightMesh.H @@ -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 -- GitLab