From 471c9f25edd93f14426ad86e42de0384fba64ebe Mon Sep 17 00:00:00 2001 From: Henry <Henry> Date: Thu, 20 Jun 2013 10:44:33 +0100 Subject: [PATCH] MGridGenGAMGAgglomerate: use magSf rather than Sf when agglomerating --- .../MGridGenGAMGAgglomerate.C | 23 ++++--- .../MGridGenGAMGAgglomeration.C | 65 ++++++++++++------- .../MGridGenGAMGAgglomeration.H | 6 +- 3 files changed, 57 insertions(+), 37 deletions(-) diff --git a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomerate.C b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomerate.C index 4d32bfa89f8..311df77f7da 100644 --- a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomerate.C +++ b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomerate.C @@ -38,7 +38,7 @@ makeCompactCellFaceAddressingAndFaceWeights const lduAddressing& fineAddressing, List<idxtype>& cellCells, List<idxtype>& cellCellOffsets, - const vectorField& Si, + const scalarField& magSi, List<scalar>& faceWeights ) { @@ -87,8 +87,8 @@ makeCompactCellFaceAddressingAndFaceWeights cellCells[l1] = nei; cellCells[l2] = own; - faceWeights[l1] = mag(Si[facei]); - faceWeights[l2] = mag(Si[facei]); + faceWeights[l1] = magSi[facei]; + faceWeights[l2] = magSi[facei]; } } @@ -100,8 +100,8 @@ Foam::tmp<Foam::labelField> Foam::MGridGenGAMGAgglomeration::agglomerate const label maxSize, const lduAddressing& fineAddressing, const scalarField& V, - const vectorField& Sf, - const scalarField& Sb + const scalarField& magSf, + const scalarField& magSb ) { const label nFineCells = fineAddressing.size(); @@ -119,15 +119,15 @@ Foam::tmp<Foam::labelField> Foam::MGridGenGAMGAgglomeration::agglomerate fineAddressing, cellCells, cellCellOffsets, - Sf, + magSf, faceWeights ); // agglomeration options. List<int> options(4, 0); - options[0] = 4; // globular agglom - options[1] = 6; // objective F3 and F2 - options[2] = 128; // debugging output level + options[0] = 4; // globular agglom + options[1] = 6; // objective F3 and F2 + options[2] = 128; // debugging output level options[3] = fvMesh_.nGeometricD(); // Dimensionality of the grid @@ -140,7 +140,7 @@ Foam::tmp<Foam::labelField> Foam::MGridGenGAMGAgglomeration::agglomerate nFineCells, cellCellOffsets.begin(), const_cast<scalar*>(V.begin()), - const_cast<scalar*>(Sb.begin()), + const_cast<scalar*>(magSb.begin()), cellCells.begin(), faceWeights.begin(), minSize, @@ -157,8 +157,7 @@ Foam::tmp<Foam::labelField> Foam::MGridGenGAMGAgglomeration::agglomerate bool ok = checkRestriction ( newRestrictAddr, - nNewCoarseCells -, + nNewCoarseCells, fineAddressing, finalAgglom, nCoarseCells diff --git a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C index cc259c50384..dd912465a0c 100644 --- a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C +++ b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.C @@ -25,6 +25,7 @@ License #include "MGridGenGAMGAgglomeration.H" #include "fvMesh.H" +#include "processorPolyPatch.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -60,20 +61,19 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration // Start geometric agglomeration from the cell volumes and areas of the mesh scalarField* VPtr = const_cast<scalarField*>(&fvMesh_.cellVolumes()); - vectorField magFaceAreas(vector::one*mag(fvMesh_.faceAreas())); - SubField<vector> Sf(magFaceAreas, fvMesh_.nInternalFaces()); - //SubField<vector> Sf(fvMesh_.faceAreas(), fvMesh_.nInternalFaces()); + scalarField magFaceAreas(sqrt(3.0)*mag(fvMesh_.faceAreas())); + SubField<scalar> magSf(magFaceAreas, fvMesh_.nInternalFaces()); - vectorField* SfPtr = const_cast<vectorField*> + scalarField* magSfPtr = const_cast<scalarField*> ( - &Sf.operator const vectorField&() + &magSf.operator const scalarField&() ); // Create the boundary area cell field - scalarField* SbPtr(new scalarField(fvMesh_.nCells(), 0)); + scalarField* magSbPtr(new scalarField(fvMesh_.nCells(), 0)); { - scalarField& Sb = *SbPtr; + scalarField& magSb = *magSbPtr; const labelList& own = fvMesh_.faceOwner(); const vectorField& Sf = fvMesh_.faceAreas(); @@ -82,11 +82,32 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration { if (!fvMesh_.isInternalFace(facei)) { - Sb[own[facei]] += mag(Sf[facei]); + magSb[own[facei]] += mag(Sf[facei]); } } } + /* + { + scalarField& magSb = *magSbPtr; + const polyBoundaryMesh& patches = fvMesh_.boundaryMesh(); + + forAll(patches, patchi) + { + const polyPatch& pp = patches[patchi]; + + if (!(Pstream::parRun() && isA<processorPolyPatch>(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 @@ -104,8 +125,8 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration maxSize, meshLevel(nCreatedLevels).lduAddr(), *VPtr, - *SfPtr, - *SbPtr + *magSfPtr, + *magSbPtr ); if (continueAgglomerating(nCoarseCells)) @@ -140,37 +161,37 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration // Agglomerate the face areas field for the next level { - vectorField* aggSfPtr + scalarField* aggMagSfPtr ( - new vectorField + new scalarField ( meshLevels_[nCreatedLevels].upperAddr().size(), - vector::zero + 0 ) ); - restrictFaceField(*aggSfPtr, *SfPtr, nCreatedLevels); + restrictFaceField(*aggMagSfPtr, *magSfPtr, nCreatedLevels); if (nCreatedLevels) { - delete SfPtr; + delete magSfPtr; } - SfPtr = aggSfPtr; + magSfPtr = aggMagSfPtr; } // Agglomerate the cell boundary areas field for the next level { - scalarField* aggSbPtr + scalarField* aggMagSbPtr ( new scalarField(meshLevels_[nCreatedLevels].size()) ); // Restrict but no parallel agglomeration (not supported) - restrictField(*aggSbPtr, *SbPtr, nCreatedLevels, false); + restrictField(*aggMagSbPtr, *magSbPtr, nCreatedLevels, false); - delete SbPtr; - SbPtr = aggSbPtr; + delete magSbPtr; + magSbPtr = aggMagSbPtr; } nCreatedLevels++; @@ -183,9 +204,9 @@ Foam::MGridGenGAMGAgglomeration::MGridGenGAMGAgglomeration if (nCreatedLevels) { delete VPtr; - delete SfPtr; + delete magSfPtr; } - delete SbPtr; + delete magSbPtr; } diff --git a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H index ea6b5e9c192..e7f18847b40 100644 --- a/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H +++ b/src/fvAgglomerationMethods/MGridGenGamgAgglomeration/MGridGenGAMGAgglomeration.H @@ -73,7 +73,7 @@ class MGridGenGAMGAgglomeration const lduAddressing& fineAddressing, List<idxtype>& cellCells, List<idxtype>& cellCellOffsets, - const vectorField& Si, + const scalarField& magSi, List<scalar>& faceWeights ); @@ -85,8 +85,8 @@ class MGridGenGAMGAgglomeration const label maxSize, const lduAddressing& fineAddressing, const scalarField& V, - const vectorField& Sf, - const scalarField& Sb + const scalarField& magSf, + const scalarField& magSb ); -- GitLab