### How to use a source function f that is stored in a matrix?

184
views
0
13 months ago by
Suppose I want to solve the PDE that appears in the ft01_poisson.py tutorial file:

-Laplace(u) = f in the unit square
u = u_D on the boundary
u_D = 1 + x^2 + 2y^2

However, suppose also that my source function function f does not have a nice closed form expression and must be computed numerically. To be concrete, suppose my f is a piecewise constant function whose values I have precomputed and stored in a matrix A, and to get the value of f(x,y), I need to read off the corresponding entry in my matrix A.

How do I proceed in solving this PDE? My understanding is that Expression requires code that is compatible with C
Community: FEniCS Project

You can create a Python subclass of Expression. See http://fenics.readthedocs.io/projects/dolfin/en/latest/demos/biharmonic/python/demo_biharmonic.py.html for an example.