I'm relatively new to fenics and I just looked through all questions related to Dirichlet boundary conditions. I don't seem to find a well-described question or answer about what I'm about to ask.
I'm solving a PDE-constrained optimization problem and I have "measured data" from experiment defined on all nodes of my mesh. I want to impose part of the "measured data" to my Dirichlet boundary condition and impose 0 Neumann boundary condition to the nodes where the "measured data" is not specified.
After some reading, I think I can read in this "measured data" together with mesh as meshdata or mesh_function, since it is defined on mesh nodes. It seems possible, though I haven't figured out how to do this exactly.
But even with that "measured data" loaded in, I still don't know how to impose them on part of boundary nodes as Dirichlet boundary conditions and impose 0 Neumann bc for the rest of the boundary nodes. Applying them pointwisely seems to be very inefficient. Tagging subdomains doesn't seem to apply to this situation very well.
For example, in my case, I 'd like to have an array, measuredData that is of the same size as the coordinates x, so that I can do something like:
mesh = UnitSquareMesh(3,2)
V = VectorFunctionSpace(mesh,"CG",1)
measD0 = Expression("measuredData[0]")
measD1 = Expression("measuredData[1]")
bc0 = DirichletBC(V.sub(0), measD0, on_boundary)
bc1 = DirichletBC(V.sub(1), measD1, on_boundary)
But now I haven't figured out a way to overload Expression to make it see my measuredData.
Keen to hear experienced fenics' users' opinions! Thanks in advance!