Usage of the laplace-matrix in example 23

52 views
Skip to first unread message

Maxi Miller

unread,
Aug 18, 2017, 11:26:37 AM8/18/17
to deal.II User Group
I am trying to develop my own code based on example 23 (\partial_t U = i/(2k)\nabla^2U), and am trying to understand the purpose of the laplace-matrix. Why is it used in order to multiply in both sides, in comparison with the weak formulation (\nabla\phi_i,\nabla\phi_j) and the assembly of the usual cell matrix? Assumed I have to split my U into a real and an imaginary value, is the approach with the Laplace-matrix better, or the split into the weak formulation and the accompanying matrices on both sides?

Daniel Arndt

unread,
Aug 22, 2017, 10:50:03 AM8/22/17
to deal.II User Group
Maxi,

citing from the documentation of step-23[1]:
"In a very similar vein, we are also too lazy to write the code to assemble mass and Laplace matrices, although it would have only taken copying the relevant code from any number of previous tutorial programs. Rather, we want to focus on the things that are truly new to this program and therefore use the MatrixCreator::create_mass_matrix and MatrixCreator::create_laplace_matrix functions."
It comes just handy that we have an easy way to get the required matrices without having to write the assembly loops ourselves.
Mutiplying the finite element vector old_solution_u by the laplace matrix is the same as assembling the right-hand side (\nabla phi, \nabla old_solution_u).

The point in this example is that you don't have to assemble the laplace matrix for each time step anew. How you do this is totally up to you. In create MatrixCreator::create_laplace_matrix we apply some more optimizations
so this might be faster then writing the assembly loop yourself. In the end, you should have a lot of time steps and assembling this matrix once should negligible in comparison to the time you spend in the solver.
Hence, my advice would be to use whatever is easier for you.

Best,
Daniel

[1] https://www.dealii.org/8.5.0/doxygen/deal.II/step_23.html#Includefiles
Message has been deleted

Wolfgang Bangerth

unread,
Jan 23, 2018, 2:27:37 PM1/23/18
to dea...@googlegroups.com
On 01/23/2018 10:35 AM, Dulcimer0909 wrote:
>
> If I do go ahead and replace code, so that it does a cell by cell assembly, I
> am a bit lost on how I would store the old_solution (U^(n-1)) for each cell
> and retrieve it during the assembly for the Rhs.

Dulcimer -- can you elaborate? It's not clear to me how the two are related.
In the thread you comment on, the question is about how to assemble the
matrices, but these matrices do not actually depend on the previous solution.
In any case, the program of course stores the old solution and so any code you
write will have access to it.

So it's not entirely clear to me what you mean in your question :-(

Best
W.

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

Message has been deleted
Message has been deleted

Wolfgang Bangerth

unread,
Feb 5, 2018, 4:49:53 PM2/5/18
to dea...@googlegroups.com

Dulcimer,
it is difficult for any of us to just look at a piece of code and tell
where exactly things are going wrong. You'll have to learn to debug what
is happening in your case, and for this it is easiest if you make the
problem as simple as possible -- for example, use zero boundary values,
zero right hand sides, no hanging nodes, etc. You can then reduce the
amount of code that deal with each of these cases. This reduces the
number of possible sources of the problem.

From a cursory look at your code, I see that you are adding
contributions to the rhs vectors and the system matrix on each cell. But
I don't see that you set these vectors and the matrix to zero before
your loop over all cells. I may be missing this, but it seems like a bug.
Reply all
Reply to author
Forward
0 new messages