changed meshing routine from python to fortran (f2py)

This commit is contained in:
Martin Diehl 2011-02-22 16:00:22 +00:00
parent 2dc3b35725
commit 333445be8b
1 changed files with 1 additions and 43 deletions

View File

@ -106,47 +106,6 @@ def transliterateToFloat(x):
except: except:
return 0.0 return 0.0
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
def mesh(res,geomdim,defgrad_av,centroids):
#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
neighbor = numpy.array([[0, 0, 0],
[1, 0, 0],
[1, 1, 0],
[0, 1, 0],
[0, 0, 1],
[1, 0, 1],
[1, 1, 1],
[0, 1, 1]])
wrappedCentroids = numpy.zeros([res[0]+2,res[1]+2,res[2]+2,3],'d')
nodes = numpy.zeros([res[0]+1,res[1]+1,res[2]+1,3],'d')
wrappedCentroids[1:-1,1:-1,1:-1] = centroids
diag = numpy.ones(3,'i')
shift = numpy.zeros(3,'i')
lookup = numpy.zeros(3,'i')
for k in range(res[2]+2):
for j in range(res[1]+2):
for i in range(res[0]+2):
if (k==0 or k==res[2]+1 or \
j==0 or j==res[1]+1 or \
i==0 or i==res[0]+1 ):
me = numpy.array([i,j,k],'i')
shift = numpy.sign(res+diag-2*me)*(numpy.abs(res+diag-2*me)/(res+diag))
lookup = me-diag+shift*res
wrappedCentroids[i,j,k] = centroids[lookup[0],lookup[1],lookup[2]]- \
numpy.dot(defgrad_av, shift*geomdim)
for k in range(res[2]+1):
for j in range(res[1]+1):
for i in range(res[0]+1):
for n in range(8):
nodes[i,j,k] += wrappedCentroids[i+neighbor[n,0],j+neighbor[n,1],k+neighbor[n,2]]
nodes[:,:,:] /= 8.0
return nodes
# ++++++++++++++++++++++++++++++++++++++++++++++++++++ # ++++++++++++++++++++++++++++++++++++++++++++++++++++
def vtk_writeASCII_mesh(mesh,data,res): def vtk_writeASCII_mesh(mesh,data,res):
# ++++++++++++++++++++++++++++++++++++++++++++++++++++ # ++++++++++++++++++++++++++++++++++++++++++++++++++++
@ -424,12 +383,11 @@ for filename in args:
numpy.reshape(values[:,column['tensor'][options.defgrad]: numpy.reshape(values[:,column['tensor'][options.defgrad]:
column['tensor'][options.defgrad]+9], column['tensor'][options.defgrad]+9],
(res[0],res[1],res[2],3,3))) (res[0],res[1],res[2],3,3)))
print defgrad_av
centroids = postprocessingMath.deformed_fft(res[0],res[1],res[2],dim,\ centroids = postprocessingMath.deformed_fft(res[0],res[1],res[2],dim,\
numpy.reshape(values[:,column['tensor'][options.defgrad]: numpy.reshape(values[:,column['tensor'][options.defgrad]:
column['tensor'][options.defgrad]+9], column['tensor'][options.defgrad]+9],
(res[0],res[1],res[2],3,3)),defgrad_av,1.0) (res[0],res[1],res[2],3,3)),defgrad_av,1.0)
ms = mesh(res,dim,defgrad_av,centroids) ms = postprocessingMath.mesh(res[0],res[1],res[2],dim,defgrad_av,centroids)
fields = {\ fields = {\
'tensors': {},\ 'tensors': {},\