#!/usr/bin/env python

###
### This file is generated automatically by SALOME v9.7.0 with dump python functionality
###

import sys
import salome

salome.salome_init()
import salome_notebook
notebook = salome_notebook.NoteBook()
sys.path.insert(0, r'/home/nafaryus/projects/anisotropy/playground')

###
### GEOM component
###

import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS


geompy = geomBuilder.New()

O = geompy.MakeVertex(0, 0, 0)
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
Box_1 = geompy.MakeBoxDXDYDZ(1, 1, 1)
Fillet_1 = geompy.MakeFilletR1R2(Box_1, 0.2, 0.5, geompy.ShapeType["EDGE"], [18])
Group_1 = geompy.CreateGroup(Fillet_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_1, [13])
Group_2 = geompy.CreateGroup(Fillet_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_2, [37])
Group_3 = geompy.CreateGroup(Fillet_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_3, [3])
Group_4 = geompy.CreateGroup(Fillet_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_4, [27])
Group_5 = geompy.CreateGroup(Fillet_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_5, [32])
Group_6 = geompy.CreateGroup(Fillet_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_6, [40])
Group_7 = geompy.CreateGroup(Fillet_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_7, [22])
[Group_1, Group_2, Group_3, Group_4, Group_5, Group_6, Group_7] = geompy.GetExistingSubObjects(Fillet_1, False)
geompy.addToStudy( O, 'O' )
geompy.addToStudy( OX, 'OX' )
geompy.addToStudy( OY, 'OY' )
geompy.addToStudy( OZ, 'OZ' )
geompy.addToStudy( Box_1, 'Box_1' )
geompy.addToStudy( Fillet_1, 'Fillet_1' )
geompy.addToStudyInFather( Fillet_1, Group_1, 'Group_1' )
geompy.addToStudyInFather( Fillet_1, Group_2, 'Group_2' )
geompy.addToStudyInFather( Fillet_1, Group_3, 'Group_3' )
geompy.addToStudyInFather( Fillet_1, Group_4, 'Group_4' )
geompy.addToStudyInFather( Fillet_1, Group_5, 'Group_5' )
geompy.addToStudyInFather( Fillet_1, Group_6, 'Group_6' )
geompy.addToStudyInFather( Fillet_1, Group_7, 'Group_7' )

###
### SMESH component
###

import  SMESH, SALOMEDS
from salome.smesh import smeshBuilder

smesh = smeshBuilder.New()
#smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations:
                                 # multiples meshes built in parallel, complex and numerous mesh edition (performance)

