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

How to store the nodal values of an FEM function?

+1 vote

Starting with

from dolfin import *
mesh = UnitSquareMesh(nx, ny)
V = FunctionSpace(mesh, "CG", 1)

I obtain an object u of class Function(V).

Is there a way to build and store a 2-dimensional numpy array arr of size nx-by-ny such that

arr[i][j] = u(i * 1.0 / nx, j * 1.0 / ny)

for each i in range(nx) and each j in range(ny)?

asked Jun 11, 2015 by kdma-at-dtu FEniCS Novice (590 points)

1 Answer

0 votes

Hi,

You can use the Probes object from fenicstool.

Have a look to the second answer in

http://fenicsproject.org/qa/4451/probing-a-function-at-a-point-when-running-in-parallel

What you wrote should work ok in serial, but it will be extremely slow.

answered Jun 11, 2015 by umberto FEniCS User (6,440 points)
...