I defined material properties by interpolating a .txt file on the mesh using dof_to_vertex_map. The txt file and the vertices of the mes have the same number of lines, otherwise it wouldn’t work.
Setting only one property, it works fine, either running not-parallel or parallel. When the second (and also the third) property is added from different .txt files, FEniCS returns the interpolate mesh corresponding to the very first .txt interpolate property.
the part of the script corresponding to this is:
FIRST PROPERTY INTERPOLATION
T = FunctionSpace(mesh, ‘CG’, 1)
local_range = T.dofmap().ownership_range()
local_dim = local_range[1] - local_range[0]
file_vals = open ( ‘E_FINE.txt’ )
list_vals = [ float ( line ) for line in file_vals.readlines() ]
array_vals = np.array ( list_vals)
E = Function ( T )
d2v = dof_to_vertex_map ( T )
global_vertex_numbers = mesh.topology().global_indices(0)
global_vertices = global_vertex_numbers[d2v[:local_dim]]
local_data = array_vals[global_vertices]
E.vector()[:] = local_data[:local_dim]
file = File (“./0/E.pvd”)
file << E
SECOND PROPERTY INTERPOLATION
TT = FunctionSpace(mesh, ‘CG’, 1)
local_range_nuu = TT.dofmap().ownership_range()
local_dim_nuu = local_range_nuu[1] - local_range_nuu[0]
file_vals_nuu = open ( ‘nu_tot.txt’ )
list_vals_nuu = [ float ( line ) for line in file_vals_nuu.readlines() ]
array_vals_nuu = np.array ( list_vals_nuu)
nuu = Function ( TT )
d2v_nuu = dof_to_vertex_map ( TT )
global_vertex_numbers_nuu = mesh.topology().global_indices(0)
global_vertices_nuu = global_vertex_numbers_nuu[d2v_nuu[:local_dim_nuu]]
local_data_nuu = array_vals[global_vertices_nuu]
nuu.vector()[:] = local_data_nuu[:local_dim_nuu]
file = File (“./1/nuu.pvd”)
file << nuu
What is the issue that I am missing? I searched through the topics, but I couldn’t manage.
I appreciate any help.
Thanks