From 27e7361627a5fc72bfb3509414783273b8a49ead Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Feb 2014 17:02:28 +0000 Subject: [PATCH 1/4] GIT: damBreak4Phase: generated file --- .../damBreak4phase/constant/polyMesh/boundary | 53 ------------------- 1 file changed, 53 deletions(-) delete mode 100644 tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/constant/polyMesh/boundary diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/constant/polyMesh/boundary b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/constant/polyMesh/boundary deleted file mode 100644 index 1b4dbb60aa..0000000000 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/constant/polyMesh/boundary +++ /dev/null @@ -1,53 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: dev | -| \\ / A nd | Web: www.OpenFOAM.org | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class polyBoundaryMesh; - location "constant/polyMesh"; - object boundary; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -5 -( - leftWall - { - type wall; - nFaces 50; - startFace 4432; - } - rightWall - { - type wall; - nFaces 50; - startFace 4482; - } - lowerWall - { - type wall; - nFaces 62; - startFace 4532; - } - atmosphere - { - type patch; - nFaces 46; - startFace 4594; - } - defaultFaces - { - type empty; - inGroups 1(empty); - nFaces 4536; - startFace 4640; - } -) - -// ************************************************************************* // From b7fbc77183b4341ee4f6ee6482e1cd7889bb2b37 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 26 Feb 2014 14:42:50 +0000 Subject: [PATCH 2/4] ENH: snappyHexMesh: multiple locationsInMesh, layers on faceZones --- .../generation/snappyHexMesh/snappyHexMesh.C | 146 +- .../snappyHexMesh/snappyHexMeshDict | 119 +- .../autoHexMeshDriver/autoLayerDriver.C | 1480 ++++++---- .../autoHexMeshDriver/autoLayerDriver.H | 21 +- .../autoHexMeshDriver/autoRefineDriver.C | 166 +- .../autoHexMeshDriver/autoRefineDriver.H | 23 +- .../autoHexMeshDriver/autoSnapDriver.C | 773 ++---- .../autoHexMeshDriver/autoSnapDriver.H | 141 +- .../autoHexMeshDriver/autoSnapDriverFeature.C | 903 ++++-- .../layerParameters/layerParameters.C | 8 + .../layerParameters/layerParameters.H | 7 + .../refinementParameters.C | 161 +- .../refinementParameters.H | 61 +- .../refinementParameters/wordPairHashTable.H | 56 + .../snapParameters/snapParameters.C | 14 +- .../snapParameters/snapParameters.H | 108 +- .../medialAxisMeshMover.C | 47 +- .../meshRefinement/meshRefinement.C | 1272 ++++----- .../meshRefinement/meshRefinement.H | 191 +- .../meshRefinement/meshRefinementBaffles.C | 2431 +++++++++++------ .../meshRefinement/meshRefinementMerge.C | 215 +- .../refinementSurfaces/surfaceZonesInfo.C | 121 +- .../refinementSurfaces/surfaceZonesInfo.H | 18 +- 23 files changed, 5641 insertions(+), 2841 deletions(-) create mode 100644 src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/refinementParameters/wordPairHashTable.H diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C index d7eeb9185b..d085c34f3b 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMesh.C @@ -1121,6 +1121,38 @@ int main(int argc, char *argv[]) ); + // Refinement parameters + const refinementParameters refineParams(refineDict); + + // Snap parameters + const snapParameters snapParams(snapDict); + + + + // Add all the cellZones and faceZones + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // 1. cellZones relating to surface (faceZones added later) + + const labelList namedSurfaces + ( + surfaceZonesInfo::getNamedSurfaces(surfaces.surfZones()) + ); + + labelList surfaceToCellZone = surfaceZonesInfo::addCellZonesToMesh + ( + surfaces.surfZones(), + namedSurfaces, + mesh + ); + + + // 2. cellZones relating to locations + + refineParams.addCellZonesToMesh(mesh); + + + // Add all the surface regions as patches // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -1128,6 +1160,8 @@ int main(int argc, char *argv[]) // (faceZone surfaces) labelList globalToMasterPatch; labelList globalToSlavePatch; + + { Info<< nl << "Adding patches for surface regions" << nl @@ -1148,6 +1182,7 @@ int main(int argc, char *argv[]) const labelList& surfaceGeometry = surfaces.surfaces(); const PtrList& surfacePatchInfo = surfaces.patchInfo(); + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); forAll(surfaceGeometry, surfI) { @@ -1157,7 +1192,9 @@ int main(int argc, char *argv[]) Info<< surfaces.names()[surfI] << ':' << nl << nl; - if (surfaces.surfZones()[surfI].faceZoneName().empty()) + const word& fzName = surfaces.surfZones()[surfI].faceZoneName(); + + if (fzName.empty()) { // 'Normal' surface forAll(regNames, i) @@ -1188,7 +1225,7 @@ int main(int argc, char *argv[]) Info<< setf(ios_base::left) << setw(6) << patchI - << setw(20) << mesh.boundaryMesh()[patchI].type() + << setw(20) << pbm[patchI].type() << setw(30) << regNames[i] << nl; globalToMasterPatch[globalRegionI] = patchI; @@ -1228,7 +1265,7 @@ int main(int argc, char *argv[]) Info<< setf(ios_base::left) << setw(6) << patchI - << setw(20) << mesh.boundaryMesh()[patchI].type() + << setw(20) << pbm[patchI].type() << setw(30) << regNames[i] << nl; globalToMasterPatch[globalRegionI] = patchI; @@ -1260,12 +1297,27 @@ int main(int argc, char *argv[]) Info<< setf(ios_base::left) << setw(6) << patchI - << setw(20) << mesh.boundaryMesh()[patchI].type() + << setw(20) << pbm[patchI].type() << setw(30) << slaveName << nl; globalToSlavePatch[globalRegionI] = patchI; } } + + // For now: have single faceZone per surface. Use first + // region in surface for patch for zoneing + if (regNames.size()) + { + label globalRegionI = surfaces.globalRegion(surfI, 0); + + meshRefiner.addFaceZone + ( + fzName, + pbm[globalToMasterPatch[globalRegionI]].name(), + pbm[globalToSlavePatch[globalRegionI]].name(), + surfaces.surfZones()[surfI].faceType() + ); + } } Info<< nl; @@ -1275,6 +1327,73 @@ int main(int argc, char *argv[]) } + + // Add all information for all the remaining faceZones + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + wordPairHashTable zonesToFaceZone; + forAll(mesh.faceZones(), zoneI) + { + const word& fzName = mesh.faceZones()[zoneI].name(); + + label mpI, spI; + surfaceZonesInfo::faceZoneType fzType; + bool hasInfo = meshRefiner.getFaceZoneInfo(fzName, mpI, spI, fzType); + + if (!hasInfo) + { + // faceZone does not originate from a surface but presumably + // from a cellZone pair instead + string::size_type i = fzName.find("_to_"); + if (i != string::npos) + { + word cz0 = fzName.substr(0, i); + word cz1 = fzName.substr(i+4, fzName.size()-i+4); + zonesToFaceZone.insert(Pair(cz0, cz1), fzName); + } + } + } + + if (zonesToFaceZone.size()) + { + autoRefineDriver::addFaceZones + ( + meshRefiner, + refineParams, + zonesToFaceZone + ); + } + + + + // Re-do intersections on meshed boundaries since they use an extrapolated + // other side + { + const labelList adaptPatchIDs(meshRefiner.meshedPatches()); + + const polyBoundaryMesh& pbm = mesh.boundaryMesh(); + + label nFaces = 0; + forAll(adaptPatchIDs, i) + { + nFaces += pbm[adaptPatchIDs[i]].size(); + } + + labelList faceLabels(nFaces); + nFaces = 0; + forAll(adaptPatchIDs, i) + { + const polyPatch& pp = pbm[adaptPatchIDs[i]]; + forAll(pp, i) + { + faceLabels[nFaces++] = pp.start()+i; + } + } + meshRefiner.updateIntersections(faceLabels); + } + + + // Parallel // ~~~~~~~~ @@ -1312,14 +1431,13 @@ int main(int argc, char *argv[]) const Switch wantSnap(meshDict.lookup("snap")); const Switch wantLayers(meshDict.lookup("addLayers")); - // Refinement parameters - const refinementParameters refineParams(refineDict); + const Switch keepHex(meshDict.lookupOrDefault("keepHex", false)); - // Snap parameters - const snapParameters snapParams(snapDict); - - // Layer addition parameters - const layerParameters layerParams(layerDict, mesh.boundaryMesh()); + if (keepHex) + { + Info<< "Avoiding generating non-(split)hex cells." << nl + << endl; + } if (wantRefine) @@ -1348,6 +1466,7 @@ int main(int argc, char *argv[]) refineParams, snapParams, refineParams.handleSnapProblems(), + keepHex, // keepHex motionDict ); @@ -1387,6 +1506,7 @@ int main(int argc, char *argv[]) ( snapDict, motionDict, + !keepHex, // mergePatchFaces curvature, planarAngle, snapParams @@ -1408,6 +1528,9 @@ int main(int argc, char *argv[]) { cpuTime timer; + // Layer addition parameters + const layerParameters layerParams(layerDict, mesh.boundaryMesh()); + autoLayerDriver layerDriver ( meshRefiner, @@ -1433,6 +1556,7 @@ int main(int argc, char *argv[]) layerDict, motionDict, layerParams, + !keepHex, //mergePatchFaces preBalance, decomposer, distributor diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 49958bb34f..39e975a6dd 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -71,6 +71,12 @@ geometry } }; + +// Optional: avoid patch-face merging. Allows mesh to be used for +// refinement/unrefinement +//keepHex true; + + // Settings for the castellatedMesh generation. castellatedMeshControls { @@ -177,7 +183,7 @@ castellatedMeshControls // how to select the cells that are in the cellZone // (inside / outside / specified insidePoint) // The orientation of the faceZone is - // - if on cellZone(s) : point out of (maximum) cellZone + // - if on cellZone(s) : point out of (minimum) cellZone // - if freestanding : oriented according to surface //faceZone sphere; @@ -249,17 +255,70 @@ castellatedMeshControls // After refinement patches get added for all refinementSurfaces and // all cells intersecting the surfaces get put into these patches. The - // section reachable from the locationInMesh is kept. + // section reachable from the location(s)InMesh is kept. // NOTE: This point should never be on a face, always inside a cell, even // after refinement. - locationInMesh (5 0.28 0.43); + // + // There are two different ways of specifying the regions to keep: + // 1. a single locationInMesh. All the 'zoned' surfaces are marked as such + // in the refinementSurfaces with the faceZone and cellZone keywords. + // + // or + // + // 2. multiple locationsInMesh, with per location the name of the cellZone. + // This uses walking to determine zones and automatically creates + // faceZones on the outside of cellZones. - // Whether any faceZones (as specified in the refinementSurfaces) - // are only on the boundary of corresponding cellZones or also allow - // free-standing zone faces and zone faces on boundaries. Not used if - // there are no faceZones. - allowFreeStandingZoneFaces true; + // Ad 1. Specify a single location and how to treat faces inbetween + // cellZones + locationInMesh (5 0.28 0.43); + + // Whether any faceZones (as specified in the refinementSurfaces) + // are only on the boundary of corresponding cellZones or also allow + // free-standing zone faces. Not used if there are no faceZones. + allowFreeStandingZoneFaces true; + + + + // 2. Specify multiple locations with optional cellZones for the + // regions. faceZones are automatically constructed from the + // names of the cellZones: _to_ + // where the cellZoneA is the lowest numbered cellZone (non-cellZone + // cells are in a special region called "none" which is always + // last). + + locationsInMesh + ( + ((-0.09 -0.039 -0.049) bottomAir) // cellZone 0 + ((-0.09 0.009 -0.049) topAir) // cellZone 1 + ((-0.09 0.001 -0.049) leftSolid) // cellZone 2 + ((0.02 0.001 -0.049) rightSolid) // cellZone 3 + ((-0.001 -0.039 0.0015) heater) // cellZone 4 + ); + + // Per synthesised faceZone name the faceType and type of baffles to + // create + faceZoneControls + { + bottomAir_to_heater + { + // Optional specification of patch type (default is wall). No + // constraint types (cyclic, symmetry) etc. are allowed. + patchInfo + { + type patch; + inGroups (patchPatches); + } + faceType baffle; + } + } + + + + // Optional locations that should not be reachable from + // location(s)InMesh + locationsOutsideMesh ((100 100 100)); // Optional: do not remove cells likely to give snapping problems // handleSnapProblems false; @@ -288,6 +347,11 @@ snapControls // before upon reaching a correct mesh. nRelaxIter 5; + // (wip) disable snapping to opposite near surfaces (revert to 22x + // behaviour) + // detectNearSurfacesSnap false; + + // Feature snapping // Number of feature edge snapping iterations. @@ -306,8 +370,28 @@ snapControls multiRegionFeatureSnap false; - // wip: disable snapping to opposite near surfaces (revert to 22x behaviour) - // detectNearSurfacesSnap false; + //- When to run face splitting (never at first iteration, always + // at last iteration). Is interval. Default -1 (disabled) + //nFaceSplitInterval 5; + + + // (wip) Optional for explicit feature snapping: + //- Detect baffle edges. Default is true. + //detectBaffles false; + //- Erase attraction close to feature point. Default is false. + //releasePoints true; + //- Walk along feature edges, adding missing ones. Default is true. + //stringFeatures false; + //- If diagonal attraction also attract other face points. Default is + // false + //avoidDiagonal true; + //- When splitting what concave faces to leave intact. Default is 45 + // degrees. + //concaveAngle 30; + //- When splitting the minimum area ratio of faces. If face split + // causes ratio of area less than this do not split. Default is 0.3 + //minAreaRatio 0.3; + } // Settings for the layer addition. @@ -348,7 +432,7 @@ addLayersControls // cannot be above minThickness do not add layer. // If relativeSizes this is relative to undistorted size of cell // outside layer.. - minThickness 0.25; + minThickness 0.1; // Per final patch (so not geometry!) the layer information @@ -395,6 +479,13 @@ addLayersControls // are perpendicular featureAngle 130; + // When to merge patch faces. Default is 0.5*featureAngle + //mergePatchFacesAngle 45; + + // Do not extrude around sharp edge if not both faces are extruded. + // Default is 0.5*featureAngle. Set to -180 always attempt extrusion + layerTerminationAngle -180; + // Stop layer growth on highly warped cells maxFaceThicknessRatio 0.5; @@ -431,8 +522,10 @@ addLayersControls // default is 0. //nSmoothDisplacement 90; - // (wip)Optional: do not extrude a point if none of the surrounding points is - // not extruded. Default is false. + // (wip)Optional: do not extrude any point where + // (false) : all surrounding faces are not fully extruded + // (true) : all surrounding points are not extruded + // Default is false. //detectExtrusionIsland true; diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 08c8f7e530..b8bf5af1d8 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -2418,6 +2418,67 @@ Foam::label Foam::autoLayerDriver::countExtrusion } +Foam::List Foam::autoLayerDriver::getBafflesOnAddedMesh +( + const polyMesh& mesh, + const labelList& newToOldFaces, + const List& baffles +) +{ + // The problem is that the baffle faces are now inside the + // mesh (addPatchCellLayer modifies original boundary faces and + // adds new ones. So 2 pass: + // - find the boundary face for all faces originating from baffle + // - use the boundary face for the new baffles + + Map