I'm in the process of solving a Poisson equation, where the Dirichlet boundary condition has to be defined via Green's function solution.
So far, if I've understood correctly, defining a boundary condition proceeds by
(1) defining the region of the boundary where the Dirichlet condition is to be applied (in my case it is the entire boundary)
def is_at_boundary(x,on_boundary):
return on_boundary
(2) providing an Expression to compute the value at the boundary
u0 = Expression( open('u0.cpp').read() )
(3) initializing a boundary condition object.
bc = DirichletBC(V, u0, is_at_boundary)
I have chosen to use a c++ class for defining the boundary expression, so the file 'u0.cpp' should look something like this:
namespace dolfin {
class u0 : public Expression
{
public :
u0 () : Expression () {}
void eval (Array <double >& values ,
const Array <double >& x) const
{
// Somehow get access to the source function f
// Compute integral over the computational
// domain given two parameters (x[0], x[1])
values [0] = assemble( f(y) * K(y,x[0],x[1]) * dy ) ;
}
};
}
Assumably, I would have to first define a class for the function K(y,x[0],x[1]) which would be initialized with x[0] and x[1], and that class should provide an Expression. That I can do.
But how can I integrate an expression throughout the entire domain, inside a c++ class that defines an Expression?
Does the Expression that defines the value of the function at the boundary have to be a 'pure function', or can it take other arguments as well? If more than the argument x is allowed, how do I set the boundary condition then when calling 'DirichletBC(...)'?
Thank you.
Eero