From 70967af85ce583a2e0e26279158de0e7a0bb36c6 Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Thu, 15 Nov 2018 18:22:51 +0100 Subject: [PATCH 01/27] Improvement in refinement cell selection Check whether the refinement level would exceed the maximum specified refinement level only after the buffer layers have been considered. --- .../polyhedralRefinement.C | 15 ++++++++----- .../prismatic2DRefinement.C | 15 ++++++++----- .../refinement/refinement/refinement.C | 21 +++++-------------- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/polyhedralRefinement/polyhedralRefinement.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/polyhedralRefinement/polyhedralRefinement.C index 9264459dc..d3036301c 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/polyhedralRefinement/polyhedralRefinement.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/polyhedralRefinement/polyhedralRefinement.C @@ -2028,11 +2028,7 @@ void Foam::polyhedralRefinement::setCellsToRefine // Get cell index const label& cellI = refinementCellCandidates[i]; - if - ( - roughCellCountAfterRefinement < maxCells_ - && cellLevel_[cellI] < maxRefinementLevel_ - ) + if (roughCellCountAfterRefinement < maxCells_) { // Mark cell for refinement refineCell[cellI] = true; @@ -2049,6 +2045,15 @@ void Foam::polyhedralRefinement::setCellsToRefine extendMarkedCellsAcrossFaces(refineCell); } + // Remove all cells that would exceed the maximum refinement level + forAll (refineCell, cellI) + { + if (refineCell[cellI] && (cellLevel_[cellI] + 1 > maxRefinementLevel_)) + { + refineCell[cellI] = false; + } + } + // Make sure that the refinement is face consistent (2:1 consistency) and // point consistent (4:1 consistency) if necessary diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/prismatic2DRefinement/prismatic2DRefinement.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/prismatic2DRefinement/prismatic2DRefinement.C index 4f8c2fa8a..f627b7f55 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/prismatic2DRefinement/prismatic2DRefinement.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/prismatic2DRefinement/prismatic2DRefinement.C @@ -2587,11 +2587,7 @@ void Foam::prismatic2DRefinement::setCellsToRefine // Get cell index const label& cellI = refinementCellCandidates[i]; - if - ( - roughCellCountAfterRefinement < maxCells_ - && cellLevel_[cellI] < maxRefinementLevel_ - ) + if (roughCellCountAfterRefinement < maxCells_) { // Mark cell for refinement refineCell[cellI] = true; @@ -2608,6 +2604,15 @@ void Foam::prismatic2DRefinement::setCellsToRefine extendMarkedCellsAcrossFaces(refineCell); } + // Remove all cells that exceed the maximum refinement level + forAll (refineCell, cellI) + { + if (refineCell[cellI] && (cellLevel_[cellI] + 1 > maxRefinementLevel_)) + { + refineCell[cellI] = false; + } + } + // Make sure that the refinement is face consistent (2:1 consistency) and // point consistent (4:1 consistency) if necessary diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/refinement/refinement.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/refinement/refinement.C index b607dfb1e..64a8a10b3 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/refinement/refinement.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/refinement/refinement/refinement.C @@ -111,17 +111,9 @@ void Foam::refinement::extendMarkedCellsAcrossFaces const label& own = owner[faceI]; const label& nei = neighbour[faceI]; - if (cellLevel_[own] < maxRefinementLevel_) - { - // Mark owner - markedCell[own] = true; - } - - if (cellLevel_[nei] < maxRefinementLevel_) - { - // Mark neighbour - markedCell[nei] = true; - } + // Mark owner and neighbour cells + markedCell[own] = true; + markedCell[nei] = true; } } @@ -134,11 +126,8 @@ void Foam::refinement::extendMarkedCellsAcrossFaces // exceeded const label& own = owner[faceI]; - if (cellLevel_[own] < maxRefinementLevel_) - { - // Mark owner - markedCell[own] = true; - } + // Mark owner + markedCell[own] = true; } } } From 75a6813d3a41892dc1d8c2fd00f747d3d00990cc Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Mon, 26 Nov 2018 10:27:15 +0100 Subject: [PATCH 02/27] Whitespace clean-up and minor formatting --- .../dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C index 9bc1cdef8..5ae37fd8e 100644 --- a/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C +++ b/src/dynamicMesh/topoChangerFvMesh/dynamicPolyRefinementFvMesh/dynamicPolyRefinementFvMesh.C @@ -361,8 +361,10 @@ bool Foam::dynamicPolyRefinementFvMesh::update() // Update current time index to skip multiple topo change checks // per time step curTimeIndex_ = time().timeIndex(); - } + } + Pout<< "No refinement/unrefinement" << endl; + // No refinement/unrefinement at this time step. Return false return false; } From 920ff7bcc466a5c15357098b5a7f437864463d6c Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Wed, 23 Jan 2019 13:03:44 +0100 Subject: [PATCH 03/27] Manually merged Henrik's DLB and some other stuff --- ...htRcThermalDiffusivityFvPatchScalarField.C | 2 +- .../finiteVolume/domainDecomposition.C | 20 ++ .../finiteVolume/domainDecomposition.H | 7 + .../fvFieldReconstructorReconstructFields.C | 8 +- .../finiteVolume/processorMeshesRebuild.C | 28 +- .../processorMeshesReconstructor.C | 2 + .../processorMeshesReconstructor.H | 9 + .../finiteVolume/sharedPoints.C | 171 +++++++++- .../finiteVolume/sharedPoints.H | 15 +- .../dynamicPolyRefinementFvMesh.C | 14 +- .../topoChangerFvMeshLoadBalance.C | 58 +++- .../topoChangerFvMeshLoadBalanceTemplates.C | 24 +- .../compressible/compressibleCourantNo.H | 21 +- .../cfdTools/incompressible/CourantNo.H | 2 +- .../fixedGradient/fixedGradientFvPatchField.C | 8 +- .../basic/mixed/mixedFvPatchField.C | 8 +- .../inletOutlet/inletOutletFvPatchField.C | 2 +- .../finiteVolume/fvSchemes/fvSchemes.C | 29 +- src/finiteVolume/fvMesh/fvMesh.C | 3 + .../fvMesh/wallDist/nearWallDist.C | 2 +- src/foam/Make/files | 1 + .../GeometricField/GeometricField.C | 10 + .../GeometricField/GeometricField.H | 4 + src/foam/fields/cloud/cloud.C | 7 + src/foam/fields/cloud/cloud.H | 4 +- .../pointBoundaryMesh/pointBoundaryMesh.C | 32 +- .../pointBoundaryMesh/pointBoundaryMesh.H | 6 +- src/foam/meshes/pointMesh/pointMesh.C | 5 +- .../globalMeshData/globalProcFaceIndex.C | 6 +- .../globalMeshData/globalProcFaceIndex.H | 2 +- .../globalMeshData/globalProcPointIndex.C | 319 ++++++++++++++++++ .../globalMeshData/globalProcPointIndex.H | 135 ++++++++ ...undaryDynamicRefineSolidBodyMotionFvMesh.C | 2 +- ...aryEpsilonWallFunctionFvPatchScalarField.C | 2 +- ...ersedBoundaryKqRWallFunctionFvPatchField.C | 2 +- ...ndaryOmegaWallFunctionFvPatchScalarField.C | 2 +- .../CloudDistributeTemplate.H | 2 +- .../basic/CloudTemplate/CloudTemplate.C | 34 ++ .../basic/CloudTemplate/CloudTemplate.H | 3 + .../InjectionModel/InjectionModel.C | 2 +- .../oversetMesh/donorAcceptor/donorAcceptor.H | 3 +- .../adaptiveOverlapFringe.C | 125 ++++--- .../adaptiveOverlapFringe.H | 10 +- .../donorSuitability/donorSuitability.H | 15 + .../overlapFringe/overlapFringe.C | 63 ++-- .../overlapFringe/overlapFringe.H | 2 +- .../oversetMesh/oversetMeshAddressing.C | 21 +- .../oversetMesh/oversetRegion/oversetRegion.C | 92 ++--- src/sampling/sampledSet/curve/curveSet.C | 4 +- src/sampling/sampledSet/face/faceOnlySet.C | 16 +- src/sampling/sampledSet/face/faceOnlySet.H | 7 + .../sampledSet/sampledSet/sampledSet.C | 24 +- .../sampledSet/sampledSet/sampledSet.H | 8 +- src/sampling/sampledSet/uniform/uniformSet.C | 4 +- .../basicChemistryModel/basicChemistryModel.C | 17 +- .../basicChemistryModel/basicChemistryModel.H | 6 +- .../incompressible/RAS/RASModel/RASModel.H | 2 +- .../turbulenceModel/turbulenceModel.H | 2 +- 58 files changed, 1225 insertions(+), 209 deletions(-) create mode 100644 src/foam/meshes/polyMesh/globalMeshData/globalProcPointIndex.C create mode 100644 src/foam/meshes/polyMesh/globalMeshData/globalProcPointIndex.H diff --git a/src/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C b/src/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C index 54497a652..9f15e1af4 100644 --- a/src/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C +++ b/src/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C @@ -261,7 +261,7 @@ Foam::chtRcThermalDiffusivityFvPatchScalarField::calcThermalDiffusivity const scalarField kOwn = fOwn/(1.0 - p.weights())/mld.magDelta(p.index()); const scalarField kNei = fNei/p.weights()/mld.magDelta(p.index()); - + tmp kTmp(new scalarField(p.size())); scalarField& k = kTmp(); diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C index 3d9069908..372ec808d 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C @@ -34,6 +34,7 @@ License #include "OSspecific.H" #include "Map.H" #include "DynamicList.H" +#include "globalMeshData.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -53,6 +54,7 @@ Foam::domainDecomposition::domainDecomposition nProcs_(readInt(decompositionDict_.lookup("numberOfSubdomains"))), distributed_(false), gfIndex_(mesh_), + gpIndex_(mesh_), cellToProc_(mesh_.nCells()), patchNbrCellToProc_(mesh_.boundaryMesh().size()), procPointAddressing_(nProcs_), @@ -503,6 +505,24 @@ Foam::autoPtr Foam::domainDecomposition::processorMesh } +Foam::labelList Foam::domainDecomposition::globalPointIndex +( + const label procI +) const +{ + const labelList& gppi = gpIndex_.globalLabel(); + const labelList& ppAddr = procPointAddressing_[procI]; + labelList globalPointIndex(ppAddr.size()); + + forAll (globalPointIndex, gpI) + { + globalPointIndex[gpI] = gppi[ppAddr[gpI]]; + } + + return globalPointIndex; +} + + bool Foam::domainDecomposition::writeDecomposition() { Info<< "\nConstructing processor meshes" << endl; diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H index b4f02aa41..fc32d24e4 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.H @@ -43,6 +43,7 @@ SourceFiles #include "PtrList.H" #include "point.H" #include "globalProcFaceIndex.H" +#include "globalProcPointIndex.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,6 +73,9 @@ class domainDecomposition //- Global face index globalProcFaceIndex gfIndex_; + //- Global face index + globalProcPointIndex gpIndex_; + //- Processor label for each cell labelList cellToProc_; @@ -205,6 +209,9 @@ public: const bool createPassiveProcPatches = false ) const; + //- Create and return global point index + labelList globalPointIndex(const label procI) const; + //- Return processor point addressing const labelListList& procPointAddressing() const { diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C index 47567fa5a..dcf8dc227 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C @@ -44,10 +44,10 @@ void Foam::fvFieldReconstructor::reconstructField ) const { // Get references to internal and boundary field - Field& iField = reconField.internalField(); + Field& iField = reconField; typename GeometricField:: - GeometricBoundaryField& bouField = reconField.boundaryField(); + GeometricBoundaryField& bouField = reconField.boundaryFieldNoStoreOldTimes(); forAll (procFields, procI) { @@ -143,10 +143,10 @@ void Foam::fvFieldReconstructor::reconstructField ) const { // Create the internalField - Field& iField = reconField.internalField(); + Field& iField = reconField; typename GeometricField:: - GeometricBoundaryField& bouField = reconField.boundaryField(); + GeometricBoundaryField& bouField = reconField.boundaryFieldNoStoreOldTimes(); forAll (procFields, procI) { diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C index fbe520e7b..9d9655059 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C @@ -652,10 +652,30 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db) reconPatchSizes = 0; - // Prepare handling for globally shared points. This is equivalent - // to parallel processor points, but working on a PtrList of meshes - // on the same processor - sharedPoints sharedData(meshes_); + // HR 21.12.18 : A bit of a hack for the moment in order to support the new + // method (using global point addressing) and old method (syncing across + // processor BCs) of constructing the shared points. The old method is still + // needed since global point addressing does not exist when the sharedPoint + // object is constructed from reconstructParMesh. + // + // TODO: Unify the methods by constructing global point addressing from the + // mesh pieces when. Or even better, calculate procPointAddressing directly + // which will simplify the mesh merging immensely. + autoPtr sharedDataPtr; + if(globalPointIndex_.size()) + { + // Determine globally shared points using global point + // adressing + sharedDataPtr.set(new sharedPoints(meshes_, globalPointIndex_)); + } + else + { + // Prepare handling for globally shared points. This is equivalent + // to parallel processor points, but working on a PtrList of meshes + // on the same processor + sharedDataPtr.set(new sharedPoints(meshes_)); + } + sharedPoints& sharedData = sharedDataPtr(); // Record global point index for shared points labelList globalPointMapping(sharedData.nGlobalPoints(), -1); diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C index 18ace98bb..55a754bca 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C @@ -71,6 +71,7 @@ Foam::processorMeshesReconstructor::processorMeshesReconstructor : meshName_(meshName), meshes_(), + globalPointIndex_(), pointProcAddressing_(), faceProcAddressing_(), cellProcAddressing_(), @@ -86,6 +87,7 @@ Foam::processorMeshesReconstructor::processorMeshesReconstructor : meshName_(meshName), meshes_(databases.size()), + globalPointIndex_(), pointProcAddressing_(), faceProcAddressing_(), cellProcAddressing_(), diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.H b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.H index 17e39cacf..a8e4af0c0 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.H +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.H @@ -72,6 +72,9 @@ class processorMeshesReconstructor //- List of processor meshes PtrList meshes_; + //- global point index per sub-mesh + labelListList globalPointIndex_; + //- List of processor point addressing lists PtrList pointProcAddressing_; @@ -161,6 +164,12 @@ public: return meshes_; } + //- Return access to meshes + labelListList& globalPointIndex() + { + return globalPointIndex_; + } + //- Return point-processor addressing arrays const PtrList& pointProcAddressing() const; diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/sharedPoints.C b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/sharedPoints.C index bc8a97d40..dc8b1d220 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/sharedPoints.C +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/sharedPoints.C @@ -451,9 +451,160 @@ void Foam::sharedPoints::calcSharedPoints() } +void Foam::sharedPoints::calcSharedPoints +( + const labelListList& globalPointIndex +) +{ + typedef HashTable, label, Hash