Hi,
How do I get a mapping that relates the output of a mesh function (defined over vertices) to the mesh coordinates (need to identify the coordinates of each vertex in the mesh function array)?
Below is the code I am working with - I think I need a mapping to reorder vertex_func.array() so that it matches the coords array. If this is not possible, how can I obtain the coordinates (or vertex indices) that correspond to the values in the vertex_array?
from dolfin import *
import numpy as np
n = 30
mesh = UnitCubeMesh.create(n,n,n,CellType.Type.hexahedron)
coords = mesh.coordinates()
class ss(SubDomain):
def inside(self,x,on_boundary):
return near(x[0],0.5)
mesh.init(3,3)
mesh.init(2,2)
vertex_func = MeshFunction('size_t', mesh,0)
vertex_func.set_all(0)
vertex_func0 = ss()
vertex_func0.mark(vertex_func,1)
vertex_array = vertex_func.array()
ordered_vertex_array = vertex_array[SOME_MAPPING]
##ORDER OF coords == ordered_vertex_array
##OR
vertex_idx_array = SOME_FUNCTION
idx_ordered_vertex_array = vertex_array[vertex_idx_array] #reorders array in order of vertex index
Many thanks,
D