-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGenPro.py
138 lines (135 loc) · 4.97 KB
/
GenPro.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###### ######## ######## ## ## ########
## ## ## ## ## ## ## ##
## ## ## ## ## ## ##
###### ###### ## ## ## ########
## ## ## ## ## ##
## ## ## ## ## ## ##
###### ######## ## ####### ##
# General modules
import sys
import numpy as np
import pandas as pd
import os
# Salome modules
import salome
import salome_notebook
# Geometry modules
import GEOM
from salome.geom import geomBuilder
import math
import SALOMEDS
# Mesh modules
import SMESH, SALOMEDS
from salome.smesh import smeshBuilder
WORKING_DIR='/media/Calculs/aster-calc-section/' # Working directory
TEMP_FILE='Temp.input' # Filename of the temp file (from input to processing)
MESH_FILE='SectionAuto.med'
fileInput = WORKING_DIR + TEMP_FILE
data = pd.read_csv(fileInput) # Open temp file
# Read data
H = data['H'][0]
B = data['B'][0]
Tw = data['Tw'][0]
Tf = data['Tf'][0]
R = data['R'][0]
MinSize = Tw/10
MaxSize = Tw/6
###### ### ## ####### ## ## ########
## ## ## ## ## ## ## ### ### ##
## ## ## ## ## ## #### #### ##
###### ## ## ## ## ## ## ### ## ######
## ######### ## ## ## ## ## ##
## ## ## ## ## ## ## ## ## ##
###### ## ## ######## ####### ## ## ########
salome.salome_init()
theStudy = salome.myStudy
notebook = salome_notebook.NoteBook(theStudy)
sys.path.insert( 0, r'/media/Calculs/aster-calc-section')
###### ######## ####### ## ##
## ## ## ## ## ### ###
## ## ## ## #### ####
## #### ###### ## ## ## ### ##
## ## ## ## ## ## ##
## ## ## ## ## ## ##
###### ######## ####### ## ##
geompy = geomBuilder.New(theStudy)
# Vertex definiton
P0 = geompy.MakeVertex(0, 0, 0)
P1 = geompy.MakeVertex(Tw/2, 0, 0)
P2 = geompy.MakeVertex(Tw/2, H/2-Tf-R, 0)
P3 = geompy.MakeVertex(Tw/2+R, H/2-Tf-R, 0)
P4 = geompy.MakeVertex(Tw/2+R, H/2-Tf, 0)
P5 = geompy.MakeVertex(B/2, H/2-Tf, 0)
P6 = geompy.MakeVertex(B/2, H/2, 0)
P7 = geompy.MakeVertex(0, H/2, 0)
# Edge definition
Ox = geompy.MakeLineTwoPnt(P0, P1)
Oy = geompy.MakeLineTwoPnt(P0, P7)
L0 = geompy.MakeLineTwoPnt(P1, P2)
L1 = geompy.MakeArcCenter(P3, P4, P2,False)
L2 = geompy.MakeLineTwoPnt(P4, P5)
L3 = geompy.MakeLineTwoPnt(P5, P6)
L4 = geompy.MakeLineTwoPnt(P6, P7)
L5 = geompy.MakeMirrorByAxis(L0, Oy)
L6 = geompy.MakeMirrorByAxis(L1, Oy)
L7 = geompy.MakeMirrorByAxis(L2, Oy)
L8 = geompy.MakeMirrorByAxis(L3, Oy)
L9 = geompy.MakeMirrorByAxis(L4, Oy)
L10 = geompy.MakeMirrorByAxis(L0, Ox)
L11 = geompy.MakeMirrorByAxis(L1, Ox)
L12 = geompy.MakeMirrorByAxis(L2, Ox)
L13 = geompy.MakeMirrorByAxis(L3, Ox)
L14 = geompy.MakeMirrorByAxis(L4, Ox)
L15 = geompy.MakeMirrorByAxis(L5, Ox)
L16 = geompy.MakeMirrorByAxis(L6, Ox)
L17 = geompy.MakeMirrorByAxis(L7, Ox)
L18 = geompy.MakeMirrorByAxis(L8, Ox)
L19 = geompy.MakeMirrorByAxis(L9, Ox)
# Face definition
Face = geompy.MakeFaceWires([L0, L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L16, L17, L18, L19], 1)
# Compound and partition definition
Compound = geompy.MakeCompound([P0, Face])
Partition = geompy.MakePartition([Compound], [], [], [], geompy.ShapeType["FACE"], 0, [], 0)
# Group definition
MyPoint = geompy.CreateGroup(Partition, geompy.ShapeType["VERTEX"])
MyBorder = geompy.CreateGroup(Partition, geompy.ShapeType["EDGE"])
MySect = geompy.CreateGroup(Partition, geompy.ShapeType["FACE"])
geompy.UnionIDs(MyPoint, [43])
geompy.UnionIDs(MyBorder, [3, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42])
geompy.UnionIDs(MySect, [1])
## ## ######## ###### ## ##
### ### ## ## ## ## ##
#### #### ## ## ## ##
## ### ## ###### ###### #########
## ## ## ## ## ##
## ## ## ## ## ## ##
## ## ######## ###### ## ##
smesh = smeshBuilder.New(theStudy)
Mesh = smesh.Mesh(Partition)
# NETGEN
NETGEN_2D = Mesh.Triangle(algo=smeshBuilder.NETGEN_1D2D)
NETGEN_2D_Parameters = NETGEN_2D.Parameters()
NETGEN_2D_Parameters.SetSecondOrder( 0 )
NETGEN_2D_Parameters.SetOptimize( 1 )
NETGEN_2D_Parameters.SetFineness( 2 )
NETGEN_2D_Parameters.SetUseSurfaceCurvature( 1 )
NETGEN_2D_Parameters.SetFuseEdges( 1 )
NETGEN_2D_Parameters.SetQuadAllowed( 0 )
NETGEN_2D_Parameters.SetMinSize( MinSize )
NETGEN_2D_Parameters.SetMaxSize( MaxSize )
# Calculation
isDone = Mesh.Compute()
# Group definition
MyPoint_1 = Mesh.GroupOnGeom(MyPoint,'MyPoint',SMESH.NODE)
MyBorder_1 = Mesh.GroupOnGeom(MyBorder,'MyBorder',SMESH.EDGE)
MySect_1 = Mesh.GroupOnGeom(MySect,'MySect',SMESH.FACE)
MyBorder_2 = Mesh.GroupOnGeom(MyBorder,'MyBorder',SMESH.NODE)
MySect_2 = Mesh.GroupOnGeom(MySect,'MySect',SMESH.NODE)
smesh.SetName(Mesh, 'Mesh')
# Export MESH
try:
Mesh.ExportMED( r'/media/Calculs/aster-calc-section/SectionAuto.med', 1, SMESH.MED_V2_2, 1, None, 1, [], 'efv' )
except:
print 'ExportPartToMED() failed. Invalid file name?'