Weak Form - Product of two surface integrals

4 months ago by
Hi there,

I am new to FEniCS and there is something I can not figure out when I define my variational formulation.
I have a trial function \(u\) and a test function \(v\) on my function space \(V\). I use classic Lagrange elements.

I also have a defined expression which is for instance:
phi = Expression('cos(N*pi*x[1])', N = 3, degree = 2)​

I want to define the product of two surface integrals as follow:

\left (\int_{\Gamma} u \varphi \, ds \right) \left (\int_{\Gamma} v \varphi \, ds\right)

I can implement both terms independently:
Term1 = inner(u,phi)*ds
Term2 = inner(v,phi)*ds​
but I do not know how to multiply them together properly.
I tried to do:
and other related operations but I get a GenericVector and not a matrix as I want.
After the multiplication, I would like to have the same form as if I do:

, which correspond to the case \(\varphi = 1\).

Do you have an idea how to do so ?
I would be grateful for any help ! 

Kind Regards,

PS: The goal of this operation is to define a Dirichlet to Neumann boundary condition.
Community: FEniCS Project

2 Answers

4 months ago by
assemble(Term1) and assemble(Term2) are both vectors. So I guess you want to form a matrix being an outter product of the vectors. DOLFIN does not have facilities for that. Immediate caveat is that for a general phi this matrix is dense - or more precisely, dense for DOFs supported on the boundary. DOLFIN does not provide any facilities for that. So assemble the vectors and follow petsc4py documentation to form the matrix from the vectors.

PS: That's a typical caveat of Dirichlet-to-Neumann opeartors - nonlocality.
4 months ago by
Great, I used petsc4py and managed to create the matrix I needed.
Thank you !
Please login to add an answer/comment or follow this question.

Similar posts:
Search »