← Back to team overview

dolfin team mailing list archive

Initialization of discrete functions (related to bug 24)

 

Hello Dolfin!

Currently, one may not initialize a DiscreteFunction with something like init(Mesh&, Form&, uint). All init-methods involve also a GenericVector&. I think it would be useful to have a init-method that uses only the form and mesh, which then allocates a vector for itself (so that the DiscreteFunction actually "owns" its own dofs). Or is there a particular reason not to allow this?

Why do I care? I'm looking at the current state of the LinearPDE class. Here, the solution vector is a member function, and the solution Function is initialized with a reference to this vector. I.e. the LinearPDE (not the DiscreteFunction) owns the solution vector. This is of course a problem if the LinearPDE goes out of scope before the solution function (bug 24). It is also a bit counter-intuitive.

If it was possible to do an initialization like above, then the solve() method would simply do
u.init(mesh, form, 1);
GenericVector& x = u.vector();
<solve>

/Dag


Follow ups