6 Apr
2017
6 Apr
'17
3:27 p.m.
On 06/04/17 15:49, Buesing, Henrik wrote:
Dear David,
Thank you for the explanation! This works! I was missing the dat.data part. Since, I only want to interpolate on DG0, I think it is enough to:
# My array which is npoints long
perm = numpy.genfromtxt('perm.txt')
# My function, constant on each element. K = Function(DG0)
# Get the local ranges Kvec = K.vector()
lrange = Kvec.local_range()
# Assign the values
K.dat.data[:] = perm[lrange[0]:lrange[1]]
This assumes that the data you've made are in the same ordering as the function space degree of freedom numbering. We make no guarantees not to change this numbering without warning behind your back, so I recommend not using this approach. Lawrence