diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C index 42f141965b..1a547204a7 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C @@ -352,7 +352,11 @@ void Foam::GAMGSolver::Vcycle // Scale coarse-grid correction field // but not on the coarsest level because it evaluates to 1 - if (scaleCorrection_ && leveli < coarsestLevel - 1) + if + ( + scaleCorrection_ + && (interpolateCorrection_ || leveli < coarsestLevel - 1) + ) { scale ( diff --git a/src/Pstream/mpi/UIPread.C b/src/Pstream/mpi/UIPread.C index 6994db9395..55b9973ff8 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) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -261,7 +261,7 @@ Foam::label Foam::UIPstream::read ( buf, bufSize, - MPI_PACKED, + MPI_BYTE, fromProcNo, tag, PstreamGlobals::MPICommunicators_[communicator], @@ -317,7 +317,7 @@ Foam::label Foam::UIPstream::read ( buf, bufSize, - MPI_PACKED, + MPI_BYTE, fromProcNo, tag, PstreamGlobals::MPICommunicators_[communicator], diff --git a/src/Pstream/mpi/UOPwrite.C b/src/Pstream/mpi/UOPwrite.C index 275c2eca43..1c27ec1dbf 100644 --- a/src/Pstream/mpi/UOPwrite.C +++ b/src/Pstream/mpi/UOPwrite.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,7 +74,7 @@ bool Foam::UOPstream::write ( const_cast(buf), bufSize, - MPI_PACKED, + MPI_BYTE, toProcNo, //procID(toProcNo), tag, PstreamGlobals::MPICommunicators_[communicator] //MPI_COMM_WORLD @@ -94,7 +94,7 @@ bool Foam::UOPstream::write ( const_cast(buf), bufSize, - MPI_PACKED, + MPI_BYTE, toProcNo, //procID(toProcNo), tag, PstreamGlobals::MPICommunicators_[communicator] //MPI_COMM_WORLD @@ -116,7 +116,7 @@ bool Foam::UOPstream::write ( const_cast(buf), bufSize, - MPI_PACKED, + MPI_BYTE, toProcNo, //procID(toProcNo), tag, PstreamGlobals::MPICommunicators_[communicator],//MPI_COMM_WORLD, diff --git a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H index 3d0d015923..8b79095b0d 100644 --- a/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H +++ b/src/finiteVolume/cfdTools/general/porosityModel/porosityModel/porosityModelList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,7 +55,7 @@ Ostream& operator<<(Ostream& os, const porosityModelList& models); class porosityModelList : - PtrList + public PtrList { private: diff --git a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C index dd912465a0..1b468f825d 100644 --- a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C +++ b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,8 +25,8 @@ License #include "MGridGenGAMGAgglomeration.H" #include "fvMesh.H" -#include "processorPolyPatch.H" #include "addToRunTimeSelectionTable.H" +#include "processorLduInterface.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -43,6 +43,121 @@ namespace Foam } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::MGridGenGAMGAgglomeration::swap +( + const lduInterfacePtrsList& interfaces, + const labelUList& cellValues, + PtrList& nbrValues +) const +{ + // Initialise transfer of restrict addressing on the interface + forAll(interfaces, inti) + { + if (interfaces.set(inti)) + { + interfaces[inti].initInternalFieldTransfer + ( + Pstream::nonBlocking, + cellValues + ); + } + } + + if (Pstream::parRun()) + { + Pstream::waitRequests(); + } + + // Get the interface agglomeration + nbrValues.setSize(interfaces.size()); + forAll(interfaces, inti) + { + if (interfaces.set(inti)) + { + nbrValues.set + ( + inti, + new labelList + ( + interfaces[inti].internalFieldTransfer + ( + Pstream::nonBlocking, + cellValues + ) + ) + ); + } + } +} + + +void Foam::MGridGenGAMGAgglomeration::getNbrAgglom +( + const lduAddressing& addr, + const lduInterfacePtrsList& interfaces, + const PtrList& nbrGlobalAgglom, + labelList& cellToNbrAgglom +) const +{ + cellToNbrAgglom.setSize(addr.size()); + cellToNbrAgglom = -1; + + forAll(interfaces, inti) + { + if (interfaces.set(inti)) + { + if (isA(interfaces[inti])) + { + const processorLduInterface& pldui = + refCast(interfaces[inti]); + + if (pldui.myProcNo() > pldui.neighbProcNo()) + { + const labelUList& faceCells = + interfaces[inti].faceCells(); + const labelList& nbrData = nbrGlobalAgglom[inti]; + + forAll(faceCells, i) + { + cellToNbrAgglom[faceCells[i]] = nbrData[i]; + } + } + } + } + } +} + + +void Foam::MGridGenGAMGAgglomeration::detectSharedFaces +( + const lduMesh& mesh, + const labelList& value, + labelHashSet& sharedFaces +) const +{ + const lduAddressing& addr = mesh.lduAddr(); + const labelUList& lower = addr.lowerAddr(); + const labelUList& upper = addr.upperAddr(); + + sharedFaces.clear(); + sharedFaces.resize(addr.lowerAddr().size()/100); + + // Detect any faces inbetween same value + forAll(lower, faceI) + { + label lowerData = value[lower[faceI]]; + label upperData = value[upper[faceI]]; + + if (lowerData != -1 && lowerData == upperData) + { + sharedFaces.insert(faceI); + } + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration @@ -58,6 +173,13 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration label minSize(readLabel(controlDict.lookup("minSize"))); label maxSize(readLabel(controlDict.lookup("maxSize"))); + // Number of iterations applied to improve agglomeration consistency across + // processor boundaries + label nProcConsistencyIter + ( + readLabel(controlDict.lookup("nProcConsistencyIter")) + ); + // Start geometric agglomeration from the cell volumes and areas of the mesh scalarField* VPtr = const_cast(&fvMesh_.cellVolumes()); @@ -87,28 +209,6 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration } } - /* - { - scalarField& magSb = *magSbPtr; - const polyBoundaryMesh& patches = fvMesh_.boundaryMesh(); - - forAll(patches, patchi) - { - const polyPatch& pp = patches[patchi]; - - if (!(Pstream::parRun() && isA(pp))) - { - const labelUList& faceCells = pp.faceCells(); - const vectorField& pSf = pp.faceAreas(); - forAll(faceCells, pfi) - { - magSb[faceCells[pfi]] += mag(pSf[pfi]); - } - } - } - } - */ - // Agglomerate until the required number of cells in the coarsest level // is reached @@ -129,6 +229,63 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration *magSbPtr ); + // Adjust weights only + for (int i=0; i nbrGlobalAgglom; + swap(interfaces, globalAgglom, nbrGlobalAgglom); + + + // Get the interface agglomeration on a cell basis (-1 for all + // other cells) + labelList cellToNbrAgglom; + getNbrAgglom(addr, interfaces, nbrGlobalAgglom, cellToNbrAgglom); + + + // Mark all faces inbetween cells with same nbragglomeration + labelHashSet sharedFaces(addr.size()/100); + detectSharedFaces(mesh, cellToNbrAgglom, sharedFaces); + + + //- Note: in-place update of weights is more effective it seems? + // Should not be. fluke? + //scalarField weights(*faceWeightsPtr); + scalarField weights = *magSfPtr; + forAllConstIter(labelHashSet, sharedFaces, iter) + { + label faceI= iter.key(); + weights[faceI] *= 2.0; + } + + // Redo the agglomeration using the new weights + finalAgglomPtr = agglomerate + ( + nCoarseCells, + minSize, + maxSize, + meshLevel(nCreatedLevels).lduAddr(), + *VPtr, + weights, + *magSbPtr + ); + } + if (continueAgglomerating(nCoarseCells)) { nCells_[nCreatedLevels] = nCoarseCells; diff --git a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H index 5ed8e2a401..21090e7513 100644 --- a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H +++ b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -67,6 +67,29 @@ class MGridGenGAMGAgglomeration // Private Member Functions + void swap + ( + const lduInterfacePtrsList& interfaces, + const labelUList& cellValues, + PtrList& nbrValues + ) const; + + void getNbrAgglom + ( + const lduAddressing& addr, + const lduInterfacePtrsList& interfaces, + const PtrList& nbrGlobalAgglom, + labelList& cellToNbrAgglom + ) const; + + void detectSharedFaces + ( + const lduMesh& mesh, + const labelList& value, + labelHashSet& sharedFaces + ) const; + + //- Construct the CSR format addressing void makeCompactCellFaceAddressingAndFaceWeights (