Read VTK file of an old dolfin 2019's solution

Hello, I’m trying to read a VTK file into dolfinx. In this file I’ve defined a velocity field c which I’ll use in the bilinear form :

a = fem.form(c*inner(grad(u),grad(v))*dx)

This VTK file was generated with dolfin 2019 as a solution.

Dolfinx: 0.3.1.0

Save the function in xdmf format ( XDMFFile, use write_checkpoint rather than write to ensure the details of the FEM is preserved). Then it may be easier to read the xdmf file from dolfinx.

Disclaimer: I haven’t tried it myself, so I’m not certain if the file formats are completely compatible.

In DOLFINx, we do not have any way of reading in data yet. This is work in progress.

Thank you for your tips and help dparsons and dokken.

I’m trying to recreate the field I created in dolfin.
Since I’m new in dolfinx I’ve being having some troubles. My goal is to create a subsection with some markers.
My problem is that on side I’ve dof indices and on the other cells indices.

tau.x.array[cells] = np.full(num_cells_ref,tau_value)

It’s probably something really easy to fix, but I’m not really familiar with all dolfinx functions.
Hole code:

import dolfinx
from mpi4py import MPI
import dolfinx.io
import ufl
import numpy as np

point = [.7, 0.55,0]


msh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, 4, 4)
tdim = msh.topology.dim

V = dolfinx.fem.FunctionSpace(msh,('CG',1))
x = V.tabulate_dof_coordinates()

def marker1(x): return x[0] <= 0.5+1e-7


indices1 = dolfinx.mesh.locate_entities(msh, 2, marker1)

num_cells = msh.topology.index_map(tdim).size_local + \
            msh.topology.index_map(tdim).num_ghosts
            
cell_marker = np.zeros(num_cells, dtype=np.int32)
cell_marker[indices1] = 1
cell_tag = dolfinx.mesh.meshtags(msh, dim=tdim, indices=np.arange(num_cells),
                                         values=cell_marker)


tau = dolfinx.fem.Function(V)
tau.x.array[:] = 0

cells=cell_tag.indices[cell_tag.values==1]
num_cells_ref= len(cells)
tau_value=50

tau.x.array[cells] = np.full(num_cells_ref,tau_value)

this did the trick:

dof=dolfinx.fem.locate_dofs_topological(V,tdim,cells)