#!/usr/bin/env python

###
### This file is generated automatically by SALOME v9.6.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/anisotrope-cube/worksheet')

###
### GEOM component
###

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


geompy = geomBuilder.New()

geomObj_1 = geompy.MakeVectorDXDYDZ(1, 0, 0)
geomObj_2 = geompy.MakeVectorDXDYDZ(0, 1, 0)
geomObj_3 = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_4 = geompy.MakeBoxDXDYDZ(2.82842712474619, 2.82842712474619, 2)
geomObj_5 = geompy.MakeRotation(geomObj_4, geomObj_3, 45*math.pi/180.0)
geomObj_6 = geompy.MakeTranslation(geomObj_5, 2, 0, 0)
geomObj_7 = geompy.MakeVertex(2, 0, 0)
geomObj_8 = geompy.MakeVertex(2, 2, 0)
geomObj_9 = geompy.MakeVertex(2, 2, 2)
geomObj_10 = geompy.MakeLineTwoPnt(geomObj_8, geomObj_9)
geomObj_11 = geompy.MakeSpherePntR(geomObj_7, 1.111111111111111)
geomObj_12 = geompy.MakeMultiTranslation1D(geomObj_11, geomObj_2, 2, 3)
geomObj_13 = geompy.MakeCutList(geomObj_6, [geomObj_12], True)
geomObj_14 = geompy.MakeTranslation(geomObj_12, 0, 0, 2)
geomObj_15 = geompy.MakeCutList(geomObj_13, [geomObj_14], True)
geomObj_16 = geompy.MakeRotation(geomObj_12, geomObj_10, 90*math.pi/180.0)
geomObj_17 = geompy.MakeCutList(geomObj_15, [geomObj_16], True)
geomObj_18 = geompy.MakeTranslation(geomObj_16, 0, 0, 2)
Pore_0_1 = geompy.MakeCutList(geomObj_17, [geomObj_18], True)
geomObj_19 = geompy.MakeBoxDXDYDZ(2, 2, 2)
geomObj_20 = geompy.MakeTranslation(geomObj_19, 2, 0, 0)
geomObj_21 = geompy.MakeCommonList([Pore_0_1, geomObj_20], True)
geomObj_22 = geompy.MakeVertex(3, 1, 0)
geomObj_23 = geompy.MakeVertex(3, 1, 1)
geomObj_24 = geompy.MakeVector(geomObj_22, geomObj_23)
geomObj_25 = geompy.MakeRotation(geomObj_20, geomObj_24, 45*math.pi/180.0)
geomObj_26 = geompy.MakeVertex(3, 1, 0)
geomObj_27 = geompy.MakeVertex(2, 0, 0)
geomObj_28 = geompy.MakeVector(geomObj_26, geomObj_27)
geomObj_29 = geompy.MakeTranslationVectorDistance(geomObj_25, geomObj_28, 1)
geomObj_30 = geompy.MakeTranslation(geomObj_29, -0.5, 0.5, 0)
geomObj_31 = geompy.MakeCommonList([geomObj_21, geomObj_30], True)
geomObj_32 = geompy.MakeVectorDXDYDZ(1, 0, 0)
geomObj_33 = geompy.MakeVectorDXDYDZ(0, 1, 0)
geomObj_34 = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_35 = geompy.MakeBoxDXDYDZ(2.82842712474619, 2.82842712474619, 2)
geomObj_36 = geompy.MakeRotation(geomObj_35, geomObj_34, 45*math.pi/180.0)
geomObj_37 = geompy.MakeTranslation(geomObj_36, 2, 0, 0)
geomObj_38 = geompy.MakeVertex(2, 0, 0)
geomObj_39 = geompy.MakeVertex(2, 2, 0)
geomObj_40 = geompy.MakeVertex(2, 2, 2)
geomObj_41 = geompy.MakeLineTwoPnt(geomObj_39, geomObj_40)
geomObj_42 = geompy.MakeSpherePntR(geomObj_38, 1.176470588235294)
geomObj_43 = geompy.MakeMultiTranslation1D(geomObj_42, geomObj_33, 2, 3)
geomObj_44 = geompy.MakeCutList(geomObj_37, [geomObj_43], True)
geomObj_45 = geompy.MakeTranslation(geomObj_43, 0, 0, 2)
geomObj_46 = geompy.MakeCutList(geomObj_44, [geomObj_45], True)
geomObj_47 = geompy.MakeRotation(geomObj_43, geomObj_41, 90*math.pi/180.0)
geomObj_48 = geompy.MakeCutList(geomObj_46, [geomObj_47], True)
geomObj_49 = geompy.MakeTranslation(geomObj_47, 0, 0, 2)
Pore_0_15 = geompy.MakeCutList(geomObj_48, [geomObj_49], True)
geomObj_50 = geompy.MakeBoxDXDYDZ(2, 2, 2)
geomObj_51 = geompy.MakeTranslation(geomObj_50, 2, 0, 0)
geomObj_52 = geompy.MakeCommonList([Pore_0_15, geomObj_51], True)
geomObj_53 = geompy.MakeVertex(3, 1, 0)
geomObj_54 = geompy.MakeVertex(3, 1, 1)
geomObj_55 = geompy.MakeVector(geomObj_53, geomObj_54)
geomObj_56 = geompy.MakeRotation(geomObj_51, geomObj_55, 45*math.pi/180.0)
geomObj_57 = geompy.MakeVertex(3, 1, 0)
geomObj_58 = geompy.MakeVertex(2, 0, 0)
geomObj_59 = geompy.MakeVector(geomObj_57, geomObj_58)
geomObj_60 = geompy.MakeTranslationVectorDistance(geomObj_56, geomObj_59, 1)
geomObj_61 = geompy.MakeTranslation(geomObj_60, -0.5, 0.5, 0)
geomObj_62 = geompy.MakeCommonList([geomObj_52, geomObj_61], True)
geomObj_63 = geompy.MakeVectorDXDYDZ(1, 0, 0)
geomObj_64 = geompy.MakeVectorDXDYDZ(0, 1, 0)
geomObj_65 = geompy.MakeVectorDXDYDZ(0, 0, 1)
geomObj_66 = geompy.MakeBoxDXDYDZ(2.82842712474619, 2.82842712474619, 2)
geomObj_67 = geompy.MakeRotation(geomObj_66, geomObj_65, 45*math.pi/180.0)
geomObj_68 = geompy.MakeTranslation(geomObj_67, 2, 0, 0)
geomObj_69 = geompy.MakeVertex(2, 0, 0)
geomObj_70 = geompy.MakeVertex(2, 2, 0)
geomObj_71 = geompy.MakeVertex(2, 2, 2)
geomObj_72 = geompy.MakeLineTwoPnt(geomObj_70, geomObj_71)
geomObj_73 = geompy.MakeSpherePntR(geomObj_69, 1.25)
geomObj_74 = geompy.MakeMultiTranslation1D(geomObj_73, geomObj_64, 2, 3)
geomObj_75 = geompy.MakeCutList(geomObj_68, [geomObj_74], True)
geomObj_76 = geompy.MakeTranslation(geomObj_74, 0, 0, 2)
geomObj_77 = geompy.MakeCutList(geomObj_75, [geomObj_76], True)
geomObj_78 = geompy.MakeRotation(geomObj_74, geomObj_72, 90*math.pi/180.0)
geomObj_79 = geompy.MakeCutList(geomObj_77, [geomObj_78], True)
geomObj_80 = geompy.MakeTranslation(geomObj_78, 0, 0, 2)
Pore_0_2 = geompy.MakeCutList(geomObj_79, [geomObj_80], True)
geomObj_81 = geompy.MakeBoxDXDYDZ(2, 2, 2)
geomObj_82 = geompy.MakeTranslation(geomObj_81, 2, 0, 0)
geomObj_83 = geompy.MakeCommonList([Pore_0_2, geomObj_82], True)
geomObj_84 = geompy.MakeVertex(3, 1, 0)
geomObj_85 = geompy.MakeVertex(3, 1, 1)
geomObj_86 = geompy.MakeVector(geomObj_84, geomObj_85)
geomObj_87 = geompy.MakeRotation(geomObj_82, geomObj_86, 45*math.pi/180.0)
geomObj_88 = geompy.MakeVertex(3, 1, 0)
geomObj_89 = geompy.MakeVertex(2, 0, 0)
geomObj_90 = geompy.MakeVector(geomObj_88, geomObj_89)
geomObj_91 = geompy.MakeTranslationVectorDistance(geomObj_87, geomObj_90, 1)
geomObj_92 = geompy.MakeTranslation(geomObj_91, -0.5, 0.5, 0)
geomObj_93 = geompy.MakeCommonList([geomObj_83, geomObj_92], True)
Fillet_1 = geompy.MakeFilletAll(Pore_0_1, 0.1)
Vertex_1 = geompy.MakeVertex(2, 2, 2)
Vertex_2 = geompy.MakeVertexWithRef(Vertex_1, 0, 0, 1)
Vector_1 = geompy.MakeVector(Vertex_1, Vertex_2)
Plane_1 = geompy.MakePlane(Vertex_1, Vector_1, 5)
Common_1 = geompy.MakeCommonList([Pore_0_1, Plane_1], True)
[Face_3,Face_4,Face_5,Face_6] = geompy.ExtractShapes(Common_1, geompy.ShapeType["FACE"], True)
[Face_7,Face_8,geomObj_94,Face_2] = geompy.ExtractShapes(Common_1, geompy.ShapeType["FACE"], True)
[Face_1,Face_2,Face_3,Face_4] = geompy.ExtractShapes(Common_1, geompy.ShapeType["SHAPE"], True)
Translation_1 = geompy.MakeTranslation(Plane_1, 0, 0, -2)
Common_2 = geompy.MakeCommonList([Pore_0_1, Translation_1], True)
[Face_5,Face_6,Face_7,Face_8] = geompy.ExtractShapes(Common_2, geompy.ShapeType["SHAPE"], True)
geomObj_95 = geompy.GetInPlace(Pore_0_1, Common_1, True)
[geomObj_96,geomObj_97,geomObj_98,geomObj_99,geomObj_100,geomObj_101,geomObj_102,geomObj_103,geomObj_104,geomObj_105,geomObj_106,geomObj_107,geomObj_108,geomObj_109,geomObj_110,geomObj_111] = geompy.SubShapeAll(geomObj_95, geompy.ShapeType["VERTEX"])
[geomObj_112,geomObj_113,geomObj_114,geomObj_115] = geompy.SubShapeAll(geomObj_95, geompy.ShapeType["FACE"])
geomObj_116 = geompy.GetInPlace(Pore_0_1, Face_1, True)
[geomObj_117] = geompy.SubShapeAll(geomObj_116, geompy.ShapeType["FACE"])
geomObj_118 = geompy.GetInPlace(Pore_0_1, Face_1, True)
[geomObj_119] = geompy.SubShapeAll(geomObj_118, geompy.ShapeType["FACE"])
geomObj_120 = geompy.GetInPlace(Pore_0_1, Common_1, True)
[geomObj_121,geomObj_122,geomObj_123,geomObj_124] = geompy.SubShapeAll(geomObj_120, geompy.ShapeType["FACE"])
[geomObj_125,geomObj_126,geomObj_127,geomObj_128] = geompy.SubShapeAll(geomObj_120, geompy.ShapeType["FACE"])
Group_1 = geompy.CreateGroup(Pore_0_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_1, [28, 165, 72, 90])
geomObj_129 = geompy.GetInPlace(Pore_0_1, Common_2, True)
[geomObj_130,geomObj_131,geomObj_132,geomObj_133,geomObj_134,geomObj_135,geomObj_136,geomObj_137,geomObj_138,geomObj_139,geomObj_140,geomObj_141,geomObj_142,geomObj_143,geomObj_144,geomObj_145] = geompy.SubShapeAll(geomObj_129, geompy.ShapeType["VERTEX"])
[geomObj_146,geomObj_147,geomObj_148,geomObj_149] = geompy.SubShapeAll(geomObj_129, geompy.ShapeType["FACE"])
[geomObj_150,geomObj_151,geomObj_152,geomObj_153] = geompy.SubShapeAll(geomObj_129, geompy.ShapeType["FACE"])
Group_2 = geompy.CreateGroup(Pore_0_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_2, [102, 117, 51, 159])
Group_3 = geompy.CreateGroup(Pore_0_1, geompy.ShapeType["FACE"])
geompy.UnionIDs(Group_3, [3, 17, 28, 33, 42, 51, 56, 63, 72, 77, 90, 95, 102, 107, 117, 120, 129, 136, 142, 149, 156, 159, 162, 165])
Cut_1 = geompy.CutListOfGroups([Group_3], [Group_1, Group_2])
geompy.addToStudy( Pore_0_1, 'Pore 0.1' )
geompy.addToStudy( Pore_0_15, 'Pore 0.15' )
geompy.addToStudy( Pore_0_2, 'Pore 0.2' )
geompy.addToStudy( Fillet_1, 'Fillet_1' )
geompy.addToStudy( Vertex_1, 'Vertex_1' )
geompy.addToStudy( Vertex_2, 'Vertex_2' )
geompy.addToStudy( Vector_1, 'Vector_1' )
geompy.addToStudy( Plane_1, 'Plane_1' )
geompy.addToStudy( Translation_1, 'Translation_1' )
geompy.addToStudyInFather( Common_2, Face_8, 'Face_8' )
geompy.addToStudyInFather( Common_2, Face_7, 'Face_7' )
geompy.addToStudyInFather( Common_1, Face_2, 'Face_2' )
geompy.addToStudy( Common_2, 'Common_2' )
geompy.addToStudyInFather( Common_1, Face_1, 'Face_1' )
geompy.addToStudy( Common_1, 'Common_1' )
geompy.addToStudyInFather( Common_1, Face_3, 'Face_3' )
geompy.addToStudyInFather( Common_1, Face_4, 'Face_4' )
geompy.addToStudyInFather( Common_2, Face_5, 'Face_5' )
geompy.addToStudyInFather( Common_2, Face_6, 'Face_6' )
geompy.addToStudyInFather( Pore_0_1, Group_1, 'Group_1' )
geompy.addToStudyInFather( Pore_0_1, Group_2, 'Group_2' )
geompy.addToStudyInFather( Pore_0_1, Group_3, 'Group_3' )
geompy.addToStudyInFather( Pore_0_1, Cut_1, 'Cut_1' )

