diff --git a/applications/solvers/basic/potentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/createFields.H index 7e228832568dd0d41d3e54b289c9381e84370daa..ef3b220257fbc7864f1fd2b9eb6481d09fa6af5c 100644 --- a/applications/solvers/basic/potentialFoam/createFields.H +++ b/applications/solvers/basic/potentialFoam/createFields.H @@ -44,6 +44,12 @@ fvc::interpolate(U) & mesh.Sf() ); + if (args.optionFound("initialiseUBCs")) + { + U.correctBoundaryConditions(); + phi = fvc::interpolate(U) & mesh.Sf(); + } + label pRefCell = 0; scalar pRefValue = 0.0; diff --git a/applications/solvers/basic/potentialFoam/potentialFoam.C b/applications/solvers/basic/potentialFoam/potentialFoam.C index 8e4a12ee0d01af803b9a615c0852547c76bc0e9e..d2a1452f7287ab02e1b373a45cec134e3c0fb905 100644 --- a/applications/solvers/basic/potentialFoam/potentialFoam.C +++ b/applications/solvers/basic/potentialFoam/potentialFoam.C @@ -38,6 +38,11 @@ Description int main(int argc, char *argv[]) { argList::addBoolOption("writep", "write the final pressure field"); + argList::addBoolOption + ( + "initialiseUBCs", + "initialise U boundary conditions" + ); #include "setRootCase.H" #include "createTime.H" diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H index 2fde518a6c10a6c55addf6d5bba10c22bf72d532..03b258042529f3e90c6ca942fdd946f094d78214 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H @@ -5,8 +5,8 @@ - fvm::Sp(fvc::div(phi), h) - fvm::laplacian(turb.alphaEff(), h) == - fvc::div(phi/fvc::interpolate(rho), rho/psi, "div(U,p)") - - (rho/psi)*fvc::div(phi/fvc::interpolate(rho)) + fvc::div(phi/fvc::interpolate(rho), p, "div(U,p)") + - p*fvc::div(phi/fvc::interpolate(rho)) + rad.Sh(thermo) ); diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 92af69626cb4eb3e378ca85dd5cbfac05292c712..5285de5819647df4efc51a440a6af2a61d12e26b 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -844,16 +844,16 @@ int main(int argc, char *argv[]) List<faceList> patchFaceVerts; - labelList nrFaceCells(boundaryFaces.size(),0); - HashTable<label,label> faceToCell[2]; + labelList own(boundaryFaces.size(), -1); + labelList nei(boundaryFaces.size(), -1); + HashTable<label, label> faceToCell[2]; { HashTable<label, face, Hash<face> > faceToFaceID(boundaryFaces.size()); forAll(boundaryFaces, faceI) { - SortableList<label> foo(boundaryFaces[faceI]); - face theFace(foo); - faceToFaceID.insert(theFace,faceI); + SortableList<label> sortedVerts(boundaryFaces[faceI]); + faceToFaceID.insert(face(sortedVerts), faceI); } forAll(cellVerts, cellI) @@ -861,31 +861,57 @@ int main(int argc, char *argv[]) faceList faces = cellVerts[cellI].faces(); forAll(faces, i) { - SortableList<label> foo(faces[i]); - face theFace(foo); - if (faceToFaceID.found(theFace)) + SortableList<label> sortedVerts(faces[i]); + HashTable<label, face, Hash<face> >::const_iterator fnd = + faceToFaceID.find(face(sortedVerts)); + + if (fnd != faceToFaceID.end()) { - label faceI = faceToFaceID[theFace]; - if (nrFaceCells[faceI] < 2) + label faceI = fnd(); + int stat = face::compare(faces[i], boundaryFaces[faceI]); + + if (stat == 1) + { + // Same orientation. Cell is owner. + own[faceI] = cellI; + } + else if (stat == -1) { - faceToCell[nrFaceCells[faceI]].insert(faceI,cellI); + // Opposite orientation. Cell is neighbour. + nei[faceI] = cellI; } - nrFaceCells[faceI]++; } } } + label nReverse = 0; + forAll(own, faceI) + { + if (own[faceI] == -1 && nei[faceI] != -1) + { + // Boundary face with incorrect orientation + boundaryFaces[faceI] = boundaryFaces[faceI].reverseFace(); + Swap(own[faceI], nei[faceI]); + nReverse++; + } + } + if (nReverse > 0) + { + Info << "Found " << nReverse << " reversed boundary faces out of " + << boundaryFaces.size() << endl; + } + + label cnt = 0; - forAll(nrFaceCells, faceI) + forAll(own, faceI) { - assert(nrFaceCells[faceI] == 1 || nrFaceCells[faceI] == 2); - if (nrFaceCells[faceI]>1) + if (own[faceI] != -1 && nei[faceI] != -1) { cnt++; } } - if (cnt>0) + if (cnt > 0) { Info << "Of " << boundaryFaces.size() << " so-called" << " boundary faces " << cnt << " belong to two cells " @@ -994,7 +1020,8 @@ int main(int argc, char *argv[]) if (boundaryFaceToIndex.found(faceIndices[i])) { label bFaceI = boundaryFaceToIndex[faceIndices[i]]; - if (nrFaceCells[bFaceI] == 1) + + if (own[bFaceI] != -1 && nei[bFaceI] == -1) { patchFaces[cnt] = boundaryFaces[bFaceI]; cnt++; diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C index 30659632021aa613a7437c48549ad1acb57db106..7f3e6ac9ef7849de39023996f4b0953f83755c55 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/backgroundMeshDecomposition/backgroundMeshDecomposition.C @@ -1294,11 +1294,12 @@ Foam::labelList Foam::backgroundMeshDecomposition::processorPosition "Foam::labelList" "Foam::backgroundMeshDecomposition::processorPosition" "(" - "const List<point>& pts" + "const List<point>&" ") const" ) << "The position " << pts[pI] - << " is not in any part of the background mesh. " + << " is not in any part of the background mesh " + << globalBackgroundBounds_ << endl << "A background mesh with a wider margin around " << "the geometry may help." << exit(FatalError); @@ -1311,11 +1312,11 @@ Foam::labelList Foam::backgroundMeshDecomposition::processorPosition "Foam::labelList" "Foam::backgroundMeshDecomposition::processorPosition" "(" - "const List<point>& pts" + "const List<point>&" ") const" - ) - << "The position " << pts[pI] - << " was not found in the background mesh, finding nearest." + ) << "The position " << pts[pI] + << " was not found in the background mesh " + << globalBackgroundBounds_ << ", finding nearest." << endl; } diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 4b074e05fc9c0aa60eafcd8d26756d8b157a34b1..732a7c225105864d6965fdd55a99fe9d3f026d57 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -30,6 +30,16 @@ License #include "backgroundMeshDecomposition.H" #include "meshSearch.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(conformalVoronoiMesh, 0); + +} + + // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // Foam::tensor Foam::conformalVoronoiMesh::requiredAlignment diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index 60adea3456b48b9c388fe7cb579000932f9c2cab..65ec474a775a11236812f03d2487252dce788359 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -722,6 +722,13 @@ private: const Delaunay::Finite_facets_iterator& fit ) const; + //- Determines if the edge constructed from the face is on + // a processor patch + inline bool isParallelDualEdge + ( + const Delaunay::Finite_facets_iterator& fit + ) const; + //- Merge vertices that are very close together void mergeCloseDualVertices ( @@ -771,7 +778,7 @@ private: ) const; //- Collapse a face to an edge, updating the point and point - // map. Returns the collapse mode that was applied. + // map. Returns the collapse mode that was applied. faceCollapseMode collapseFace ( const face& f, @@ -783,7 +790,7 @@ private: label maxFC ) const; - // Identify the index of the longest edge on the face + //- Identify the index of the longest edge on the face label longestEdge(const face& f, const pointField& pts) const; //- Identify the face labels of the deferred collapse faces @@ -886,6 +893,10 @@ private: public: + //- Runtime type information + ClassName("conformalVoronoiMesh"); + + // Constructors //- Construct from Time and cvMeshDict diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index 5a5cbfe44d054a906ea1bb85aa9b54b4b4abdab0..2f3a2717d7cf9ca87192655ccf7a9fbfc4b38418 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -543,8 +543,21 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices { label nPtsMerged = 0; + label nIdentical = 0; + label nProcEdge = 0; + + // Relative distance for points to be merged scalar closenessTolerance = cvMeshControls().mergeClosenessCoeff(); + // Absolute distance for points to be considered coincident. Bit adhoc + // but points were seen with distSqr ~ 1E-30 which is SMALL^2. Add a few + // digits to account for truncation errors. + scalar coincidentDistanceSqr = sqr + ( + SMALL*1E2*geometryToConformTo_.globalBounds().mag() + ); + + for ( Delaunay::Finite_facets_iterator fit = finite_facets_begin(); @@ -567,14 +580,14 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices continue; } - if (!c1->farCell() && !c2->farCell() && (c1I != c2I)) + if ((c1I != c2I) && !c1->farCell() && !c2->farCell()) { - if - ( - magSqr(pts[c1I] - pts[c2I]) - < sqr(averageAnyCellSize(fit)*closenessTolerance) - ) + scalar distSqr = magSqr(pts[c1I] - pts[c2I]); + + if (pts[c1I] == pts[c2I] || distSqr < coincidentDistanceSqr) { + nIdentical++; + if (boundaryPts[c2I] == true) { // If c2I is a boundary point, then it is kept. @@ -583,18 +596,59 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices dualPtIndexMap.insert(c1I, c2I); dualPtIndexMap.insert(c2I, c2I); + nPtsMerged++; } else { dualPtIndexMap.insert(c1I, c1I); dualPtIndexMap.insert(c2I, c1I); + nPtsMerged++; } - nPtsMerged++; + } + else if (distSqr < sqr(averageAnyCellSize(fit)*closenessTolerance)) + { + if (c1->parallelDualVertex() || c2->parallelDualVertex()) + //if (isParallelDualEdge(fit)) + { + // Skip if face uses any edge that becomes a processor + // dual face. + // Note: the real test should be whether the Delaunay edge + // will form a processor patch. + nProcEdge++; + } + else if (boundaryPts[c2I] == true) + { + // If c2I is a boundary point, then it is kept. + // If both are boundary points then c2I is chosen + // arbitrarily to be kept. + + dualPtIndexMap.insert(c1I, c2I); + dualPtIndexMap.insert(c2I, c2I); + nPtsMerged++; + } + else + { + dualPtIndexMap.insert(c1I, c1I); + dualPtIndexMap.insert(c2I, c1I); + nPtsMerged++; + } } } } + if (debug) + { + Info<< "mergeCloseDualVertices:" + << " coincident distance:" << coincidentDistanceSqr + << " closenessTolerance:" << closenessTolerance << endl + << " identical points : " + << returnReduce(nIdentical, sumOp<label>()) << endl + << " processor edges : " + << returnReduce(nProcEdge, sumOp<label>()) << endl + << endl; + } + return nPtsMerged; } diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H index e92a7b93693d0b827c835336124ecf8d430f9374..e8e8514aab263839c09768709309883d250ca19a 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshI.H @@ -384,6 +384,23 @@ inline Foam::List<Foam::label> Foam::conformalVoronoiMesh::processorsAttached } +inline bool Foam::conformalVoronoiMesh::isParallelDualEdge +( + const Delaunay::Finite_facets_iterator& fit +) const +{ + const Cell_handle c1(fit->first); + const int oppositeVertex = fit->second; + + return + ( + c1->vertex(vertex_triple_index(oppositeVertex, 0))->referred() + || c1->vertex(vertex_triple_index(oppositeVertex, 1))->referred() + || c1->vertex(vertex_triple_index(oppositeVertex, 2))->referred() + ); +} + + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // #ifdef CGAL_INEXACT diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell.H index 2a85ab49b56a698e13aa909f80534a1e7f79aa8f..ca1a34d906ef13a19edeef4dc36e9fbae9126f03 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/indexedCell.H @@ -208,7 +208,6 @@ public: ); } - //- Does the Dual vertex form part of a processor patch inline Foam::label dualVertexMasterProc() const { diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index e01dd5ca434bdfbbebe21ec5a0d0099731f99b69..e8d634f7a355d77f089caa2b11da4bc721a7d1c3 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,7 +55,6 @@ Description this if you don't mind having disconnected domains in a single region. This option requires all cells to be in one (and one only) cellZone. - - Should work in parallel. cellZones can differ on either side of processor boundaries in which case the faces get moved from processor patch to directMapped patch. Not @@ -66,6 +65,13 @@ Description region that covers more than 50% of the zone. It has to be a subset so cannot have any cells in any other zone. + - If explicitly a single region has been selected (-largestOnly or + -insidePoint) its region name will be either + - name of a cellZone it matches to or + - "largestOnly" respectively "insidePoint" or + - polyMesh::defaultRegion if additionally -overwrite + (so it will overwrite the input mesh!) + - writes maps like decomposePar back to original mesh: - pointRegionAddressing : for every point in this region the point in the original mesh @@ -1866,6 +1872,29 @@ int main(int argc, char *argv[]) regionNames, zoneToRegion ); + + // Override any default region names if single region selected + if (largestOnly || insidePoint) + { + forAll(regionToZone, regionI) + { + if (regionToZone[regionI] == -1) + { + if (overwrite) + { + regionNames[regionI] = polyMesh::defaultRegion; + } + else if (insidePoint) + { + regionNames[regionI] = "insidePoint"; + } + else if (largestOnly) + { + regionNames[regionI] = "largestOnly"; + } + } + } + } } Info<< endl << "Number of regions:" << nCellRegions << nl << endl; @@ -2173,7 +2202,8 @@ int main(int argc, char *argv[]) Info<< nl << "Subsetting region " << regionI - << " of size " << regionSizes[regionI] << endl; + << " of size " << regionSizes[regionI] + << " as named region " << regionNames[regionI] << endl; createAndWriteRegion ( diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index d391ea966b8043b71b576f7fe4e5fcdef1dfc4e2..59ced69afaf34bb9940c7ac40411527d25c99e93 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -541,29 +541,51 @@ int main(int argc, char *argv[]) IOobjectList objects(mesh, runTime.timeName()); HashSet<word> selectedFields; - args.optionReadIfPresent("fields", selectedFields); + bool specifiedFields = args.optionReadIfPresent + ( + "fields", + selectedFields + ); // Construct the vol fields (on the original mesh if subsetted) PtrList<volScalarField> vsf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vsf); - print(" volScalarFields :", Info, vsf); - PtrList<volVectorField> vvf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vvf); - print(" volVectorFields :", Info, vvf); - PtrList<volSphericalTensorField> vSpheretf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSpheretf); - print(" volSphericalTensorFields :", Info, vSpheretf); - PtrList<volSymmTensorField> vSymmtf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSymmtf); - print(" volSymmTensorFields :", Info, vSymmtf); - PtrList<volTensorField> vtf; - readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vtf); - print(" volTensorFields :", Info, vtf); + + if (!specifiedFields || selectedFields.size()) + { + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vsf); + print(" volScalarFields :", Info, vsf); + + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vvf); + print(" volVectorFields :", Info, vvf); + + readFields + ( + vMesh, + vMesh.baseMesh(), + objects, + selectedFields, + vSpheretf + ); + print(" volSphericalTensorFields :", Info, vSpheretf); + + readFields + ( + vMesh, + vMesh.baseMesh(), + objects, + selectedFields, + vSymmtf + ); + print(" volSymmTensorFields :", Info, vSymmtf); + + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vtf); + print(" volTensorFields :", Info, vtf); + } label nVolFields = vsf.size() @@ -589,7 +611,7 @@ int main(int argc, char *argv[]) PtrList<pointSymmTensorField> pSymmtf; PtrList<pointTensorField> ptf; - if (!noPointValues) + if (!noPointValues && !(specifiedFields && selectedFields.empty())) { readFields ( diff --git a/bin/tools/pre-commit-hook b/bin/tools/pre-commit-hook index 94018f90b7fff4649360ae3ca6601439052836e6..eab03d8e77a619f260c696fa19f15a50d202af1a 100755 --- a/bin/tools/pre-commit-hook +++ b/bin/tools/pre-commit-hook @@ -263,6 +263,26 @@ checkLineLengthNonDirective() } +# +# check that OpenCFD copyright is currents +# +checkCopyright() +{ + year=$(date +%Y) + echo "$hookName: check copyright ..." 1>&2 + + for f in $fileList + do + sYear=`grep "Copyright.*OpenCFD" $f | sed 's/[^0-9]//g' | cut -c 5-9` + if [ "$year" != "" ] && [ "$year" != "$sYear" ]; then + echo "Updated copyright for: $f" + sed -i "s/$sYear OpenCFD/$year OpenCFD/g" $f + fi + + done +} + + #------------------------------------------------------------------------------ # Main code : do all checks # @@ -276,6 +296,7 @@ checkIllegalCode # ensure code conforms to 80 columns max checkLineLengthNonDirective +checkCopyright exit 0 #------------------------------------------------------------------------------ diff --git a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C index b1e90be3000b86216579e4d1abcdf10a131962e9..286cb2e7583186d3ca3a1f68cc02280b3beef6e2 100644 --- a/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C +++ b/src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionaryIO.C @@ -66,8 +66,13 @@ void Foam::IOdictionary::readFile(const bool masterOnly) // Master reads headerclassname from file. Make sure this gets // transfered as well as contents. - Pstream::scatter(comms, const_cast<word&>(headerClassName())); - Pstream::scatter(comms, note()); + Pstream::scatter + ( + comms, + const_cast<word&>(headerClassName()), + Pstream::msgType() + ); + Pstream::scatter(comms, note(), Pstream::msgType()); // Get my communication order const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; @@ -88,6 +93,7 @@ void Foam::IOdictionary::readFile(const bool masterOnly) Pstream::scheduled, myComm.above(), 0, + Pstream::msgType(), IOstream::ASCII ); IOdictionary::readData(fromAbove); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C index 513e5b0fabf75ed43641fb65a4a2ca54fa0a09da..3e4f284f07308be1d52558146841aa80019aea5e 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,6 +32,7 @@ Foam::IPstream::IPstream const commsTypes commsType, const int fromProcNo, const label bufSize, + const int tag, streamFormat format, versionNumber version ) @@ -43,7 +44,7 @@ Foam::IPstream::IPstream fromProcNo, buf_, externalBufPosition_, - UPstream::msgType(), // tag + tag, // tag false, // do not clear buf_ if at end format, version diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H index f2b3a4974ce0510529cc6377a2563605c5efa587..2b2a685566e3ea7cf2bbd32879d63f50437c25eb 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,6 +68,7 @@ public: const commsTypes commsType, const int fromProcNo, const label bufSize = 0, + const int tag = UPstream::msgType(), streamFormat format=BINARY, versionNumber version=currentVersion ); diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H index 711a522e7a77a28a08a0660a7930b111958012e1..3f24764a37cc7a323f1da1cb20b5859ec8b97b2e 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -97,20 +97,31 @@ public: ( const List<commsStruct>& comms, T& Value, - const BinaryOp& bop + const BinaryOp& bop, + const int tag ); //- Like above but switches between linear/tree communication template <class T, class BinaryOp> - static void gather(T& Value, const BinaryOp& bop); + static void gather + ( + T& Value, + const BinaryOp& bop, + const int tag = Pstream::msgType() + ); //- Scatter data. Distribute without modification. Reverse of gather template <class T> - static void scatter(const List<commsStruct>& comms, T& Value); + static void scatter + ( + const List<commsStruct>& comms, + T& Value, + const int tag + ); //- Like above but switches between linear/tree communication template <class T> - static void scatter(T& Value); + static void scatter(T& Value, const int tag = Pstream::msgType()); // Combine variants. Inplace combine values from processors. @@ -121,24 +132,35 @@ public: ( const List<commsStruct>& comms, T& Value, - const CombineOp& cop + const CombineOp& cop, + const int tag ); //- Like above but switches between linear/tree communication template <class T, class CombineOp> - static void combineGather(T& Value, const CombineOp& cop); + static void combineGather + ( + T& Value, + const CombineOp& cop, + const int tag = Pstream::msgType() + ); //- Scatter data. Reverse of combineGather template <class T> static void combineScatter ( const List<commsStruct>& comms, - T& Value + T& Value, + const int tag ); //- Like above but switches between linear/tree communication template <class T> - static void combineScatter(T& Value); + static void combineScatter + ( + T& Value, + const int tag = Pstream::msgType() + ); // Combine variants working on whole List at a time. @@ -147,24 +169,35 @@ public: ( const List<commsStruct>& comms, List<T>& Value, - const CombineOp& cop + const CombineOp& cop, + const int tag ); //- Like above but switches between linear/tree communication template <class T, class CombineOp> - static void listCombineGather(List<T>& Value, const CombineOp& cop); + static void listCombineGather + ( + List<T>& Value, + const CombineOp& cop, + const int tag = Pstream::msgType() + ); //- Scatter data. Reverse of combineGather template <class T> static void listCombineScatter ( const List<commsStruct>& comms, - List<T>& Value + List<T>& Value, + const int tag ); //- Like above but switches between linear/tree communication template <class T> - static void listCombineScatter(List<T>& Value); + static void listCombineScatter + ( + List<T>& Value, + const int tag = Pstream::msgType() + ); // Combine variants working on whole map at a time. Container needs to // have iterators and find() defined. @@ -174,7 +207,8 @@ public: ( const List<commsStruct>& comms, Container& Values, - const CombineOp& cop + const CombineOp& cop, + const int tag ); //- Like above but switches between linear/tree communication @@ -182,7 +216,8 @@ public: static void mapCombineGather ( Container& Values, - const CombineOp& cop + const CombineOp& cop, + const int tag = Pstream::msgType() ); //- Scatter data. Reverse of combineGather @@ -190,12 +225,17 @@ public: static void mapCombineScatter ( const List<commsStruct>& comms, - Container& Values + Container& Values, + const int tag ); //- Like above but switches between linear/tree communication template <class Container> - static void mapCombineScatter(Container& Values); + static void mapCombineScatter + ( + Container& Values, + const int tag = Pstream::msgType() + ); @@ -208,24 +248,34 @@ public: static void gatherList ( const List<commsStruct>& comms, - List<T>& Values + List<T>& Values, + const int tag ); //- Like above but switches between linear/tree communication template <class T> - static void gatherList(List<T>& Values); + static void gatherList + ( + List<T>& Values, + const int tag = Pstream::msgType() + ); //- Scatter data. Reverse of gatherList template <class T> static void scatterList ( const List<commsStruct>& comms, - List<T>& Values + List<T>& Values, + const int tag ); //- Like above but switches between linear/tree communication template <class T> - static void scatterList(List<T>& Values); + static void scatterList + ( + List<T>& Values, + const int tag = Pstream::msgType() + ); // Exchange diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H index e27403910243bb4b927f08a11412641d60db9cc8..a166e6e491e5a424c4259a81cf1bc7361dff2b26 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -137,6 +137,11 @@ public: // Member functions + int tag() const + { + return tag_; + } + //- Mark all sends as having been done. This will start receives // in non-blocking mode. If block will wait for all transfers to // finish (only relevant for nonBlocking mode) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H index 834504f57acf90e9b5307a355307d993cc4ed2f0..6e326754fc7a0d4f9cd047d52059d539f4bdbba4 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,26 +52,38 @@ void combineReduce ( const List<UPstream::commsStruct>& comms, T& Value, - const CombineOp& cop + const CombineOp& cop, + const int tag ) { - Pstream::combineGather(comms, Value, cop); - Pstream::combineScatter(comms, Value); + Pstream::combineGather(comms, Value, cop, tag); + Pstream::combineScatter(comms, Value, tag); } template <class T, class CombineOp> -void combineReduce(T& Value, const CombineOp& cop) +void combineReduce +( + T& Value, + const CombineOp& cop, + const int tag = Pstream::msgType() +) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - Pstream::combineGather(UPstream::linearCommunication(), Value, cop); - Pstream::combineScatter(UPstream::linearCommunication(), Value); + Pstream::combineGather + ( + UPstream::linearCommunication(), + Value, + cop, + tag + ); + Pstream::combineScatter(UPstream::linearCommunication(), Value, tag); } else { - Pstream::combineGather(UPstream::treeCommunication(), Value, cop); - Pstream::combineScatter(UPstream::treeCommunication(), Value); + Pstream::combineGather(UPstream::treeCommunication(), Value, cop, tag); + Pstream::combineScatter(UPstream::treeCommunication(), Value, tag); } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H index 60c6a4620e92b00b63a9fb36ef2d44d424f29cd5..51a1dcad08d06b3cfa5d369ca4b7ee0f18fe2338 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,11 +42,12 @@ void reduce ( const List<UPstream::commsStruct>& comms, T& Value, - const BinaryOp& bop + const BinaryOp& bop, + const int tag ) { - Pstream::gather(comms, Value, bop); - Pstream::scatter(comms, Value); + Pstream::gather(comms, Value, bop, tag); + Pstream::scatter(comms, Value, tag); } @@ -55,16 +56,17 @@ template <class T, class BinaryOp> void reduce ( T& Value, - const BinaryOp& bop + const BinaryOp& bop, + const int tag = Pstream::msgType() ) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - reduce(UPstream::linearCommunication(), Value, bop); + reduce(UPstream::linearCommunication(), Value, bop, tag); } else { - reduce(UPstream::treeCommunication(), Value, bop); + reduce(UPstream::treeCommunication(), Value, bop, tag); } } @@ -74,18 +76,19 @@ template <class T, class BinaryOp> T returnReduce ( const T& Value, - const BinaryOp& bop + const BinaryOp& bop, + const int tag = Pstream::msgType() ) { T WorkValue(Value); if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - reduce(UPstream::linearCommunication(), WorkValue, bop); + reduce(UPstream::linearCommunication(), WorkValue, bop, tag); } else { - reduce(UPstream::treeCommunication(), WorkValue, bop); + reduce(UPstream::treeCommunication(), WorkValue, bop, tag); } return WorkValue; @@ -93,7 +96,12 @@ T returnReduce // Insist there is a specialisation for the reduction of a scalar -void reduce(scalar& Value, const sumOp<scalar>& bop); +void reduce +( + scalar& Value, + const sumOp<scalar>& bop, + const int tag = Pstream::msgType() +); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index 50728c425ccba43a2f960d4b8d00d102089dcbb7..5d8be0aa2e913652271e3852d932e8ab16ade7ab 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -84,13 +84,17 @@ Foam::UIPstream::~UIPstream() { if (debug) { - Pout<< "UIPstream::~UIPstream() : clearing externalBuf_ of size " - << externalBuf_.size() << endl; + Pout<< "UIPstream::~UIPstream() : tag:" << tag_ + << " fromProcNo:" << fromProcNo_ + << " clearing externalBuf_ of size " + << externalBuf_.size() + << " messageSize_:" << messageSize_ << endl; } externalBuf_.clearStorage(); } } + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // Foam::Istream& Foam::UIPstream::read(token& t) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H index 38a42593d20458eabf917a1493d4f09551614fa4..62a15feb4456f4e462f93dd7d454e3f11191c12b 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -262,14 +262,23 @@ public: // Spawns slave processes and initialises inter-communication static bool init(int& argc, char**& argv); - //- Non-blocking comms: wait until all have finished. - static void waitRequests(); + // Non-blocking comms + + //- Get number of outstanding requests + static label nRequests(); + + //- Truncate number of outstanding requests + static void resetRequests(const label sz); + + //- Wait until all requests (from start onwards) have finished. + static void waitRequests(const label start = 0); + + //- Non-blocking comms: has request i finished? + static bool finishedRequest(const label i); - //- Non-blocking comms: has request i finished? - static bool finishedRequest(const label i); //- Is this a parallel run? - static bool parRun() + static bool& parRun() { return parRun_; } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C b/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C index 7646d8029a6487fde020e24eed9b1ae90e149baa..e08c3794c1093d2f9c84a2b35e83cae70391089e 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,7 +50,8 @@ void Pstream::combineGather ( const List<UPstream::commsStruct>& comms, T& Value, - const CombineOp& cop + const CombineOp& cop, + const int tag ) { if (UPstream::parRun()) @@ -71,7 +72,8 @@ void Pstream::combineGather UPstream::scheduled, belowID, reinterpret_cast<char*>(&value), - sizeof(T) + sizeof(T), + tag ); if (debug & 2) @@ -84,7 +86,7 @@ void Pstream::combineGather } else { - IPstream fromBelow(UPstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID, 0, tag); T value(fromBelow); if (debug & 2) @@ -113,12 +115,13 @@ void Pstream::combineGather UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(&Value), - sizeof(T) + sizeof(T), + tag ); } else { - OPstream toAbove(UPstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above(), 0, tag); toAbove << Value; } } @@ -127,15 +130,15 @@ void Pstream::combineGather template <class T, class CombineOp> -void Pstream::combineGather(T& Value, const CombineOp& cop) +void Pstream::combineGather(T& Value, const CombineOp& cop, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - combineGather(UPstream::linearCommunication(), Value, cop); + combineGather(UPstream::linearCommunication(), Value, cop, tag); } else { - combineGather(UPstream::treeCommunication(), Value, cop); + combineGather(UPstream::treeCommunication(), Value, cop, tag); } } @@ -144,7 +147,8 @@ template <class T> void Pstream::combineScatter ( const List<UPstream::commsStruct>& comms, - T& Value + T& Value, + const int tag ) { if (UPstream::parRun()) @@ -162,12 +166,13 @@ void Pstream::combineScatter UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(&Value), - sizeof(T) + sizeof(T), + tag ); } else { - IPstream fromAbove(UPstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above(), 0, tag); Value = T(fromAbove); } @@ -195,12 +200,13 @@ void Pstream::combineScatter UPstream::scheduled, belowID, reinterpret_cast<const char*>(&Value), - sizeof(T) + sizeof(T), + tag ); } else { - OPstream toBelow(UPstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID, 0, tag); toBelow << Value; } } @@ -209,15 +215,15 @@ void Pstream::combineScatter template <class T> -void Pstream::combineScatter(T& Value) +void Pstream::combineScatter(T& Value, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - combineScatter(UPstream::linearCommunication(), Value); + combineScatter(UPstream::linearCommunication(), Value, tag); } else { - combineScatter(UPstream::treeCommunication(), Value); + combineScatter(UPstream::treeCommunication(), Value, tag); } } @@ -231,7 +237,8 @@ void Pstream::listCombineGather ( const List<UPstream::commsStruct>& comms, List<T>& Values, - const CombineOp& cop + const CombineOp& cop, + const int tag ) { if (UPstream::parRun()) @@ -253,7 +260,8 @@ void Pstream::listCombineGather UPstream::scheduled, belowID, reinterpret_cast<char*>(receivedValues.begin()), - receivedValues.byteSize() + receivedValues.byteSize(), + tag ); if (debug & 2) @@ -269,7 +277,7 @@ void Pstream::listCombineGather } else { - IPstream fromBelow(UPstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID, 0, tag); List<T> receivedValues(fromBelow); if (debug & 2) @@ -301,12 +309,13 @@ void Pstream::listCombineGather UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(Values.begin()), - Values.byteSize() + Values.byteSize(), + tag ); } else { - OPstream toAbove(UPstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above(), 0, tag); toAbove << Values; } } @@ -315,15 +324,20 @@ void Pstream::listCombineGather template <class T, class CombineOp> -void Pstream::listCombineGather(List<T>& Values, const CombineOp& cop) +void Pstream::listCombineGather +( + List<T>& Values, + const CombineOp& cop, + const int tag +) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - listCombineGather(UPstream::linearCommunication(), Values, cop); + listCombineGather(UPstream::linearCommunication(), Values, cop, tag); } else { - listCombineGather(UPstream::treeCommunication(), Values, cop); + listCombineGather(UPstream::treeCommunication(), Values, cop, tag); } } @@ -332,7 +346,8 @@ template <class T> void Pstream::listCombineScatter ( const List<UPstream::commsStruct>& comms, - List<T>& Values + List<T>& Values, + const int tag ) { if (UPstream::parRun()) @@ -350,12 +365,13 @@ void Pstream::listCombineScatter UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(Values.begin()), - Values.byteSize() + Values.byteSize(), + tag ); } else { - IPstream fromAbove(UPstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above(), 0, tag); fromAbove >> Values; } @@ -383,12 +399,13 @@ void Pstream::listCombineScatter UPstream::scheduled, belowID, reinterpret_cast<const char*>(Values.begin()), - Values.byteSize() + Values.byteSize(), + tag ); } else { - OPstream toBelow(UPstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID, 0, tag); toBelow << Values; } } @@ -397,15 +414,15 @@ void Pstream::listCombineScatter template <class T> -void Pstream::listCombineScatter(List<T>& Values) +void Pstream::listCombineScatter(List<T>& Values, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - listCombineScatter(UPstream::linearCommunication(), Values); + listCombineScatter(UPstream::linearCommunication(), Values, tag); } else { - listCombineScatter(UPstream::treeCommunication(), Values); + listCombineScatter(UPstream::treeCommunication(), Values, tag); } } @@ -421,7 +438,8 @@ void Pstream::mapCombineGather ( const List<UPstream::commsStruct>& comms, Container& Values, - const CombineOp& cop + const CombineOp& cop, + const int tag ) { if (UPstream::parRun()) @@ -434,7 +452,7 @@ void Pstream::mapCombineGather { label belowID = myComm.below()[belowI]; - IPstream fromBelow(UPstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID, 0, tag); Container receivedValues(fromBelow); if (debug & 2) @@ -474,7 +492,7 @@ void Pstream::mapCombineGather << " data:" << Values << endl; } - OPstream toAbove(UPstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above(), 0, tag); toAbove << Values; } } @@ -482,15 +500,20 @@ void Pstream::mapCombineGather template <class Container, class CombineOp> -void Pstream::mapCombineGather(Container& Values, const CombineOp& cop) +void Pstream::mapCombineGather +( + Container& Values, + const CombineOp& cop, + const int tag +) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - mapCombineGather(UPstream::linearCommunication(), Values, cop); + mapCombineGather(UPstream::linearCommunication(), Values, cop, tag); } else { - mapCombineGather(UPstream::treeCommunication(), Values, cop); + mapCombineGather(UPstream::treeCommunication(), Values, cop, tag); } } @@ -499,7 +522,8 @@ template <class Container> void Pstream::mapCombineScatter ( const List<UPstream::commsStruct>& comms, - Container& Values + Container& Values, + const int tag ) { if (UPstream::parRun()) @@ -510,7 +534,7 @@ void Pstream::mapCombineScatter // Reveive from up if (myComm.above() != -1) { - IPstream fromAbove(UPstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above(), 0, tag); fromAbove >> Values; if (debug & 2) @@ -530,7 +554,7 @@ void Pstream::mapCombineScatter Pout<< " sending to " << belowID << " data:" << Values << endl; } - OPstream toBelow(UPstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID, 0, tag); toBelow << Values; } } @@ -538,15 +562,15 @@ void Pstream::mapCombineScatter template <class Container> -void Pstream::mapCombineScatter(Container& Values) +void Pstream::mapCombineScatter(Container& Values, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - mapCombineScatter(UPstream::linearCommunication(), Values); + mapCombineScatter(UPstream::linearCommunication(), Values, tag); } else { - mapCombineScatter(UPstream::treeCommunication(), Values); + mapCombineScatter(UPstream::treeCommunication(), Values, tag); } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C index 2998eb9c38bdc539b679e7358142d9b43a81d62f..9c5d118c91ca6098fdd574b33429042feda585b9 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -42,8 +42,8 @@ namespace Foam template <class Container, class T> void Pstream::exchange ( - const List<Container >& sendBufs, - List<Container >& recvBufs, + const List<Container>& sendBufs, + List<Container>& recvBufs, labelListList& sizes, const int tag, const bool block @@ -77,14 +77,13 @@ void Pstream::exchange nsTransPs[procI] = sendBufs[procI].size(); } - // Send sizes across. - int oldTag = UPstream::msgType(); - UPstream::msgType() = tag; - combineReduce(sizes, UPstream::listEq()); - UPstream::msgType() = oldTag; + // Send sizes across. Note: blocks. + combineReduce(sizes, UPstream::listEq(), tag); if (Pstream::parRun()) { + label startOfRequests = Pstream::nRequests(); + // Set up receives // ~~~~~~~~~~~~~~~ @@ -142,7 +141,7 @@ void Pstream::exchange if (block) { - Pstream::waitRequests(); + Pstream::waitRequests(startOfRequests); } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C index 2495a56c3c5a0a6deec687e70bd42576c7050259..493f9b079bde81785b086b5431e9724a1fbb124d 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -47,7 +47,8 @@ void Pstream::gather ( const List<UPstream::commsStruct>& comms, T& Value, - const BinaryOp& bop + const BinaryOp& bop, + const int tag ) { if (UPstream::parRun()) @@ -67,12 +68,19 @@ void Pstream::gather UPstream::scheduled, myComm.below()[belowI], reinterpret_cast<char*>(&value), - sizeof(T) + sizeof(T), + tag ); } else { - IPstream fromBelow(UPstream::scheduled, myComm.below()[belowI]); + IPstream fromBelow + ( + UPstream::scheduled, + myComm.below()[belowI], + 0, + tag + ); fromBelow >> value; } @@ -89,12 +97,13 @@ void Pstream::gather UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(&Value), - sizeof(T) + sizeof(T), + tag ); } else { - OPstream toAbove(UPstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above(), 0, tag); toAbove << Value; } } @@ -103,21 +112,26 @@ void Pstream::gather template <class T, class BinaryOp> -void Pstream::gather(T& Value, const BinaryOp& bop) +void Pstream::gather(T& Value, const BinaryOp& bop, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - gather(UPstream::linearCommunication(), Value, bop); + gather(UPstream::linearCommunication(), Value, bop, tag); } else { - gather(UPstream::treeCommunication(), Value, bop); + gather(UPstream::treeCommunication(), Value, bop, tag); } } template <class T> -void Pstream::scatter(const List<UPstream::commsStruct>& comms, T& Value) +void Pstream::scatter +( + const List<UPstream::commsStruct>& comms, + T& Value, + const int tag +) { if (UPstream::parRun()) { @@ -134,12 +148,13 @@ void Pstream::scatter(const List<UPstream::commsStruct>& comms, T& Value) UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(&Value), - sizeof(T) + sizeof(T), + tag ); } else { - IPstream fromAbove(UPstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above(), 0, tag); fromAbove >> Value; } } @@ -154,12 +169,19 @@ void Pstream::scatter(const List<UPstream::commsStruct>& comms, T& Value) UPstream::scheduled, myComm.below()[belowI], reinterpret_cast<const char*>(&Value), - sizeof(T) + sizeof(T), + tag ); } else { - OPstream toBelow(UPstream::scheduled,myComm.below()[belowI]); + OPstream toBelow + ( + UPstream::scheduled, + myComm.below()[belowI], + 0, + tag + ); toBelow << Value; } } @@ -168,15 +190,15 @@ void Pstream::scatter(const List<UPstream::commsStruct>& comms, T& Value) template <class T> -void Pstream::scatter(T& Value) +void Pstream::scatter(T& Value, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - scatter(UPstream::linearCommunication(), Value); + scatter(UPstream::linearCommunication(), Value, tag); } else { - scatter(UPstream::treeCommunication(), Value); + scatter(UPstream::treeCommunication(), Value, tag); } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C index 1c97cc74cf0ed81d4457c7fd9c3009b428ee4f82..72870edd9a965b001e4f383efd815720a9ec1d6f 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,7 +48,8 @@ template <class T> void Pstream::gatherList ( const List<UPstream::commsStruct>& comms, - List<T>& Values + List<T>& Values, + const int tag ) { if (UPstream::parRun()) @@ -83,7 +84,8 @@ void Pstream::gatherList UPstream::scheduled, belowID, reinterpret_cast<char*>(receivedValues.begin()), - receivedValues.byteSize() + receivedValues.byteSize(), + tag ); Values[belowID] = receivedValues[0]; @@ -95,7 +97,7 @@ void Pstream::gatherList } else { - IPstream fromBelow(UPstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID, 0, tag); fromBelow >> Values[belowID]; if (debug & 2) @@ -150,12 +152,13 @@ void Pstream::gatherList UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(sendingValues.begin()), - sendingValues.byteSize() + sendingValues.byteSize(), + tag ); } else { - OPstream toAbove(UPstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above(), 0, tag); toAbove << Values[UPstream::myProcNo()]; forAll(belowLeaves, leafI) @@ -177,15 +180,15 @@ void Pstream::gatherList template <class T> -void Pstream::gatherList(List<T>& Values) +void Pstream::gatherList(List<T>& Values, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - gatherList(UPstream::linearCommunication(), Values); + gatherList(UPstream::linearCommunication(), Values, tag); } else { - gatherList(UPstream::treeCommunication(), Values); + gatherList(UPstream::treeCommunication(), Values, tag); } } @@ -194,7 +197,8 @@ template <class T> void Pstream::scatterList ( const List<UPstream::commsStruct>& comms, - List<T>& Values + List<T>& Values, + const int tag ) { if (UPstream::parRun()) @@ -228,7 +232,8 @@ void Pstream::scatterList UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(receivedValues.begin()), - receivedValues.byteSize() + receivedValues.byteSize(), + tag ); forAll(notBelowLeaves, leafI) @@ -238,7 +243,7 @@ void Pstream::scatterList } else { - IPstream fromAbove(UPstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above(), 0, tag); forAll(notBelowLeaves, leafI) { @@ -275,12 +280,13 @@ void Pstream::scatterList UPstream::scheduled, belowID, reinterpret_cast<const char*>(sendingValues.begin()), - sendingValues.byteSize() + sendingValues.byteSize(), + tag ); } else { - OPstream toBelow(UPstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID, 0, tag); // Send data destined for all other processors below belowID forAll(notBelowLeaves, leafI) @@ -302,15 +308,15 @@ void Pstream::scatterList template <class T> -void Pstream::scatterList(List<T>& Values) +void Pstream::scatterList(List<T>& Values, const int tag) { if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - scatterList(UPstream::linearCommunication(), Values); + scatterList(UPstream::linearCommunication(), Values, tag); } else { - scatterList(UPstream::treeCommunication(), Values); + scatterList(UPstream::treeCommunication(), Values, tag); } } diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C index 93d934a1b548c79df4965eb497ebc3906337b9c8..f04b9c1af6156208f4221cbcdf0a129ff3dc5a78 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C @@ -35,8 +35,6 @@ defineTypeNameAndDebug(Foam::dlLibraryTable, 0); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::dlLibraryTable::dlLibraryTable() -: - HashTable<fileName, void*, Hash<void*> >() {} @@ -45,8 +43,6 @@ Foam::dlLibraryTable::dlLibraryTable const dictionary& dict, const word& libsEntry ) -: - HashTable<fileName, void*, Hash<void*> >() { open(dict, libsEntry); } @@ -56,17 +52,18 @@ Foam::dlLibraryTable::dlLibraryTable Foam::dlLibraryTable::~dlLibraryTable() { - forAllConstIter(dlLibraryTable, *this, iter) + forAllReverse(libPtrs_, i) { - // bug in dlclose - does not call static destructors of - // loaded library when actually unloading the library. - // See https://bugzilla.novell.com/show_bug.cgi?id=680125 and 657627. - if (debug) + if (libPtrs_[i]) { - Info<< "dlLibraryTable::~dlLibraryTable() : closing " << iter() - << " with handle " << long(iter.key()) << endl; + if (debug) + { + Info<< "dlLibraryTable::~dlLibraryTable() : closing " + << libNames_[i] + << " with handle " << long(libPtrs_[i]) << endl; + } + dlClose(libPtrs_[i]); } - dlClose(iter.key()); } } @@ -95,7 +92,7 @@ bool Foam::dlLibraryTable::open { WarningIn ( - "dlLibraryTable::open(const fileName&)" + "dlLibraryTable::open(const fileName&, const bool)" ) << "could not load " << functionLibName << endl; } @@ -104,7 +101,9 @@ bool Foam::dlLibraryTable::open } else { - return insert(functionLibPtr, functionLibName); + libPtrs_.append(functionLibPtr); + libNames_.append(functionLibName); + return true; } } else @@ -120,18 +119,30 @@ bool Foam::dlLibraryTable::close const bool verbose ) { - void* libPtr = findLibrary(functionLibName); - if (libPtr) + label index = -1; + forAllReverse(libNames_, i) + { + if (libNames_[i] == functionLibName) + { + index = i; + break; + } + } + + if (index != -1) { if (debug) { Info<< "dlLibraryTable::close : closing " << functionLibName - << " with handle " << long(libPtr) << endl; + << " with handle " << long(libPtrs_[index]) << endl; } - erase(libPtr); + bool ok = dlClose(libPtrs_[index]); + + libPtrs_[index] = NULL; + libNames_[index] = fileName::null; - if (!dlClose(libPtr)) + if (!ok) { if (verbose) { @@ -153,13 +164,20 @@ bool Foam::dlLibraryTable::close void* Foam::dlLibraryTable::findLibrary(const fileName& functionLibName) { - forAllConstIter(dlLibraryTable, *this, iter) + label index = -1; + forAllReverse(libNames_, i) { - if (iter() == functionLibName) + if (libNames_[i] == functionLibName) { - return iter.key(); + index = i; + break; } } + + if (index != -1) + { + return libPtrs_[index]; + } return NULL; } diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H index f2925fe511e866e1a3821dff3b5dd7896dcdb46d..9d92fea15374371827d0a4d8611ab3398f8a7388 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.H @@ -36,8 +36,7 @@ SourceFiles #define dlLibraryTable_H #include "label.H" -#include "Hash.H" -#include "HashTable.H" +#include "DynamicList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,11 +48,14 @@ namespace Foam \*---------------------------------------------------------------------------*/ class dlLibraryTable -: - public HashTable<fileName, void*, Hash<void*> > { // Private Member Functions + DynamicList<void*> libPtrs_; + + DynamicList<fileName> libNames_; + + //- Disallow default bitwise copy construct dlLibraryTable(const dlLibraryTable&); diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C index 13a9ae919f178531f9835e217c268f5a9616e164..abb2e365653139dc1946ec77e6306fe0d279bf4d 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTableTemplates.C @@ -57,13 +57,23 @@ bool Foam::dlLibraryTable::open bool opened = dlLibraryTable::open(libName); allOpened = opened && allOpened; - if (opened && (!tablePtr || tablePtr->size() <= nEntries)) + if (!opened) { WarningIn ( "dlLibraryTable::open" - "(const dictionary& dict, const word& libsEntry, " - "const TablePtr tablePtr)" + "(const dictionary&, const word&, " + "const TablePtr&)" + ) << "Could not open library " << libName + << endl << endl; + } + else if (debug && (!tablePtr || tablePtr->size() <= nEntries)) + { + WarningIn + ( + "dlLibraryTable::open" + "(const dictionary&, const word&, " + "const TablePtr&)" ) << "library " << libName << " did not introduce any new entries" << endl << endl; diff --git a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C index fde2452e136d86c3b022334a3f880efca6c5334f..31b932bbdfdfef4bd38aeb76965746c79f797a2d 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobjectRead.C +++ b/src/OpenFOAM/db/regIOobject/regIOobjectRead.C @@ -203,8 +203,13 @@ bool Foam::regIOobject::read() // Master reads headerclassname from file. Make sure this gets // transfered as well as contents. - Pstream::scatter(comms, const_cast<word&>(headerClassName())); - Pstream::scatter(comms, note()); + Pstream::scatter + ( + comms, + const_cast<word&>(headerClassName()), + Pstream::msgType() + ); + Pstream::scatter(comms, note(), Pstream::msgType()); // Get my communication order @@ -228,6 +233,7 @@ bool Foam::regIOobject::read() Pstream::scheduled, myComm.above(), 0, + Pstream::msgType(), IOstream::ASCII ); ok = readData(fromAbove); diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 418abd09cc3e50fea0c9bf78768a5b07d6862dd9..8b5f0a7add03294b24b18c921f3b097b76d23e16 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -340,6 +340,8 @@ evaluate() || Pstream::defaultCommsType == Pstream::nonBlocking ) { + label nReq = Pstream::nRequests(); + forAll(*this, patchi) { this->operator[](patchi).initEvaluate(Pstream::defaultCommsType); @@ -352,7 +354,7 @@ evaluate() && Pstream::defaultCommsType == Pstream::nonBlocking ) { - Pstream::waitRequests(); + Pstream::waitRequests(nReq); } forAll(*this, patchi) diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C index 60a08729f8c68198e67ab8df64570a6ee0d422ae..9c9dcdb4248da9973e5feca3d57d5dac9a2c58a7 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,14 +27,14 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::globalIndex::globalIndex(const label localSize) +Foam::globalIndex::globalIndex(const label localSize, const int tag) : offsets_(Pstream::nProcs()+1) { labelList localSizes(Pstream::nProcs()); localSizes[Pstream::myProcNo()] = localSize; - Pstream::gatherList(localSizes); - Pstream::scatterList(localSizes); + Pstream::gatherList(localSizes, tag); + Pstream::scatterList(localSizes, tag); label offset = 0; offsets_[0] = 0; diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H index e3ecbedfeabe29c65dee8702e828cbfa666beee6..671f71cf1281c3ca0e6007558a6aeb08b15fd1a3 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,7 +72,7 @@ public: // Constructors //- Construct from local max size - globalIndex(const label localSize); + globalIndex(const label localSize, const int tag = Pstream::msgType()); //- Construct from Istream globalIndex(Istream& is); diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index b8ed0276c71803919d1e0dc18280da0acbb2008f..5660b65e1776106c0b7380973b919c3f9282e86d 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -133,7 +133,8 @@ void Foam::mapDistribute::transform::operator() Foam::List<Foam::labelPair> Foam::mapDistribute::schedule ( const labelListList& subMap, - const labelListList& constructMap + const labelListList& constructMap, + const int tag ) { // Communications: send and receive processor @@ -174,7 +175,7 @@ Foam::List<Foam::labelPair> Foam::mapDistribute::schedule slave++ ) { - IPstream fromSlave(Pstream::scheduled, slave); + IPstream fromSlave(Pstream::scheduled, slave, 0, tag); List<labelPair> nbrData(fromSlave); forAll(nbrData, i) @@ -195,18 +196,24 @@ Foam::List<Foam::labelPair> Foam::mapDistribute::schedule slave++ ) { - OPstream toSlave(Pstream::scheduled, slave); + OPstream toSlave(Pstream::scheduled, slave, 0, tag); toSlave << allComms; } } else { { - OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); + OPstream toMaster(Pstream::scheduled, Pstream::masterNo(), 0, tag); toMaster << allComms; } { - IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); + IPstream fromMaster + ( + Pstream::scheduled, + Pstream::masterNo(), + 0, + tag + ); fromMaster >> allComms; } } @@ -257,7 +264,7 @@ const Foam::List<Foam::labelPair>& Foam::mapDistribute::schedule() const ( new List<labelPair> ( - schedule(subMap_, constructMap_) + schedule(subMap_, constructMap_, Pstream::msgType()) ) ); } @@ -471,6 +478,7 @@ void Foam::mapDistribute::calcCompactAddressing void Foam::mapDistribute::exchangeAddressing ( + const int tag, const globalIndex& globalNumbering, labelList& elements, List<Map<label> >& compactMap, @@ -535,7 +543,8 @@ void Foam::mapDistribute::exchangeAddressing ( wantedRemoteElements, subMap_, - sendSizes + sendSizes, + tag ); // Renumber elements @@ -548,6 +557,7 @@ void Foam::mapDistribute::exchangeAddressing void Foam::mapDistribute::exchangeAddressing ( + const int tag, const globalIndex& globalNumbering, labelListList& cellCells, List<Map<label> >& compactMap, @@ -612,7 +622,8 @@ void Foam::mapDistribute::exchangeAddressing ( wantedRemoteElements, subMap_, - sendSizes + sendSizes, + tag ); // Renumber elements @@ -750,7 +761,8 @@ Foam::mapDistribute::mapDistribute ( const globalIndex& globalNumbering, labelList& elements, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag ) : constructSize_(0), @@ -789,6 +801,7 @@ Foam::mapDistribute::mapDistribute labelList compactStart; exchangeAddressing ( + tag, globalNumbering, elements, compactMap, @@ -806,7 +819,8 @@ Foam::mapDistribute::mapDistribute ( const globalIndex& globalNumbering, labelListList& cellCells, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag ) : constructSize_(0), @@ -845,6 +859,7 @@ Foam::mapDistribute::mapDistribute labelList compactStart; exchangeAddressing ( + tag, globalNumbering, cellCells, compactMap, @@ -865,7 +880,8 @@ Foam::mapDistribute::mapDistribute const globalIndexAndTransform& globalTransforms, const labelPairList& transformedElements, labelList& transformedIndices, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag ) : constructSize_(0), @@ -900,6 +916,7 @@ Foam::mapDistribute::mapDistribute labelList compactStart; exchangeAddressing ( + tag, globalNumbering, elements, compactMap, @@ -969,7 +986,8 @@ Foam::mapDistribute::mapDistribute const globalIndexAndTransform& globalTransforms, const List<labelPairList>& transformedElements, labelListList& transformedIndices, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag ) : constructSize_(0), @@ -1008,6 +1026,7 @@ Foam::mapDistribute::mapDistribute labelList compactStart; exchangeAddressing ( + tag, globalNumbering, cellCells, compactMap, @@ -1150,7 +1169,7 @@ Foam::label Foam::mapDistribute::renumber } -void Foam::mapDistribute::compact(const boolList& elemIsUsed) +void Foam::mapDistribute::compact(const boolList& elemIsUsed, const int tag) { // 1. send back to sender. Have sender delete the corresponding element // from the submap and do the same to the constructMap locally @@ -1160,53 +1179,59 @@ void Foam::mapDistribute::compact(const boolList& elemIsUsed) // mapDistribute but in reverse order. if (Pstream::parRun()) { - List<boolList> sendFields(Pstream::nProcs()); + label startOfRequests = Pstream::nRequests(); + + // Set up receives from neighbours + + List<boolList> recvFields(Pstream::nProcs()); for (label domain = 0; domain < Pstream::nProcs(); domain++) { - const labelList& map = constructMap_[domain]; + const labelList& map = subMap_[domain]; if (domain != Pstream::myProcNo() && map.size()) { - boolList& subField = sendFields[domain]; - subField.setSize(map.size()); - forAll(map, i) - { - subField[i] = elemIsUsed[map[i]]; - } - - OPstream::write + recvFields[domain].setSize(map.size()); + IPstream::read ( Pstream::nonBlocking, domain, - reinterpret_cast<const char*>(subField.begin()), - subField.size()*sizeof(bool) + reinterpret_cast<char*>(recvFields[domain].begin()), + recvFields[domain].size()*sizeof(bool), + tag ); } } - // Set up receives from neighbours - List<boolList> recvFields(Pstream::nProcs()); + List<boolList> sendFields(Pstream::nProcs()); for (label domain = 0; domain < Pstream::nProcs(); domain++) { - const labelList& map = subMap_[domain]; + const labelList& map = constructMap_[domain]; if (domain != Pstream::myProcNo() && map.size()) { - recvFields[domain].setSize(map.size()); - IPstream::read + boolList& subField = sendFields[domain]; + subField.setSize(map.size()); + forAll(map, i) + { + subField[i] = elemIsUsed[map[i]]; + } + + OPstream::write ( Pstream::nonBlocking, domain, - reinterpret_cast<char*>(recvFields[domain].begin()), - recvFields[domain].size()*sizeof(bool) + reinterpret_cast<const char*>(subField.begin()), + subField.size()*sizeof(bool), + tag ); } } + // Set up 'send' to myself - write directly into recvFields { @@ -1222,7 +1247,7 @@ void Foam::mapDistribute::compact(const boolList& elemIsUsed) // Wait for all to finish - Pstream::waitRequests(); + Pstream::waitRequests(startOfRequests); // Compact out all submap entries that are referring to unused elements diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index b5c31754ff15af2c0db7085d661ca05e24251af2..d1b42f029979e91718daa55e09281e0c15f0d1c1 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -201,6 +201,7 @@ class mapDistribute void exchangeAddressing ( + const int tag, const globalIndex& globalNumbering, labelList& elements, List<Map<label> >& compactMap, @@ -208,6 +209,7 @@ class mapDistribute ); void exchangeAddressing ( + const int tag, const globalIndex& globalNumbering, labelListList& elements, List<Map<label> >& compactMap, @@ -380,7 +382,8 @@ public: ( const globalIndex&, labelList& elements, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag = Pstream::msgType() ); //- Special variant that works with the info sorted into bins @@ -390,7 +393,8 @@ public: ( const globalIndex&, labelListList& cellCells, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag = Pstream::msgType() ); //- Construct from list of (possibly remote) untransformed elements @@ -406,7 +410,8 @@ public: const globalIndexAndTransform&, const labelPairList& transformedElements, labelList& transformedIndices, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag = Pstream::msgType() ); //- As above but with ListLists. @@ -417,7 +422,8 @@ public: const globalIndexAndTransform&, const List<labelPairList>& transformedElements, labelListList& transformedIndices, - List<Map<label> >& compactMap + List<Map<label> >& compactMap, + const int tag = Pstream::msgType() ); //- Construct by transferring parameter content @@ -487,7 +493,8 @@ public: static List<labelPair> schedule ( const labelListList& subMap, - const labelListList& constructMap + const labelListList& constructMap, + const int tag ); //- Return a schedule. Demand driven. See above. @@ -514,7 +521,7 @@ public: //- Compact maps. Gets per field a bool whether it is used (locally) // and works out itself what this side and sender side can remove // from maps. - void compact(const boolList& elemIsUsed); + void compact(const boolList& elemIsUsed, const int tag); //- Distribute data. Note:schedule only used for Pstream::scheduled @@ -527,7 +534,8 @@ public: const label constructSize, const labelListList& subMap, const labelListList& constructMap, - List<T>& + List<T>&, + const int tag = UPstream::msgType() ); //- Distribute data. If multiple processors writing to same @@ -542,13 +550,18 @@ public: const labelListList& constructMap, List<T>&, const CombineOp& cop, - const T& nullValue + const T& nullValue, + const int tag = UPstream::msgType() ); //- Distribute data using default commsType. template<class T> - void distribute(List<T>& fld, const bool dummyTransform = true) - const; + void distribute + ( + List<T>& fld, + const bool dummyTransform = true, + const int tag = UPstream::msgType() + ) const; //- Same but with transforms template<class T, class TransformOp> @@ -556,7 +569,8 @@ public: ( const globalIndexAndTransform&, List<T>& fld, - const TransformOp& top + const TransformOp& top, + const int tag = UPstream::msgType() ) const; //- Reverse distribute data using default commsType. @@ -565,7 +579,8 @@ public: ( const label constructSize, List<T>&, - const bool dummyTransform = true + const bool dummyTransform = true, + const int tag = UPstream::msgType() ) const; //- Same but with transforms @@ -575,7 +590,8 @@ public: const globalIndexAndTransform&, const label constructSize, List<T>& fld, - const TransformOp& top + const TransformOp& top, + const int tag = UPstream::msgType() ) const; //- Reverse distribute data using default commsType. @@ -587,7 +603,8 @@ public: const label constructSize, const T& nullValue, List<T>& fld, - const bool dummyTransform = true + const bool dummyTransform = true, + const int tag = UPstream::msgType() ) const; //- Same but with transforms @@ -598,7 +615,8 @@ public: const label constructSize, const T& nullValue, List<T>& fld, - const TransformOp& top + const TransformOp& top, + const int tag = UPstream::msgType() ) const; //- Do all sends using PstreamBuffers diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index d22b3abaa3c76d90c342489977177427475a6434..8f32a9b6339cc7b0158c7778fff4a75ec6569ce9 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -40,7 +40,8 @@ void Foam::mapDistribute::distribute const label constructSize, const labelListList& subMap, const labelListList& constructMap, - List<T>& field + List<T>& field, + const int tag ) { if (!Pstream::parRun()) @@ -79,7 +80,7 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - OPstream toNbr(Pstream::blocking, domain); + OPstream toNbr(Pstream::blocking, domain, 0, tag); toNbr << UIndirectList<T>(field, map); } } @@ -110,7 +111,7 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - IPstream fromNbr(Pstream::blocking, domain); + IPstream fromNbr(Pstream::blocking, domain, 0, tag); List<T> subField(fromNbr); checkReceivedSize(domain, map.size(), subField.size()); @@ -154,11 +155,11 @@ void Foam::mapDistribute::distribute { // I am send first, receive next { - OPstream toNbr(Pstream::scheduled, recvProc); + OPstream toNbr(Pstream::scheduled, recvProc, 0, tag); toNbr << UIndirectList<T>(field, subMap[recvProc]); } { - IPstream fromNbr(Pstream::scheduled, recvProc); + IPstream fromNbr(Pstream::scheduled, recvProc, 0, tag); List<T> subField(fromNbr); const labelList& map = constructMap[recvProc]; @@ -175,7 +176,7 @@ void Foam::mapDistribute::distribute { // I am receive first, send next { - IPstream fromNbr(Pstream::scheduled, sendProc); + IPstream fromNbr(Pstream::scheduled, sendProc, 0, tag); List<T> subField(fromNbr); const labelList& map = constructMap[sendProc]; @@ -188,7 +189,7 @@ void Foam::mapDistribute::distribute } } { - OPstream toNbr(Pstream::scheduled, sendProc); + OPstream toNbr(Pstream::scheduled, sendProc, 0, tag); toNbr << UIndirectList<T>(field, subMap[sendProc]); } } @@ -197,9 +198,11 @@ void Foam::mapDistribute::distribute } else if (commsType == Pstream::nonBlocking) { + label nOutstanding = Pstream::nRequests(); + if (!contiguous<T>()) { - PstreamBuffers pBufs(Pstream::nonBlocking); + PstreamBuffers pBufs(Pstream::nonBlocking, tag); // Stream data into buffer for (label domain = 0; domain < Pstream::nProcs(); domain++) @@ -214,8 +217,8 @@ void Foam::mapDistribute::distribute } } - // Start receiving - pBufs.finishedSends(); + // Start receiving. Do not block. + pBufs.finishedSends(false); { // Set up 'send' to myself @@ -238,6 +241,9 @@ void Foam::mapDistribute::distribute } } + // Block ourselves, waiting only for the current comms + Pstream::waitRequests(nOutstanding); + // Consume for (label domain = 0; domain < Pstream::nProcs(); domain++) { @@ -281,7 +287,8 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast<const char*>(subField.begin()), - subField.byteSize() + subField.byteSize(), + tag ); } } @@ -302,7 +309,8 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast<char*>(recvFields[domain].begin()), - recvFields[domain].byteSize() + recvFields[domain].byteSize(), + tag ); } } @@ -341,7 +349,8 @@ void Foam::mapDistribute::distribute // Wait for all to finish - Pstream::waitRequests(); + Pstream::waitRequests(nOutstanding); + // Collect neighbour fields @@ -383,7 +392,8 @@ void Foam::mapDistribute::distribute const labelListList& constructMap, List<T>& field, const CombineOp& cop, - const T& nullValue + const T& nullValue, + const int tag ) { if (!Pstream::parRun()) @@ -423,7 +433,7 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - OPstream toNbr(Pstream::blocking, domain); + OPstream toNbr(Pstream::blocking, domain, 0, tag); toNbr << UIndirectList<T>(field, map); } } @@ -455,7 +465,7 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - IPstream fromNbr(Pstream::blocking, domain); + IPstream fromNbr(Pstream::blocking, domain, 0, tag); List<T> subField(fromNbr); checkReceivedSize(domain, map.size(), subField.size()); @@ -499,11 +509,11 @@ void Foam::mapDistribute::distribute { // I am send first, receive next { - OPstream toNbr(Pstream::scheduled, recvProc); + OPstream toNbr(Pstream::scheduled, recvProc, 0, tag); toNbr << UIndirectList<T>(field, subMap[recvProc]); } { - IPstream fromNbr(Pstream::scheduled, recvProc); + IPstream fromNbr(Pstream::scheduled, recvProc, 0, tag); List<T> subField(fromNbr); const labelList& map = constructMap[recvProc]; @@ -519,7 +529,7 @@ void Foam::mapDistribute::distribute { // I am receive first, send next { - IPstream fromNbr(Pstream::scheduled, sendProc); + IPstream fromNbr(Pstream::scheduled, sendProc, 0, tag); List<T> subField(fromNbr); const labelList& map = constructMap[sendProc]; @@ -531,7 +541,7 @@ void Foam::mapDistribute::distribute } } { - OPstream toNbr(Pstream::scheduled, sendProc); + OPstream toNbr(Pstream::scheduled, sendProc, 0, tag); toNbr << UIndirectList<T>(field, subMap[sendProc]); } } @@ -540,9 +550,11 @@ void Foam::mapDistribute::distribute } else if (commsType == Pstream::nonBlocking) { + label nOutstanding = Pstream::nRequests(); + if (!contiguous<T>()) { - PstreamBuffers pBufs(Pstream::nonBlocking); + PstreamBuffers pBufs(Pstream::nonBlocking, tag); // Stream data into buffer for (label domain = 0; domain < Pstream::nProcs(); domain++) @@ -557,8 +569,8 @@ void Foam::mapDistribute::distribute } } - // Start receiving - pBufs.finishedSends(); + // Start receiving. Do not block. + pBufs.finishedSends(false); { // Set up 'send' to myself @@ -577,9 +589,8 @@ void Foam::mapDistribute::distribute } } - - // Wait till all finished - UPstream::waitRequests(); + // Block ourselves, waiting only for the current comms + Pstream::waitRequests(nOutstanding); // Consume for (label domain = 0; domain < Pstream::nProcs(); domain++) @@ -624,7 +635,8 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast<const char*>(subField.begin()), - subField.size()*sizeof(T) + subField.size()*sizeof(T), + tag ); } } @@ -645,7 +657,8 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast<char*>(recvFields[domain].begin()), - recvFields[domain].size()*sizeof(T) + recvFields[domain].size()*sizeof(T), + tag ); } } @@ -683,7 +696,8 @@ void Foam::mapDistribute::distribute // Wait for all to finish - Pstream::waitRequests(); + Pstream::waitRequests(nOutstanding); + // Collect neighbour fields @@ -878,7 +892,8 @@ template<class T> void Foam::mapDistribute::distribute ( List<T>& fld, - const bool dummyTransform + const bool dummyTransform, + const int tag ) const { if (Pstream::defaultCommsType == Pstream::nonBlocking) @@ -890,7 +905,8 @@ void Foam::mapDistribute::distribute constructSize_, subMap_, constructMap_, - fld + fld, + tag ); } else if (Pstream::defaultCommsType == Pstream::scheduled) @@ -902,7 +918,8 @@ void Foam::mapDistribute::distribute constructSize_, subMap_, constructMap_, - fld + fld, + tag ); } else @@ -914,7 +931,8 @@ void Foam::mapDistribute::distribute constructSize_, subMap_, constructMap_, - fld + fld, + tag ); } @@ -932,7 +950,8 @@ void Foam::mapDistribute::reverseDistribute ( const label constructSize, List<T>& fld, - const bool dummyTransform + const bool dummyTransform, + const int tag ) const { if (dummyTransform) @@ -949,7 +968,8 @@ void Foam::mapDistribute::reverseDistribute constructSize, constructMap_, subMap_, - fld + fld, + tag ); } else if (Pstream::defaultCommsType == Pstream::scheduled) @@ -961,7 +981,8 @@ void Foam::mapDistribute::reverseDistribute constructSize, constructMap_, subMap_, - fld + fld, + tag ); } else @@ -973,7 +994,8 @@ void Foam::mapDistribute::reverseDistribute constructSize, constructMap_, subMap_, - fld + fld, + tag ); } } @@ -988,7 +1010,8 @@ void Foam::mapDistribute::reverseDistribute const label constructSize, const T& nullValue, List<T>& fld, - const bool dummyTransform + const bool dummyTransform, + const int tag ) const { if (dummyTransform) @@ -1007,7 +1030,8 @@ void Foam::mapDistribute::reverseDistribute subMap_, fld, eqOp<T>(), - nullValue + nullValue, + tag ); } else if (Pstream::defaultCommsType == Pstream::scheduled) @@ -1021,7 +1045,8 @@ void Foam::mapDistribute::reverseDistribute subMap_, fld, eqOp<T>(), - nullValue + nullValue, + tag ); } else @@ -1035,7 +1060,8 @@ void Foam::mapDistribute::reverseDistribute subMap_, fld, eqOp<T>(), - nullValue + nullValue, + tag ); } } @@ -1047,11 +1073,12 @@ void Foam::mapDistribute::distribute ( const globalIndexAndTransform& git, List<T>& fld, - const TransformOp& top + const TransformOp& top, + const int tag ) const { // Distribute. Leave out dummy transforms since we're doing them ourselves - distribute(fld, false); + distribute(fld, false, tag); // Do transforms applyTransforms(git, fld, top); } @@ -1063,7 +1090,8 @@ void Foam::mapDistribute::reverseDistribute const globalIndexAndTransform& git, const label constructSize, List<T>& fld, - const TransformOp& top + const TransformOp& top, + const int tag ) const { // Fill slots with reverse-transformed data. Note that it also copies @@ -1072,7 +1100,7 @@ void Foam::mapDistribute::reverseDistribute applyInverseTransforms(git, fld, top); // And send back (the remote slots). Disable dummy transformations. - reverseDistribute(constructSize, fld, false); + reverseDistribute(constructSize, fld, false, tag); } @@ -1083,7 +1111,8 @@ void Foam::mapDistribute::reverseDistribute const label constructSize, const T& nullValue, List<T>& fld, - const TransformOp& top + const TransformOp& top, + const int tag ) const { // Fill slots with reverse-transformed data Note that it also copies @@ -1092,7 +1121,7 @@ void Foam::mapDistribute::reverseDistribute applyInverseTransforms(git, fld, top); //, eqOp<T>()); // And send back (the remote slots) Disable dummy transformations. - reverseDistribute(constructSize, nullValue, fld, false); + reverseDistribute(constructSize, nullValue, fld, false, tag); } diff --git a/src/Pstream/dummy/UPstream.C b/src/Pstream/dummy/UPstream.C index 29146051f85fef0232dd8404721d037fd2450beb..21e83a30b6f492077e1006752c2700c4b5878a72 100644 --- a/src/Pstream/dummy/UPstream.C +++ b/src/Pstream/dummy/UPstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,12 +55,22 @@ void Foam::UPstream::abort() } -void Foam::reduce(scalar&, const sumOp<scalar>&) +void Foam::reduce(scalar&, const sumOp<scalar>&, const int) {} -void Foam::UPstream::waitRequests() +Foam::label Foam::UPstream::nRequests() +{ + return 0; +} + + +void Foam::UPstream::resetRequests(const label i) +{} + + +void Foam::UPstream::waitRequests(const label start) {} diff --git a/src/Pstream/mpi/UIPread.C b/src/Pstream/mpi/UIPread.C index dac3c35ccafa3bf0786ae535180b27059be773f6..24a2c4170e7b71f92497d935a8eeff3003aa5b53 100644 --- a/src/Pstream/mpi/UIPread.C +++ b/src/Pstream/mpi/UIPread.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -145,6 +145,14 @@ Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers) { // Message is already received into externalBuf messageSize_ = buffers.recvBuf_[fromProcNo].size(); + + if (debug) + { + Pout<< "UIPstream::UIPstream PstreamBuffers :" + << " fromProcNo:" << fromProcNo + << " tag:" << tag_ << " receive buffer size:" << messageSize_ + << Foam::endl; + } } else { diff --git a/src/Pstream/mpi/UPstream.C b/src/Pstream/mpi/UPstream.C index 2b8181fb5d46584bbf1e74afc2a0e3dc8f4dedd0..694587ece1144b68b83a7f54a4e6f95a91bd3c46 100644 --- a/src/Pstream/mpi/UPstream.C +++ b/src/Pstream/mpi/UPstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,7 @@ License #include "PstreamReduceOps.H" #include "OSspecific.H" #include "PstreamGlobals.H" +#include "SubList.H" #include <cstring> #include <cstdlib> @@ -172,7 +173,7 @@ void Foam::UPstream::abort() } -void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) +void Foam::reduce(scalar& Value, const sumOp<scalar>& bop, const int tag) { if (Pstream::debug) { @@ -205,7 +206,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(slave), - UPstream::msgType(), + tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -231,7 +232,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(UPstream::masterNo()), - UPstream::msgType(), + tag, MPI_COMM_WORLD ) ) @@ -262,7 +263,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(slave), - UPstream::msgType(), + tag, MPI_COMM_WORLD ) ) @@ -285,7 +286,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(UPstream::masterNo()), - UPstream::msgType(), + tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -337,7 +338,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(childProcId), - UPstream::msgType(), + tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -373,7 +374,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(parentId), - UPstream::msgType(), + tag, MPI_COMM_WORLD ) ) @@ -393,7 +394,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(parentId), - UPstream::msgType(), + tag, MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -429,7 +430,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) 1, MPI_SCALAR, UPstream::procID(childProcId), - UPstream::msgType(), + tag, MPI_COMM_WORLD ) ) @@ -456,23 +457,45 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) } -void Foam::UPstream::waitRequests() +Foam::label Foam::UPstream::nRequests() +{ + return PstreamGlobals::outstandingRequests_.size(); +} + + +void Foam::UPstream::resetRequests(const label i) +{ + if (i < PstreamGlobals::outstandingRequests_.size()) + { + PstreamGlobals::outstandingRequests_.setSize(i); + } +} + + +void Foam::UPstream::waitRequests(const label start) { if (debug) { Pout<< "UPstream::waitRequests : starting wait for " - << PstreamGlobals::outstandingRequests_.size() - << " outstanding requests." << endl; + << PstreamGlobals::outstandingRequests_.size()-start + << " outstanding requests starting at " << start << endl; } if (PstreamGlobals::outstandingRequests_.size()) { + SubList<MPI_Request> waitRequests + ( + PstreamGlobals::outstandingRequests_, + PstreamGlobals::outstandingRequests_.size() - start, + start + ); + if ( MPI_Waitall ( - PstreamGlobals::outstandingRequests_.size(), - PstreamGlobals::outstandingRequests_.begin(), + waitRequests.size(), + waitRequests.begin(), MPI_STATUSES_IGNORE ) ) @@ -483,7 +506,7 @@ void Foam::UPstream::waitRequests() ) << "MPI_Waitall returned with error" << Foam::endl; } - PstreamGlobals::outstandingRequests_.clear(); + resetRequests(start); } if (debug) diff --git a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C index 9351673f14d07baf2b0625a9c5c618c9ddef4c38..8feabb183909b37ba556e47ab03aa9a63c1d006f 100644 --- a/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C +++ b/src/dynamicFvMesh/solidBodyMotionFvMesh/solidBodyMotionFvMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,8 +87,11 @@ bool Foam::solidBodyMotionFvMesh::update() fvMesh::movePoints ( - transform(SBMFPtr_().transformation(), - undisplacedPoints_) + transform + ( + SBMFPtr_().transformation(), + undisplacedPoints_ + ) ); if (foundObject<volVectorField>("U")) diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C index 805e6ebcdd15f2de2ce9e153904b806efaa3a883..91cc0fb7c52f0ddac222a4ad2d1c1c2a1c4d60c9 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,7 +68,7 @@ void Foam::extendedCentredCellToFaceStencil::compact() } } - mapPtr_().compact(isInStencil); + mapPtr_().compact(isInStencil, Pstream::msgType()); } diff --git a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C index 46e20fc6bc51275dd0713212dd9c1f9d79e0a460..73685f891c79e3894f1088d76e8001abc86df875 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,7 +68,7 @@ void Foam::extendedCentredFaceToCellStencil::compact() } } - mapPtr_().compact(isInStencil); + mapPtr_().compact(isInStencil, Pstream::msgType()); } diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C index d7f1904df782eede7de568d74b1251cb076247b2..b20587ac82859eab877bb4b51cd85f2cce55e660 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -193,9 +193,7 @@ void Foam::fvMeshSubset::doCoupledPatches if (nUncoupled > 0) { Info<< "Uncoupled " << nUncoupled << " faces on coupled patches. " - << "(processorPolyPatch, cyclicPolyPatch)" << nl - << "You might need to run couplePatches to restore the patch face" - << " ordering." << nl << endl; + << "(processorPolyPatch, cyclicPolyPatch)" << endl; } } diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.C b/src/lagrangian/basic/InteractionLists/InteractionLists.C index 5b3d16f5d3b07e87708946dbb232468d5456db77..93587a5c269926891e2e18a1a473e9ecb5624b1d 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.C +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.C @@ -1208,10 +1208,11 @@ void Foam::InteractionLists<ParticleType>::sendReferredData template<class ParticleType> void Foam::InteractionLists<ParticleType>::receiveReferredData ( - PstreamBuffers& pBufs + PstreamBuffers& pBufs, + const label startOfRequests ) { - Pstream::waitRequests(); + Pstream::waitRequests(startOfRequests); referredParticles_.setSize(cellMap().constructSize()); diff --git a/src/lagrangian/basic/InteractionLists/InteractionLists.H b/src/lagrangian/basic/InteractionLists/InteractionLists.H index 0292b65c0ca08475a98f37e3eb06314fc64053f1..821e54b40bc84c5fac16796d9bc64c64af9f7b89 100644 --- a/src/lagrangian/basic/InteractionLists/InteractionLists.H +++ b/src/lagrangian/basic/InteractionLists/InteractionLists.H @@ -38,9 +38,10 @@ Description \verbatim PstreamBuffers pBufs(Pstream::nonBlocking); + label startOfRequests = Pstream::nRequests(); il_.sendReferredData(cellOccupancy_, pBufs); // Do other things - il_.receiveReferredData(pBufs); + il_.receiveReferredData(pBufs, startOfRequests); \endverbatim Requiring data: @@ -237,7 +238,11 @@ public: ); //- Receive referred data - void receiveReferredData(PstreamBuffers& pBufs); + void receiveReferredData + ( + PstreamBuffers& pBufs, + const label startReq = 0 + ); // Access diff --git a/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C b/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C index bbce1c49d293d35a7a13678f08fff29c7917a931..4801ac1a991ac4fa113f6fcaa8964b44c0bd9423 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C +++ b/src/lagrangian/dieselSpray/spraySubModels/atomizationModel/LISA/LISA.C @@ -109,10 +109,6 @@ void Foam::LISA::atomizeParcel scalar rhoFuel = fuels.rho(1.0e+5, p.T(), p.X()); scalar nuFuel = muFuel/rhoFuel; - vector uDir = p.U()/mag(p.U()); - - scalar uGas = mag(vel & uDir); - // Might be the relative velocity between Liquid and Gas, but using the // absolute velocity of the parcel as suggested by the authors // scalar U = mag(p.Urel(vel)); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C index fc78488bf845df4b2318aaeee3a339bbe5dbe9c5..4563c0243f867f413559bff2967435af5611e996 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,11 +59,13 @@ void Foam::PairCollision<CloudType>::parcelInteraction() { PstreamBuffers pBufs(Pstream::nonBlocking); + label startOfRequests = Pstream::nRequests(); + il_.sendReferredData(this->owner().cellOccupancy(), pBufs); realRealInteraction(); - il_.receiveReferredData(pBufs); + il_.receiveReferredData(pBufs, startOfRequests); realReferredInteraction(); } diff --git a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C index 289735c1703c75d1dd6fd046324f8f6c93779be0..fa69126644fdb6d0918669c0ae16ae21fa4c31ff 100644 --- a/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C +++ b/src/lagrangian/molecularDynamics/molecule/moleculeCloud/moleculeCloud.C @@ -130,6 +130,7 @@ void Foam::moleculeCloud::calculatePairForce() PstreamBuffers pBufs(Pstream::nonBlocking); // Start sending referred data + label startOfRequests = Pstream::nRequests(); il_.sendReferredData(cellOccupancy(), pBufs); molecule* molI = NULL; @@ -173,7 +174,7 @@ void Foam::moleculeCloud::calculatePairForce() } // Receive referred data - il_.receiveReferredData(pBufs); + il_.receiveReferredData(pBufs, startOfRequests); { // Real-Referred interactions @@ -361,10 +362,12 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps() PstreamBuffers pBufs(Pstream::nonBlocking); // Start sending referred data + label startOfRequests = Pstream::nRequests(); + il_.sendReferredData(cellOccupancy(), pBufs); // Receive referred data - il_.receiveReferredData(pBufs); + il_.receiveReferredData(pBufs, startOfRequests); // Real-Referred interaction @@ -451,10 +454,12 @@ void Foam::moleculeCloud::removeHighEnergyOverlaps() buildCellOccupancy(); // Start sending referred data + startOfRequests = Pstream::nRequests(); + il_.sendReferredData(cellOccupancy(), pBufs); // Receive referred data - il_.receiveReferredData(pBufs); + il_.receiveReferredData(pBufs, startOfRequests); label molsRemoved = initialSize - this->size(); diff --git a/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C b/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C index a705c370967266f3bd348db18b3fd10bc7cc8085..79f3713d3e218d0ba2781f212ef9112814985943 100644 --- a/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C +++ b/src/lagrangian/spray/submodels/BreakupModel/SHF/SHF.C @@ -154,9 +154,6 @@ bool Foam::SHF<CloudType>::update scalar reLiquid = 0.5*Urmag*d/mu; scalar ohnesorge = sqrt(weLiquid)/(reLiquid + VSMALL); - vector acceleration = Urel/tMom; - vector trajectory = U/mag(U); - scalar weGasCorr = weGas/(1.0 + weCorrCoeff_*ohnesorge); // droplet deformation characteristic time diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C index fb168c8813b5834bea7d8bf4c5f277d4101369a0..b462678e39fb5fba374c31e21448b43be4b3a135 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/linearAxialAngularSpring/linearAxialAngularSpring.C @@ -85,7 +85,6 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain vector refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 1, 0); vector oldDir = refQ_ & refDir; - vector newDir = motion.orientation() & refDir; if (mag(oldDir & axis_) > 0.95 || mag(newDir & axis_) > 0.95) @@ -93,10 +92,8 @@ Foam::sixDoFRigidBodyMotionRestraints::linearAxialAngularSpring::restrain // Directions getting close to the axis, change reference refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 0, 1); - - vector oldDir = refQ_ & refDir; - - vector newDir = motion.orientation() & refDir; + oldDir = refQ_ & refDir; + newDir = motion.orientation() & refDir; } // Removing any axis component from oldDir and newDir and normalising diff --git a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C index 50cdb1460b0935750e22003b1cd10f4a7ee759b1..b80b809cd7a30f33ce3231b52943139335f81f33 100644 --- a/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C +++ b/src/postProcessing/functionObjects/forces/pointPatchFields/derived/sixDoFRigidBodyMotion/sixDoFRigidBodyMotionRestraint/tabulatedAxialAngularSpring/tabulatedAxialAngularSpring.C @@ -95,10 +95,8 @@ Foam::sixDoFRigidBodyMotionRestraints::tabulatedAxialAngularSpring::restrain // Directions getting close to the axis, change reference refDir = rotationTensor(vector(1, 0 ,0), axis_) & vector(0, 0, 1); - - vector oldDir = refQ_ & refDir; - - vector newDir = motion.orientation() & refDir; + oldDir = refQ_ & refDir; + newDir = motion.orientation() & refDir; } // Removing any axis component from oldDir and newDir and normalising diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C index 6b95d77d03ab57d128de16b8f988056c57e0d2f7..7f4fd76c734cd27f20513464e36658dcd3a51e5d 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C @@ -457,7 +457,7 @@ scalar reactingOneDim::addMassSources(const label patchI, const label faceI) scalar reactingOneDim::solidRegionDiffNo() const { scalar DiNum = 0.0; - scalar meanDiNum = 0.0; + if (regionMesh().nInternalFaces() > 0) { surfaceScalarField KrhoCpbyDelta @@ -468,8 +468,6 @@ scalar reactingOneDim::solidRegionDiffNo() const ); DiNum = max(KrhoCpbyDelta.internalField())*time_.deltaTValue(); - - meanDiNum = average(KrhoCpbyDelta.internalField())*time().deltaTValue(); } return DiNum; diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C index 9c4228dbfbd9a30f13d456960b94720bfc89575b..a972476a96e7e78564744828121ee9353f00cfee 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C +++ b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.C @@ -955,13 +955,6 @@ Foam::triSurface Foam::isoSurfaceCell::stitchTriPoints for (label oldTriI = 0; oldTriI < nTris; oldTriI++) { - labelledTri oldTri - ( - rawPointI, - rawPointI+1, - rawPointI+2, - 0 - ); labelledTri tri ( triPointReverseMap[rawPointI], diff --git a/tutorials/incompressible/pimpleFoam/TJunction/system/controlDict b/tutorials/incompressible/pimpleFoam/TJunction/system/controlDict index 9fa32ec6fddb12284102a0d80829367bf9a066de..caf8b298c20481f35803486b8b86508cd3cf2d34 100644 --- a/tutorials/incompressible/pimpleFoam/TJunction/system/controlDict +++ b/tutorials/incompressible/pimpleFoam/TJunction/system/controlDict @@ -23,7 +23,7 @@ startTime 0; stopAt endTime; -endTime 1; +endTime 1.5; deltaT 0.001; diff --git a/tutorials/incompressible/pimpleFoam/TJunctionFan/system/controlDict b/tutorials/incompressible/pimpleFoam/TJunctionFan/system/controlDict index 63b26690081d708fb88fc371777da73e5f6f5a7e..6316dad569827cfeacc6a2d3949764c6b1e0df6a 100644 --- a/tutorials/incompressible/pimpleFoam/TJunctionFan/system/controlDict +++ b/tutorials/incompressible/pimpleFoam/TJunctionFan/system/controlDict @@ -23,7 +23,7 @@ startTime 0; stopAt endTime; -endTime 1; +endTime 1.5; deltaT 0.001;