Hi,
I am update my code from fenicsx-0.6.0 to fenicsx-0.8.0. I find that the update of meshtags function makes the values read only. However, in my previous code, I defined a meshtag and changed its values in my loop, like the demo:
import os
os.environ['OMP_NUM_THREADS'] = '1'
from mpi4py import MPI
comm = MPI.COMM_WORLD
import numpy as np
from dolfinx import mesh
msh = mesh.create_unit_square(MPI.COMM_WORLD, 96, 96, mesh.CellType.triangle)
num_cells = msh.topology.index_map(msh.topology.dim).size_local + msh.topology.index_map(msh.topology.dim).num_ghosts
indices = np.arange(num_cells).astype(np.int32)
values = np.full(indices.shape, 1, dtype=np.intc)
meshtag = mesh.meshtags(msh, msh.topology.dim, indices, values)
for i in range(0,5):
meshtag.values[:] = np.full(indices.shape, i, dtype=np.intc)
This works fine in fenicsx-0.6.0. But when I run the code in fenicsx-0.8.0, it returns the error.
ValueError: assignment destination is read-only
meshtag.values[:] = np.full(indices.shape, i, dtype=np.intc)
I also tried
for i in range(0,5):
meshtag._cpp_object.values[:] = np.full(indices.shape, i, dtype=np.intc)
but the error is the same. Although I have lots of other ways instead to implement my algorithm, I still would like to know that is there any way to change this value as in fenicsx-0.6.0?