###
### 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)

Pore_0_1_1 = smesh.Mesh(Pore_0_1)
NETGEN_2D3D_1 = Pore_0_1_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
NETGEN_Parameters = NETGEN_2D3D_1.Parameters()
NETGEN_Parameters.SetSecondOrder( 0 )
NETGEN_Parameters.SetOptimize( 1 )
NETGEN_Parameters.SetChordalError( -1 )
NETGEN_Parameters.SetChordalErrorEnabled( 0 )
NETGEN_Parameters.SetUseSurfaceCurvature( 1 )
NETGEN_Parameters.SetFuseEdges( 1 )
NETGEN_Parameters.SetCheckChartBoundary( 0 )
NETGEN_Parameters.SetMinSize( 0.01 )
NETGEN_Parameters.SetMaxSize( 0.05 )
NETGEN_Parameters.SetFineness( 5 )
NETGEN_Parameters.SetGrowthRate( 0.1 )
NETGEN_Parameters.SetNbSegPerEdge( 5 )
NETGEN_Parameters.SetNbSegPerRadius( 10 )
NETGEN_Parameters.SetQuadAllowed( 1 )
isDone = Pore_0_1_1.Compute()
Pore_0_15_1 = smesh.Mesh(Pore_0_15)
NETGEN_2D3D_1_1 = Pore_0_15_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
NETGEN_Parameters_1 = NETGEN_2D3D_1_1.Parameters()
NETGEN_Parameters_1.SetSecondOrder( 0 )
NETGEN_Parameters_1.SetOptimize( 1 )
NETGEN_Parameters_1.SetChordalError( -1 )
NETGEN_Parameters_1.SetChordalErrorEnabled( 0 )
NETGEN_Parameters_1.SetUseSurfaceCurvature( 1 )
NETGEN_Parameters_1.SetFuseEdges( 1 )
NETGEN_Parameters_1.SetCheckChartBoundary( 0 )
NETGEN_Parameters_1.SetMinSize( 0.01 )
NETGEN_Parameters_1.SetMaxSize( 0.05 )
NETGEN_Parameters_1.SetFineness( 5 )
NETGEN_Parameters_1.SetGrowthRate( 0.1 )
NETGEN_Parameters_1.SetNbSegPerEdge( 5 )
NETGEN_Parameters_1.SetNbSegPerRadius( 10 )
NETGEN_Parameters_1.SetQuadAllowed( 1 )
isDone = Pore_0_15_1.Compute()
Pore_0_2_1 = smesh.Mesh(Pore_0_2)
NETGEN_2D3D_1_2 = Pore_0_2_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
NETGEN_Parameters_2 = NETGEN_2D3D_1_2.Parameters()
NETGEN_Parameters_2.SetSecondOrder( 0 )
NETGEN_Parameters_2.SetOptimize( 1 )
NETGEN_Parameters_2.SetChordalError( -1 )
NETGEN_Parameters_2.SetChordalErrorEnabled( 0 )
NETGEN_Parameters_2.SetUseSurfaceCurvature( 1 )
NETGEN_Parameters_2.SetFuseEdges( 1 )
NETGEN_Parameters_2.SetCheckChartBoundary( 0 )
NETGEN_Parameters_2.SetMinSize( 0.01 )
NETGEN_Parameters_2.SetMaxSize( 0.05 )
NETGEN_Parameters_2.SetFineness( 5 )
NETGEN_Parameters_2.SetGrowthRate( 0.1 )
NETGEN_Parameters_2.SetNbSegPerEdge( 5 )
NETGEN_Parameters_2.SetNbSegPerRadius( 10 )
NETGEN_Parameters_2.SetQuadAllowed( 1 )
isDone = Pore_0_2_1.Compute()
Mesh_1 = smesh.Mesh(Fillet_1)
status = Mesh_1.AddHypothesis(NETGEN_Parameters_2)
NETGEN_2D3D_1_3 = Mesh_1.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
Viscous_Layers_1 = NETGEN_2D3D_1_3.ViscousLayers(0.05,1,1,None,None,smeshBuilder.SURF_OFFSET_SMOOTH)
NETGEN_Parameters_2.SetMaxSize( 0.1 )
NETGEN_Parameters_2.SetFineness( 3 )
NETGEN_Parameters_2.SetQuadAllowed( 0 )
Viscous_Layers_1.SetTotalThickness( 0.01 )
Viscous_Layers_1.SetNumberLayers( 1 )
Viscous_Layers_1.SetStretchFactor( 1 )
Viscous_Layers_1.SetMethod( smeshBuilder.FACE_OFFSET )
Viscous_Layers_1.SetFaces( [], 1 )
isDone = Mesh_1.Compute()
Mesh_2 = smesh.Mesh(Pore_0_1)
status = Mesh_2.AddHypothesis(NETGEN_Parameters_2)
status = Mesh_2.AddHypothesis(Viscous_Layers_1)
NETGEN_2D3D_1_4 = Mesh_2.Tetrahedron(algo=smeshBuilder.NETGEN_1D2D3D)
Viscous_Layers_1.SetTotalThickness( 0.025 )
Viscous_Layers_1.SetNumberLayers( 5 )
Viscous_Layers_1.SetStretchFactor( 1.1 )
Viscous_Layers_1.SetMethod( smeshBuilder.NODE_OFFSET )
Viscous_Layers_1.SetFaces( [], 1 )
isDone = Mesh_2.Compute()
Group_1_1 = Mesh_2.GroupOnGeom(Group_1,'Group_1',SMESH.FACE)
[ Group_1_1 ] = Mesh_2.GetGroups()
Group_2_1 = Mesh_2.GroupOnGeom(Group_2,'Group_2',SMESH.FACE)
[ Group_1_1, Group_2_1 ] = Mesh_2.GetGroups()
Group_3_1 = Mesh_2.GroupOnGeom(Cut_1,'Group_3',SMESH.FACE)
[ Group_1_1, Group_2_1, Group_3_1 ] = Mesh_2.GetGroups()


## Set names of Mesh objects
smesh.SetName(NETGEN_2D3D_1.GetAlgorithm(), 'NETGEN_2D3D_1')
smesh.SetName(NETGEN_Parameters_1, 'NETGEN_Parameters')
smesh.SetName(NETGEN_Parameters_2, 'NETGEN_Parameters')
smesh.SetName(NETGEN_Parameters, 'NETGEN_Parameters')
smesh.SetName(Viscous_Layers_1, 'Viscous Layers_1')
smesh.SetName(Pore_0_1_1.GetMesh(), 'Pore 0.1')
smesh.SetName(Pore_0_2_1.GetMesh(), 'Pore 0.2')
smesh.SetName(Pore_0_15_1.GetMesh(), 'Pore 0.15')
smesh.SetName(Mesh_2.GetMesh(), 'Mesh_2')
smesh.SetName(Mesh_1.GetMesh(), 'Mesh_1')
smesh.SetName(Group_1_1, 'Group_1')
smesh.SetName(Group_2_1, 'Group_2')
smesh.SetName(Group_3_1, 'Group_3')


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