Hello,
this question is still related to my first case I'm trying to solve with DOLFIN (and FEniCS), i.e. a 2D advection-diffusion-reaction problem for temperature with exotic source terms.
In particular I have a source term that is spatially "spotted", like a grid of localized heat sinks, imagine it to be the sum of several gaussian distributions that are localized in several $x_i$ locations:
$$ q(x, T) = f(x)g(T) $$
where $T$ is the temperature. The spatial function is:
$$ f(\mathbf{x}) = \sum_i\left[ \frac{1}{\sqrt{2\pi\sigma^2}}\exp \left( - \frac{(x-x_i)^2 + (y-y_i)^2}{2\sigma^2} \right)\right]$$
I implemented this with Python, subclassing Expression
, but it is hyperslow. So I thought to save the distribution of $f(\mathbf{x})$ in a file and then interpolate it from the file and use it in the source expression.
q = InterpolateFromFile('spatial_source.pvd')
def source(u):
return q*g(u)
I imagine there should be something integrated in dolfin
to do this low-level. Am I right?