extended for 2D, finds the bounding edges and assigns them 'physical' attribute.
This commit is contained in:
parent
bcf0a1fc74
commit
30920801aa
|
@ -37,9 +37,14 @@ parser.add_option('-s','--size', dest = 'size', \
|
||||||
type='float',\
|
type='float',\
|
||||||
metavar='float',\
|
metavar='float',\
|
||||||
help='mesh size' )
|
help='mesh size' )
|
||||||
|
parser.add_option('-d','--dim', dest = 'dimension', \
|
||||||
|
type='int',\
|
||||||
|
metavar='float',\
|
||||||
|
help='dimension of geometry' )
|
||||||
|
|
||||||
(options, filename) = parser.parse_args()
|
(options, filename) = parser.parse_args()
|
||||||
parser.set_defaults(size = 0.1)
|
parser.set_defaults(size = 0.1)
|
||||||
|
parser.set_defaults(dimension = 3)
|
||||||
|
|
||||||
my_geofile = filename[0]
|
my_geofile = filename[0]
|
||||||
numVol = options.N
|
numVol = options.N
|
||||||
|
@ -87,54 +92,113 @@ xmin = min([x[0] for x in point]); xmax = max([x[0] for x in point])
|
||||||
ymin = min([x[1] for x in point]); ymax = max([x[1] for x in point])
|
ymin = min([x[1] for x in point]); ymax = max([x[1] for x in point])
|
||||||
zmin = min([x[2] for x in point]); zmax = max([x[2] for x in point])
|
zmin = min([x[2] for x in point]); zmax = max([x[2] for x in point])
|
||||||
|
|
||||||
for i,l in enumerate(lineloop):
|
|
||||||
for lines in l:
|
|
||||||
for pts in line[int(abs(lines)-1)]:
|
|
||||||
x_coord.append(point[int(pts)-1][0])
|
|
||||||
y_coord.append(point[int(pts)-1][1])
|
|
||||||
z_coord.append(point[int(pts)-1][2])
|
|
||||||
if all_same(x_coord,xmax) and any([surface == 'x' for surface in options.surfaces]):
|
|
||||||
xp.append(int(i+1))
|
|
||||||
elif all_same(x_coord,xmin) and any([surface == 'x' for surface in options.surfaces]):
|
|
||||||
xm.append(int(i+1))
|
|
||||||
elif all_same(y_coord,ymax) and any([surface == 'y' for surface in options.surfaces]):
|
|
||||||
yp.append(int(i+1))
|
|
||||||
elif all_same(y_coord,ymin) and any([surface == 'y' for surface in options.surfaces]):
|
|
||||||
ym.append(int(i+1))
|
|
||||||
elif all_same(z_coord,zmax) and any([surface == 'z' for surface in options.surfaces]):
|
|
||||||
zp.append(int(i+1))
|
|
||||||
elif all_same(z_coord,zmin) and any([surface == 'z' for surface in options.surfaces]):
|
|
||||||
zm.append(int(i+1))
|
|
||||||
x_coord = []
|
|
||||||
y_coord = []
|
|
||||||
z_coord = []
|
|
||||||
|
|
||||||
with open(my_geofile,'a') as f:
|
if (options.dimension == 3):
|
||||||
f.write('Delete Physicals; \n')
|
for i,l in enumerate(lineloop):
|
||||||
if any([surface == 'x' for surface in options.surfaces]):
|
for lines in l:
|
||||||
f.write('%s%s%s\n' %('Physical Surface(1) = {',','.join(map(str, xp)),'};'))
|
for pts in line[int(abs(lines)-1)]:
|
||||||
f.write('%s%s%s\n' %('Physical Surface(2) = {',','.join(map(str, xm)),'};'))
|
x_coord.append(point[int(pts)-1][0])
|
||||||
|
y_coord.append(point[int(pts)-1][1])
|
||||||
|
z_coord.append(point[int(pts)-1][2])
|
||||||
|
if all_same(x_coord,xmax) and any([surface == 'x' for surface in options.surfaces]):
|
||||||
|
xp.append(int(i+1))
|
||||||
|
elif all_same(x_coord,xmin) and any([surface == 'x' for surface in options.surfaces]):
|
||||||
|
xm.append(int(i+1))
|
||||||
|
elif all_same(y_coord,ymax) and any([surface == 'y' for surface in options.surfaces]):
|
||||||
|
yp.append(int(i+1))
|
||||||
|
elif all_same(y_coord,ymin) and any([surface == 'y' for surface in options.surfaces]):
|
||||||
|
ym.append(int(i+1))
|
||||||
|
elif all_same(z_coord,zmax) and any([surface == 'z' for surface in options.surfaces]):
|
||||||
|
zp.append(int(i+1))
|
||||||
|
elif all_same(z_coord,zmin) and any([surface == 'z' for surface in options.surfaces]):
|
||||||
|
zm.append(int(i+1))
|
||||||
|
x_coord = []
|
||||||
|
y_coord = []
|
||||||
|
z_coord = []
|
||||||
|
|
||||||
|
with open(my_geofile,'a') as f:
|
||||||
|
f.write('Delete Physicals; \n')
|
||||||
|
if any([surface == 'x' for surface in options.surfaces]):
|
||||||
|
f.write('%s%s%s\n' %('Physical Surface(1) = {',','.join(map(str, xp)),'};'))
|
||||||
|
f.write('%s%s%s\n' %('Physical Surface(2) = {',','.join(map(str, xm)),'};'))
|
||||||
|
|
||||||
|
if any([surface == 'y' for surface in options.surfaces]):
|
||||||
|
f.write('%s%s%s\n' %('Physical Surface(3) = {',','.join(map(str, yp)),'};'))
|
||||||
|
f.write('%s%s%s\n' %('Physical Surface(4) = {',','.join(map(str, ym)),'};'))
|
||||||
|
|
||||||
|
if any([surface == 'z' for surface in options.surfaces]):
|
||||||
|
f.write('%s%s%s\n' %('Physical Surface(5) = {',','.join(map(str, zp)),'};'))
|
||||||
|
f.write('%s%s%s\n' %('Physical Surface(6) = {',','.join(map(str, zm)),'};'))
|
||||||
|
|
||||||
|
for i in range(numVol):
|
||||||
|
f.write('%s%d%s%d%s\n' %('Physical Volume (', i+1,') = {',i+1,'};'))
|
||||||
|
|
||||||
|
f.write('Field[1] = Box;\n')
|
||||||
|
f.write('%s%f%s\n' %('Field[1].VIn = ', options.size,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].VOut = ',options.size,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].XMin = ',xmin,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].XMax = ',xmax,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].YMin = ',ymin,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].YMax = ',ymax,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].ZMin = ',zmin,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].ZMax = ',zmax,';'))
|
||||||
|
f.write('Background Field = 1;\n')
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
if any([surface == 'y' for surface in options.surfaces]):
|
elif (options.dimension == 2):
|
||||||
f.write('%s%s%s\n' %('Physical Surface(3) = {',','.join(map(str, yp)),'};'))
|
for i,l in enumerate(line):
|
||||||
f.write('%s%s%s\n' %('Physical Surface(4) = {',','.join(map(str, ym)),'};'))
|
# for pts in line[int(abs(lines)-1)]:
|
||||||
|
for pts in l:
|
||||||
|
x_coord.append(point[int(pts)-1][0])
|
||||||
|
y_coord.append(point[int(pts)-1][1])
|
||||||
|
z_coord.append(point[int(pts)-1][2])
|
||||||
|
|
||||||
|
if all_same(x_coord,xmax) and any([surface == 'x' for surface in options.surfaces]):
|
||||||
|
xp.append(int(i+1))
|
||||||
|
elif all_same(x_coord,xmin) and any([surface == 'x' for surface in options.surfaces]):
|
||||||
|
xm.append(int(i+1))
|
||||||
|
elif all_same(y_coord,ymax) and any([surface == 'y' for surface in options.surfaces]):
|
||||||
|
yp.append(int(i+1))
|
||||||
|
elif all_same(y_coord,ymin) and any([surface == 'y' for surface in options.surfaces]):
|
||||||
|
ym.append(int(i+1))
|
||||||
|
elif all_same(z_coord,zmax) and any([surface == 'z' for surface in options.surfaces]):
|
||||||
|
zp.append(int(i+1))
|
||||||
|
elif all_same(z_coord,zmin) and any([surface == 'z' for surface in options.surfaces]):
|
||||||
|
zm.append(int(i+1))
|
||||||
|
x_coord = []
|
||||||
|
y_coord = []
|
||||||
|
z_coord = []
|
||||||
|
|
||||||
if any([surface == 'z' for surface in options.surfaces]):
|
|
||||||
f.write('%s%s%s\n' %('Physical Surface(5) = {',','.join(map(str, zp)),'};'))
|
|
||||||
f.write('%s%s%s\n' %('Physical Surface(6) = {',','.join(map(str, zm)),'};'))
|
|
||||||
|
|
||||||
for i in range(numVol):
|
with open(my_geofile,'a') as f:
|
||||||
f.write('%s%d%s%d%s\n' %('Physical Volume (', i+1,') = {',i+1,'};'))
|
f.write('Delete Physicals; \n')
|
||||||
|
if any([surface == 'x' for surface in options.surfaces]):
|
||||||
f.write('Field[1] = Box;\n')
|
f.write('%s%s%s\n' %('Physical Line(1) = {',','.join(map(str, xp)),'};'))
|
||||||
f.write('%s%f%s\n' %('Field[1].VIn = ', options.size,';'))
|
f.write('%s%s%s\n' %('Physical Line(2) = {',','.join(map(str, xm)),'};'))
|
||||||
f.write('%s%f%s\n' %('Field[1].VOut = ',options.size,';'))
|
|
||||||
f.write('%s%f%s\n' %('Field[1].XMin = ',xmin,';'))
|
if any([surface == 'y' for surface in options.surfaces]):
|
||||||
f.write('%s%f%s\n' %('Field[1].XMax = ',xmax,';'))
|
f.write('%s%s%s\n' %('Physical Line(3) = {',','.join(map(str, yp)),'};'))
|
||||||
f.write('%s%f%s\n' %('Field[1].YMin = ',ymin,';'))
|
f.write('%s%s%s\n' %('Physical Line(4) = {',','.join(map(str, ym)),'};'))
|
||||||
f.write('%s%f%s\n' %('Field[1].YMax = ',ymax,';'))
|
|
||||||
f.write('%s%f%s\n' %('Field[1].ZMin = ',zmin,';'))
|
if any([surface == 'z' for surface in options.surfaces]):
|
||||||
f.write('%s%f%s\n' %('Field[1].ZMax = ',zmax,';'))
|
f.write('%s%s%s\n' %('Physical Line(5) = {',','.join(map(str, zp)),'};'))
|
||||||
f.write('Background Field = 1;\n')
|
f.write('%s%s%s\n' %('Physical Line(6) = {',','.join(map(str, zm)),'};'))
|
||||||
|
|
||||||
|
for i in range(numVol):
|
||||||
|
f.write('%s%d%s%d%s\n' %('Physical Surface (', i+1,') = {',i+1,'};'))
|
||||||
|
|
||||||
|
f.write('Field[1] = Box;\n')
|
||||||
|
f.write('%s%f%s\n' %('Field[1].VIn = ', options.size,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].VOut = ',options.size,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].XMin = ',xmin,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].XMax = ',xmax,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].YMin = ',ymin,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].YMax = ',ymax,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].ZMin = ',zmin,';'))
|
||||||
|
f.write('%s%f%s\n' %('Field[1].ZMax = ',zmax,';'))
|
||||||
|
f.write('Background Field = 1;\n')
|
||||||
|
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
f.close()
|
|
||||||
|
|
Loading…
Reference in New Issue