Hi,
How about using a DG0
function to assign the values to each dof (through a dof-to-cell map) ?
# E = # I want to use 6 different E for 6 elements : E = [1E6 , 2E6 , 3E6, 4E6 , 5E6 , 6E6]
DG = FunctionSpace(mesh, "DG", 0)
E = Function(DG)
dofmap = DG.dofmap()
coords = DG.tabulate_dof_coordinates()
dof_to_cell = [cell for cell in range(mesh.num_cells())
for dof in dofmap.cell_dofs(cell)]
for i in range(coords.shape[0]):
cell_index = dof_to_cell[i]
E.vector()[i] = 1.e6 * (cell_index + 1)
There could be multiple ways of doing this I feel.
Edit 1: I had come accross MiroK’s answer on the old forum sometime back for something in my work.