From 43839bab02495b232466cdea2ce31a4d9ff7f455 Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 15 Oct 2012 14:52:18 +0000 Subject: [PATCH] 0021543: EDF 1978 SMESH: Viscous layer for 2D meshes Add StdMeshers_ViscousLayers2D hypothesis --- src/StdMeshers/StdMeshers_MEFISTO_2D.cxx | 80 ++++--- src/StdMeshers/StdMeshers_MEFISTO_2D.hxx | 2 +- src/StdMeshers/StdMeshers_Quadrangle_2D.cxx | 167 +++++++------ src/StdMeshers/StdMeshers_Quadrangle_2D.hxx | 19 +- src/StdMeshers/StdMeshers_ViscousLayers.cxx | 85 ++++--- src/StdMeshers/StdMeshers_ViscousLayers.hxx | 19 +- .../StdMeshersGUI_StdHypothesisCreator.cxx | 66 ++++- src/StdMeshersGUI/StdMeshers_msg_en.ts | 5 + src/StdMeshers_I/Makefile.am | 2 + .../StdMeshers_ViscousLayers2D_i.cxx | 225 ++++++++++++++++++ .../StdMeshers_ViscousLayers2D_i.hxx | 74 ++++++ .../StdMeshers_ViscousLayers_i.cxx | 4 +- .../StdMeshers_ViscousLayers_i.hxx | 1 - src/StdMeshers_I/StdMeshers_i.cxx | 3 + 14 files changed, 571 insertions(+), 181 deletions(-) create mode 100644 src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx index f7a91a6b1..55091c7f9 100644 --- a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx @@ -28,29 +28,28 @@ // #include "StdMeshers_MEFISTO_2D.hxx" +#include "SMDS_EdgePosition.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMESH_Comment.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" -#include "SMESH_subMesh.hxx" -#include "SMESH_Block.hxx" #include "SMESH_MesherHelper.hxx" -#include "SMESH_Comment.hxx" - +#include "SMESH_subMesh.hxx" #include "StdMeshers_FaceSide.hxx" -#include "StdMeshers_MaxElementArea.hxx" #include "StdMeshers_LengthFromEdges.hxx" +#include "StdMeshers_MaxElementArea.hxx" +#include "StdMeshers_ViscousLayers2D.hxx" + +#include "utilities.h" #include "Rn.h" #include "aptrte.h" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" -#include "SMDS_EdgePosition.hxx" -#include "SMDS_FacePosition.hxx" - -#include "utilities.h" - +#include #include #include +#include #include #include #include @@ -67,12 +66,12 @@ #include #include -#include -#include -#include - using namespace std; +#ifdef _DEBUG_ +//#define DUMP_POINTS // to print coordinates of MEFISTO input +#endif + //============================================================================= /*! * @@ -87,12 +86,13 @@ StdMeshers_MEFISTO_2D::StdMeshers_MEFISTO_2D(int hypId, int studyId, SMESH_Gen * _shapeType = (1 << TopAbs_FACE); _compatibleHypothesis.push_back("MaxElementArea"); _compatibleHypothesis.push_back("LengthFromEdges"); + _compatibleHypothesis.push_back("ViscousLayers2D"); _edgeLength = 0; _maxElementArea = 0; _hypMaxElementArea = NULL; _hypLengthFromEdges = NULL; - myTool = 0; + _helper = 0; } //============================================================================= @@ -191,13 +191,19 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh // helper builds quadratic mesh if necessary SMESH_MesherHelper helper(aMesh); - myTool = &helper; - _quadraticMesh = myTool->IsQuadraticSubMesh(aShape); - const bool ignoreMediumNodes = _quadraticMesh; + _helper = &helper; + _quadraticMesh = _helper->IsQuadraticSubMesh(aShape); + const bool skipMediumNodes = _quadraticMesh; + + // build viscous layers if required + SMESH_ProxyMesh::Ptr proxyMesh = StdMeshers_ViscousLayers2D::Compute( aMesh, F ); + if ( !proxyMesh ) + return false; // get all edges of a face TError problem; - TWireVector wires = StdMeshers_FaceSide::GetFaceWires( F, aMesh, ignoreMediumNodes, problem ); + TWireVector wires = + StdMeshers_FaceSide::GetFaceWires( F, aMesh, skipMediumNodes, problem, proxyMesh ); int nbWires = wires.size(); if ( problem && !problem->IsOK() ) return error( problem ); if ( nbWires == 0 ) return error( "Problem in StdMeshers_FaceSide::GetFaceWires()"); @@ -575,7 +581,7 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(TWireVector & wires, TopTools_IndexedDataMapOfShapeListOfShape VWMap; if ( wires.size() > 1 ) { - F = TopoDS::Face( myTool->GetSubShape() ); + F = TopoDS::Face( _helper->GetSubShape() ); TopExp::MapShapesAndAncestors( F, TopAbs_VERTEX, TopAbs_WIRE, VWMap ); int nbVertices = 0; for ( int iW = 0; iW < wires.size(); ++iW ) @@ -616,10 +622,10 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(TWireVector & wires, case SMDS_TOP_EDGE: // In order to detect degenerated faces easily, we replace // nodes on a degenerated edge by node on the vertex of that edge - if ( myTool->IsDegenShape( uvPt->node->getshapeId() )) + if ( _helper->IsDegenShape( uvPt->node->getshapeId() )) { int edgeID = uvPt->node->getshapeId(); - SMESH_subMesh* edgeSM = myTool->GetMesh()->GetSubMeshContaining( edgeID ); + SMESH_subMesh* edgeSM = _helper->GetMesh()->GetSubMeshContaining( edgeID ); SMESH_subMeshIteratorPtr smIt = edgeSM->getDependsOnIterator( /*includeSelf=*/0, /*complexShapeFirst=*/0); if ( smIt->more() ) @@ -644,8 +650,8 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(TWireVector & wires, if ( iW && !VWMap.IsEmpty()) { // except outer wire // avoid passing same uv point for a vertex common to 2 wires int vID = mefistoToDS[m]->getshapeId(); - TopoDS_Vertex V = TopoDS::Vertex( myTool->GetMeshDS()->IndexToShape( vID )); - if ( fixCommonVertexUV( uvslf[m], V, F, VWMap, *myTool->GetMesh(), + TopoDS_Vertex V = TopoDS::Vertex( _helper->GetMeshDS()->IndexToShape( vID )); + if ( fixCommonVertexUV( uvslf[m], V, F, VWMap, *_helper->GetMesh(), scalex, scaley, _quadraticMesh )) { myNodesOnCommonV.push_back( mefistoToDS[m] ); continue; @@ -659,9 +665,13 @@ bool StdMeshers_MEFISTO_2D::LoadPoints(TWireVector & wires, fixOverlappedLinkUV (uvslf[ mB ], uvslf[ m ], uvslf[ mA ]); } } -// cout << "MEFISTO INPUT************" << endl; -// for ( int i =0; i < m; ++i ) -// cout << i << ": \t" << uvslf[i].x << ", " << uvslf[i].y << " Node " << mefistoToDS[i]->GetID()<< endl; + +#ifdef DUMP_POINTS + cout << "MEFISTO INPUT************" << endl; + for ( int i =0; i < m; ++i ) + cout << i << ": \t" << uvslf[i].x << ", " << uvslf[i].y + << " Node " << mefistoToDS[i]->GetID()<< endl; +#endif return true; } @@ -770,10 +780,10 @@ void StdMeshers_MEFISTO_2D::StoreResult(Z nbst, R2 * uvst, Z nbt, Z * nust, vector< const SMDS_MeshNode*>&mefistoToDS, double scalex, double scaley) { - SMESHDS_Mesh * meshDS = myTool->GetMeshDS(); - int faceID = myTool->GetSubShapeID(); + SMESHDS_Mesh * meshDS = _helper->GetMeshDS(); + int faceID = _helper->GetSubShapeID(); - TopoDS_Face F = TopoDS::Face( myTool->GetSubShape() ); + TopoDS_Face F = TopoDS::Face( _helper->GetSubShape() ); Handle(Geom_Surface) S = BRep_Tool::Surface( F ); Z n = mefistoToDS.size(); // nb input points @@ -809,14 +819,14 @@ void StdMeshers_MEFISTO_2D::StoreResult(Z nbst, R2 * uvst, Z nbt, Z * nust, const SMDS_MeshNode * n3 = mefistoToDS[ nust[m++] - 1 ]; // avoid creating degenetrated faces - bool isDegen = ( myTool->HasDegeneratedEdges() && ( n1 == n2 || n1 == n3 || n2 == n3 )); + bool isDegen = ( _helper->HasDegeneratedEdges() && ( n1 == n2 || n1 == n3 || n2 == n3 )); if ( !isDegen ) { SMDS_MeshElement * elt; if (triangleIsWellOriented) - elt = myTool->AddFace(n1, n2, n3); + elt = _helper->AddFace(n1, n2, n3); else - elt = myTool->AddFace(n1, n3, n2); + elt = _helper->AddFace(n1, n3, n2); meshDS->SetMeshElementOnShape(elt, faceID); } m++; diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx index 219df4089..28f2da8a2 100644 --- a/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx @@ -85,7 +85,7 @@ protected: std::list myNodesOnCommonV; - SMESH_MesherHelper* myTool; // tool for working with quadratic elements + SMESH_MesherHelper* _helper; // tool for working with quadratic elements }; #endif diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 3842b4733..d5c4c9ad7 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -26,21 +26,19 @@ #include "StdMeshers_Quadrangle_2D.hxx" -#include "StdMeshers_FaceSide.hxx" - -#include "StdMeshers_QuadrangleParams.hxx" - +#include "SMDS_EdgePosition.hxx" +#include "SMDS_FacePosition.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMESH_Block.hxx" +#include "SMESH_Comment.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" -#include "SMESH_subMesh.hxx" #include "SMESH_MesherHelper.hxx" -#include "SMESH_Block.hxx" -#include "SMESH_Comment.hxx" - -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" -#include "SMDS_EdgePosition.hxx" -#include "SMDS_FacePosition.hxx" +#include "SMESH_subMesh.hxx" +#include "StdMeshers_FaceSide.hxx" +#include "StdMeshers_QuadrangleParams.hxx" +#include "StdMeshers_ViscousLayers2D.hxx" #include #include @@ -79,7 +77,8 @@ typedef SMESH_Comment TComm; StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, SMESH_Gen* gen) - : SMESH_2D_Algo(hypId, studyId, gen) + : SMESH_2D_Algo(hypId, studyId, gen), + myHelper( 0 ) { MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D"); _name = "Quadrangle_2D"; @@ -87,7 +86,7 @@ StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, _compatibleHypothesis.push_back("QuadrangleParams"); _compatibleHypothesis.push_back("QuadranglePreference"); _compatibleHypothesis.push_back("TrianglePreference"); - myHelper = 0; + _compatibleHypothesis.push_back("ViscousLayers2D"); } //============================================================================= @@ -193,11 +192,11 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis */ //============================================================================= -bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape)// throw (SALOME_Exception) +bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape) { - // PAL14921. Enable catching std::bad_alloc and Standard_OutOfMemory outside - //Unexpect aCatchSalomeException); + const TopoDS_Face& F = TopoDS::Face(aShape); + Handle(Geom_Surface) S = BRep_Tool::Surface(F); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); aMesh.GetSubMesh(aShape); @@ -205,6 +204,10 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, SMESH_MesherHelper helper (aMesh); myHelper = &helper; + myProxyMesh = StdMeshers_ViscousLayers2D::Compute( aMesh, F ); + if ( !myProxyMesh ) + return false; + _quadraticMesh = myHelper->IsQuadraticSubMesh(aShape); myNeedSmooth = false; @@ -263,9 +266,6 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, int nbhoriz = Min(nbdown, nbup); int nbvertic = Min(nbright, nbleft); - const TopoDS_Face& F = TopoDS::Face(aShape); - Handle(Geom_Surface) S = BRep_Tool::Surface(F); - // internal mesh nodes int i, j, geomFaceID = meshDS->ShapeToIndex(F); for (i = 1; i < nbhoriz - 1; i++) { @@ -307,10 +307,10 @@ bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, for (i = ilow; i < iup; i++) { for (j = jlow; j < jup; j++) { const SMDS_MeshNode *a, *b, *c, *d; - a = quad->uv_grid[j * nbhoriz + i].node; - b = quad->uv_grid[j * nbhoriz + i + 1].node; + a = quad->uv_grid[j * nbhoriz + i ].node; + b = quad->uv_grid[j * nbhoriz + i + 1].node; c = quad->uv_grid[(j + 1) * nbhoriz + i + 1].node; - d = quad->uv_grid[(j + 1) * nbhoriz + i].node; + d = quad->uv_grid[(j + 1) * nbhoriz + i ].node; SMDS_MeshFace* face = myHelper->AddFace(a, b, c, d); if (face) { meshDS->SetMeshElementOnShape(face, geomFaceID); @@ -831,9 +831,16 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMes } if (!E1.IsNull() && !E2.IsNull() && !E3.IsNull()) { - quad->side.push_back(new StdMeshers_FaceSide(F, E1, &aMesh, true, ignoreMediumNodes)); - quad->side.push_back(new StdMeshers_FaceSide(F, E2, &aMesh, true, ignoreMediumNodes)); - quad->side.push_back(new StdMeshers_FaceSide(F, E3, &aMesh, false,ignoreMediumNodes)); + if ( myProxyMesh->GetProxySubMesh( E1 ) || + myProxyMesh->GetProxySubMesh( E2 ) || + myProxyMesh->GetProxySubMesh( E3 ) ) + + quad->side.push_back(new StdMeshers_FaceSide(F, E1, &aMesh, true, + ignoreMediumNodes, myProxyMesh)); + quad->side.push_back(new StdMeshers_FaceSide(F, E2, &aMesh, true, + ignoreMediumNodes, myProxyMesh)); + quad->side.push_back(new StdMeshers_FaceSide(F, E3, &aMesh, false, + ignoreMediumNodes, myProxyMesh)); const vector& UVPSleft = quad->side[0]->GetUVPtStruct(true,0); /* vector& UVPStop = */quad->side[1]->GetUVPtStruct(false,1); /* vector& UVPSright = */quad->side[2]->GetUVPtStruct(true,1); @@ -856,8 +863,8 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMes else if (nbEdgesInWire.front() == 4) // exactly 4 edges { for (; edgeIt != edges.end(); ++edgeIt, nbSides++) - quad->side.push_back(new StdMeshers_FaceSide(F, *edgeIt, &aMesh, - nbSidesside.push_back(new StdMeshers_FaceSide(F, *edgeIt, &aMesh, nbSides < TOP_SIDE, + ignoreMediumNodes, myProxyMesh)); } else if (nbEdgesInWire.front() > 4) // more than 4 edges - try to unite some { @@ -883,8 +890,8 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMes if ( sideEdges.size() == 1 && BRep_Tool::Degenerated( sideEdges.front() )) degenSides.push_back( nbSides ); - quad->side.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh, - nbSidesside.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh, nbSides < TOP_SIDE, + ignoreMediumNodes, myProxyMesh)); ++nbSides; } if ( !degenSides.empty() && nbSides - degenSides.size() == 4 ) @@ -935,7 +942,8 @@ FaceQuadStruct* StdMeshers_Quadrangle_2D::CheckNbEdges(SMESH_Mesh & aMes } } quad->side.push_back(new StdMeshers_FaceSide(F, sideEdges, &aMesh, - nbSidesisEdgeOut[0]) { - int j = 0; - for (int i = 0; i < nbhoriz; i++) { // down - int ij = j * nbhoriz + i; - uv_grid[ij].node = uv_e0[i].node; - } + // copy data of face boundary + /*if (! quad->isEdgeOut[0])*/ { + const int j = 0; + for (int i = 0; i < nbhoriz; i++) // down + uv_grid[ j * nbhoriz + i ] = uv_e0[i]; } - if (! quad->isEdgeOut[1]) { - int i = nbhoriz - 1; - for (int j = 0; j < nbvertic; j++) { // right - int ij = j * nbhoriz + i; - uv_grid[ij].node = uv_e1[j].node; - } + /*if (! quad->isEdgeOut[1])*/ { + const int i = nbhoriz - 1; + for (int j = 0; j < nbvertic; j++) // right + uv_grid[ j * nbhoriz + i ] = uv_e1[j]; } - if (! quad->isEdgeOut[2]) { - int j = nbvertic - 1; - for (int i = 0; i < nbhoriz; i++) { // up - int ij = j * nbhoriz + i; - uv_grid[ij].node = uv_e2[i].node; - } + /*if (! quad->isEdgeOut[2])*/ { + const int j = nbvertic - 1; + for (int i = 0; i < nbhoriz; i++) // up + uv_grid[ j * nbhoriz + i ] = uv_e2[i]; } - if (! quad->isEdgeOut[3]) { + /*if (! quad->isEdgeOut[3])*/ { int i = 0; - for (int j = 0; j < nbvertic; j++) { // left - int ij = j * nbhoriz + i; - uv_grid[ij].node = uv_e3[j].node; - } + for (int j = 0; j < nbvertic; j++) // left + uv_grid[ j * nbhoriz + i ] = uv_e3[j]; } - // normalized 2d values on grid + // normalized 2d parameters on grid for (int i = 0; i < nbhoriz; i++) { for (int j = 0; j < nbvertic; j++) { int ij = j * nbhoriz + i; @@ -1316,26 +1316,23 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, } // 4 --- projection on 2d domain (u,v) - gp_UV a0(uv_e0.front().u, uv_e0.front().v); - gp_UV a1(uv_e0.back().u, uv_e0.back().v); - gp_UV a2(uv_e2.back().u, uv_e2.back().v); - gp_UV a3(uv_e2.front().u, uv_e2.front().v); + gp_UV a0 (uv_e0.front().u, uv_e0.front().v); + gp_UV a1 (uv_e0.back().u, uv_e0.back().v ); + gp_UV a2 (uv_e2.back().u, uv_e2.back().v ); + gp_UV a3 (uv_e2.front().u, uv_e2.front().v); + + for (int i = 0; i < nbhoriz; i++) + { + gp_UV p0( uv_e0[i].u, uv_e0[i].v ); + gp_UV p2( uv_e2[i].u, uv_e2[i].v ); + for (int j = 0; j < nbvertic; j++) + { + gp_UV p1( uv_e1[j].u, uv_e1[j].v ); + gp_UV p3( uv_e3[j].u, uv_e3[j].v ); - for (int i = 0; i < nbhoriz; i++) { - for (int j = 0; j < nbvertic; j++) { int ij = j * nbhoriz + i; double x = uv_grid[ij].x; double y = uv_grid[ij].y; - double param_0 = uv_e0[0].normParam + x * (uv_e0.back().normParam - uv_e0[0].normParam); // sud - double param_2 = uv_e2[0].normParam + x * (uv_e2.back().normParam - uv_e2[0].normParam); // nord - double param_1 = uv_e1[0].normParam + y * (uv_e1.back().normParam - uv_e1[0].normParam); // est - double param_3 = uv_e3[0].normParam + y * (uv_e3.back().normParam - uv_e3[0].normParam); // ouest - - //MESSAGE("params "<side[0]->Value2d(param_0).XY(); - gp_UV p1 = quad->side[1]->Value2d(param_1).XY(); - gp_UV p2 = quad->side[2]->Value2d(param_2).XY(); - gp_UV p3 = quad->side[3]->Value2d(param_3).XY(); gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3); @@ -1353,7 +1350,8 @@ bool StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, static void ShiftQuad(FaceQuadStruct* quad, const int num, bool) { - StdMeshers_FaceSide* side[4] = { quad->side[0], quad->side[1], quad->side[2], quad->side[3] }; + StdMeshers_FaceSide* side[4] = { quad->side[0], quad->side[1], + quad->side[2], quad->side[3] }; for (int i = BOTTOM_SIDE; i < NB_SIDES; ++i) { int id = (i + num) % NB_SIDES; bool wasForward = (i < TOP_SIDE); @@ -1374,23 +1372,18 @@ static gp_UV CalcUV(double x0, double x1, double y0, double y1, const gp_UV& a0, const gp_UV& a1, const gp_UV& a2, const gp_UV& a3) { - const vector& uv_eb = quad->side[0]->GetUVPtStruct(true,0); - const vector& uv_er = quad->side[1]->GetUVPtStruct(false,1); - const vector& uv_et = quad->side[2]->GetUVPtStruct(true,1); - const vector& uv_el = quad->side[3]->GetUVPtStruct(false,0); + // const vector& uv_eb = quad->side[0]->GetUVPtStruct(true,0); + // const vector& uv_er = quad->side[1]->GetUVPtStruct(false,1); + // const vector& uv_et = quad->side[2]->GetUVPtStruct(true,1); + // const vector& uv_el = quad->side[3]->GetUVPtStruct(false,0); double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0)); double y = y0 + x * (y1 - y0); - double param_b = uv_eb[0].normParam + x * (uv_eb.back().normParam - uv_eb[0].normParam); - double param_t = uv_et[0].normParam + x * (uv_et.back().normParam - uv_et[0].normParam); - double param_r = uv_er[0].normParam + y * (uv_er.back().normParam - uv_er[0].normParam); - double param_l = uv_el[0].normParam + y * (uv_el.back().normParam - uv_el[0].normParam); - - gp_UV p0 = quad->side[BOTTOM_SIDE]->Value2d(param_b).XY(); - gp_UV p1 = quad->side[RIGHT_SIDE ]->Value2d(param_r).XY(); - gp_UV p2 = quad->side[TOP_SIDE ]->Value2d(param_t).XY(); - gp_UV p3 = quad->side[LEFT_SIDE ]->Value2d(param_l).XY(); + gp_UV p0 = quad->side[BOTTOM_SIDE]->Value2d(x).XY(); + gp_UV p1 = quad->side[RIGHT_SIDE ]->Value2d(y).XY(); + gp_UV p2 = quad->side[TOP_SIDE ]->Value2d(x).XY(); + gp_UV p3 = quad->side[LEFT_SIDE ]->Value2d(y).XY(); gp_UV uv = CalcUV(x,y, a0,a1,a2,a3, p0,p1,p2,p3); diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx index e200bc5af..000c01f66 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx @@ -27,19 +27,18 @@ #ifndef _SMESH_QUADRANGLE_2D_HXX_ #define _SMESH_QUADRANGLE_2D_HXX_ +#include "SMESH_Algo.hxx" +#include "SMESH_ProxyMesh.hxx" #include "SMESH_StdMeshers.hxx" - #include "StdMeshers_QuadrangleParams.hxx" -#include "SMESH_Algo.hxx" -#include "Utils_SALOME_Exception.hxx" - #include +class SMDS_MeshNode; class SMESH_Mesh; class SMESH_MesherHelper; +class SMESH_ProxyMesh; class StdMeshers_FaceSide; -class SMDS_MeshNode; struct uvPtStruct; @@ -124,13 +123,15 @@ protected: bool myTrianglePreference; - int myTriaVertexID; + int myTriaVertexID; + + bool myNeedSmooth; - StdMeshers_QuadType myQuadType; + StdMeshers_QuadType myQuadType; - SMESH_MesherHelper* myHelper; // tool for working with quadratic elements + SMESH_MesherHelper* myHelper; // tool for working with quadratic elements - bool myNeedSmooth; + SMESH_ProxyMesh::Ptr myProxyMesh; }; #endif diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.cxx b/src/StdMeshers/StdMeshers_ViscousLayers.cxx index c875ca104..f5bc7afbe 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.cxx @@ -82,7 +82,7 @@ using namespace std; //================================================================================ -namespace VISCOUS +namespace VISCOUS_3D { typedef int TGeomID; @@ -121,13 +121,13 @@ namespace VISCOUS * \brief Listener of events of 3D sub-meshes computed with viscous layers. * It is used to clear an inferior dim sub-meshes modified by viscous layers */ - class _SrinkShapeListener : SMESH_subMeshEventListener + class _ShrinkShapeListener : SMESH_subMeshEventListener { - _SrinkShapeListener() + _ShrinkShapeListener() : SMESH_subMeshEventListener(/*isDeletable=*/false, - "StdMeshers_ViscousLayers::_SrinkShapeListener") {} - static SMESH_subMeshEventListener* Get() { static _SrinkShapeListener l; return &l; } + "StdMeshers_ViscousLayers::_ShrinkShapeListener") {} public: + static SMESH_subMeshEventListener* Get() { static _ShrinkShapeListener l; return &l; } virtual void ProcessEvent(const int event, const int eventType, SMESH_subMesh* solidSM, @@ -139,23 +139,6 @@ namespace VISCOUS SMESH_subMeshEventListener::ProcessEvent(event,eventType,solidSM,data,hyp); } } - static void ToClearSubMeshWithSolid( SMESH_subMesh* sm, - const TopoDS_Shape& solid) - { - SMESH_subMesh* solidSM = sm->GetFather()->GetSubMesh( solid ); - SMESH_subMeshEventListenerData* data = solidSM->GetEventListenerData( Get()); - if ( data ) - { - if ( find( data->mySubMeshes.begin(), data->mySubMeshes.end(), sm ) == - data->mySubMeshes.end()) - data->mySubMeshes.push_back( sm ); - } - else - { - data = SMESH_subMeshEventListenerData::MakeData( /*dependent=*/sm ); - sm->SetEventListener( Get(), data, /*whereToListenTo=*/solidSM ); - } - } }; //-------------------------------------------------------------------------------- /*! @@ -205,6 +188,32 @@ namespace VISCOUS } }; + //================================================================================ + /*! + * \brief sets a sub-mesh event listener to clear sub-meshes of sub-shapes of + * the main shape when sub-mesh of the main shape is cleared, + * for example to clear sub-meshes of FACEs when sub-mesh of a SOLID + * is cleared + */ + //================================================================================ + + void ToClearSubWithMain( SMESH_subMesh* sub, const TopoDS_Shape& main) + { + SMESH_subMesh* mainSM = sub->GetFather()->GetSubMesh( main ); + SMESH_subMeshEventListenerData* data = + mainSM->GetEventListenerData( _ShrinkShapeListener::Get()); + if ( data ) + { + if ( find( data->mySubMeshes.begin(), data->mySubMeshes.end(), sub ) == + data->mySubMeshes.end()) + data->mySubMeshes.push_back( sub ); + } + else + { + data = SMESH_subMeshEventListenerData::MakeData( /*dependent=*/sub ); + sub->SetEventListener( _ShrinkShapeListener::Get(), data, /*whereToListenTo=*/mainSM ); + } + } //-------------------------------------------------------------------------------- /*! * \brief Simplex (triangle or tetrahedron) based on 1 (tria) or 2 (tet) nodes of @@ -547,7 +556,7 @@ virtual SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const _nn[3]=_le2->_nodes[0]; } }; -} // namespace VISCOUS +} // namespace VISCOUS_3D //================================================================================ // StdMeshers_ViscousLayers hypothesis @@ -559,10 +568,15 @@ StdMeshers_ViscousLayers::StdMeshers_ViscousLayers(int hypId, int studyId, SMESH _name = StdMeshers_ViscousLayers::GetHypType(); _param_algo_dim = -3; // auxiliary hyp used by 3D algos } // -------------------------------------------------------------------------------- -void StdMeshers_ViscousLayers::SetIgnoreFaces(const std::vector& faceIds) +void StdMeshers_ViscousLayers::SetBndShapesToIgnore(const std::vector& faceIds) +{ + if ( faceIds != _ignoreBndShapeIds ) + _ignoreBndShapeIds = faceIds, NotifySubMeshesHypothesisModification(); +} // -------------------------------------------------------------------------------- +bool StdMeshers_ViscousLayers::IsIgnoredShape(const int shapeID) const { - if ( faceIds != _ignoreFaceIds ) - _ignoreFaceIds = faceIds, NotifySubMeshesHypothesisModification(); + return ( find( _ignoreBndShapeIds.begin(), _ignoreBndShapeIds.end(), shapeID ) + != _ignoreBndShapeIds.end() ); } // -------------------------------------------------------------------------------- void StdMeshers_ViscousLayers::SetTotalThickness(double thickness) { @@ -584,7 +598,7 @@ StdMeshers_ViscousLayers::Compute(SMESH_Mesh& theMesh, const TopoDS_Shape& theShape, const bool toMakeN2NMap) const { - using namespace VISCOUS; + using namespace VISCOUS_3D; _ViscousBuilder bulder; SMESH_ComputeErrorPtr err = bulder.Compute( theMesh, theShape ); if ( err && !err->IsOK() ) @@ -620,17 +634,17 @@ std::ostream & StdMeshers_ViscousLayers::SaveTo(std::ostream & save) save << " " << _nbLayers << " " << _thickness << " " << _stretchFactor - << " " << _ignoreFaceIds.size(); - for ( unsigned i = 0; i < _ignoreFaceIds.size(); ++i ) - save << " " << _ignoreFaceIds[i]; + << " " << _ignoreBndShapeIds.size(); + for ( unsigned i = 0; i < _ignoreBndShapeIds.size(); ++i ) + save << " " << _ignoreBndShapeIds[i]; return save; } // -------------------------------------------------------------------------------- std::istream & StdMeshers_ViscousLayers::LoadFrom(std::istream & load) { int nbFaces, faceID; load >> _nbLayers >> _thickness >> _stretchFactor >> nbFaces; - while ( _ignoreFaceIds.size() < nbFaces && load >> faceID ) - _ignoreFaceIds.push_back( faceID ); + while ( _ignoreBndShapeIds.size() < nbFaces && load >> faceID ) + _ignoreBndShapeIds.push_back( faceID ); return load; } // -------------------------------------------------------------------------------- bool StdMeshers_ViscousLayers::SetParametersByMesh(const SMESH_Mesh* theMesh, @@ -849,7 +863,7 @@ namespace #endif } -using namespace VISCOUS; +using namespace VISCOUS_3D; //================================================================================ /*! @@ -1051,7 +1065,7 @@ bool _ViscousBuilder::findFacesWithLayers() vector ignoreFaces; for ( unsigned i = 0; i < _sdVec.size(); ++i ) { - vector ids = _sdVec[i]._hyp->GetIgnoreFaces(); + vector ids = _sdVec[i]._hyp->GetBndShapesToIgnore(); for ( unsigned i = 0; i < ids.size(); ++i ) { const TopoDS_Shape& s = getMeshDS()->IndexToShape( ids[i] ); @@ -3599,6 +3613,7 @@ bool _ViscousBuilder::shrink() _Shrinker1D& srinker = e2shrMap[ edgeIndex ]; eShri1D.insert( & srinker ); srinker.AddEdge( edge, helper ); + VISCOUS_3D::ToClearSubWithMain( _mesh->GetSubMesh( edge->_sWOL ), data._solid ); // restore params of nodes on EGDE if the EDGE has been already // srinked while srinking another FACE srinker.RestoreParams(); @@ -3684,7 +3699,7 @@ bool _ViscousBuilder::shrink() dumpFunctionEnd(); } // Set an event listener to clear FACE sub-mesh together with SOLID sub-mesh - _SrinkShapeListener::ToClearSubMeshWithSolid( sm, data._solid ); + VISCOUS_3D::ToClearSubWithMain( sm, data._solid ); if ( !getMeshDS()->IsEmbeddedMode() ) // Log node movement diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.hxx b/src/StdMeshers/StdMeshers_ViscousLayers.hxx index 42c187130..4fa07a9ef 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.hxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.hxx @@ -39,9 +39,10 @@ class STDMESHERS_EXPORT StdMeshers_ViscousLayers : public SMESH_Hypothesis public: StdMeshers_ViscousLayers(int hypId, int studyId, SMESH_Gen* gen); - // Set faces to exclude from treatment - void SetIgnoreFaces(const std::vector& faceIds); - std::vector GetIgnoreFaces() const { return _ignoreFaceIds; } + // Set boundary shapes to exclude from treatment, faces in 3D, edges in 2D + void SetBndShapesToIgnore(const std::vector& shapeIds); + std::vector GetBndShapesToIgnore() const { return _ignoreBndShapeIds; } + bool IsIgnoredShape(const int shapeID) const; // Set total thickness of layers of prisms void SetTotalThickness(double thickness); @@ -85,10 +86,20 @@ public: private: - std::vector _ignoreFaceIds; + std::vector _ignoreBndShapeIds; int _nbLayers; double _thickness; double _stretchFactor; }; +class SMESH_subMesh; +namespace VISCOUS_3D +{ + // sets a sub-mesh event listener to clear sub-meshes of sub-shapes of + // the main shape when sub-mesh of the main shape is cleared, + // for example to clear sub-meshes of FACEs when sub-mesh of a SOLID + // is cleared + void ToClearSubWithMain( SMESH_subMesh* sub, const TopoDS_Shape& main); +} + #endif diff --git a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx index 127be9f4e..0a033c033 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_StdHypothesisCreator.cxx @@ -694,6 +694,24 @@ QString StdMeshersGUI_StdHypothesisCreator::storeParams() const h->SetIgnoreFaces( idsWg->GetListOfIDs() ); } } + else if( hypType()=="ViscousLayers2D" ) + { + StdMeshers::StdMeshers_ViscousLayers2D_var h = + StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hypothesis() ); + + h->SetVarParameter( params[0].text(), "SetTotalThickness" ); + h->SetTotalThickness( params[0].myValue.toDouble() ); + h->SetVarParameter( params[1].text(), "SetNumberLayers" ); + h->SetNumberLayers ( params[1].myValue.toInt() ); + h->SetVarParameter( params[2].text(), "SetStretchFactor" ); + h->SetStretchFactor ( params[2].myValue.toDouble() ); + + if ( StdMeshersGUI_SubShapeSelectorWdg* idsWg = + widget< StdMeshersGUI_SubShapeSelectorWdg >( 3 )) + { + h->SetIgnoreEdges( idsWg->GetListOfIDs() ); + } + } else if( hypType()=="QuadrangleParams" ) { StdMeshers::StdMeshers_QuadrangleParams_var h = @@ -1152,6 +1170,45 @@ bool StdMeshersGUI_StdHypothesisCreator::stdParams( ListOfStdParams& p ) const customWidgets()->append ( idsWg ); } } + else if( hypType()=="ViscousLayers2D" ) + { + StdMeshers::StdMeshers_ViscousLayers2D_var h = + StdMeshers::StdMeshers_ViscousLayers2D::_narrow( hyp ); + + item.myName = tr( "SMESH_TOTAL_THICKNESS" ); + if(!initVariableName( hyp, item, "SetTotalThickness" )) + item.myValue = h->GetTotalThickness(); + p.append( item ); + customWidgets()->append (0); + + item.myName = tr( "SMESH_NUMBER_OF_LAYERS" ); + if(!initVariableName( hyp, item, "SetNumberLayers" )) + item.myValue = h->GetNumberLayers(); + p.append( item ); + customWidgets()->append (0); + + item.myName = tr( "SMESH_STRETCH_FACTOR" ); + if(!initVariableName( hyp, item, "SetStretchFactor" )) + item.myValue = h->GetStretchFactor(); + p.append( item ); + customWidgets()->append (0); + + QString aMainEntry = SMESHGUI_GenericHypothesisCreator::getMainShapeEntry(); + if ( !aMainEntry.isEmpty() ) + { + item.myName = tr( "SMESH_EDGES_WO_LAYERS" ); + p.append( item ); + + StdMeshersGUI_SubShapeSelectorWdg* idsWg = + new StdMeshersGUI_SubShapeSelectorWdg(0,TopAbs_EDGE); + + idsWg->SetGeomShapeEntry( aMainEntry ); + idsWg->SetMainShapeEntry( aMainEntry ); + idsWg->SetListOfIDs( h->GetIgnoreEdges() ); + idsWg->showPreview( true ); + customWidgets()->append ( idsWg ); + } + } else if (hypType() == "QuadrangleParams") { StdMeshers::StdMeshers_QuadrangleParams_var h = @@ -1242,7 +1299,7 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) { sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "parametric_precision" ); } - else if( hypType()=="ViscousLayers" ) + else if( hypType().startsWith( "ViscousLayers" )) { if (sb->objectName() == tr("SMESH_STRETCH_FACTOR")) sb->RangeStepAndValidator( 1.0, VALUE_MAX, 0.1, "parametric_precision" ); @@ -1254,12 +1311,6 @@ void StdMeshersGUI_StdHypothesisCreator::attuneStdWidget (QWidget* w, const int) sb->RangeStepAndValidator( VALUE_SMALL, VALUE_MAX, 1.0, "length_precision" ); } } -// else if ( QtxIntSpinBox* ib = w->inherits( "QtxIntSpinBox" ) ? ( QtxIntSpinBox* )w : 0) -// { -// if( hypType()=="ViscousLayers" ) -// { -// } -// } } //================================================================================ @@ -1334,6 +1385,7 @@ QString StdMeshersGUI_StdHypothesisCreator::hypTypeName( const QString& t ) cons types.insert( "SegmentLengthAroundVertex", "SEGMENT_LENGTH_AROUND_VERTEX" ); types.insert( "MaxLength", "MAX_LENGTH" ); types.insert( "ViscousLayers", "VISCOUS_LAYERS" ); + types.insert( "ViscousLayers2D", "VISCOUS_LAYERS" ); types.insert( "QuadrangleParams", "QUADRANGLE_PARAMS" ); types.insert( "CartesianParameters3D", "CARTESIAN_PARAMS" ); } diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.ts b/src/StdMeshersGUI/StdMeshers_msg_en.ts index df97c12a1..2b506311f 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.ts +++ b/src/StdMeshersGUI/StdMeshers_msg_en.ts @@ -166,6 +166,11 @@ SMESH_FACES_WO_LAYERS Faces without layers +(inlets and oulets) + + + SMESH_EDGES_WO_LAYERS + Edges without layers (inlets and oulets) diff --git a/src/StdMeshers_I/Makefile.am b/src/StdMeshers_I/Makefile.am index 4bc901d2d..c9f50b4d0 100644 --- a/src/StdMeshers_I/Makefile.am +++ b/src/StdMeshers_I/Makefile.am @@ -68,6 +68,7 @@ salomeinclude_HEADERS = \ StdMeshers_Import_1D_i.hxx \ StdMeshers_Import_1D2D_i.hxx \ StdMeshers_ViscousLayers_i.hxx \ + StdMeshers_ViscousLayers2D_i.hxx \ StdMeshers_CartesianParameters3D_i.hxx \ StdMeshers_Cartesian_3D_i.hxx @@ -116,6 +117,7 @@ dist_libStdMeshersEngine_la_SOURCES = \ StdMeshers_Import_1D_i.cxx \ StdMeshers_Import_1D2D_i.cxx \ StdMeshers_ViscousLayers_i.cxx \ + StdMeshers_ViscousLayers2D_i.cxx \ StdMeshers_CartesianParameters3D_i.cxx \ StdMeshers_Cartesian_3D_i.cxx diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx new file mode 100644 index 000000000..b60672a9e --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.cxx @@ -0,0 +1,225 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : StdMeshers_ViscousLayers2D_i.cxx +// Module : SMESH +// +#include "StdMeshers_ViscousLayers2D_i.hxx" + +#include "SMESH_Gen.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_PythonDump.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +#include + +#include CORBA_SERVER_HEADER(SMESH_Group) + +using namespace std; + +//============================================================================= +/*! + * StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_ViscousLayers2D_i::StdMeshers_ViscousLayers2D_i" ); + myBaseImpl = new ::StdMeshers_ViscousLayers2D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i() +{ + MESSAGE( "StdMeshers_ViscousLayers2D_i::~StdMeshers_ViscousLayers2D_i" ); +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +void StdMeshers_ViscousLayers2D_i::SetIgnoreEdges(const ::SMESH::long_array& edgeIDs) +throw ( SALOME::SALOME_Exception ) +{ + vector ids( edgeIDs.length() ); + for ( unsigned i = 0; i < ids.size(); ++i ) + if (( ids[i] = edgeIDs[i] ) < 1 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid edge id", SALOME::BAD_PARAM ); + GetImpl()->SetBndShapesToIgnore( ids ); + SMESH::TPythonDump() << _this() << ".SetIgnoreEdges( " << edgeIDs << " )"; +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +SMESH::long_array* StdMeshers_ViscousLayers2D_i::GetIgnoreEdges() +{ + vector idsVec = GetImpl()->GetBndShapesToIgnore(); + SMESH::long_array_var ids = new SMESH::long_array; + ids->length( idsVec.size() ); + for ( unsigned i = 0; i < idsVec.size(); ++i ) + ids[i] = idsVec[i]; + return ids._retn(); +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +void StdMeshers_ViscousLayers2D_i::SetTotalThickness(::CORBA::Double thickness) +throw ( SALOME::SALOME_Exception ) +{ + if ( thickness < 1e-100 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid thickness", SALOME::BAD_PARAM ); + GetImpl()->SetTotalThickness(thickness); + SMESH::TPythonDump() << _this() << ".SetTotalThickness( " << SMESH::TVar(thickness) << " )"; +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +::CORBA::Double StdMeshers_ViscousLayers2D_i::GetTotalThickness() +{ + return GetImpl()->GetTotalThickness(); +} + +//================================================================================ +/*! + * \brief + * \param nb - + */ +//================================================================================ + +void StdMeshers_ViscousLayers2D_i::SetNumberLayers(::CORBA::Short nb) +throw ( SALOME::SALOME_Exception ) +{ + if ( nb < 1 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid number of layers", SALOME::BAD_PARAM ); + GetImpl()->SetNumberLayers( nb ); + SMESH::TPythonDump() << _this() << ".SetNumberLayers( " << SMESH::TVar(nb) << " )"; +} + +//================================================================================ +/*! + * \brief + */ +//================================================================================ + +::CORBA::Short StdMeshers_ViscousLayers2D_i::GetNumberLayers() +{ + return CORBA::Short( GetImpl()->GetNumberLayers() ); +} + +//================================================================================ +/*! + * \brief + * \param factor - + */ +//================================================================================ + +void StdMeshers_ViscousLayers2D_i::SetStretchFactor(::CORBA::Double factor) +throw ( SALOME::SALOME_Exception ) +{ + if ( factor < 1 ) + THROW_SALOME_CORBA_EXCEPTION( "Invalid stretch factor, it must be >= 1.0", SALOME::BAD_PARAM ); + GetImpl()->SetStretchFactor(factor); + SMESH::TPythonDump() << _this() << ".SetStretchFactor( " << SMESH::TVar(factor) << " )"; +} + +//================================================================================ +/*! + * \brief + * + */ +//================================================================================ + +::CORBA::Double StdMeshers_ViscousLayers2D_i::GetStretchFactor() +{ + return GetImpl()->GetStretchFactor(); +} + +//============================================================================= +/*! + * Get implementation + */ +//============================================================================= + +::StdMeshers_ViscousLayers2D* StdMeshers_ViscousLayers2D_i::GetImpl() +{ + MESSAGE( "StdMeshers_ViscousLayers2D_i::GetImpl" ); + return ( ::StdMeshers_ViscousLayers2D* )myBaseImpl; +} + +//================================================================================ +/*! + * \brief Verify whether hypothesis supports given entity type + * \param type - dimension (see SMESH::Dimension enumeration) + * \retval CORBA::Boolean - TRUE if dimension is supported, FALSE otherwise + * + * Verify whether hypothesis supports given entity type (see SMESH::Dimension enumeration) + */ +//================================================================================ + +CORBA::Boolean StdMeshers_ViscousLayers2D_i::IsDimSupported( SMESH::Dimension type ) +{ + return type == SMESH::DIM_2D; +} + +//================================================================================ +/*! + * \brief Sets sub-mesh event listeners to clear sub-meshes of edges + * shrinked by viscous layers + */ +//================================================================================ + +void StdMeshers_ViscousLayers2D_i::UpdateAsMeshesRestored() +{ + GetImpl()->RestoreListeners(); +} diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx new file mode 100644 index 000000000..8a6eacf03 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers2D_i.hxx @@ -0,0 +1,74 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : StdMeshers_ViscousLayers2D_i.hxx +// Module : SMESH +// +#ifndef _SMESH_ViscousLayers2D_I_HXX_ +#define _SMESH_ViscousLayers2D_I_HXX_ + +#include "SMESH_StdMeshers_I.hxx" + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "StdMeshers_ViscousLayers_i.hxx" +#include "StdMeshers_ViscousLayers2D.hxx" + +class SMESH_Gen; + +class STDMESHERS_I_EXPORT StdMeshers_ViscousLayers2D_i: + public virtual POA_StdMeshers::StdMeshers_ViscousLayers2D, + public virtual SMESH_Hypothesis_i +{ + public: + // Constructor + StdMeshers_ViscousLayers2D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_ViscousLayers2D_i(); + + void SetIgnoreEdges(const ::SMESH::long_array& edgeIDs) throw ( SALOME::SALOME_Exception ); + SMESH::long_array* GetIgnoreEdges(); + + void SetTotalThickness(::CORBA::Double thickness) throw ( SALOME::SALOME_Exception ); + ::CORBA::Double GetTotalThickness(); + + void SetNumberLayers(::CORBA::Short nb) throw ( SALOME::SALOME_Exception ); + ::CORBA::Short GetNumberLayers(); + + void SetStretchFactor(::CORBA::Double factor) throw ( SALOME::SALOME_Exception ); + ::CORBA::Double GetStretchFactor(); + + // Get implementation + ::StdMeshers_ViscousLayers2D* GetImpl(); + + // Verify whether hypothesis supports given entity type + CORBA::Boolean IsDimSupported( SMESH::Dimension type ); + + // Sets sub-mesh event listeners to clear sub-meshes of edges + // shrinked by viscous layers + virtual void UpdateAsMeshesRestored(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx index 55ca30d75..e6e7897f0 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.cxx @@ -85,7 +85,7 @@ throw ( SALOME::SALOME_Exception ) for ( unsigned i = 0; i < ids.size(); ++i ) if (( ids[i] = faceIDs[i] ) < 1 ) THROW_SALOME_CORBA_EXCEPTION( "Invalid face id", SALOME::BAD_PARAM ); - GetImpl()->SetIgnoreFaces( ids ); + GetImpl()->SetBndShapesToIgnore( ids ); SMESH::TPythonDump() << _this() << ".SetIgnoreFaces( " << faceIDs << " )"; } @@ -97,7 +97,7 @@ throw ( SALOME::SALOME_Exception ) SMESH::long_array* StdMeshers_ViscousLayers_i::GetIgnoreFaces() { - vector idsVec = GetImpl()->GetIgnoreFaces(); + vector idsVec = GetImpl()->GetBndShapesToIgnore(); SMESH::long_array_var ids = new SMESH::long_array; ids->length( idsVec.size() ); for ( unsigned i = 0; i < idsVec.size(); ++i ) diff --git a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx index e4d5d6e2e..b17f9f242 100644 --- a/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx +++ b/src/StdMeshers_I/StdMeshers_ViscousLayers_i.hxx @@ -20,7 +20,6 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses // File : StdMeshers_ViscousLayers_i.hxx // Module : SMESH // diff --git a/src/StdMeshers_I/StdMeshers_i.cxx b/src/StdMeshers_I/StdMeshers_i.cxx index 20104d9c8..992082758 100644 --- a/src/StdMeshers_I/StdMeshers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -73,6 +73,7 @@ #include "StdMeshers_Import_1D_i.hxx" #include "StdMeshers_Import_1D2D_i.hxx" #include "StdMeshers_ViscousLayers_i.hxx" +#include "StdMeshers_ViscousLayers2D_i.hxx" #include "StdMeshers_CartesianParameters3D_i.hxx" template class StdHypothesisCreator_i:public HypothesisCreator_i @@ -179,6 +180,8 @@ STDMESHERS_I_EXPORT aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "ViscousLayers") == 0) aCreator = new StdHypothesisCreator_i; + else if (strcmp(aHypName, "ViscousLayers2D") == 0) + aCreator = new StdHypothesisCreator_i; else if (strcmp(aHypName, "CartesianParameters3D") == 0) aCreator = new StdHypothesisCreator_i; -- 2.39.2