def nodal_values(self, f):
""" Convert dolfin function to nodal values. """
farray = f.vector().array()
fdim = len(farray)/len(self.indices)
farray = farray.reshape((len(self.indices), fdim))
arr = np.zeros((len(self.nodes), fdim))
arr_loc = np.zeros_like(arr)
for i, fval in zip(self.indices, farray):
arr_loc[i, :] = fval
comm.Allreduce(arr_loc, arr, op=MPI.SUM)
return arr
评论列表
文章目录