This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

load "measured data" together with mesh

0 votes

I posted a question about how to impose "measured data" to Dirichlet boundary conditions here (the other question). Then I realized that I'm also not able to figure out how to load in the "measured data" properly. I don't want to complicate the other question, so I posted this one as a separate one here.

I'm solving a PDE-constrained optimization problem and we have the experimentally "measured data" on all points in the mesh, and they are vector-valued. Is there a way to load the data together with the mesh data so that the "measured data" can fall to proper places, such as right vertices and dofs, from the mesh information, suppose I'm reading in a mesh?

I found MeshFunctions and MeshCollectionValues can be loaded with mesh data, but they seem to only work with cells instead of points / vertices. My "measured data" is defined on points. Also, the purpose of MeshFunctions and MeshCollectionValues seems to help mesh generation, refinement and boundary tagging, which is not my aim.

Many thanks in advance for advices from experienced fenics' users?

asked Jun 28, 2016 by ldong87 FEniCS Novice (580 points)

1 Answer

+1 vote
 
Best answer

Once you have the data in a python array and sorted like the mesh coordinates, you can do

u = Function(FunctionSpace(mesh,'CG',1))
u.vector().set_local(measured_data_array)
u.vector().apply("")

If it does not work, you might have to make use of

parameters["reorder_dofs_serial"] = False

It will be more complicated, if you want to do things in parallel.

answered Jun 29, 2016 by KristianE FEniCS Expert (12,900 points)
selected Jun 30, 2016 by ldong87

Thanks for your reply. Based on your reply, I also found a relevant link about this question, related question. But I don't quite understand the meaning of your last line of code:
u.vector().apply("")
It doesn't operate on mesured_data_array. What does it do?

...