Mesh_1 = smesh.Mesh(Fillet_1)
GMSH = Mesh_1.Tetrahedron(algo=smeshBuilder.GMSH)
Gmsh_Parameters = GMSH.Parameters()
Gmsh_Parameters.Set2DAlgo( 0 )
Gmsh_Parameters.SetMinSize( 0 )
Gmsh_Parameters.SetMaxSize( 0.5 )
Gmsh_Parameters.SetIs2d( 0 )
Group_1_1 = Mesh_1.GroupOnGeom(Group_1,'Group_1',SMESH.FACE)
Group_2_1 = Mesh_1.GroupOnGeom(Group_2,'Group_2',SMESH.FACE)
Group_3_1 = Mesh_1.GroupOnGeom(Group_3,'Group_3',SMESH.FACE)
Group_4_1 = Mesh_1.GroupOnGeom(Group_4,'Group_4',SMESH.FACE)
Group_5_1 = Mesh_1.GroupOnGeom(Group_5,'Group_5',SMESH.FACE)
Group_6_1 = Mesh_1.GroupOnGeom(Group_6,'Group_6',SMESH.FACE)
Group_7_1 = Mesh_1.GroupOnGeom(Group_7,'Group_7',SMESH.FACE)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
Gmsh_Parameters.SetMinSize( 0.15307 )
Gmsh_Parameters.SetMaxSize( 0.17443 )
Gmsh_Parameters.SetIs2d( 0 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(GMSH)
PolyhedronPerSolid_3D = Mesh_1.Polyhedron()
status = Mesh_1.RemoveHypothesis(Gmsh_Parameters)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
NETGEN_1D_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D)
NETGEN_2D_Parameters_1 = NETGEN_1D_2D.Parameters()
NETGEN_2D_Parameters_1.SetMaxSize( 0.173205 )
NETGEN_2D_Parameters_1.SetMinSize( 0.0147777 )
NETGEN_2D_Parameters_1.SetSecondOrder( 0 )
NETGEN_2D_Parameters_1.SetOptimize( 1 )
NETGEN_2D_Parameters_1.SetFineness( 2 )
NETGEN_2D_Parameters_1.SetChordalError( -1 )
NETGEN_2D_Parameters_1.SetChordalErrorEnabled( 0 )
NETGEN_2D_Parameters_1.SetUseSurfaceCurvature( 1 )
NETGEN_2D_Parameters_1.SetFuseEdges( 1 )
NETGEN_2D_Parameters_1.SetWorstElemMeasure( 0 )
NETGEN_2D_Parameters_1.SetUseDelauney( 0 )
NETGEN_2D_Parameters_1.SetQuadAllowed( 0 )
NETGEN_2D_Parameters_1.SetCheckChartBoundary( 16 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(NETGEN_1D_2D)
status = Mesh_1.RemoveHypothesis(PolyhedronPerSolid_3D)
status = Mesh_1.RemoveHypothesis(NETGEN_2D_Parameters_1)
Prism_3D = Mesh_1.Prism()
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
UseExisting_1D = Mesh_1.UseExistingSegments()
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(UseExisting_1D)
Regular_1D = Mesh_1.Segment()
Number_of_Segments_1 = Regular_1D.NumberOfSegments(15)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(Regular_1D)
status = Mesh_1.RemoveHypothesis(Prism_3D)
status = Mesh_1.RemoveHypothesis(Number_of_Segments_1)
Hexa_3D = Mesh_1.Hexahedron(algo=smeshBuilder.Hexa)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
Quadrangle_2D = Mesh_1.Quadrangle(algo=smeshBuilder.QUADRANGLE)
Quadrangle_Parameters_1 = Quadrangle_2D.QuadrangleParameters(smeshBuilder.QUAD_QUADRANGLE_PREF,-1,[],[])
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
Renumber_1 = Hexa_3D.Renumber()
Renumber_1.SetBlocksOrientation([  ])
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
Regular_1D_1 = Mesh_1.Segment()
Number_of_Segments_2 = Regular_1D.NumberOfSegments(15)
status = Mesh_1.RemoveHypothesis(Renumber_1)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
SegmentAroundVertex_0D = smesh.CreateHypothesis('SegmentAroundVertex_0D')
Length_Near_Vertex_1 = Regular_1D.LengthNearVertex(0.1,Fillet_1)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(Quadrangle_2D)
status = Mesh_1.RemoveHypothesis(Hexa_3D)
MEFISTO_2D = Mesh_1.Triangle(algo=smeshBuilder.MEFISTO)
status = Mesh_1.RemoveHypothesis(Quadrangle_Parameters_1)
Max_Element_Area_1 = MEFISTO_2D.MaxElementArea(0.03)
MG_Tetra = Mesh_1.Tetrahedron(algo=smeshBuilder.MG_Tetra)
MG_Tetra_Parameters_1 = MG_Tetra.Parameters()
MG_Tetra_Parameters_1.SetOptimizationLevel( 2 )
MG_Tetra_Parameters_1.SetToMeshHoles( 0 )
MG_Tetra_Parameters_1.SetToMakeGroupsOfDomains( 0 )
MG_Tetra_Parameters_1.SetMaximumMemory( -1 )
MG_Tetra_Parameters_1.SetInitialMemory( -1 )
MG_Tetra_Parameters_1.SetKeepFiles( 0 )
MG_Tetra_Parameters_1.SetWorkingDirectory( '/tmp/' )
MG_Tetra_Parameters_1.SetVerboseLevel( 10 )
MG_Tetra_Parameters_1.SetStandardOutputLog( 0 )
MG_Tetra_Parameters_1.SetRemoveLogOnSuccess( 0 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(MG_Tetra)
NETGEN_3D = Mesh_1.Tetrahedron()
status = Mesh_1.RemoveHypothesis(MG_Tetra_Parameters_1)
NETGEN_3D_Parameters_1 = NETGEN_3D.Parameters()
NETGEN_3D_Parameters_1.SetMaxSize( 0.173205 )
NETGEN_3D_Parameters_1.SetMinSize( 0.0147777 )
NETGEN_3D_Parameters_1.SetOptimize( 1 )
NETGEN_3D_Parameters_1.SetFineness( 2 )
NETGEN_3D_Parameters_1.SetElemSizeWeight( -5.29735e+296 )
NETGEN_3D_Parameters_1.SetCheckOverlapping( 0 )
NETGEN_3D_Parameters_1.SetCheckChartBoundary( 16 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
NETGEN_1D_2D_1 = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_1D2D,geom=Group_7)
NETGEN_2D_Parameters_2 = NETGEN_1D_2D_1.Parameters()
NETGEN_2D_Parameters_2.SetMaxSize( 0.173205 )
NETGEN_2D_Parameters_2.SetMinSize( 0.015262 )
NETGEN_2D_Parameters_2.SetSecondOrder( 0 )
NETGEN_2D_Parameters_2.SetOptimize( 1 )
NETGEN_2D_Parameters_2.SetFineness( 2 )
NETGEN_2D_Parameters_2.SetChordalError( -1 )
NETGEN_2D_Parameters_2.SetChordalErrorEnabled( 0 )
NETGEN_2D_Parameters_2.SetUseSurfaceCurvature( 1 )
NETGEN_2D_Parameters_2.SetFuseEdges( 1 )
NETGEN_2D_Parameters_2.SetWorstElemMeasure( 0 )
NETGEN_2D_Parameters_2.SetUseDelauney( 0 )
NETGEN_2D_Parameters_2.SetQuadAllowed( 0 )
NETGEN_2D_Parameters_2.SetCheckChartBoundary( 112 )
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(NETGEN_1D_2D,Group_7)
Regular_1D_2 = Mesh_1.Segment(geom=Group_7)
Max_Size_1 = Regular_1D_2.MaxSize(0.01)
NETGEN_2D = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_2D,geom=Group_7)
status = Mesh_1.RemoveHypothesis(NETGEN_2D_Parameters_2,Group_7)
Length_From_Edges_1 = NETGEN_2D.LengthFromEdges()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(MEFISTO_2D)
status = Mesh_1.RemoveHypothesis(Number_of_Segments_2)
Deflection_1 = Regular_1D.Deflection1D(0.001)
NETGEN_2D_1 = Mesh_1.Triangle(algo=smeshBuilder.NETGEN_2D)
status = Mesh_1.RemoveHypothesis(Max_Element_Area_1)
Max_Element_Area_2 = MEFISTO_2D.MaxElementArea(0.05)
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(Length_From_Edges_1,Group_7)
Max_Element_Area_3 = NETGEN_2D.MaxElementArea(0.01)
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(Max_Element_Area_3,Group_7)
NETGEN_2D_Parameters_1_1 = NETGEN_2D.Parameters()
NETGEN_2D_Parameters_1_1.SetMaxSize( 0.173205 )
NETGEN_2D_Parameters_1_1.SetMinSize( 0.015262 )
NETGEN_2D_Parameters_1_1.SetOptimize( 1 )
NETGEN_2D_Parameters_1_1.SetFineness( 2 )
NETGEN_2D_Parameters_1_1.SetChordalError( -1 )
NETGEN_2D_Parameters_1_1.SetChordalErrorEnabled( 0 )
NETGEN_2D_Parameters_1_1.SetUseSurfaceCurvature( 1 )
NETGEN_2D_Parameters_1_1.SetWorstElemMeasure( 0 )
NETGEN_2D_Parameters_1_1.SetUseDelauney( 0 )
NETGEN_2D_Parameters_1_1.SetCheckChartBoundary( 0 )
NETGEN_2D_Parameters_1_1.SetQuadAllowed( 0 )
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
#Mesh_1.GetMesh().RemoveSubMesh( smeshObj_1 ) ### smeshObj_1 has not been yet created
status = Mesh_1.RemoveHypothesis(Length_Near_Vertex_1)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
Max_Element_Area_2.SetMaxElementArea( 0.01 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(NETGEN_3D_Parameters_1)
NETGEN_3D_Parameters_2 = NETGEN_3D.Parameters()
NETGEN_3D_Parameters_2.SetMaxSize( 0.173205 )
NETGEN_3D_Parameters_2.SetMinSize( 0.015262 )
NETGEN_3D_Parameters_2.SetOptimize( 1 )
NETGEN_3D_Parameters_2.SetFineness( 4 )
NETGEN_3D_Parameters_2.SetElemSizeWeight( -5.29735e+296 )
NETGEN_3D_Parameters_2.SetCheckOverlapping( 0 )
NETGEN_3D_Parameters_2.SetCheckChartBoundary( 16 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(Deflection_1)
Automatic_Length_1 = Regular_1D.AutomaticLength(1)
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
Automatic_Length_1.SetFineness( 0.5 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
status = Mesh_1.RemoveHypothesis(Max_Element_Area_2)
Length_From_Edges_2 = MEFISTO_2D.LengthFromEdges()
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()
Automatic_Length_1.SetFineness( 0.25 )
isDone = Mesh_1.Compute()
[ Group_1_1, Group_2_1, Group_3_1, Group_4_1, Group_5_1, Group_6_1, Group_7_1 ] = Mesh_1.GetGroups()


## Set names of Mesh objects
smesh.SetName(GMSH.GetAlgorithm(), 'GMSH')
smesh.SetName(Automatic_Length_1, 'Automatic Length_1')
smesh.SetName(NETGEN_1D_2D.GetAlgorithm(), 'NETGEN 1D-2D')
smesh.SetName(Length_From_Edges_2, 'Length From Edges_2')
smesh.SetName(PolyhedronPerSolid_3D.GetAlgorithm(), 'PolyhedronPerSolid_3D')
smesh.SetName(UseExisting_1D.GetAlgorithm(), 'UseExisting_1D')
smesh.SetName(NETGEN_2D_Parameters_1, 'NETGEN 2D Parameters_1')
smesh.SetName(Number_of_Segments_1, 'Number of Segments_1')
smesh.SetName(Prism_3D.GetAlgorithm(), 'Prism_3D')
smesh.SetName(Hexa_3D.GetAlgorithm(), 'Hexa_3D')
smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D')
smesh.SetName(Gmsh_Parameters, 'Gmsh Parameters')
smesh.SetName(SegmentAroundVertex_0D, 'SegmentAroundVertex_0D')
smesh.SetName(Renumber_1, 'Renumber_1')
smesh.SetName(Number_of_Segments_2, 'Number of Segments_2')
smesh.SetName(Quadrangle_2D.GetAlgorithm(), 'Quadrangle_2D')
smesh.SetName(Group_1_1, 'Group_1')
smesh.SetName(Quadrangle_Parameters_1, 'Quadrangle Parameters_1')
smesh.SetName(Group_2_1, 'Group_2')
smesh.SetName(Group_3_1, 'Group_3')
smesh.SetName(Group_4_1, 'Group_4')
smesh.SetName(Length_Near_Vertex_1, 'Length Near Vertex_1')
smesh.SetName(Group_5_1, 'Group_5')
smesh.SetName(MG_Tetra_Parameters_1, 'MG-Tetra Parameters_1')
smesh.SetName(Group_6_1, 'Group_6')
smesh.SetName(Group_7_1, 'Group_7')
smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
smesh.SetName(Length_From_Edges_1, 'Length From Edges_1')
smesh.SetName(NETGEN_2D_Parameters_2, 'NETGEN 2D Parameters_2')
smesh.SetName(NETGEN_3D_Parameters_1, 'NETGEN 3D Parameters_1')
smesh.SetName(Max_Element_Area_1, 'Max. Element Area_1')
smesh.SetName(Max_Element_Area_3, 'Max. Element Area_3')
smesh.SetName(Deflection_1, 'Deflection_1')
smesh.SetName(Max_Element_Area_2, 'Max. Element Area_2')
smesh.SetName(Max_Size_1, 'Max Size_1')
smesh.SetName(NETGEN_3D_Parameters_2, 'NETGEN 3D Parameters_2')
smesh.SetName(NETGEN_2D_Parameters_1_1, 'NETGEN 2D Parameters_1')
smesh.SetName(MEFISTO_2D.GetAlgorithm(), 'MEFISTO_2D')
smesh.SetName(MG_Tetra.GetAlgorithm(), 'MG-Tetra')
smesh.SetName(NETGEN_3D.GetAlgorithm(), 'NETGEN 3D')
smesh.SetName(NETGEN_2D.GetAlgorithm(), 'NETGEN 2D')


if salome.sg.hasDesktop():
  salome.sg.updateObjBrowser()
