Salome HOME
23207: EDF 11232 SMESH: viscou layers builder fails at the very fist inflation
[modules/smesh.git] / src / StdMeshers / StdMeshers_ViscousLayers2D.cxx
index 585bcaf7164c2181e35fecb80b4cf8ca08f94f87..111ea47cb5a2a02dd870b91e10469dd5eed744b9 100644 (file)
@@ -113,6 +113,7 @@ namespace VISCOUS_2D
       //virtual int NbElements() const { return _elements.size()+1; }
       virtual int NbNodes() const { return Max( 0, _uvPtStructVec.size()-2 ); }
       void SetUVPtStructVec(UVPtStructVec& vec) { _uvPtStructVec.swap( vec ); }
       //virtual int NbElements() const { return _elements.size()+1; }
       virtual int NbNodes() const { return Max( 0, _uvPtStructVec.size()-2 ); }
       void SetUVPtStructVec(UVPtStructVec& vec) { _uvPtStructVec.swap( vec ); }
+      UVPtStructVec& GetUVPtStructVec() { return _uvPtStructVec; }
     };
     _ProxyMeshOfFace(const SMESH_Mesh& mesh): SMESH_ProxyMesh(mesh) {}
     _EdgeSubMesh* GetEdgeSubMesh(int ID) { return (_EdgeSubMesh*) getProxySubMesh(ID); }
     };
     _ProxyMeshOfFace(const SMESH_Mesh& mesh): SMESH_ProxyMesh(mesh) {}
     _EdgeSubMesh* GetEdgeSubMesh(int ID) { return (_EdgeSubMesh*) getProxySubMesh(ID); }
@@ -515,29 +516,53 @@ SMESH_ProxyMesh::Ptr
 StdMeshers_ViscousLayers2D::Compute(SMESH_Mesh&        theMesh,
                                     const TopoDS_Face& theFace)
 {
 StdMeshers_ViscousLayers2D::Compute(SMESH_Mesh&        theMesh,
                                     const TopoDS_Face& theFace)
 {
-  SMESH_ProxyMesh::Ptr pm;
-
+  using namespace VISCOUS_2D;
   vector< const StdMeshers_ViscousLayers2D* > hyps;
   vector< TopoDS_Shape >                      hypShapes;
   vector< const StdMeshers_ViscousLayers2D* > hyps;
   vector< TopoDS_Shape >                      hypShapes;
-  if ( VISCOUS_2D::findHyps( theMesh, theFace, hyps, hypShapes ))
+
+  SMESH_ProxyMesh::Ptr pm = _ProxyMeshHolder::FindProxyMeshOfFace( theFace, theMesh );
+  if ( !pm )
   {
   {
-    VISCOUS_2D::_ViscousBuilder2D builder( theMesh, theFace, hyps, hypShapes );
-    pm = builder.Compute();
-    SMESH_ComputeErrorPtr error = builder.GetError();
-    if ( error && !error->IsOK() )
-      theMesh.GetSubMesh( theFace )->GetComputeError() = error;
-    else if ( !pm )
+    if ( findHyps( theMesh, theFace, hyps, hypShapes ))
+    {
+      VISCOUS_2D::_ViscousBuilder2D builder( theMesh, theFace, hyps, hypShapes );
+      pm = builder.Compute();
+      SMESH_ComputeErrorPtr error = builder.GetError();
+      if ( error && !error->IsOK() )
+        theMesh.GetSubMesh( theFace )->GetComputeError() = error;
+      else if ( !pm )
+        pm.reset( new SMESH_ProxyMesh( theMesh ));
+      if ( getenv("__ONLY__VL2D__"))
+        pm.reset();
+    }
+    else
+    {
       pm.reset( new SMESH_ProxyMesh( theMesh ));
       pm.reset( new SMESH_ProxyMesh( theMesh ));
-    if ( getenv("__ONLY__VL2D__"))
-      pm.reset();
-  }
-  else
-  {
-    pm.reset( new SMESH_ProxyMesh( theMesh ));
+    }
   }
   return pm;
 }
 // --------------------------------------------------------------------------------
   }
   return pm;
 }
 // --------------------------------------------------------------------------------
+void StdMeshers_ViscousLayers2D::SetProxyMeshOfEdge( const StdMeshers_FaceSide& edgeNodes )
+{
+  using namespace VISCOUS_2D;
+  SMESH_ProxyMesh::Ptr pm =
+    _ProxyMeshHolder::FindProxyMeshOfFace( edgeNodes.Face(), *edgeNodes.GetMesh() );
+  if ( !pm ) {
+    _ProxyMeshOfFace* proxyMeshOfFace = new _ProxyMeshOfFace( *edgeNodes.GetMesh() );
+    pm.reset( proxyMeshOfFace );
+    new _ProxyMeshHolder( edgeNodes.Face(), pm );
+  }
+  _ProxyMeshOfFace*  proxyMeshOfFace = static_cast<_ProxyMeshOfFace*>( pm.get() );
+  _ProxyMeshOfFace::_EdgeSubMesh* sm = proxyMeshOfFace->GetEdgeSubMesh( edgeNodes.EdgeID(0) );
+  sm->GetUVPtStructVec() = edgeNodes.GetUVPtStruct();
+}
+// --------------------------------------------------------------------------------
+bool StdMeshers_ViscousLayers2D::HasProxyMesh( const TopoDS_Face& face, SMESH_Mesh& mesh )
+{
+  return VISCOUS_2D::_ProxyMeshHolder::FindProxyMeshOfFace( face, mesh );
+}
+// --------------------------------------------------------------------------------
 SMESH_ComputeErrorPtr
 StdMeshers_ViscousLayers2D::CheckHypothesis(SMESH_Mesh&                          theMesh,
                                             const TopoDS_Shape&                  theShape,
 SMESH_ComputeErrorPtr
 StdMeshers_ViscousLayers2D::CheckHypothesis(SMESH_Mesh&                          theMesh,
                                             const TopoDS_Shape&                  theShape,