diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 02e5a06567d8fcea74a6b1464d3b0e9095bf5419..487fde704a57b0d1d597ebcbd99ac40ac7598743 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anispulation | ------------------------------------------------------------------------------- License @@ -105,6 +105,44 @@ label getBand(const labelList& owner, const labelList& neighbour) } +// Calculate band of matrix +void getBand +( + const label nCells, + const labelList& owner, + const labelList& neighbour, + label& bandwidth, + scalar& profile, // scalar to avoid overflow + scalar& sumSqrIntersect // scalar to avoid overflow +) +{ + labelList cellBandwidth(nCells, 0); + scalarField nIntersect(nCells, 0.0); + + forAll(neighbour, faceI) + { + label own = owner[faceI]; + label nei = neighbour[faceI]; + + // Note: mag not necessary for correct (upper-triangular) ordering. + label diff = nei-own; + cellBandwidth[nei] = max(cellBandwidth[nei], diff); + } + + forAll(nIntersect, cellI) + { + for (label rowI = cellI-cellBandwidth[cellI]; rowI < cellI; rowI++) + { + nIntersect[rowI]++; + } + } + + bandwidth = max(cellBandwidth); + profile = sum(cellBandwidth); + sumSqrIntersect = sum(Foam::sqr(nIntersect)); +} + + // Determine upper-triangular face order labelList getFaceOrder ( @@ -488,21 +526,12 @@ labelList regionRenumber const fvMesh& subMesh = subsetter.subMesh(); - labelList subReverseCellOrder = method.renumber + labelList subCellOrder = method.renumber ( subMesh, subMesh.cellCentres() ); - labelList subCellOrder - ( - invert - ( - subMesh.nCells(), - subReverseCellOrder - ) - ); - // Restore state UPstream::parRun() = oldParRun; @@ -556,13 +585,46 @@ int main(int argc, char *argv[]) const bool overwrite = args.optionFound("overwrite"); - label band = getBand(mesh.faceOwner(), mesh.faceNeighbour()); + label band; + scalar profile; + scalar sumSqrIntersect; + getBand + ( + mesh.nCells(), + mesh.faceOwner(), + mesh.faceNeighbour(), + band, + profile, + sumSqrIntersect + ); - Info<< "Mesh size: " << returnReduce(mesh.nCells(), sumOp<label>()) << nl - << "Band before renumbering: " - << returnReduce(band, maxOp<label>()) << nl << endl; + if (band != getBand(mesh.faceOwner(), mesh.faceNeighbour())) + { + FatalErrorIn(args.executable()) + << "band:" << band + << abort(FatalError); + } + reduce(band, maxOp<label>()); + reduce(profile, sumOp<scalar>()); + scalar rmsFrontwidth = Foam::sqrt + ( + returnReduce + ( + sumSqrIntersect, + sumOp<scalar>() + ) + / mesh.globalData().nTotalCells() + ); + + Info<< "Mesh size: " << mesh.globalData().nTotalCells() << nl + << "Before renumbering :" << nl + << " band : " << band << nl + << " profile : " << profile << nl + << " rms frontwidth : " << rmsFrontwidth << nl + << endl; + bool sortCoupledFaceCells = false; bool writeMaps = false; bool orderPoints = false; @@ -803,14 +865,13 @@ int main(int argc, char *argv[]) } else { - // Detemines old to new cell ordering - labelList reverseCellOrder = renumberPtr().renumber + // Detemines sorted back to original cell ordering + cellOrder = renumberPtr().renumber ( mesh, mesh.cellCentres() ); - - cellOrder = invert(mesh.nCells(), reverseCellOrder); + labelList reverseCellOrder = invert(mesh.nCells(), cellOrder); if (sortCoupledFaceCells) @@ -969,11 +1030,36 @@ int main(int argc, char *argv[]) } - band = getBand(mesh.faceOwner(), mesh.faceNeighbour()); - - Info<< "Band after renumbering: " - << returnReduce(band, maxOp<label>()) << nl << endl; - + { + label band; + scalar profile; + scalar sumSqrIntersect; + getBand + ( + mesh.nCells(), + mesh.faceOwner(), + mesh.faceNeighbour(), + band, + profile, + sumSqrIntersect + ); + reduce(band, maxOp<label>()); + reduce(profile, sumOp<scalar>()); + scalar rmsFrontwidth = Foam::sqrt + ( + returnReduce + ( + sumSqrIntersect, + sumOp<scalar>() + ) + / mesh.globalData().nTotalCells() + ); + Info<< "After renumbering :" << nl + << " band : " << band << nl + << " profile : " << profile << nl + << " rms frontwidth : " << rmsFrontwidth << nl + << endl; + } if (orderPoints) { diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict b/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict index 988379720bc1b6af0f94f2e1ad5a06612f882dcb..bc7084616d93d33eae69ae22460f72e5eba4b109 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMeshDict @@ -50,7 +50,7 @@ method CuthillMcKee; manualCoeffs { - // In system directory: old to new labelIOList + // In system directory: new-to-original (i.e. order) labelIOList dataFile "cellMap"; } diff --git a/src/OpenFOAM/meshes/bandCompression/bandCompression.C b/src/OpenFOAM/meshes/bandCompression/bandCompression.C index cec9dc9c6c717f30db9d84c8dd5366302411b6a8..ad589fc1d71a5c186f589772a8bef669a9c870e9 100644 --- a/src/OpenFOAM/meshes/bandCompression/bandCompression.C +++ b/src/OpenFOAM/meshes/bandCompression/bandCompression.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,6 +32,10 @@ Description #include "bandCompression.H" #include "SLList.H" +#include "IOstreams.H" +#include "DynamicList.H" +#include "ListOps.H" +#include "PackedBoolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,58 +47,97 @@ Foam::labelList Foam::bandCompression(const labelListList& cellCellAddressing) // the business bit of the renumbering SLList<label> nextCell; - labelList visited(cellCellAddressing.size()); + PackedBoolList visited(cellCellAddressing.size()); - label currentCell; label cellInOrder = 0; - // reset the visited cells list - forAll(visited, cellI) - { - visited[cellI] = 0; - } - // loop over the cells - forAll(visited, cellI) + // Work arrays. Kept outside of loop to minimise allocations. + // - neighbour cells + DynamicList<label> nbrs; + // - corresponding weights + DynamicList<label> weights; + + // - ordering + labelList order; + + + while (true) { - // find the first cell that has not been visited yet - if (visited[cellI] == 0) + // For a disconnected region find the lowest connected cell. + + label currentCell = -1; + label minWeight = labelMax; + + forAll(visited, cellI) + { + // find the lowest connected cell that has not been visited yet + if (!visited[cellI]) + { + if (cellCellAddressing[cellI].size() < minWeight) + { + minWeight = cellCellAddressing[cellI].size(); + currentCell = cellI; + } + } + } + + + if (currentCell == -1) { - currentCell = cellI; + break; + } + - // use this cell as a start - nextCell.append(currentCell); + // Starting from currentCell walk breadth-first - // loop through the nextCell list. Add the first cell into the - // cell order if it has not already been visited and ask for its - // neighbours. If the neighbour in question has not been visited, - // add it to the end of the nextCell list - while (nextCell.size()) + // use this cell as a start + nextCell.append(currentCell); + + // loop through the nextCell list. Add the first cell into the + // cell order if it has not already been visited and ask for its + // neighbours. If the neighbour in question has not been visited, + // add it to the end of the nextCell list + + while (nextCell.size()) + { + currentCell = nextCell.removeHead(); + + if (!visited[currentCell]) { - currentCell = nextCell.removeHead(); + visited[currentCell] = 1; - if (visited[currentCell] == 0) - { - visited[currentCell] = 1; + // add into cellOrder + newOrder[cellInOrder] = currentCell; + cellInOrder++; + + // find if the neighbours have been visited + const labelList& neighbours = cellCellAddressing[currentCell]; - // add into cellOrder - newOrder[cellInOrder] = currentCell; - cellInOrder++; + // Add in increasing order of connectivity - // find if the neighbours have been visited - const labelList& neighbours = - cellCellAddressing[currentCell]; + // 1. Count neighbours of unvisited neighbours + nbrs.clear(); + weights.clear(); - forAll(neighbours, nI) + forAll(neighbours, nI) + { + label nbr = neighbours[nI]; + if (!visited[nbr]) { - if (visited[neighbours[nI]] == 0) - { - // not visited, add to the list - nextCell.append(neighbours[nI]); - } + // not visited, add to the list + nbrs.append(nbr); + weights.append(cellCellAddressing[nbr].size()); } } + // 2. Sort + sortedOrder(weights, order); + // 3. Add in sorted order + forAll(order, i) + { + nextCell.append(nbrs[i]); + } } } } diff --git a/src/OpenFOAM/meshes/bandCompression/bandCompression.H b/src/OpenFOAM/meshes/bandCompression/bandCompression.H index 8cbad9fbded857b79d60fa7927a5e44ca9466a4a..f1506e5dbcdd2a07ef9967722fa952d5657290c9 100644 --- a/src/OpenFOAM/meshes/bandCompression/bandCompression.H +++ b/src/OpenFOAM/meshes/bandCompression/bandCompression.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,7 +27,8 @@ InNamespace Description The bandCompression function renumbers the addressing such that the band of the matrix is reduced. The algorithm uses a simple search - through the neighbour list + through the neighbour list in order of connectivity. + (CutHill-McKee algorithm) SourceFiles bandCompression.C diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 58a897666b51489b796780d25628ebcaefa395f9..9000380aa10ab4a13b8f71ec44744b49ac6f3921 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -604,52 +604,96 @@ Foam::label Foam::polyTopoChange::getCellOrder label cellInOrder = 0; - // loop over the cells - forAll(visited, cellI) + // Work arrays. Kept outside of loop to minimise allocations. + // - neighbour cells + DynamicList<label> nbrs; + // - corresponding weights + DynamicList<label> weights; + + // - ordering + labelList order; + + + while (true) { - // find the first non-removed cell that has not been visited yet - if (!cellRemoved(cellI) && visited[cellI] == 0) + // For a disconnected region find the lowest connected cell. + + label currentCell = -1; + label minWeight = labelMax; + + forAll(visited, cellI) { - // use this cell as a start - nextCell.append(cellI); + // find the lowest connected cell that has not been visited yet + if (!cellRemoved(cellI) && !visited[cellI]) + { + if (cellCellAddressing[cellI].size() < minWeight) + { + minWeight = cellCellAddressing[cellI].size(); + currentCell = cellI; + } + } + } + + + if (currentCell == -1) + { + break; + } - // loop through the nextCell list. Add the first cell into the - // cell order if it has not already been visited and ask for its - // neighbours. If the neighbour in question has not been visited, - // add it to the end of the nextCell list - do + // Starting from currentCell walk breadth-first + + + // use this cell as a start + nextCell.append(currentCell); + + // loop through the nextCell list. Add the first cell into the + // cell order if it has not already been visited and ask for its + // neighbours. If the neighbour in question has not been visited, + // add it to the end of the nextCell list + + while (nextCell.size()) + { + currentCell = nextCell.removeHead(); + + if (!visited[currentCell]) { - label currentCell = nextCell.removeHead(); + visited[currentCell] = 1; - if (visited[currentCell] == 0) - { - visited[currentCell] = 1; + // add into cellOrder + newOrder[cellInOrder] = currentCell; + cellInOrder++; - // add into cellOrder - newOrder[cellInOrder] = currentCell; - cellInOrder++; + // find if the neighbours have been visited + const labelList& neighbours = cellCellAddressing[currentCell]; - // find if the neighbours have been visited - const UList<label> cCells = cellCellAddressing[currentCell]; + // Add in increasing order of connectivity - forAll(cCells, i) - { - label nbr = cCells[i]; + // 1. Count neighbours of unvisited neighbours + nbrs.clear(); + weights.clear(); - if (!cellRemoved(nbr) && visited[nbr] == 0) - { - // not visited, add to the list - nextCell.append(nbr); - } + forAll(neighbours, nI) + { + label nbr = neighbours[nI]; + if (!cellRemoved(nbr) && !visited[nbr]) + { + // not visited, add to the list + nbrs.append(nbr); + weights.append(cellCellAddressing[nbr].size()); } } + // 2. Sort + sortedOrder(weights, order); + // 3. Add in sorted order + forAll(order, i) + { + nextCell.append(nbrs[i]); + } } - while (nextCell.size()); } } - // Now we have new-to-old in newOrder. newOrder.setSize(cellInOrder); diff --git a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C index e0e96412d3fb4f1f78cd5930fb34b53653549779..573b6e520664374f7ba3765849e5890ad805c521 100644 --- a/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/parallel/decompose/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -275,7 +275,7 @@ void Foam::decompositionMethod::calcCellCells { const polyPatch& pp = patches[patchI]; - if (pp.coupled()) + if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp))) { label faceI = pp.start(); label bFaceI = pp.start()-mesh.nInternalFaces(); diff --git a/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C b/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C index 2732484b36ddcdd7f3c474e21df4e97024be1b88..a756b2c5147dbddc4d6bc276979cc58862939228 100644 --- a/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C +++ b/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -82,7 +82,7 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber reverse(orderedToOld); } - return invert(orderedToOld.size(), orderedToOld); + return orderedToOld; } @@ -99,7 +99,7 @@ Foam::labelList Foam::CuthillMcKeeRenumber::renumber reverse(orderedToOld); } - return invert(orderedToOld.size(), orderedToOld); + return orderedToOld; } diff --git a/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H b/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H index a4ec011b4074f07246d30fe7fdbb9d685cbb0e73..237b828e25521eba3dc95cb9d64280009d8333f7 100644 --- a/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H +++ b/src/renumber/renumberMethods/CuthillMcKeeRenumber/CuthillMcKeeRenumber.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,23 +80,26 @@ public: // Member Functions - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // This is only defined for geometric renumberMethods. virtual labelList renumber(const pointField&) const { notImplemented("CuthillMcKeeRenumber::renumber(const pointField&)"); return labelList(0); } - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Use the mesh connectivity (if needed) virtual labelList renumber ( const polyMesh& mesh, const pointField& cc ) const; - //- Return for every cell the new cell label. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. // The connectivity is equal to mesh.cellCells() except // - the connections are across coupled patches virtual labelList renumber diff --git a/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C b/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C index 293e5ba19b940628ee67aec82087de852ae116fa..a26ca1e207a9513fe3eeecee274e3637b044965a 100644 --- a/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C +++ b/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -194,7 +194,7 @@ Foam::labelList Foam::boundaryFirstRenumber::renumber // << endl; //} - return invert(newOrder.size(), newOrder); + return newOrder; } diff --git a/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H b/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H index 690af21455a6689ce47cda252cb9d9857c66c82f..1b5ac139e222ad95d1dbd5cb5efd070c609cdda5 100644 --- a/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H +++ b/src/renumber/renumberMethods/boundaryFirstRenumber/boundaryFirstRenumber.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,8 +80,9 @@ public: // Member Functions - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // This is only defined for geometric renumberMethods. virtual labelList renumber(const pointField&) const { notImplemented @@ -91,15 +92,17 @@ public: return labelList(0); } - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Use the mesh connectivity (if needed) virtual labelList renumber ( const polyMesh& mesh, const pointField& cc ) const; - //- Return for every cell the new cell label. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. // The connectivity is equal to mesh.cellCells() except // - the connections are across coupled patches virtual labelList renumber diff --git a/src/renumber/renumberMethods/manualRenumber/manualRenumber.C b/src/renumber/renumberMethods/manualRenumber/manualRenumber.C index 92b5c8e00cb5782e09d62eb10a25100ef82a9dac..99ac60b666d938183a5de6929e4aa7e93d0b5595 100644 --- a/src/renumber/renumberMethods/manualRenumber/manualRenumber.C +++ b/src/renumber/renumberMethods/manualRenumber/manualRenumber.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -63,7 +63,7 @@ Foam::labelList Foam::manualRenumber::renumber const pointField& points ) const { - labelIOList oldToNew + labelIOList newToOld ( IOobject ( @@ -78,14 +78,14 @@ Foam::labelList Foam::manualRenumber::renumber // check if the final renumbering is OK - if (oldToNew.size() != points.size()) + if (newToOld.size() != points.size()) { FatalErrorIn ( "manualRenumber::renumber(const pointField&, const scalarField&)" ) << "Size of renumber list does not correspond " << "to the number of points. Size: " - << oldToNew.size() << " Number of points: " + << newToOld.size() << " Number of points: " << points.size() << ".\n" << "Manual renumbering data read from file " << dataFile_ << "." << endl @@ -93,27 +93,27 @@ Foam::labelList Foam::manualRenumber::renumber } // Invert to see if one to one - labelList newToOld(points.size(), -1); - forAll(oldToNew, i) + labelList oldToNew(points.size(), -1); + forAll(newToOld, i) { - label newI = oldToNew[i]; + label origCellI = newToOld[i]; - if (newI < 0 || newI >= oldToNew.size()) + if (origCellI < 0 || origCellI >= points.size()) { FatalErrorIn ( "manualRenumber::renumber(const pointField&" ", const scalarField&)" ) << "Renumbering is not one-to-one. Index " - << i << " maps onto " << newI + << i << " maps onto original cell " << origCellI << ".\n" << "Manual renumbering data read from file " << dataFile_ << "." << endl << exit(FatalError); } - if (newToOld[newI] == -1) + if (oldToNew[origCellI] == -1) { - newToOld[newI] = i; + oldToNew[origCellI] = i; } else { @@ -122,15 +122,15 @@ Foam::labelList Foam::manualRenumber::renumber "manualRenumber::renumber(const pointField&" ", const scalarField&)" ) << "Renumbering is not one-to-one. Both index " - << newToOld[newI] - << " and " << i << " map onto " << newI + << oldToNew[origCellI] + << " and " << i << " map onto " << origCellI << ".\n" << "Manual renumbering data read from file " << dataFile_ << "." << endl << exit(FatalError); } } - return oldToNew; + return newToOld; } diff --git a/src/renumber/renumberMethods/manualRenumber/manualRenumber.H b/src/renumber/renumberMethods/manualRenumber/manualRenumber.H index a4d4b2f46f28fa74d94c9b3b33f5b1e27910d023..74197543691a0b1acef8af2944c1b22e0d3f6b8e 100644 --- a/src/renumber/renumberMethods/manualRenumber/manualRenumber.H +++ b/src/renumber/renumberMethods/manualRenumber/manualRenumber.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ Class Foam::manualRenumber Description - Renumber given a cell-to-new cell association in a file + Renumber given a ordered-to-original cell association in a file SourceFiles manualRenumber.C @@ -79,23 +79,26 @@ public: // Member Functions - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // This is only defined for geometric renumberMethods. virtual labelList renumber(const pointField&) const { notImplemented("manualRenumber::renumber(const pointField&)"); return labelList(0); } - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Use the mesh connectivity (if needed) virtual labelList renumber ( const polyMesh& mesh, const pointField& cc ) const; - //- Return for every cell the new cell label. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. // The connectivity is equal to mesh.cellCells() except // - the connections are across coupled patches virtual labelList renumber diff --git a/src/renumber/renumberMethods/randomRenumber/randomRenumber.C b/src/renumber/renumberMethods/randomRenumber/randomRenumber.C index 2dae28e4381c325442b0707cea5abe30f3256965..e5268f7ed7450ccf69a9ce503d745de5de3dd31e 100644 --- a/src/renumber/renumberMethods/randomRenumber/randomRenumber.C +++ b/src/renumber/renumberMethods/randomRenumber/randomRenumber.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,17 +59,17 @@ Foam::labelList Foam::randomRenumber::renumber { Random rndGen(0); - labelList oldToNew(identity(points.size())); + labelList newToOld(identity(points.size())); for (label iter = 0; iter < 10; iter++) { - forAll(oldToNew, i) + forAll(newToOld, i) { - label j = rndGen.integer(0, oldToNew.size()-1); - Swap(oldToNew[i], oldToNew[j]); + label j = rndGen.integer(0, newToOld.size()-1); + Swap(newToOld[i], newToOld[j]); } } - return oldToNew; + return newToOld; } diff --git a/src/renumber/renumberMethods/randomRenumber/randomRenumber.H b/src/renumber/renumberMethods/randomRenumber/randomRenumber.H index 0665d5159b318e89c5e40802d81f592d2a4e5497..f2860eac2a075c091514810039dd4edb7acab224 100644 --- a/src/renumber/renumberMethods/randomRenumber/randomRenumber.H +++ b/src/renumber/renumberMethods/randomRenumber/randomRenumber.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,19 +74,22 @@ public: // Member Functions - //- Return for every coordinate the wanted processor number. - // We need a polyMesh (to be able to load the file) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Use the mesh connectivity (if needed) virtual labelList renumber(const pointField&) const; - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Use the mesh connectivity (if needed) virtual labelList renumber ( const polyMesh& mesh, const pointField& cc ) const; - //- Return for every cell the new cell label. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. // The connectivity is equal to mesh.cellCells() except // - the connections are across coupled patches virtual labelList renumber diff --git a/src/renumber/renumberMethods/renumberMethod/renumberMethod.H b/src/renumber/renumberMethods/renumberMethod/renumberMethod.H index ead92b1e4152bd68692b27693bd190110dbe63cb..b7b02f2dbd2ef50c1ecc0e6ca742cdd2c6caff62 100644 --- a/src/renumber/renumberMethods/renumberMethod/renumberMethod.H +++ b/src/renumber/renumberMethods/renumberMethod/renumberMethod.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -109,7 +109,8 @@ public: // Member Functions - //- Return for every cell the new cell label. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. // This is only defined for geometric renumberMethods. virtual labelList renumber(const pointField&) const { @@ -120,12 +121,14 @@ public: return labelList(0); } - //- Return for every cell the new cell label. Use the - // mesh connectivity (if needed) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Use the mesh connectivity (if needed) virtual labelList renumber(const polyMesh&, const pointField&) const; - //- Return for every cell the new cell label. Gets - // passed agglomeration map (from fine to coarse cells) and coarse + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Gets passed agglomeration map (from fine to coarse cells) and coarse // cell // location. Can be overridden by renumberMethods that provide this // functionality natively. Coarse cells are local to the processor @@ -138,7 +141,8 @@ public: const pointField& regionPoints ) const; - //- Return for every cell the new cell label. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. // The connectivity is equal to mesh.cellCells() except // - the connections are across coupled patches virtual labelList renumber diff --git a/src/renumber/renumberMethods/springRenumber/springRenumber.C b/src/renumber/renumberMethods/springRenumber/springRenumber.C index 64a15145ce4d200da625d0eee9ed808a0ddf2605..0bc9466494f3eda66aa538954717d74ef7f800db 100644 --- a/src/renumber/renumberMethods/springRenumber/springRenumber.C +++ b/src/renumber/renumberMethods/springRenumber/springRenumber.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -165,7 +165,7 @@ Foam::labelList Foam::springRenumber::renumber // Reorder oldToNew inplaceReorder(shuffle, oldToNew); - return oldToNew; + return invert(oldToNew.size(), oldToNew); } diff --git a/src/renumber/renumberMethods/springRenumber/springRenumber.H b/src/renumber/renumberMethods/springRenumber/springRenumber.H index 30f7a3d8381487f5f32b139f809b5c01cea5b46d..c58bcf21d0d4dd725b135def519e922b8fd592fd 100644 --- a/src/renumber/renumberMethods/springRenumber/springRenumber.H +++ b/src/renumber/renumberMethods/springRenumber/springRenumber.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -95,22 +95,26 @@ public: // Member Functions - //- Return for every coordinate the wanted processor number. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // This is only defined for geometric renumberMethods. virtual labelList renumber(const pointField&) const { notImplemented("springRenumber::renumber(const pointField&)"); return labelList(0); } - //- Return for every coordinate the wanted processor number. Use the - // mesh connectivity (if needed) + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. + // Use the mesh connectivity (if needed) virtual labelList renumber ( const polyMesh& mesh, const pointField& cc ) const; - //- Return for every cell the new cell label. + //- Return the order in which cells need to be visited, i.e. + // from ordered back to original cell label. // The connectivity is equal to mesh.cellCells() except // - the connections are across coupled patches virtual labelList renumber