106 lines
3.5 KiB
Python
Raw Normal View History

2014-01-09 14:20:44 +00:00
# -*- coding: iso-8859-1 -*-
2021-03-23 17:44:27 +03:00
# Copyright (C) 2014-2021 EDF R&D
2019-02-14 14:55:47 +03:00
#
# 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
#
2021-04-06 11:58:50 +02:00
"""Géométrie et maillage de base nécessaire au cas-test :
2021-04-06 11:42:59 +02:00
. disque_perce
"""
import os
2014-01-09 14:20:44 +00:00
2021-01-26 18:49:09 +01:00
import logging
2014-01-09 14:20:44 +00:00
import salome
2021-04-06 11:42:59 +02:00
from salome.smesh import smeshBuilder
from salome.StdMeshers import StdMeshersBuilder
import GEOM
import SMESH
import SALOMEDS
2014-01-09 14:20:44 +00:00
from blocFissure import gmu
2021-04-06 11:42:59 +02:00
from blocFissure.gmu.geomsmesh import geompy
from blocFissure.gmu.geomsmesh import geomPublish
from blocFissure.gmu.geomsmesh import geomPublishInFather
2014-01-09 14:20:44 +00:00
2021-04-06 11:42:59 +02:00
from blocFissure.gmu.triedreBase import triedreBase
from blocFissure.gmu.putName import putName
from blocFissure.gmu import initLog
2014-01-09 14:20:44 +00:00
###
### GEOM component
###
2021-04-06 11:42:59 +02:00
O, OX, OY, OZ = triedreBase()
2014-01-09 14:20:44 +00:00
Cylinder_1 = geompy.MakeCylinderRH(100, 300)
Cylinder_2 = geompy.MakeCylinderRH(600, 200)
Cut_1 = geompy.MakeCut(Cylinder_2, Cylinder_1)
Face_1 = geompy.MakeFaceHW(500, 1500, 3)
Disque = geompy.MakePartition([Cut_1], [Face_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
[Compound_1, Compound_2, Compound_3, Compound_4] = geompy.Propagate(Disque)
geompy.addToStudy( Disque, 'Disque' )
geompy.addToStudyInFather( Disque, Compound_1, 'Compound_1' )
geompy.addToStudyInFather( Disque, Compound_2, 'Compound_2' )
geompy.addToStudyInFather( Disque, Compound_3, 'Compound_3' )
geompy.addToStudyInFather( Disque, Compound_4, 'Compound_4' )
2021-04-06 11:42:59 +02:00
geomPublish(initLog.debug, Cylinder_1, 'Cylinder_1' )
geomPublish(initLog.debug, Cylinder_2, 'Cylinder_2' )
geomPublish(initLog.debug, Cut_1, 'Cut_1' )
geomPublish(initLog.debug, Face_1, 'Face_1' )
2014-01-09 14:20:44 +00:00
###
### SMESH component
###
2017-06-13 13:01:10 +03:00
smesh = smeshBuilder.New()
2014-01-09 14:20:44 +00:00
Disque_1 = smesh.Mesh(Disque)
2021-04-06 11:42:59 +02:00
putName(Disque_1.GetMesh(), 'Disque')
2014-01-09 14:20:44 +00:00
Regular_1D = Disque_1.Segment()
Nb_Segments_1 = Regular_1D.NumberOfSegments(10)
Nb_Segments_1.SetDistrType( 0 )
Hexa_3D = Disque_1.Hexahedron(algo=smeshBuilder.Hexa)
Regular_1D_1 = Disque_1.Segment(geom=Compound_3)
Nb_Segments_2 = Regular_1D_1.NumberOfSegments(20)
Nb_Segments_2.SetDistrType( 0 )
Regular_1D_2 = Disque_1.Segment(geom=Compound_4)
status = Disque_1.AddHypothesis(Nb_Segments_2,Compound_4)
Quadrangle_2D = Disque_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
2021-01-27 11:51:06 +01:00
2021-04-06 11:42:59 +02:00
## set object names
#smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
#smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
#smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
putName(Nb_Segments_1, 'Nb. Segments_1', i_pref='Disque')
putName(Nb_Segments_2, 'Nb. Segments_2', i_pref='Disque')
2021-01-26 18:34:02 +01:00
is_done = Disque_1.Compute()
text = "Disque_1.Compute"
if is_done:
logging.info(text+" OK")
else:
text = "Erreur au calcul du maillage.\n" + text
logging.info(text)
raise Exception(text)
2021-01-27 11:51:06 +01:00
2021-01-22 18:08:58 +01:00
Disque_1.ExportMED(os.path.join(gmu.pathBloc, "materielCasTests", "disque.med"))
2014-01-09 14:20:44 +00:00
if salome.sg.hasDesktop():
2017-06-13 13:01:10 +03:00
salome.sg.updateObjBrowser()