← Back to team overview

dolfin team mailing list archive

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

 



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.

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


Kent





Follow ups

References