started to write a script for finding bounding surfaces from gmsh geo file.

This commit is contained in:
Luv Sharma 2014-10-16 14:07:25 +00:00
parent fec71e2986
commit ff0f619015
1 changed files with 80 additions and 0 deletions

View File

@ -0,0 +1,80 @@
import numpy as np
import re
def func(seq):
for x in seq:
try:
yield float(x)
except ValueError:
yield x
my_geofile = 'polyXtal_5grains.geo'
PointCount = 0
LineCount = 0
LineLoopCount = 0
PlaneSurfaceCount = 0
SurfaceLoopCount = 0
point = []
line = []
lineloop = []
plane = []
surface = []
f = open(my_geofile,'r')
lines = f.readlines()
for eachline in lines:
if eachline.startswith('Point', 0, 5):
PointCount += 1
r = re.compile('{(.*?)}')
m = r.search(eachline)
if m:
a = m.group(1)
point.append(list(func(a.split(","))))
elif eachline.startswith('Line (', 0, 6):
LineCount += 1
r = re.compile('{(.*?)}')
m = r.search(eachline)
if m:
a = m.group(1)
line.append(list(func(a.split(","))))
elif eachline.startswith('Line Loop', 0, 9):
LineLoopCount += 1
r = re.compile('{(.*?)}')
m = r.search(eachline)
if m:
a = m.group(1)
lineloop.append(list(func(a.split(","))))
elif eachline.startswith('Plane', 0, len(eachline)):
PlaneSurfaceCount += 1
r = re.compile('{(.*?)}')
m = r.search(eachline)
if m:
a = m.group(1)
plane.append(list(func(a.split(","))))
elif eachline.startswith('Surface', 0,len(eachline)):
SurfaceLoopCount += 1
r = re.compile('{(.*?)}')
m = r.search(eachline)
if m:
a = m.group(1)
surface.append(list(func(a.split(","))))
print point
print line
print 'll'
print np.size(lineloop)
print lineloop
print 'ss'
print surface
#for sn, ll in enumerate(lineloop):
# for l in ll:
# for points in l[abs(int(l))]:
# if point[int(points)-1][0] == float(0):
# print 'abc'