X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=tests%2Fenforced_mesh.py;h=121033d7ab6fde22a2f2138a7afcff3f939f8164;hb=7972d6e3ce34777547876d3f4d52fc7c09d39334;hp=d2675f250127619d57bd51d4e029cceda57a68db;hpb=d797fa4d76751c59832d908640eea64483d0bacd;p=plugins%2Fhybridplugin.git diff --git a/tests/enforced_mesh.py b/tests/enforced_mesh.py index d2675f2..121033d 100644 --- a/tests/enforced_mesh.py +++ b/tests/enforced_mesh.py @@ -1,10 +1,27 @@ # -*- coding: utf-8 -*- +# Copyright (C) 2017-2023 CEA, EDF +# +# 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, or (at your option) any later version. +# +# 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 +# import sys import salome salome.salome_init() -theStudy = salome.myStudy ### ### GEOM component @@ -16,39 +33,54 @@ import math import SALOMEDS -geompy = geomBuilder.New(theStudy) +geompy = geomBuilder.New() + +# first cylinder +r1 = 0.5 +h1 = 5 + +# second cylinder +r2 = 0.3 +h2 = 3 + +length_piquage = 1.5 O = geompy.MakeVertex(0, 0, 0) OX = geompy.MakeVectorDXDYDZ(1, 0, 0) OY = geompy.MakeVectorDXDYDZ(0, 1, 0) OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) -Cylinder_1 = geompy.MakeCylinderRH(0.5, 5) -Cylinder_2 = geompy.MakeCylinderRH(0.3, 3) -Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) -Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, 1.5) -piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) -[Outlet] = geompy.SubShapes(piquage, [15]) -[Inlet_z,Inlet_x] = geompy.SubShapes(piquage, [3, 22]) -[corner] = geompy.SubShapes(piquage, [14]) -geomObj_1 = geompy.MakeVertex(0, 0, 0) -geomObj_2 = geompy.MakeVectorDXDYDZ(1, 0, 0) -geomObj_3 = geompy.MakeVectorDXDYDZ(0, 1, 0) -geomObj_4 = geompy.MakeVectorDXDYDZ(0, 0, 1) -Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) -geompy.UnionIDs(Wall, [7, 17]) geompy.addToStudy( O, 'O' ) geompy.addToStudy( OX, 'OX' ) geompy.addToStudy( OY, 'OY' ) geompy.addToStudy( OZ, 'OZ' ) -geompy.addToStudy( Cylinder_1, 'Cylinder_1' ) -geompy.addToStudy( Cylinder_2, 'Cylinder_2' ) -geompy.addToStudy( Rotation_1, 'Rotation_1' ) -geompy.addToStudy( Translation_1, 'Translation_1' ) + +Cylinder_1 = geompy.MakeCylinderRH(r1, h1) +Cylinder_2 = geompy.MakeCylinderRH(r2, h2) +Rotation_1 = geompy.MakeRotation(Cylinder_2, OY, -90*math.pi/180.0) +Translation_1 = geompy.MakeTranslation(Rotation_1, 0, 0, length_piquage) + +piquage = geompy.MakeFuseList([Cylinder_1, Translation_1], True, True) geompy.addToStudy( piquage, 'piquage' ) + +Inlet_z = geompy.GetFaceNearPoint(piquage, O) +geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) + +p_inlet_x = geompy.MakeVertex(-h2, 0, length_piquage) +Inlet_x = geompy.GetFaceNearPoint(piquage, p_inlet_x) geompy.addToStudyInFather( piquage, Inlet_x, 'Inlet_x' ) + +p_outlet = geompy.MakeVertex(0, 0, h1) +Outlet = geompy.GetFaceNearPoint(piquage, p_outlet) geompy.addToStudyInFather( piquage, Outlet, 'Outlet' ) + +Wall = geompy.CreateGroup(piquage, geompy.ShapeType["FACE"]) +faces = geompy.SubShapeAll(piquage, geompy.ShapeType["FACE"]) +geompy.UnionList(Wall, faces) +geompy.DifferenceList(Wall, [Inlet_x, Inlet_z, Outlet]) geompy.addToStudyInFather( piquage, Wall, 'Wall' ) -geompy.addToStudyInFather( piquage, Inlet_z, 'Inlet_z' ) + +p_corner = geompy.MakeVertex(-r2, 0, length_piquage+r2) +corner = geompy.GetVertexNearPoint(piquage, p_corner) geompy.addToStudyInFather( piquage, corner, 'corner' ) p1 = geompy.MakeVertex(0, -0.25, 1) @@ -68,7 +100,7 @@ from salome.smesh import smeshBuilder from salome.StdMeshers import StdMeshersBuilder -smesh = smeshBuilder.New(theStudy) +smesh = smeshBuilder.New() Mesh_faces = smesh.Mesh(face) Mesh_faces.Triangle(algo=smeshBuilder.MG_CADSurf) @@ -89,13 +121,16 @@ NETGEN_2D_Parameters.SetGrowthRate( 0.1 ) NETGEN_2D_Parameters.SetNbSegPerEdge( 2 ) NETGEN_2D_Parameters.SetNbSegPerRadius( 3 ) +wall_faces = geompy.SubShapeAll(Wall, geompy.ShapeType["FACE"]) +wall_ids = geompy.GetSubShapesIDs(piquage, wall_faces) + NETGEN_3D = Mesh_1.Tetrahedron() Viscous_Layers_1 = NETGEN_3D.ViscousLayers(0.05,3,1.1,[],1,StdMeshersBuilder.SURF_OFFSET_SMOOTH) Viscous_Layers_1.SetTotalThickness( 0.05 ) Viscous_Layers_1.SetNumberLayers( 3 ) Viscous_Layers_1.SetStretchFactor( 1.1 ) Viscous_Layers_1.SetMethod( StdMeshersBuilder.SURF_OFFSET_SMOOTH ) -Viscous_Layers_1.SetFaces( [ 7, 17 ], 0 ) +Viscous_Layers_1.SetFaces( wall_ids, 0 ) #isDone = Mesh_1.Compute() @@ -164,5 +199,3 @@ assert len(Mesh_3.GetGroups()) == 1 assert Mesh_3.GetGroups()[0].GetName() == 'LayersGroup' assert Mesh_3.GetGroups()[0].Size() > 0 -if salome.sg.hasDesktop(): - salome.sg.updateObjBrowser(1)