From d95fc106b6837dea9ec9f2b0c2bc5c2b8892a6ab Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 21 Oct 2015 12:47:02 +0100 Subject: [PATCH 001/141] polyMesh: Ensure parallel consistency in findCell by ensuring tetBasePtIs is called on all processors, even for those with 0 cells. Also use unique communicator for globalMeshData to avoid data transfer interference. Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1792 --- .../polyMesh/globalMeshData/globalMeshData.C | 9 ++++++++- src/OpenFOAM/meshes/polyMesh/polyMesh.C | 16 ++++++++++------ 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index b36a0e9579..5cf963fff3 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -2748,7 +2748,12 @@ void Foam::globalMeshData::updateMesh() // *** Temporary hack to avoid problems with overlapping communication // *** between these reductions and the calculation of deltaCoeffs - label comm = UPstream::worldComm + 1; + label comm = UPstream::allocateCommunicator + ( + UPstream::worldComm, + identity(UPstream::nProcs()), + true + ); // Total number of faces. nTotalFaces_ = returnReduce @@ -2785,6 +2790,8 @@ void Foam::globalMeshData::updateMesh() comm ); + UPstream::freeCommunicator(comm); + if (debug) { Pout<< "globalMeshData : nTotalPoints_:" << nTotalPoints_ << endl; diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 4b8012b71d..67ae5db9b3 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -1478,12 +1478,11 @@ Foam::label Foam::polyMesh::findCell const cellDecomposition decompMode ) const { - if (nCells() == 0) - { - return -1; - } - - if (Pstream::parRun() && decompMode == FACE_DIAG_TRIS) + if + ( + Pstream::parRun() + && (decompMode == FACE_DIAG_TRIS || decompMode == CELL_TETS) + ) { // Force construction of face-diagonal decomposition before testing // for zero cells. @@ -1494,6 +1493,11 @@ Foam::label Foam::polyMesh::findCell (void)tetBasePtIs(); } + if (nCells() == 0) + { + return -1; + } + if (decompMode == CELL_TETS) { // Advanced search method utilizing an octree From 765b81853e58295d341cce51825e09f1bf1dc901 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Wed, 21 Oct 2015 16:49:57 +0100 Subject: [PATCH 002/141] renumberMesh: Now supports sets Resolves bug-report http://www.openfoam.org/mantisbt/view.php?id=1377 --- .../manipulation/renumberMesh/renumberMesh.C | 266 +++++++++++++----- .../renumberMesh/renumberMeshDict | 2 + 2 files changed, 195 insertions(+), 73 deletions(-) diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 6b3b632467..1c7748c1bf 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anispulation | + \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,11 +46,15 @@ Description #include "zeroGradientFvPatchFields.H" #include "CuthillMcKeeRenumber.H" #include "fvMeshSubset.H" +#include "cellSet.H" +#include "faceSet.H" +#include "pointSet.H" #ifdef FOAM_USE_ZOLTAN #include "zoltanRenumber.H" #endif + using namespace Foam; @@ -163,7 +167,7 @@ void getBand labelList getFaceOrder ( const primitiveMesh& mesh, - const labelList& cellOrder // new to old cell + const labelList& cellOrder // New to old cell ) { labelList reverseCellOrder(invert(cellOrder.size(), cellOrder)); @@ -244,8 +248,7 @@ labelList getFaceOrder ( "getFaceOrder" "(const primitiveMesh&, const labelList&, const labelList&)" - ) << "Did not determine new position" - << " for face " << faceI + ) << "Did not determine new position" << " for face " << faceI << abort(FatalError); } } @@ -259,12 +262,10 @@ labelList getFaceOrder labelList getRegionFaceOrder ( const primitiveMesh& mesh, - const labelList& cellOrder, // new to old cell - const labelList& cellToRegion // old cell to region + const labelList& cellOrder, // New to old cell + const labelList& cellToRegion // Old cell to region ) { - //Pout<< "Determining face order:" << endl; - labelList reverseCellOrder(invert(cellOrder.size(), cellOrder)); labelList oldToNewFace(mesh.nFaces(), -1); @@ -280,8 +281,6 @@ labelList getRegionFaceOrder if (cellToRegion[oldCellI] != prevRegion) { prevRegion = cellToRegion[oldCellI]; - //Pout<< " region " << prevRegion << " internal faces start at " - // << newFaceI << endl; } const cell& cFaces = mesh.cells()[oldCellI]; @@ -368,9 +367,6 @@ labelList getRegionFaceOrder if (prevKey != key) { - //Pout<< " faces inbetween region " << key/nRegions - // << " and " << key%nRegions - // << " start at " << newFaceI << endl; prevKey = key; } @@ -399,7 +395,6 @@ labelList getRegionFaceOrder << abort(FatalError); } } - //Pout<< endl; return invert(mesh.nFaces(), oldToNewFace); } @@ -407,7 +402,7 @@ labelList getRegionFaceOrder // cellOrder: old cell for every new cell // faceOrder: old face for every new face. Ordering of boundary faces not -// changed. +// changed. autoPtr reorderMesh ( polyMesh& mesh, @@ -528,7 +523,7 @@ autoPtr reorderMesh ( new mapPolyMesh ( - mesh, //const polyMesh& mesh, + mesh, // const polyMesh& mesh, mesh.nPoints(), // nOldPoints, mesh.nFaces(), // nOldFaces, mesh.nCells(), // nOldCells, @@ -634,17 +629,20 @@ int main(int argc, char *argv[]) "calculate the rms of the frontwidth" ); - // Force linker to include zoltan symbols. This section is only needed since - // Zoltan is a static library - #ifdef FOAM_USE_ZOLTAN - Info<< "renumberMesh built with zoltan support." << nl << endl; - (void)zoltanRenumber::typeName; - #endif #include "setRootCase.H" #include "createTime.H" runTime.functionObjects().off(); + + // Force linker to include zoltan symbols. This section is only needed since + // Zoltan is a static library + #ifdef FOAM_USE_ZOLTAN + Info<< "renumberMesh built with zoltan support." << nl << endl; + (void)zoltanRenumber::typeName; + #endif + + // Get times list instantList Times = runTime.times(); @@ -682,24 +680,26 @@ int main(int argc, char *argv[]) ( sumSqrIntersect, sumOp() - ) - /mesh.globalData().nTotalCells() + )/mesh.globalData().nTotalCells() ); Info<< "Mesh size: " << mesh.globalData().nTotalCells() << nl << "Before renumbering :" << nl << " band : " << band << nl << " profile : " << profile << nl; + if (doFrontWidth) { Info<< " rms frontwidth : " << rmsFrontwidth << nl; } + Info<< endl; bool sortCoupledFaceCells = false; bool writeMaps = false; bool orderPoints = false; label blockSize = 0; + bool renumberSets = true; // Construct renumberMethod autoPtr renumberDictPtr; @@ -717,7 +717,6 @@ int main(int argc, char *argv[]) renumberPtr = renumberMethod::New(renumberDict); - sortCoupledFaceCells = renumberDict.lookupOrDefault ( "sortCoupledFaceCells", @@ -760,6 +759,8 @@ int main(int argc, char *argv[]) Info<< "Writing renumber maps (new to old) to polyMesh." << nl << endl; } + + renumberSets = renumberDict.lookupOrDefault("renumberSets", true); } else { @@ -827,6 +828,7 @@ int main(int argc, char *argv[]) // Read objects in time directory IOobjectList objects(mesh, runTime.timeName()); + // Read vol fields. PtrList vsFlds; @@ -844,6 +846,7 @@ int main(int argc, char *argv[]) PtrList vtFlds; ReadFields(mesh, objects, vtFlds); + // Read surface fields. PtrList ssFlds; @@ -861,6 +864,25 @@ int main(int argc, char *argv[]) PtrList stFlds; ReadFields(mesh, objects, stFlds); + + // Read point fields. + + PtrList psFlds; + ReadFields(pointMesh::New(mesh), objects, psFlds); + + PtrList pvFlds; + ReadFields(pointMesh::New(mesh), objects, pvFlds); + + PtrList pstFlds; + ReadFields(pointMesh::New(mesh), objects, pstFlds); + + PtrList psymtFlds; + ReadFields(pointMesh::New(mesh), objects, psymtFlds); + + PtrList ptFlds; + ReadFields(pointMesh::New(mesh), objects, ptFlds); + + Info<< endl; // From renumbering: @@ -873,7 +895,7 @@ int main(int argc, char *argv[]) // Renumbering in two phases. Should be done in one so mapping of // fields is done correctly! - label nBlocks = mesh.nCells() / blockSize; + label nBlocks = mesh.nCells()/blockSize; Info<< "nBlocks = " << nBlocks << endl; // Read decompositionMethod dictionary @@ -1011,7 +1033,7 @@ int main(int argc, char *argv[]) faceOrder = getFaceOrder ( mesh, - cellOrder // new to old cell + cellOrder // New to old cell ); } @@ -1032,17 +1054,19 @@ int main(int argc, char *argv[]) autoPtr pointOrderMap = meshMod.changeMesh ( mesh, - false, //inflate - true, //syncParallel - false, //orderCells - orderPoints //orderPoints + false, // inflate + true, // syncParallel + false, // orderCells + orderPoints // orderPoints ); + // Combine point reordering into map. const_cast(map().pointMap()) = UIndirectList