From 5d4030b7f2b5b2e165d193c498c73dd8d65417fb Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 21 Dec 2011 10:34:42 +0000 Subject: [PATCH 01/18] BUG: renumberMesh.C: reading bool from dictionary --- .../utilities/mesh/manipulation/renumberMesh/renumberMesh.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 7e090fa30e..924096a22f 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -562,7 +562,7 @@ int main(int argc, char *argv[]) << endl; } - writeMaps = readLabel(renumberDict.lookup("writeMaps")); + renumberDict.lookup("writeMaps") >> writeMaps; if (writeMaps) { Info<< "Writing renumber maps (new to old) to polyMesh." << nl From 744162e74e1e74e890e66b2686f61f1648348ae2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 21 Dec 2011 10:35:34 +0000 Subject: [PATCH 02/18] STYLE: tetIndices.H: improved comment --- .../meshes/polyMesh/polyMeshTetDecomposition/tetIndices.H | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/tetIndices.H b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/tetIndices.H index afd31e642a..76f82fa78c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/tetIndices.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/tetIndices.H @@ -144,11 +144,13 @@ public: inline tetPointRef oldTet(const polyMesh& mesh) const; //- Return the geometry corresponding to the tri on the - // mesh face for this tet from the supplied mesh + // mesh face for this tet from the supplied mesh. Normal of + // the tri points out of the cell. inline triPointRef faceTri(const polyMesh& mesh) const; //- Return the point indices corresponding to the tri on the mesh - // face for this tet from the supplied mesh + // face for this tet from the supplied mesh. Normal of + // the tri points out of the cell. inline triFace faceTriIs(const polyMesh& mesh) const; //- Return the geometry corresponding to the tri on the From 0504c7a4f6a79e4a4cc510fab8062eb5aa32facd Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 21 Dec 2011 11:22:02 +0000 Subject: [PATCH 03/18] STYLE: system/streamLines: documented new tracking option --- .../simpleFoam/motorBike/system/streamLines | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/streamLines b/tutorials/incompressible/simpleFoam/motorBike/system/streamLines index 8b82eccbb1..50b9eefdd1 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/streamLines +++ b/tutorials/incompressible/simpleFoam/motorBike/system/streamLines @@ -28,8 +28,15 @@ streamLines // Steps particles can travel before being removed lifeTime 10000; - // Number of steps per cell (estimate). Set to 1 to disable subcycling. - nSubCycle 5; + //- Specify either absolute length of steps (trackLength) or a number + // of subcycling steps per cell (nSubCycle) + + // Size of single track segment [m] + //trackLength 1e-3; + + // Number of steps per cell (estimate). Set to 1 to disable subcycling. + nSubCycle 5; + // Cloud name to use cloudName particleTracks; From 704b33fa79397870c6ba22733e3cce7745b42122 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 21 Dec 2011 15:13:04 +0000 Subject: [PATCH 04/18] ENH: renumberMesh: get block ordering working - added boundaryFirst renumbering method - renumbering in parallel - make api methods const --- .../manipulation/renumberMesh/Make/options | 2 +- .../manipulation/renumberMesh/renumberMesh.C | 125 +++++++---- .../renumberMesh/renumberMeshDict | 35 ++- .../CuthillMcKeeRenumber.C | 14 +- .../CuthillMcKeeRenumber.H | 6 +- src/renumberMethods/Make/files | 1 + .../boundaryFirstRenumber.C | 201 ++++++++++++++++++ .../boundaryFirstRenumber.H | 129 +++++++++++ .../manualRenumber/manualRenumber.C | 2 +- .../manualRenumber/manualRenumber.H | 6 +- .../randomRenumber/randomRenumber.C | 6 +- .../randomRenumber/randomRenumber.H | 6 +- .../renumberMethod/renumberMethod.C | 4 +- .../renumberMethod/renumberMethod.H | 8 +- .../springRenumber/springRenumber.C | 4 +- .../springRenumber/springRenumber.H | 6 +- 16 files changed, 473 insertions(+), 82 deletions(-) create mode 100644 src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C create mode 100644 src/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H diff --git a/applications/utilities/mesh/manipulation/renumberMesh/Make/options b/applications/utilities/mesh/manipulation/renumberMesh/Make/options index 2981cf30be..dc78db3436 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/Make/options +++ b/applications/utilities/mesh/manipulation/renumberMesh/Make/options @@ -11,4 +11,4 @@ EXE_LIBS = \ -lfiniteVolume \ -lgenericPatchFields \ -lrenumberMethods \ - -ldecompositionMethods + -ldecompositionMethods -L$(FOAM_LIBBIN)/dummy -lmetisDecomp -lscotchDecomp diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 924096a22f..02e5a06567 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -29,7 +29,7 @@ Description renumbering all fields from all the time directories. By default uses bandCompression (CuthillMcKee) but will - read system/renumberMeshDict if present and use the method from there. + read system/renumberMeshDict if -dict option is present \*---------------------------------------------------------------------------*/ @@ -45,6 +45,7 @@ Description #include "renumberMethod.H" #include "zeroGradientFvPatchFields.H" #include "CuthillMcKeeRenumber.H" +#include "fvMeshSubset.H" using namespace Foam; @@ -455,6 +456,69 @@ autoPtr reorderMesh } +// Return new to old cell numbering +labelList regionRenumber +( + const renumberMethod& method, + const fvMesh& mesh, + const labelList& cellToRegion +) +{ + Info<< "Determining cell order:" << endl; + + labelList cellOrder(cellToRegion.size()); + + label nRegions = max(cellToRegion)+1; + + labelListList regionToCells(invertOneToMany(nRegions, cellToRegion)); + + label cellI = 0; + + forAll(regionToCells, regionI) + { + Info<< " region " << regionI << " starts at " << cellI << endl; + + // Make sure no parallel comms + bool oldParRun = UPstream::parRun(); + UPstream::parRun() = false; + + // Per region do a reordering. + fvMeshSubset subsetter(mesh); + subsetter.setLargeCellSubset(cellToRegion, regionI); + + const fvMesh& subMesh = subsetter.subMesh(); + + labelList subReverseCellOrder = method.renumber + ( + subMesh, + subMesh.cellCentres() + ); + + labelList subCellOrder + ( + invert + ( + subMesh.nCells(), + subReverseCellOrder + ) + ); + + // Restore state + UPstream::parRun() = oldParRun; + + const labelList& cellMap = subsetter.cellMap(); + + forAll(subCellOrder, i) + { + cellOrder[cellI++] = cellMap[subCellOrder[i]]; + } + } + Info<< endl; + + return cellOrder; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) @@ -505,23 +569,28 @@ int main(int argc, char *argv[]) label blockSize = 0; // Construct renumberMethod + autoPtr renumberDictPtr; autoPtr renumberPtr; if (readDict) { Info<< "Renumber according to renumberMeshDict." << nl << endl; - IOdictionary renumberDict + renumberDictPtr.reset ( - IOobject + new IOdictionary ( - "renumberMeshDict", - runTime.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE + IOobject + ( + "renumberMeshDict", + runTime.system(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) ) ); + const IOdictionary renumberDict = renumberDictPtr(); renumberPtr = renumberMethod::New(renumberDict); @@ -683,22 +752,15 @@ int main(int argc, char *argv[]) // fields is done correctly! label nBlocks = mesh.nCells() / blockSize; - Info<< "nBlocks = " << nBlocks << endl; + Info<< "nBlocks = " << nBlocks << endl; - // Read decomposePar dictionary - IOdictionary decomposeDict - ( - IOobject - ( - "decomposeParDict", - runTime.system(), - mesh, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE - ) - ); + // Read decompositionMethod dictionary + dictionary decomposeDict(renumberDictPtr().subDict("blockCoeffs")); decomposeDict.set("numberOfSubdomains", nBlocks); + bool oldParRun = UPstream::parRun(); + UPstream::parRun() = false; + autoPtr decomposePtr = decompositionMethod::New ( decomposeDict @@ -713,6 +775,9 @@ int main(int argc, char *argv[]) ) ); + // Restore state + UPstream::parRun() = oldParRun; + // For debugging: write out region createScalarField ( @@ -726,23 +791,7 @@ int main(int argc, char *argv[]) << nl << endl; - // Find point per region - pointField regionPoints(nBlocks, vector::zero); - forAll(cellToRegion, cellI) - { - regionPoints[cellToRegion[cellI]] = mesh.cellCentres()[cellI]; - } - - // Use block based renumbering. - // Detemines old to new cell ordering - labelList reverseCellOrder = renumberPtr().renumber - ( - mesh, - cellToRegion, - regionPoints - ); - - cellOrder = invert(mesh.nCells(), reverseCellOrder); + cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion); // Determine new to old face order with new cell numbering faceOrder = getRegionFaceOrder diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict b/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict index a852fad7db..988379720b 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict @@ -22,10 +22,14 @@ writeMaps true; // e.g. nonBlockingGaussSeidel. sortCoupledFaceCells false; -// Optional entry: renumber on a block-by-block basis. This can be used on -// large cases to keep the blocks fitting in cache with all the the cache -// missed bunched at the end. -//blockSize 0; +// Optional entry: renumber on a block-by-block basis. It uses a +// blockCoeffs dictionary to construct a decompositionMethod to do +// a block subdivision) and then applies the renumberMethod to each +// block in turn. This can be used in large cases to keep the blocks +// fitting in cache with all the the cache misses bunched at the end. +// This number is the approximate size of the blocks - this gets converted +// to a number of blocks that is the input to the decomposition method. +//blockSize 1000; // Optional entry: sort points into internal and boundary points //orderPoints false; @@ -37,11 +41,11 @@ method CuthillMcKee; //method random; //method spring; -CuthillMcKeeCoeffs -{ - // Reverse CuthillMcKee (RCM) or plain - reverse true; -} +//CuthillMcKeeCoeffs +//{ +// // Reverse CuthillMcKee (RCM) or plain +// reverse true; +//} manualCoeffs @@ -65,4 +69,17 @@ springCoeffs } +blockCoeffs +{ + method scotch; + //method hierarchical; + //hierarchicalCoeffs + //{ + // n (1 2 1); + // delta 0.001; + // order xyz; + //} +} + + // ************************************************************************* // diff --git a/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C b/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C index e1ec010335..2732484b36 100644 --- a/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C +++ b/src/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C @@ -63,7 +63,7 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber ( const polyMesh& mesh, const pointField& points -) +) const { CompactListList