Re: [deal.II] Setting off-diagonal elements in the matrix

On 08/08/2017 05:07 AM, 'Maxi Miller' via deal.II User Group wrote:

Having a coupled set of poisson-like equations
\partial_t a = \nabla^2 a
\partial_t b = \nabla^2 b + \nabla^2 a
I can write the weak form(s) as (while ignoring boundary conditions)
\partial_t a = (\nabla v_1, \nabla a)
\partial_t b = (\nabla v_2, \nabla b) + (\nabla v_2, \nabla a)
Now in deal.II I add both equations to the same matrix (first the main
diagonals):
|
system_matrix(i,j)=(scalar_product(fe_values[a].gradient(i,q_point),fe_values[a].gradient(j,q_point))+scalar_product(fe_values[b].gradient(i,q_point),fe_values[b].gradient(j,q_point)))*fe_values.JxW(q_point);
|

and then the off-diagonal term
\partial_t b = (\nabla v_2, \nabla a)

|
system_matrix(i,j)+=(scalar_product(fe_values[b].gradient(i,q_point),fe_values[a].gradient(j,q_point)))*fe_values.JxW(q_point);
|
But wouldn't that be the same as for the system of equations
\partial_t a = \nabla^2 a + \nabla^2 b
\partial_t b = \nabla^2 b
?
How does deal.II distinguish between both?



The subsect of shape functions i or j for which fe_values[a].value(i) and fe_values[b].value(i) is nonzero, is different. So if you exchange a<->b and i<->j in the right hand side of

system_matrix(i,j)+=(scalar_product(fe_values[b].gradient(i,q_point),fe_values[a].gradient(j,q_point)))*fe_values.JxW(q_point);


then you will get the same number, but you really have to change both. But unless you also change i<->j on the left, you will get the transpose matrix, as you suspected.

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth          email:                 bange...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see
https://groups.google.com/d/forum/dealii?hl=en

--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.