From 48e88528c47eaf8db87f3e8d44ee97d962182c28 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 2 Oct 2014 13:28:55 +0400 Subject: [PATCH] Regressions 2D_mesh_NETGEN_03/D2 bugs_05/F2 bugs_16/S8 --- src/GUI/NETGENPlugin_images.ts | 4 ++ .../NETGENPlugin_NETGEN_2D_ONLY.cxx | 45 ++++++++++++++++++- src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx | 38 ++++++++++++++++ 3 files changed, 85 insertions(+), 2 deletions(-) diff --git a/src/GUI/NETGENPlugin_images.ts b/src/GUI/NETGENPlugin_images.ts index 1f9a4e2..a399bc6 100644 --- a/src/GUI/NETGENPlugin_images.ts +++ b/src/GUI/NETGENPlugin_images.ts @@ -39,6 +39,10 @@ ICON_SMESH_TREE_HYPO_NETGEN_Parameters mesh_tree_hypo_netgen.png + + ICON_SMESH_TREE_HYPO_NETGEN_Parameters_3D + mesh_tree_hypo_netgen.png + ICON_SMESH_TREE_HYPO_NETGEN_Parameters_2D mesh_tree_hypo_netgen_2d.png diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index 8795625..d2b6d16 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -184,6 +184,42 @@ bool NETGENPlugin_NETGEN_2D_ONLY::CheckHypothesis (SMESH_Mesh& aMesh, return ( aStatus == HYP_OK ); } +namespace +{ + void limitSize( netgen::Mesh* ngMesh, + const double maxh ) + { + // get bnd box + netgen::Point3d pmin, pmax; + ngMesh->GetBox( pmin, pmax, 0 ); + const double dx = pmax.X() - pmin.X(); + const double dy = pmax.Y() - pmin.Y(); + const double dz = pmax.Z() - pmin.Z(); + + const int nbX = Max( 2, int( dx / maxh * 3 )); + const int nbY = Max( 2, int( dy / maxh * 3 )); + const int nbZ = Max( 2, int( dz / maxh * 3 )); + + if ( ! & ngMesh->LocalHFunction() ) + ngMesh->SetLocalH( pmin, pmax, 0.1 ); + + netgen::Point3d p; + for ( int i = 0; i <= nbX; ++i ) + { + p.X() = pmin.X() + i * dx / nbX; + for ( int j = 0; j <= nbY; ++j ) + { + p.Y() = pmin.Y() + j * dy / nbY; + for ( int k = 0; k <= nbZ; ++k ) + { + p.Z() = pmin.Z() + k * dz / nbZ; + ngMesh->RestrictLocalH( p, maxh ); + } + } + } + } +} + //============================================================================= /*! *Here we are going to use the NETGEN mesher @@ -227,9 +263,11 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, { netgen::mparam.maxh = sqrt( 2. * _hypMaxElementArea->GetMaxArea() / sqrt(3.0) ); } + if ( _hypQuadranglePreference ) + netgen::mparam.quad = true; // local size is common for all FACEs in aShape? - const bool isCommonLocalSize = ( !_hypLengthFromEdges && netgen::mparam.uselocalh ); + const bool isCommonLocalSize = ( !_hypLengthFromEdges && !_hypMaxElementArea && netgen::mparam.uselocalh ); const bool isDefaultHyp = ( !_hypLengthFromEdges && !_hypMaxElementArea && !_hypParameters ); if ( isCommonLocalSize ) // compute common local size in ngMeshes[0] @@ -241,7 +279,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, // minh, face_maxh, grading and curvaturesafety; find minh if not set by the user if ( !_hypParameters || netgen::mparam.minh < DBL_MIN ) { - if ( !_hypMaxElementArea ) + if ( !_hypParameters ) netgen::mparam.maxh = occgeoComm.GetBoundingBox().Diam() / 3.; netgen::mparam.minh = aMesher.GetDefaultMinSize( aShape, netgen::mparam.maxh ); } @@ -417,6 +455,9 @@ bool NETGENPlugin_NETGEN_2D_ONLY::Compute(SMESH_Mesh& aMesh, if ( faceErr && !faceErr->IsOK() ) break; + //if ( !isCommonLocalSize ) + //limitSize( ngMesh, mparam.maxh * 0.8); + // ------------------------- // Generate surface mesh // ------------------------- diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx index 1a5ad5c..9137887 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx @@ -339,6 +339,43 @@ bool NETGENPlugin_NETGEN_3D::Compute(SMESH_Mesh& aMesh, return ( ngLib._isComputeOk = compute( aMesh, helper, nodeVec, Netgen_mesh)); } +namespace +{ + void limitVolumeSize( netgen::Mesh* ngMesh, + const double maxh ) + { + // get bnd box + netgen::Point3d pmin, pmax; + ngMesh->GetBox( pmin, pmax, 0 ); + const double dx = pmax.X() - pmin.X(); + const double dy = pmax.Y() - pmin.Y(); + const double dz = pmax.Z() - pmin.Z(); + + // adjusted by SALOME_TESTS/Grids/smesh/bugs_08/I8 + const int nbX = Max( 2, int( dx / maxh * 2 )); + const int nbY = Max( 2, int( dy / maxh * 2 )); + const int nbZ = Max( 2, int( dz / maxh * 2 )); + + if ( ! & ngMesh->LocalHFunction() ) + ngMesh->SetLocalH( pmin, pmax, 0.1 ); + + netgen::Point3d p; + for ( int i = 0; i <= nbX; ++i ) + { + p.X() = pmin.X() + i * dx / nbX; + for ( int j = 0; j <= nbY; ++j ) + { + p.Y() = pmin.Y() + j * dy / nbY; + for ( int k = 0; k <= nbZ; ++k ) + { + p.Z() = pmin.Z() + k * dz / nbZ; + ngMesh->RestrictLocalH( p, maxh ); + } + } + } + } +} + //================================================================================ /*! * \brief set parameters and generate the volume mesh @@ -374,6 +411,7 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh, else if ( _hypMaxElementVolume ) { netgen::mparam.maxh = pow( 72, 1/6. ) * pow( _maxElementVolume, 1/3. ); + limitVolumeSize( ngMesh, netgen::mparam.maxh * 0.8 ); } else if ( aMesh.HasShapeToMesh() ) { -- 2.39.2