Salome HOME
Regression of SALOME_TESTS/Grids/smesh/viscous_layers_01/B2
authoreap <eap@opencascade.com>
Wed, 11 May 2016 13:59:07 +0000 (16:59 +0300)
committereap <eap@opencascade.com>
Wed, 11 May 2016 13:59:07 +0000 (16:59 +0300)
This modif allows re-meshing a face on which _ViscousBuilder::shrink() fails

src/NETGENPlugin/NETGENPlugin_Hypothesis_i.cxx
src/NETGENPlugin/NETGENPlugin_Mesher.cxx
src/NETGENPlugin/NETGENPlugin_Mesher.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_i.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D_i.cxx
src/NETGENPlugin/NETGENPlugin_i.cxx

index 2f220f066c3a14b77d27547ac30eadc8a93b26e6..26048f7753f1b0489e69d415bc00d4a8c6e0698e 100644 (file)
@@ -65,7 +65,6 @@ NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
     SMESH_Hypothesis_i( thePOA ),
     mySetMethodFlags(0)
 {
-  MESSAGE( "NETGENPlugin_Hypothesis_i::NETGENPlugin_Hypothesis_i" );
   myBaseImpl = new ::NETGENPlugin_Hypothesis (theGenImpl->GetANewId(),
                                               theStudyId,
                                               theGenImpl);
@@ -80,7 +79,6 @@ NETGENPlugin_Hypothesis_i (PortableServer::POA_ptr thePOA,
 //=============================================================================
 NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i()
 {
-  MESSAGE( "NETGENPlugin_Hypothesis_i::~NETGENPlugin_Hypothesis_i" );
 }
 
 //=============================================================================
index 680fd9f01afc600912f89f621a966db714299b96..0970b1e87bee1a89054d4acd446112e7558147f0 100644 (file)
@@ -572,9 +572,6 @@ void NETGENPlugin_Mesher::PrepareOCCgeometry(netgen::OCCGeometry&     occgeo,
   BRepBndLib::Add (shape, bb);
   double x1,y1,z1,x2,y2,z2;
   bb.Get (x1,y1,z1,x2,y2,z2);
-  MESSAGE("shape bounding box:\n" <<
-          "(" << x1 << " " << y1 << " " << z1 << ") " <<
-          "(" << x2 << " " << y2 << " " << z2 << ")");
   netgen::Point<3> p1 = netgen::Point<3> (x1,y1,z1);
   netgen::Point<3> p2 = netgen::Point<3> (x2,y2,z2);
   occgeo.boundingbox = netgen::Box<3> (p1,p2);
@@ -1824,7 +1821,7 @@ NETGENPlugin_Mesher::AddSegmentsToMesh(netgen::Mesh&                    ngMesh,
     int edgeID = 1, posID = -2;
     bool isInternalWire = false;
     double vertexNormPar = 0;
-    //const int prevNbNGSeg = ngMesh.GetNSeg();
+    const int prevNbNGSeg = ngMesh.GetNSeg();
     for ( int i = 0; i < nbSegments; ++i ) // loop on segments
     {
       // Add the first point of a segment
@@ -1962,6 +1959,8 @@ NETGENPlugin_Mesher::AddSegmentsToMesh(netgen::Mesh&                    ngMesh,
            << "\tp1 edge: " << seg.epgeominfo[ 1 ].edgenr << endl;
     }
     cout << "--END WIRE " << iW << endl;
+#else
+    SMESH_Comment __not_unused_variable( prevNbNGSeg );
 #endif
 
   } // loop on WIREs of a FACE
@@ -2708,7 +2707,8 @@ bool NETGENPlugin_Mesher::Compute()
       }
 
       // Build viscous layers
-      if ( _isViscousLayers2D )
+      if ( _isViscousLayers2D ||
+           StdMeshers_ViscousLayers2D::HasProxyMesh( TopoDS::Face( occgeo.fmap(1) ), *_mesh ))
       {
         if ( !internals.hasInternalVertexInFace() ) {
           FillSMesh( occgeo, *_ngMesh, initState, *_mesh, nodeVec, comment );
@@ -2722,6 +2722,8 @@ bool NETGENPlugin_Mesher::Compute()
           viscousMesh = StdMeshers_ViscousLayers2D::Compute( *_mesh, F );
           if ( !viscousMesh )
             return false;
+          if ( viscousMesh->NbProxySubMeshes() == 0 )
+            continue;
           // exclude from computation ng segments built on EDGEs of F
           for (int i = 1; i <= _ngMesh->GetNSeg(); i++)
           {
@@ -2951,12 +2953,6 @@ bool NETGENPlugin_Mesher::Compute()
   int nbVol = _ngMesh->GetNE();
   bool isOK = ( !err && (_isVolume ? (nbVol > 0) : (nbFac > 0)) );
 
-  MESSAGE((err ? "Mesh Generation failure" : "End of Mesh Generation") <<
-          ", nb nodes: "    << nbNod <<
-          ", nb segments: " << nbSeg <<
-          ", nb faces: "    << nbFac <<
-          ", nb volumes: "  << nbVol);
-
   // Feed back the SMESHDS with the generated Nodes and Elements
   if ( true /*isOK*/ ) // get whatever built
   {
@@ -3372,26 +3368,6 @@ double NETGENPlugin_Mesher::GetProgress(const SMESH_Algo* holder,
   return Min( progress, 0.99 );
 }
 
-//================================================================================
-/*!
- * \brief Remove "test.out" and "problemfaces" files in current directory
- */
-//================================================================================
-
-void NETGENPlugin_Mesher::RemoveTmpFiles()
-{
-  bool rm =  SMESH_File("test.out").remove() ;
-#ifndef WIN32
-  if (rm && netgen::testout)
-  {
-    delete netgen::testout;
-    netgen::testout = 0;
-  }
-#endif
-  SMESH_File("problemfaces").remove();
-  SMESH_File("occmesh.rep").remove();
-}
-
 //================================================================================
 /*!
  * \brief Read mesh entities preventing successful computation from "test.out" file
@@ -3942,6 +3918,18 @@ SMESH_Mesh& NETGENPlugin_Internals::getMesh() const
   return const_cast<SMESH_Mesh&>( _mesh );
 }
 
+//================================================================================
+/*!
+ * \brief Access to a counter of NETGENPlugin_NetgenLibWrapper instances
+ */
+//================================================================================
+
+int& NETGENPlugin_NetgenLibWrapper::instanceCounter()
+{
+  static int theCouner = 0;
+  return theCouner;
+}
+
 //================================================================================
 /*!
  * \brief Initialize netgen library
@@ -3950,14 +3938,21 @@ SMESH_Mesh& NETGENPlugin_Internals::getMesh() const
 
 NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
 {
-  Ng_Init();
+  if ( instanceCounter() == 0 )
+    Ng_Init();
+
+  ++instanceCounter();
 
   _isComputeOk      = false;
   _coutBuffer       = NULL;
+  _ngcout           = NULL;
+  _ngcerr           = NULL;
   if ( !getenv( "KEEP_NETGEN_OUTPUT" ))
   {
     // redirect all netgen output (mycout,myerr,cout) to _outputFileName
     _outputFileName = getOutputFileName();
+    _ngcout         = netgen::mycout;
+    _ngcerr         = netgen::myerr;
     netgen::mycout  = new ofstream ( _outputFileName.c_str() );
     netgen::myerr   = netgen::mycout;
     _coutBuffer     = std::cout.rdbuf();
@@ -3979,9 +3974,11 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper()
 
 NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper()
 {
+  --instanceCounter();
+
   Ng_DeleteMesh( _ngMesh );
   Ng_Exit();
-  NETGENPlugin_Mesher::RemoveTmpFiles();
+  RemoveTmpFiles();
   if ( _coutBuffer )
     std::cout.rdbuf( _coutBuffer );
 #ifdef _DEBUG_
@@ -4027,6 +4024,26 @@ std::string NETGENPlugin_NetgenLibWrapper::getOutputFileName()
   return aGenericName.ToCString();
 }
 
+//================================================================================
+/*!
+ * \brief Remove "test.out" and "problemfaces" files in current directory
+ */
+//================================================================================
+
+void NETGENPlugin_NetgenLibWrapper::RemoveTmpFiles()
+{
+  bool rm =  SMESH_File("test.out").remove() ;
+#ifndef WIN32
+  if ( rm && netgen::testout && instanceCounter() == 0 )
+  {
+    delete netgen::testout;
+    netgen::testout = 0;
+  }
+#endif
+  SMESH_File("problemfaces").remove();
+  SMESH_File("occmesh.rep").remove();
+}
+
 //================================================================================
 /*!
  * \brief Remove file with netgen output
@@ -4037,11 +4054,12 @@ void NETGENPlugin_NetgenLibWrapper::removeOutputFile()
 {
   if ( !_outputFileName.empty() )
   {
-    if ( netgen::mycout )
+    if ( _ngcout )
     {
       delete netgen::mycout;
-      netgen::mycout = 0;
-      netgen::myerr = 0;
+      netgen::mycout = _ngcout;
+      netgen::myerr  = _ngcerr;
+      _ngcout        = 0;
     }
     string    tmpDir = SALOMEDS_Tool::GetDirFromPath ( _outputFileName );
     string aFileName = SALOMEDS_Tool::GetNameFromPath( _outputFileName ) + ".out";
index a378aeb139117c364606bdc29b06e7cb3ead6aed..1e81fd6fe804a2652ec93e55a22b01549e009876 100644 (file)
@@ -88,11 +88,16 @@ struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
   ~NETGENPlugin_NetgenLibWrapper();
   void setMesh( nglib::Ng_Mesh* mesh );
 
+  static void RemoveTmpFiles();
+  static int& instanceCounter();
+
  private:
   std::string getOutputFileName();
   void        removeOutputFile();
   std::string _outputFileName;
 
+  ostream *       _ngcout;
+  ostream *       _ngcerr;
   std::streambuf* _coutBuffer;   // to re-/store cout.rdbuf()
 };
 
@@ -181,8 +186,6 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher
 
   void SetDefaultParameters();
 
-  static void RemoveTmpFiles();
-
   static SMESH_ComputeErrorPtr ReadErrors(const std::vector< const SMDS_MeshNode* >& nodeVec);
 
 
index 9d68310188660af95f1e2ff822d1df81f5f2f3c6..cc5bb1895014c26c64deac4f0e2f47b4080afb56 100644 (file)
@@ -58,7 +58,6 @@ NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D(int hypId, int studyId,
                                                SMESH_Gen* gen)
   : SMESH_2D_Algo(hypId, studyId, gen)
 {
-  MESSAGE("NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D");
   _name = "NETGEN_2D";
   _shapeType = (1 << TopAbs_FACE); // 1 bit /shape type
   _compatibleHypothesis.push_back("NETGEN_Parameters_2D");
@@ -78,7 +77,6 @@ NETGENPlugin_NETGEN_2D::NETGENPlugin_NETGEN_2D(int hypId, int studyId,
 
 NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D()
 {
-  MESSAGE("NETGENPlugin_NETGEN_2D::~NETGENPlugin_NETGEN_2D");
 }
 
 //=============================================================================
index ac187c55d7e6cafa90ad5bd1702ead27b6bb14d9..96d1f0789d4359818bbd3d04522ee56d21fca137 100644 (file)
@@ -50,7 +50,6 @@ NETGENPlugin_NETGEN_2D_i::NETGENPlugin_NETGEN_2D_i( PortableServer::POA_ptr theP
        SMESH_Algo_i( thePOA ),
        SMESH_2D_Algo_i( thePOA )
 {
-  MESSAGE( "NETGENPlugin_NETGEN_2D_i::NETGENPlugin_NETGEN_2D_i" );
   myBaseImpl = new ::NETGENPlugin_NETGEN_2D( theGenImpl->GetANewId(),
                                              theStudyId,
                                              theGenImpl );
@@ -66,7 +65,6 @@ NETGENPlugin_NETGEN_2D_i::NETGENPlugin_NETGEN_2D_i( PortableServer::POA_ptr theP
 
 NETGENPlugin_NETGEN_2D_i::~NETGENPlugin_NETGEN_2D_i()
 {
-  MESSAGE( "NETGENPlugin_NETGEN_2D_i::~NETGENPlugin_NETGEN_2D_i" );
 }
 
 //=============================================================================
@@ -79,6 +77,5 @@ NETGENPlugin_NETGEN_2D_i::~NETGENPlugin_NETGEN_2D_i()
 
 ::NETGENPlugin_NETGEN_2D* NETGENPlugin_NETGEN_2D_i::GetImpl()
 {
-  MESSAGE( "NETGENPlugin_NETGEN_2D_i::GetImpl" );
   return ( ::NETGENPlugin_NETGEN_2D* )myBaseImpl;
 }
index fda27fc517d60c326ef6c8970ed767c399b83be7..0229eea903f7ec14ca499236684e46e10ad2727e 100644 (file)
@@ -96,7 +96,6 @@ NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D(int hypId, int studyId,
                              SMESH_Gen* gen)
   : SMESH_3D_Algo(hypId, studyId, gen)
 {
-  MESSAGE("NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D");
   _name = "NETGEN_3D";
   _shapeType = (1 << TopAbs_SHELL) | (1 << TopAbs_SOLID);// 1 bit /shape type
   _compatibleHypothesis.push_back("MaxElementVolume");
@@ -120,7 +119,6 @@ NETGENPlugin_NETGEN_3D::NETGENPlugin_NETGEN_3D(int hypId, int studyId,
 
 NETGENPlugin_NETGEN_3D::~NETGENPlugin_NETGEN_3D()
 {
-  MESSAGE("NETGENPlugin_NETGEN_3D::~NETGENPlugin_NETGEN_3D");
 }
 
 //=============================================================================
@@ -133,8 +131,6 @@ bool NETGENPlugin_NETGEN_3D::CheckHypothesis (SMESH_Mesh&         aMesh,
                                               const TopoDS_Shape& aShape,
                                               Hypothesis_Status&  aStatus)
 {
-  MESSAGE("NETGENPlugin_NETGEN_3D::CheckHypothesis");
-
   _hypMaxElementVolume = NULL;
   _hypParameters = NULL;
   _viscousLayersHyp = NULL;
index 1de14e0472aec91463a50343fb7e4801390b7bca..0b53170fdd81a7574369b6921e43ac7173bda833 100644 (file)
@@ -51,7 +51,6 @@ NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr theP
        SMESH_Algo_i( thePOA ),
        SMESH_3D_Algo_i( thePOA )
 {
-  MESSAGE( "NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i" );
   myBaseImpl = new ::NETGENPlugin_NETGEN_3D( theGenImpl->GetANewId(),
                                       theStudyId,
                                       theGenImpl );
@@ -67,7 +66,6 @@ NETGENPlugin_NETGEN_3D_i::NETGENPlugin_NETGEN_3D_i( PortableServer::POA_ptr theP
 
 NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i()
 {
-  MESSAGE( "NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i" );
 }
 
 //=============================================================================
@@ -80,7 +78,6 @@ NETGENPlugin_NETGEN_3D_i::~NETGENPlugin_NETGEN_3D_i()
 
 ::NETGENPlugin_NETGEN_3D* NETGENPlugin_NETGEN_3D_i::GetImpl()
 {
-  MESSAGE( "NETGENPlugin_NETGEN_3D_i::GetImpl" );
   return ( ::NETGENPlugin_NETGEN_3D* )myBaseImpl;
 }
 
index f76095cc2d78853681e6ccb02ba4a9fb56e8a91b..7cf2c100614e1a553115b678176c699b2606b4ef 100644 (file)
@@ -56,8 +56,6 @@ extern "C"
   NETGENPLUGIN_EXPORT
   GenericHypothesisCreator_i* GetHypothesisCreator (const char* aHypName)
   {
-    MESSAGE("GetHypothesisCreator " << aHypName);
-
     GenericHypothesisCreator_i* aCreator = 0;
 
     // Hypotheses