Problem with "constraints.distribute_local_to_global(local_rhs, local_dof_indices, system_rhs)"

47 views
Skip to first unread message

Magdalini Ntetsika

unread,
Mar 5, 2020, 11:24:12 AM3/5/20
to deal.II User Group
Hi,

I want to assemble my system matrix only once since it doesn't change throughout the time steps. For that my code is similar to step-57:

if (assemble_matrix){
     constraints.distribute_local_to_global(local_matrix, local_rhs, local_dof_indices, system_matrix, system_rhs);
}
else{
    constraints.distribute_local_to_global(local_rhs, local_dof_indices, system_rhs);
}

but I don't seem to get the same system_rhs when assemble_system=false as when assemble_system=true. To be more specific, it seems that there is something wrong with how constraints.distribute_local_to_global(local_rhs, local_dof_indices, system_rhs) creates the system_rhs from local_rhs and local_dofs_indices. I don't change anything about constraints etc throughout the time steps since I set those things up at the very beginning and then I just run several times without updating anything. Any idea about what the problem could be?

Best,
Magda

Wolfgang Bangerth

unread,
Mar 5, 2020, 12:41:11 PM3/5/20
to dea...@googlegroups.com
On 3/5/20 9:24 AM, Magdalini Ntetsika wrote:
>
> but I don't seem to get the same *system_rhs *when
> *assemble_system=false* as when *assemble_system=true*. To be more
> specific, it seems that there is something wrong with how
> constraints.distribute_local_to_global(local_rhs, local_dof_indices,
> system_rhs) creates the system_rhs from local_rhs and
> local_dofs_indices. I don't change anything about constraints etc
> throughout the time steps since I set those things up at the very
> beginning and then I just run several times without updating anything.
> Any idea about what the problem could be?

Magdalini,
it's not in the function you point to, but in your understanding. In
order to compute the correct values of the right hand side when you have
non-zero constraints (e.g., when you have nonzer boundary values), the
function you call needs to have access to the matrix elements.

The issue is a bit complicated to understand, but you may want to look
up the video lectures on the topic of Dirichlet boundary conditions.

As for your case, take a look at step-26, which deals with exactly this
problem by building the matrix only once, but then using it for several
time steps.

Best
W.

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

Magdalini Ntetsika

unread,
Mar 5, 2020, 4:13:37 PM3/5/20
to deal.II User Group
Hi Wolfgang,

thank you for the prompt reply. I see, I'll look up both. But I have a quick question: what if I have periodic boundary conditions all around my domain? It seems to be working in that case, even if the boundary values are nonzero, I get to have the correct system_rhs vector. I guess will need first to watch the topic on Dirichlet Boundary conditions to understand better, but it will be very helpful if I could get some feedback on that specific observation from you.

Best,
Magda

Daniel Arndt

unread,
Mar 5, 2020, 4:39:26 PM3/5/20
to dea...@googlegroups.com
Magdalini,

The problem only appears with inhomogeneous boundary conditions, but periodic boundary conditions don't set any inhomogeneity.

Best,
Daniel

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/a320a562-6800-4650-871f-83a5eff9b79a%40googlegroups.com.

Magdalini Ntetsika

unread,
Mar 5, 2020, 5:38:41 PM3/5/20
to deal.II User Group
I see. Thank you Daniel!

Best,
Magda
To unsubscribe from this group and stop receiving emails from it, send an email to dea...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages