I found this python code to read data and create GMSH .geo file. However, when I use it i get an error
Thanks
Narahari
# script to create a .geo file for a multi element airfoil # Read the coordinates to two lists mainCoords = [] flapCoords = [] with open('gaw.txt') as fin: fin.readline() # skip header fin.readline() # skip header for l in fin: coords = map(float,l.split()) print('coords') mainCoords.append(coords[:2]) if len(coords) > 2: flapCoords.append(coords[2:]) # Create a GMSH file and write the points in GMSH format with open('multi.geo','w') as fout: for i, c in enumerate(mainCoords): fout.write('Point (%i) = {%f, %f, 0, 1};\n'%(i+1,c[0],c[1])) for i, c in enumerate(flapCoords): fout.write('Point (%i) = {%f, %f, 0, 1};\n'%(i+len(mainCoords)+1,c[0],c[1])) # Create two splines fout.write('Spline (1) = {%s};\n' % ','.join(map(str,range(1,len(mainCoords)+1)))) fout.write('Spline (2) = {%s};\n' % ','.join(map(str,range(len(mainCoords)+1,len(mainCoords)+len(flapCoords)+1))))I get the following error :
Error:runfile('D:/AERO_AUTO/CFD_HKN/gmsh-4.3.0-Windows64/hkn/Multi_element.py', wdir='D:/AERO_AUTO/CFD_HKN/gmsh-4.3.0-Windows64/hkn')
coords
Traceback (most recent call last):
File "<ipython-input-5-d8984351fb2d>", line 1, in <module>
runfile('D:/AERO_AUTO/CFD_HKN/gmsh-4.3.0-Windows64/hkn/Multi_element.py', wdir='D:/AERO_AUTO/CFD_HKN/gmsh-4.3.0-Windows64/hkn')
File "E:\aconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 704, in runfile
execfile(filename, namespace)
File "E:\aconda\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "D:/AERO_AUTO/CFD_HKN/gmsh-4.3.0-Windows64/hkn/Multi_element.py", line 11, in <module>
mainCoords.append(coords[:2])
TypeError: 'map' object is not subscriptable
I think the error is due to python version (i use 3., but not sure Any help will be greatly helpful. Thanks
Narahari