Need help setting up the left hand side in a modification of example 52

15 views
Skip to first unread message

Maxi Miller

unread,
Aug 3, 2017, 5:16:56 AM8/3/17
to deal.II User Group
I am following example 52 for writing code which should solve a system of three equations. In it I can rewrite my equations such that my source term is zero, but my matrices on the left side are depending on time, which means that I have to reassemble the system matrix and the inverse system matrix at every time step. Is that a good idea, or rather performance-degrading? The function
assemble_system()
has been rewritten to
assemble_system(const double time)  
Furthermore I then have to call
assemble_system(time)
in the function
evaluate_diffusion(const double time, const Vector<double> &y)
but compilation fails with
error: passing const Step52::Diffusion<3>’ as this argument discards qualifiers [-fpermissive]
     assemble_system
(time);
but why? And how can I fix that?

Wolfgang Bangerth

unread,
Aug 3, 2017, 7:08:47 AM8/3/17
to dea...@googlegroups.com
On 08/03/2017 03:16 AM, 'Maxi Miller' via deal.II User Group wrote:
> I am following example 52 for writing code which should solve a system of
> three equations. In it I can rewrite my equations such that my source term is
> zero, but my matrices on the left side are depending on time, which means that
> I have to reassemble the system matrix and the inverse system matrix at every
> time step. Is that a good idea, or rather performance-degrading?

Like all performance questions, it is not worth thinking about them *unless
you have concrete evidence* that your performance is too slow for what you
want to do. For example, if your solver takes 90% of the time, then it doesn't
make sense to look at the run time of the assembly.

> Furthermore I then have to call
> |
> assemble_system(time)
> |
> in the function
> |
> evaluate_diffusion(constdoubletime,constVector<double>&y)
> |
> but compilation fails with
> |
> error:passing ‘constStep52::Diffusion<3>’as‘this’argument discards qualifiers
> [-fpermissive]
> assemble_system(time);
> |
> but why? And how can I fix that?

Your evaluate_diffusion() function is declared as `const`. But you can only
call `const` functions from `const` functions, so you are not allowed to call
the non-`const` function assemble_system().

Best
W.

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

Maxi Miller

unread,
Aug 3, 2017, 7:44:10 AM8/3/17
to deal.II User Group, bang...@colostate.edu
Why is evaluate_diffusion() declared as const? When removing the const-keyword, compilation works fine (running not tested yet).

Wolfgang Bangerth

unread,
Aug 3, 2017, 8:37:38 AM8/3/17
to Maxi Miller, deal.II User Group
On 08/03/2017 05:44 AM, Maxi Miller wrote:
> Why is evaluate_diffusion() declared as const? When removing the
> const-keyword, compilation works fine (running not tested yet).

You mean in the program you copied it from? I don't know -- but in general if
something *can* be declared `const`, then it *should* be declared `const`.
That just doesn't seem to work in your case any more.
Reply all
Reply to author
Forward
0 new messages