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

13 months ago by
Suppose I want to solve the PDE that appears in the 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

1 Answer

13 months ago by
You can create a Python subclass of Expression. See for an example.
Please login to add an answer/comment or follow this question.

Similar posts:
Search »