diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 4bef1736f0..050204d8a8 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -226,37 +226,37 @@ castellatedMeshControls // Settings for the snapping. snapControls { - //- Number of patch smoothing iterations before finding correspondence - // to surface + // Number of patch smoothing iterations before finding correspondence + // to surface nSmoothPatch 3; - //- Maximum relative distance for points to be attracted by surface. - // True distance is this factor times local maximum edge length. + // Maximum relative distance for points to be attracted by surface. + // True distance is this factor times local maximum edge length. // Note: changed(corrected) w.r.t 17x! (17x used 2* tolerance) tolerance 2.0; - //- Number of mesh displacement relaxation iterations. + // Number of mesh displacement relaxation iterations. nSolveIter 30; - //- Maximum number of snapping relaxation iterations. Should stop - // before upon reaching a correct mesh. + // Maximum number of snapping relaxation iterations. Should stop + // before upon reaching a correct mesh. nRelaxIter 5; // Feature snapping - //- Number of feature edge snapping iterations. - // Leave out altogether to disable. + // Number of feature edge snapping iterations. + // Leave out altogether to disable. nFeatureSnapIter 10; - //- Detect (geometric only) features by sampling the surface - // (default=false). + // Detect (geometric only) features by sampling the surface + // (default=false). implicitFeatureSnap false; - //- Use castellatedMeshControls::features (default = true) + // Use castellatedMeshControls::features (default = true) explicitFeatureSnap true; - //- Detect features between multiple surfaces - // (only for explicitFeatureSnap, default = false) + // Detect features between multiple surfaces + // (only for explicitFeatureSnap, default = false) multiRegionFeatureSnap false; } @@ -267,9 +267,43 @@ 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 + // - expansionRatio and finalLayerThickness (cell nearest internal mesh) + // - expansionRatio and firstLayerThickness (cell on surface) + // - overall thickness and firstLayerThickness + // - overall thickness and finalLayerThickness + + // Expansion factor for layer mesh + expansionRatio 1.0; + + // Wanted thickness of the layer furthest away from the wall. + // If relativeSizes this is relative to undistorted size of cell + // outside layer. + finalLayerThickness 0.3; + + // Wanted thickness of the layer next to the wall. + // If relativeSizes this is relative to undistorted size of cell + // outside layer. + //firstLayerThickness 0.3; + + // Wanted overall thickness of layers. + // If relativeSizes this is relative to undistorted size of cell + // outside layer. + //thickness 0.5 + + + // Minimum overall thickness of total layers. If for any reason layer + // cannot be above minThickness do not add layer. + // If relativeSizes this is relative to undistorted size of cell + // outside layer.. + minThickness 0.25; + + // Per final patch (so not geometry!) the layer information // Note: This behaviour changed after 21x. Any non-mentioned patches - // now slide unless nSurfaceLayers is explicitly mentioned to be 0. + // now slide unless: + // - nSurfaceLayers is explicitly mentioned to be 0. + // - angle to nearest surface < slipFeatureAngle (see below) layers { sphere.stl_firstSolid @@ -281,9 +315,9 @@ addLayersControls { nSurfaceLayers 1; // Per patch layer data - expansionRatio 1.3; + expansionRatio 1.3; finalLayerThickness 0.3; - minThickness 0.1; + minThickness 0.1; } // Disable any mesh shrinking and layer addition on any point of @@ -294,41 +328,24 @@ addLayersControls } } - // Expansion factor for layer mesh - expansionRatio 1.0; - - //- Wanted thickness of final added cell layer. If multiple layers - // is the - // thickness of the layer furthest away from the wall. - // Relative to undistorted size of cell outside layer. - // is the thickness of the layer furthest away from the wall. - // See relativeSizes parameter. - finalLayerThickness 0.3; - - //- Minimum thickness of cell layer. If for any reason layer - // cannot be above minThickness do not add layer. - // Relative to undistorted size of cell outside layer. - // See relativeSizes parameter. - minThickness 0.25; - - //- If points get not extruded do nGrow layers of connected faces that are - // also not grown. This helps convergence of the layer addition process - // close to features. + // If points get not extruded do nGrow layers of connected faces that are + // also not grown. This helps convergence of the layer addition process + // close to features. // Note: changed(corrected) w.r.t 17x! (didn't do anything in 17x) nGrow 0; // Advanced settings - //- When not to extrude surface. 0 is flat surface, 90 is when two faces - // make straight angle. + // When not to extrude surface. 0 is flat surface, 90 is when two faces + // make straight angle. featureAngle 60; - //- At non-patched sides allow mesh to slip if extrusion direction makes - // angle larger than slipFeatureAngle. + // At non-patched sides allow mesh to slip if extrusion direction makes + // angle larger than slipFeatureAngle. slipFeatureAngle 30; - //- Maximum number of snapping relaxation iterations. Should stop - // before upon reaching a correct mesh. + // Maximum number of snapping relaxation iterations. Should stop + // before upon reaching a correct mesh. nRelaxIter 5; // Number of smoothing iterations of surface normals @@ -374,51 +391,51 @@ addLayersControls // where to undo. meshQualityControls { - //- Maximum non-orthogonality allowed. Set to 180 to disable. + // Maximum non-orthogonality allowed. Set to 180 to disable. maxNonOrtho 65; - //- Max skewness allowed. Set to <0 to disable. + // Max skewness allowed. Set to <0 to disable. maxBoundarySkewness 20; maxInternalSkewness 4; - //- Max concaveness allowed. Is angle (in degrees) below which concavity - // is allowed. 0 is straight face, <0 would be convex face. - // Set to 180 to disable. + // Max concaveness allowed. Is angle (in degrees) below which concavity + // is allowed. 0 is straight face, <0 would be convex face. + // Set to 180 to disable. maxConcave 80; - //- Minimum pyramid volume. Is absolute volume of cell pyramid. - // Set to a sensible fraction of the smallest cell volume expected. - // Set to very negative number (e.g. -1E30) to disable. + // Minimum pyramid volume. Is absolute volume of cell pyramid. + // Set to a sensible fraction of the smallest cell volume expected. + // Set to very negative number (e.g. -1E30) to disable. minVol 1e-13; - //- Minimum quality of the tet formed by the face-centre - // and variable base point minimum decomposition triangles and - // the cell centre. This has to be a positive number for tracking - // to work. Set to very negative number (e.g. -1E30) to - // disable. - // <0 = inside out tet, - // 0 = flat tet - // 1 = regular tet + // Minimum quality of the tet formed by the face-centre + // and variable base point minimum decomposition triangles and + // the cell centre. This has to be a positive number for tracking + // to work. Set to very negative number (e.g. -1E30) to + // disable. + // <0 = inside out tet, + // 0 = flat tet + // 1 = regular tet minTetQuality 1e-9; - //- Minimum face area. Set to <0 to disable. + // Minimum face area. Set to <0 to disable. minArea -1; - //- Minimum face twist. Set to <-1 to disable. dot product of face normal - //- and face centre triangles normal + // Minimum face twist. Set to <-1 to disable. dot product of face normal + // and face centre triangles normal minTwist 0.05; - //- minimum normalised cell determinant - //- 1 = hex, <= 0 = folded or flattened illegal cell + // minimum normalised cell determinant + // 1 = hex, <= 0 = folded or flattened illegal cell minDeterminant 0.001; - //- minFaceWeight (0 -> 0.5) + // minFaceWeight (0 -> 0.5) minFaceWeight 0.05; - //- minVolRatio (0 -> 1) + // minVolRatio (0 -> 1) minVolRatio 0.01; - //must be >0 for Fluent compatibility + // must be >0 for Fluent compatibility minTriangleTwist -1; //- if >0 : preserve single cells with all points on the surface if the @@ -429,9 +446,9 @@ meshQualityControls // Advanced - //- Number of error distribution iterations + // Number of error distribution iterations nSmoothScale 4; - //- amount to scale back displacement at error points + // amount to scale back displacement at error points errorReduction 0.75; // Optional : some meshing phases allow usage of relaxed rules. diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C index 2da0382671..b08cccbb85 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.C @@ -318,7 +318,6 @@ void Foam::autoLayerDriver::handleNonManifolds } } - Info<< "Set displacement to zero for all " << nNonManif << " non-manifold points" << endl; } @@ -443,86 +442,6 @@ void Foam::autoLayerDriver::handleFeatureAngle } -//Foam::tmp Foam::autoLayerDriver::undistortedEdgeLength -//( -// const indirectPrimitivePatch& pp, -// const bool relativeSizes, -// const bool faceSize -//) -//{ -// const fvMesh& mesh = meshRefiner_.mesh(); -// -// tmp tfld(new scalarField()); -// scalarField& fld = tfld(); -// -// if (faceSize) -// { -// fld.setSize(pp.size()); -// } -// else -// { -// fld.setSize(pp.nPoints()); -// } -// -// -// if (relativeSizes) -// { -// const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength(); -// const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel(); -// -// if (faceSize) -// { -// forAll(pp, i) -// { -// label faceI = pp.addressing()[i]; -// label ownLevel = cellLevel[mesh.faceOwner()[faceI]]; -// fld[i] = edge0Len/(1<(), -// labelMin // null value -// ); -// -// -// forAll(maxPointLevel, pointI) -// { -// // Find undistorted edge size for this level. -// fld[i] = edge0Len/(1<(), GREAT // null value ); @@ -1160,7 +1074,23 @@ void Foam::autoLayerDriver::calculateLayerThickness ( mesh, pp.meshPoints(), - thickness, + finalLayerThickness, + minEqOp(), + GREAT // null value + ); + syncTools::syncPointList + ( + mesh, + pp.meshPoints(), + totalThickness, + minEqOp(), + GREAT // null value + ); + syncTools::syncPointList + ( + mesh, + pp.meshPoints(), + expRatio, minEqOp(), GREAT // null value ); @@ -1182,14 +1112,18 @@ void Foam::autoLayerDriver::calculateLayerThickness // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // by multiplying with the internal cell size. - if (relativeSizes) + if (layerParams.relativeSizes()) { - if (min(patchMinThickness) < 0 || max(patchMinThickness) > 2) + if + ( + min(layerParams.minThickness()) < 0 + || max(layerParams.minThickness()) > 2 + ) { FatalErrorIn("calculateLayerThickness(..)") << "Thickness should be factor of local undistorted cell size." << " Valid values are [0..2]." << nl - << " minThickness:" << patchMinThickness + << " minThickness:" << layerParams.minThickness() << exit(FatalError); } @@ -1225,38 +1159,114 @@ void Foam::autoLayerDriver::calculateLayerThickness { // Find undistorted edge size for this level. scalar edgeLen = edge0Len/(1<()); + + // For empty patches, totNPoints is 0. + scalar avgThickness = 0; + scalar avgNearWallThickness = 0; + + if (totNPoints > 0) + { + avgThickness = + returnReduce(sumThickness, sumOp()) + / totNPoints; + avgNearWallThickness = + returnReduce(sumNearWallThickness, sumOp()) + / totNPoints; + } + + Info<< setf(ios_base::left) << setw(maxPatchNameLen) + << patches[patchI].name() << setprecision(3) + << " " << setw(8) + << returnReduce(patches[patchI].size(), sumOp()) + << " " << setw(6) << layerParams.numLayers()[patchI] + << " " << setw(8) << avgNearWallThickness + << " " << setw(8) << avgThickness + << endl; + } + Info<< endl; + } } @@ -2618,7 +2628,8 @@ void Foam::autoLayerDriver::addLayers const scalar edge0Len = meshRefiner_.meshCutter().level0EdgeLength(); const labelList& cellLevel = meshRefiner_.meshCutter().cellLevel(); - // Determine (wanted) point-wise layer thickness and expansion ratio + // Determine (wanted) point-wise overall layer thickness and expansion + // ratio scalarField thickness(pp().nPoints()); scalarField minThickness(pp().nPoints()); scalarField expansionRatio(pp().nPoints()); @@ -2626,12 +2637,7 @@ void Foam::autoLayerDriver::addLayers ( pp, meshMover().adaptPatchIDs(), - layerParams.expansionRatio(), - - layerParams.relativeSizes(), // thickness relative to cellsize? - layerParams.finalLayerThickness(), // wanted thicknes - layerParams.minThickness(), // minimum thickness - + layerParams, cellLevel, patchNLayers, edge0Len, @@ -2642,87 +2648,6 @@ void Foam::autoLayerDriver::addLayers ); - // Print a bit - { - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - // Find maximum length of a patch name, for a nicer output - label maxPatchNameLen = 0; - forAll(meshMover().adaptPatchIDs(), i) - { - label patchI = meshMover().adaptPatchIDs()[i]; - word patchName = patches[patchI].name(); - maxPatchNameLen = max(maxPatchNameLen, label(patchName.size())); - } - - Info<< nl - << setf(ios_base::left) << setw(maxPatchNameLen) << "patch" - << setw(0) << " faces layers avg thickness[m]" << nl - << setf(ios_base::left) << setw(maxPatchNameLen) << " " - << setw(0) << " near-wall overall" << nl - << setf(ios_base::left) << setw(maxPatchNameLen) << "-----" - << setw(0) << " ----- ------ --------- -------" << endl; - - forAll(meshMover().adaptPatchIDs(), i) - { - label patchI = meshMover().adaptPatchIDs()[i]; - - const labelList& meshPoints = patches[patchI].meshPoints(); - - scalar sumThickness = 0; - scalar sumNearWallThickness = 0; - - forAll(meshPoints, patchPointI) - { - label ppPointI = pp().meshPointMap()[meshPoints[patchPointI]]; - - sumThickness += thickness[ppPointI]; - - label nLay = patchNLayers[ppPointI]; - if (nLay > 0) - { - if (expansionRatio[ppPointI] == 1) - { - sumNearWallThickness += thickness[ppPointI]/nLay; - } - else - { - scalar s = - (1.0-pow(expansionRatio[ppPointI], nLay)) - / (1.0-expansionRatio[ppPointI]); - sumNearWallThickness += thickness[ppPointI]/s; - } - } - } - - label totNPoints = returnReduce(meshPoints.size(), sumOp