← Back to team overview

ffc team mailing list archive

Re: Changed storage of constants from reference to copy in forms. This is [...]

 

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