ffc team mailing list archive
-
ffc team
-
Mailing list archive
-
Message #00267
Re: Changed storage of constants from reference to copy in forms. This is [...]
-
To:
Discussion of FFC development <ffc-dev@xxxxxxxxxx>
-
From:
Anders Logg <logg@xxxxxxxxx>
-
Date:
Sun, 11 Sep 2005 07:49:35 -0500
-
In-reply-to:
<E1EEPop-0006TU-00@bamse>
-
Mail-followup-to:
Discussion of FFC development <ffc-dev@xxxxxxxxxx>
-
User-agent:
Mutt/1.5.9i
The reason it's a reference is that in a time-stepping loop, you want
to be able to give the time step k or time t as an argument to the
form and have it automatically get updated as you change k and t.
Maybe one should require that one uses references for the constants,
that is, the constant must exist in a variable outside of the form, in
the same way as a Function must exist outside of the form?
/Anders
On Sun, Sep 11, 2005 at 01:16:19PM +0200, ffc@xxxxxxxxxx wrote:
> Commit from johanjan (2005-09-11 13:16 CEST)
> --------------------
>
> Changed storage of constants from reference to copy in forms. This is
> to avoid this type of subtle memory error:
>
> class LinearForm
> {
> public:
> Linearform(real& c0) : c0(c0)
> {
> }
> real& c0;
> }
>
> class MySolver
> {
> public:
> MySolver(real c) : L(c)
> {
> // !!! After this constructor returns, the contents of LinearForm::c0 are
> // no longer allocated.
> }
> LinearForm L;
> }
>
> ffc src/ffc/format/dolfin.py 1.34
>
> _______________________________________________
> FFC-dev mailing list
> FFC-dev@xxxxxxxxxx
> http://www.fenics.org/cgi-bin/mailman/listinfo/ffc-dev
>
--
Anders Logg
Research Assistant Professor
Toyota Technological Institute at Chicago
http://www.tti-c.org/logg/
Follow ups
References