# imposing "measured data" to Dirichlet boundary conditions in fenics

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!

Update: As Bill Barth clarified, the Dirichlet boundaries are well connected and so are the Neumann boundaries. So this problem is well-posed.

## 1 Answer

I don't know how to do this in FEciCS, but that question should probably be asked of the developers or their mailing list per this SE's policy. That being said, I'm not sure such a problem is well-posed. Maybe someone will correct me, but even if you can figure out how to enforce inter-mixed point-wise Dirichlet and Neumann conditions on the same edge or face (2d vs. 3d) in FEniCS, you may get into mathematical trouble. If the condition transitions from one kind to the other on that boundary, such that the two regions are compact, connected, or something else, then I think you should be OK.

Are the conditions randomly imposed at different points, or do you have consistent regions of the boundary where they are applied?

• Sorry, I should be clearer about that point. My Dirichlet boundaries are connected and so are my Neumann boundaries. So there is no mathematical trouble in this case. Jun 28, 2016 at 22:25
• By the way, sorry I'm not quite familiar with the policy here. I just thought there might be some way to work around this issue instead of going deep in their code and tweak it. So I asked this question here. Jun 28, 2016 at 22:27
• @ldong87, you should ask them instead. There's a general policy about not asking software-specific usage or bug problems here. You will still find them, but they may also get closed for this reason. Jun 28, 2016 at 23:22