← Back to team overview

dolfin team mailing list archive

Re: [HG DOLFIN] Don't initialize vector in DiscreteFunction if already initialized.

 

On ma., 2008-09-15 at 11:48 +0100, Garth N. Wells wrote:
> 
> Kent Andre wrote:
> > On ma., 2008-09-15 at 11:19 +0100, Garth N. Wells wrote:
> >> DOLFIN wrote:
> >>> One or more new changesets pushed to the primary dolfin repository.
> >>> A short summary of the last three changesets is included below.
> >>>
> >>> changeset:   4751:df802d1b2b349e91a51b70f799ba6d0d3b825376
> >>> tag:         tip
> >>> user:        Anders Logg <logg@xxxxxxxxx>
> >>> date:        Sat Sep 13 08:55:34 2008 +0200
> >>> files:       dolfin/function/DiscreteFunction.cpp
> >>> description:
> >>> Don't initialize vector in DiscreteFunction if already initialized.
> >>>
> >> Vector::init() only resizes the vector if necessary, but it also zeroes 
> >> the vector. Looks to me like it is desirable to zero the vector?
> >>
> >> Garth
> >>
> > 
> > The reason for this, I think, is initialization as such: 
> > 
> > solve(A, x, b, cg, amg)
> > u = Function(element, mesh, x)
> > plot(u)
> >
> 
> The problem is that I could also create the function, and then use it 
> with a vector that hasn't been initialised properly.

But then you would not use this constructor? 

> 
> The most robust approach, which I've been working towards, is that a 
> DiscreteFunction always owns it's vector and can't be initialised with a 
> Vector. The above code would be
> 
>    u = Function(element, mesh)
>    solve(A, u.vec(), b, cg, amg)
>    plot(u)
> 
> Garth
> 

It is fine by me if DiscreteFunction owns the vector, then the entries
of x has to be copied. 

I'm having similar design decisions in BlockVectors and BlockMatrix.
Should they own the subvectors and submatrices ?  For now I have a
boolean flag. In general I think it should be possible to set and get
underlying pointers. This is dangerous but it is often something one
would like to do particulary when coupling to other software packages. 

Kent






Follow ups

References