From 2131f9f3e4345944527a576ecd1e7e1e44efa433 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 30 Oct 2013 09:08:27 +0000 Subject: [PATCH 1/8] BUG: reconstructPar: mesh re-reading --- .../reconstruct/reconstruct/processorMeshes.C | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/parallel/reconstruct/reconstruct/processorMeshes.C b/src/parallel/reconstruct/reconstruct/processorMeshes.C index b3729c8b7e..875e96c38e 100644 --- a/src/parallel/reconstruct/reconstruct/processorMeshes.C +++ b/src/parallel/reconstruct/reconstruct/processorMeshes.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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,15 @@ License void Foam::processorMeshes::read() { + forAll(databases_, procI) + { + meshes_.set(procI, NULL); + pointProcAddressing_.set(procI, NULL); + faceProcAddressing_.set(procI, NULL); + cellProcAddressing_.set(procI, NULL); + boundaryProcAddressing_.set(procI, NULL); + } + forAll(databases_, procI) { meshes_.set From dfc680a212e1e096e980aeacb4a12b8c038f1309 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 30 Oct 2013 11:57:15 +0000 Subject: [PATCH 2/8] ENH: mapDistribute: missing default --- .../polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index 7c94b9b138..96004c3e26 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -542,8 +542,11 @@ public: //- Compact maps. Gets per field a bool whether it is used (locally) // and works out itself what this side and sender side can remove // from maps. - void compact(const boolList& elemIsUsed, const int tag); - + void compact + ( + const boolList& elemIsUsed, + const int tag = UPstream::msgType() + ); //- Distribute data. Note:schedule only used for Pstream::scheduled // for now, all others just use send-to-all, receive-from-all. From fa328ab6783221e513560163dd1349beeb94c926 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 30 Oct 2013 15:12:36 +0000 Subject: [PATCH 3/8] ENH: reconstructPar: additional printing --- .../reconstructPar/reconstructPar.C | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 3ad100d4f2..aa7fa5554b 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -720,6 +720,20 @@ int main(int argc, char *argv[]) PtrList faceSets(fSetNames.size()); PtrList pointSets(pSetNames.size()); + Info<< "Reconstructing sets:" << endl; + if (cSetNames.size()) + { + Info<< " cellSets " << cSetNames.sortedToc() << endl; + } + if (fSetNames.size()) + { + Info<< " faceSets " << fSetNames.sortedToc() << endl; + } + if (pSetNames.size()) + { + Info<< " pointSets " << pSetNames.sortedToc() << endl; + } + // Load sets forAll(procMeshes.meshes(), procI) { From cca229f78522f1c20a861b00a4faba7581e15a32 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 30 Oct 2013 15:17:57 +0000 Subject: [PATCH 4/8] ENH: snappyHexMesh: layer coverage volfields --- .../generation/snappyHexMesh/snappyHexMesh.C | 6 +- .../snappyHexMesh/snappyHexMeshDict | 4 +- .../autoHexMeshDriver/autoLayerDriver.C | 348 ++++++++++++++---- .../autoHexMeshDriver/autoLayerDriver.H | 24 +- .../layerParameters/layerParameters.C | 37 +- .../layerParameters/layerParameters.H | 4 +- 6 files changed, 346 insertions(+), 77 deletions(-) diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index 65bc15d852..c349740ea7 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -1253,6 +1253,9 @@ int main(int argc, char *argv[]) // Snap parameters const snapParameters snapParams(snapDict); + // Layer addition parameters + const layerParameters layerParams(layerDict, mesh.boundaryMesh()); + if (wantRefine) { @@ -1346,9 +1349,6 @@ int main(int argc, char *argv[]) globalToSlavePatch ); - // Layer addition parameters - layerParameters layerParams(layerDict, mesh.boundaryMesh()); - // Use the maxLocalCells from the refinement parameters bool preBalance = returnReduce ( diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 9db10ea85e..b850033a44 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -304,11 +304,13 @@ addLayersControls // size of the refined cell outside layer (true) or absolute sizes (false). relativeSizes true; - // Layer thickness specification. This can be specified in one of four ways + // Layer thickness specification. This can be specified in one of following + // ways: // - expansionRatio and finalLayerThickness (cell nearest internal mesh) // - expansionRatio and firstLayerThickness (cell on surface) // - overall thickness and firstLayerThickness // - overall thickness and finalLayerThickness + // - overall thickness and expansionRatio // Expansion factor for layer mesh expansionRatio 1.0; diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 2c6add9fc9..7bb72786b8 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -52,6 +52,7 @@ Description #include "fixedValuePointPatchFields.H" #include "calculatedPointPatchFields.H" #include "cyclicSlipPointPatchFields.H" +#include "fixedValueFvPatchFields.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -110,6 +111,31 @@ void Foam::autoLayerDriver::dumpDisplacement } +Foam::tmp Foam::autoLayerDriver::avgPointData +( + const indirectPrimitivePatch& pp, + const scalarField& pointFld +) +{ + tmp tfaceFld(new scalarField(pp.size(), 0.0)); + scalarField& faceFld = tfaceFld(); + + forAll(pp.localFaces(), faceI) + { + const face& f = pp.localFaces()[faceI]; + if (f.size()) + { + forAll(f, fp) + { + faceFld[faceI] += pointFld[f[fp]]; + } + faceFld[faceI] /= f.size(); + } + } + return tfaceFld; +} + + // Check that primitivePatch is not multiply connected. Collect non-manifold // points in pointSet. void Foam::autoLayerDriver::checkManifold @@ -2391,19 +2417,21 @@ Foam::label Foam::autoLayerDriver::countExtrusion } -// Collect layer faces and layer cells into bools for ease of handling +// Collect layer faces and layer cells into mesh fields for ease of handling void Foam::autoLayerDriver::getLayerCellsFaces ( const polyMesh& mesh, const addPatchCellLayer& addLayer, - boolList& flaggedCells, - boolList& flaggedFaces + const scalarField& oldRealThickness, + + labelList& cellNLayers, + scalarField& faceRealThickness ) { - flaggedCells.setSize(mesh.nCells()); - flaggedCells = false; - flaggedFaces.setSize(mesh.nFaces()); - flaggedFaces = false; + cellNLayers.setSize(mesh.nCells()); + cellNLayers = 0; + faceRealThickness.setSize(mesh.nFaces()); + faceRealThickness = 0; // Mark all faces in the layer const labelListList& layerFaces = addLayer.layerFaces(); @@ -2415,27 +2443,195 @@ void Foam::autoLayerDriver::getLayerCellsFaces { const labelList& added = addedCells[oldPatchFaceI]; - forAll(added, i) + const labelList& layer = layerFaces[oldPatchFaceI]; + + if (layer.size()) { - flaggedCells[added[i]] = true; + forAll(added, i) + { + cellNLayers[added[i]] = layer.size()-1; + } } } forAll(layerFaces, oldPatchFaceI) { const labelList& layer = layerFaces[oldPatchFaceI]; + const scalar realThickness = oldRealThickness[oldPatchFaceI]; if (layer.size()) { - for (label i = 1; i < layer.size()-1; i++) + // Layer contains both original boundary face and new boundary + // face so is nLayers+1 + forAll(layer, i) { - flaggedFaces[layer[i]] = true; + faceRealThickness[layer[i]] = realThickness; } } } } +bool Foam::autoLayerDriver::writeLayerData +( + const fvMesh& mesh, + const labelList& patchIDs, + const labelList& cellNLayers, + const scalarField& faceWantedThickness, + const scalarField& faceRealThickness +) const +{ + bool allOk = true; + + { + label nAdded = 0; + forAll(cellNLayers, cellI) + { + if (cellNLayers[cellI] > 0) + { + nAdded++; + } + } + cellSet addedCellSet(mesh, "addedCells", nAdded); + forAll(cellNLayers, cellI) + { + if (cellNLayers[cellI] > 0) + { + addedCellSet.insert(cellI); + } + } + addedCellSet.instance() = meshRefiner_.timeName(); + Info<< "Writing " + << returnReduce(addedCellSet.size(), sumOp