diff --git a/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C b/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C index 47ec7f9137..f4bf559009 100644 --- a/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C +++ b/applications/utilities/mesh/conversion/Optional/ccm26ToFoam/ccm26ToFoam.C @@ -908,10 +908,10 @@ int main(int argc, char *argv[]) runTime.constant(), runTime ), - foamPoints, - foamFaces, - foamOwner, - foamNeighbour + xferMove(foamPoints), + xferMove(foamFaces), + xferCopy(foamOwner), + xferMove(foamNeighbour) ); // Create patches. Use patch types to determine what Foam types to generate. diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C index 3534519ca7..29841d3ec8 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCheck/primitiveMeshCheck.C @@ -626,7 +626,8 @@ bool Foam::primitiveMesh::checkFaceSkewness vector d = cellCtrs[nei[faceI]] - cellCtrs[own[faceI]]; // Skewness vector - vector sv = Cpf - ((fAreas[faceI] & Cpf)/(fAreas[faceI] & d))*d; + vector sv = + Cpf - ((fAreas[faceI] & Cpf)/((fAreas[faceI] & d) + SMALL))*d; vector svHat = sv/(mag(sv) + VSMALL); // Normalisation distance calculated as the approximate distance diff --git a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C index 01b1a56d03..c38e0494ae 100644 --- a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C +++ b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.C @@ -25,8 +25,6 @@ License InClass decompositionMethod -Description - \*---------------------------------------------------------------------------*/ #include "decompositionMethod.H" @@ -104,14 +102,26 @@ Foam::autoPtr Foam::decompositionMethod::New } +Foam::labelList Foam::decompositionMethod::decompose +( + const pointField& points +) +{ + scalarField weights(0); + + return decompose(points, weights); +} + + Foam::labelList Foam::decompositionMethod::decompose ( const labelList& fineToCoarse, - const pointField& coarsePoints + const pointField& coarsePoints, + const scalarField& coarseWeights ) { // Decompose based on agglomerated points - labelList coarseDistribution(decompose(coarsePoints)); + labelList coarseDistribution(decompose(coarsePoints, coarseWeights)); // Rework back into decomposition for original mesh_ labelList fineDistribution(fineToCoarse.size()); @@ -125,6 +135,18 @@ Foam::labelList Foam::decompositionMethod::decompose } +Foam::labelList Foam::decompositionMethod::decompose +( + const labelList& fineToCoarse, + const pointField& coarsePoints +) +{ + scalarField coarseWeights(0); + + return decompose(fineToCoarse, coarsePoints, coarseWeights); +} + + void Foam::decompositionMethod::calcCellCells ( const polyMesh& mesh, @@ -170,4 +192,16 @@ void Foam::decompositionMethod::calcCellCells } +Foam::labelList Foam::decompositionMethod::decompose +( + const labelListList& globalCellCells, + const pointField& cc +) +{ + scalarField cWeights(0); + + return decompose(globalCellCells, cc, cWeights); +} + + // ************************************************************************* // diff --git a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H index 7055f24d7b..7f66e9f50d 100644 --- a/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H +++ b/src/decompositionMethods/decompositionMethods/decompositionMethod/decompositionMethod.H @@ -150,20 +150,37 @@ public: //- Return for every coordinate the wanted processor number. Use the // mesh connectivity (if needed) - virtual labelList decompose(const pointField&) = 0; + virtual labelList decompose + ( + const pointField& points, + const scalarField& pointWeights + ) = 0; + + //- Like decompose but with uniform weights on the points + virtual labelList decompose(const pointField&); + //- Return for every coordinate the wanted processor number. Gets // passed agglomeration map (from fine to coarse cells) and coarse cell // location. Can be overridden by decomposers that provide this // functionality natively. Coarse cells are local to the processor // (if in parallel). If you want to have coarse cells spanning - // processors use the next function below instead. + // processors use the globalCellCells instead. + virtual labelList decompose + ( + const labelList& cellToRegion, + const pointField& regionPoints, + const scalarField& regionWeights + ); + + //- Like decompose but with uniform weights on the regions virtual labelList decompose ( const labelList& cellToRegion, const pointField& regionPoints ); + //- Return for every coordinate the wanted processor number. Explicitly // provided connectivity - does not use mesh_. // The connectivity is equal to mesh.cellCells() except for @@ -174,9 +191,17 @@ public: virtual labelList decompose ( const labelListList& globalCellCells, - const pointField& cc + const pointField& cc, + const scalarField& cWeights ) = 0; + //- Like decompose but with uniform weights on the cells + virtual labelList decompose + ( + const labelListList& globalCellCells, + const pointField& cc + ); + }; diff --git a/src/decompositionMethods/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C b/src/decompositionMethods/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C index 72d39d215c..bde1181c09 100644 --- a/src/decompositionMethods/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C +++ b/src/decompositionMethods/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C @@ -142,6 +142,38 @@ Foam::label Foam::hierarchGeomDecomp::findLower } +// Create a mapping between the index and the weighted size. +// For convenience, sortedWeightedSize is one size bigger than current. This +// avoids extra tests. +void Foam::hierarchGeomDecomp::calculateSortedWeightedSizes +( + const labelList& current, + const labelList& indices, + const scalarField& weights, + const label globalCurrentSize, + + scalarField& sortedWeightedSizes +) +{ + // Evaluate cumulative weights. + sortedWeightedSizes[0] = 0; + forAll(current, i) + { + label pointI = current[indices[i]]; + sortedWeightedSizes[i + 1] = sortedWeightedSizes[i] + weights[pointI]; + } + // Non-dimensionalise and multiply by size. + scalar globalCurrentLength = returnReduce + ( + sortedWeightedSizes[current.size()], + sumOp() + ); + // Normalise weights by global sum of weights and multiply through + // by global size. + sortedWeightedSizes *= (globalCurrentSize/globalCurrentLength); +} + + // Find position in values so between minIndex and this position there // are wantedSize elements. void Foam::hierarchGeomDecomp::findBinary @@ -170,7 +202,6 @@ void Foam::hierarchGeomDecomp::findBinary label midPrev = -1; label highPrev = -1; - //while (low <= high) while (true) { label size = returnReduce(mid-minIndex, sumOp