← Back to team overview

dolfin team mailing list archive

Re: Function design

 



Anders Logg wrote:
On Wed, Dec 17, 2008 at 12:15:38AM +0000, Garth N. Wells wrote:
I'm running into some problems with the new Function design when trying to update a solver. I'll try to sketch the issue as simply as possible.

     Function v;
     Function u, p;

     // First form for U = (u, p)
     FirstBilinearForm a_1(V1, V1);
     FirstLinearForm   L_1(V1);
     LinearPDE pde_first(a_1, L_1);

     // Second form which depends on u
     SecondBilinearForm a_2(V2, V2);
     SecondLinearForm   L_2(V2, u);
     LinearPDE pde_second(a_2, L_2);

     Function U;
     for(uint i = 0; i < 10; ++i)
     {
       pde_first.solve(U);

       // This step breaks down because FunctionSpaces don't match
       u = U[0];
       p = U[1];

       pde_second.solve(v);
     }

The problem is in assigning Functions since we now check the FunctionSpace.

Which check is it that fails?

To get around this, I tried

     FunctionSpace V(mesh);
     Function U(V);
     Function u = U[0];
     Function p = U[1];

which throws an exception because U does not have a vector.

What if we remove the check in operator[] and then in the constructor
that gets a SubFunction we rely on v.v.vector() which (after Martin's
fix from yesterday) will always return a vector with the dofs
(possibly interpolated if there were no dofs before).



We don't seem to have reached a conclusion on this. The problem is that

    Function::Function(const SubFunction& v)

always creates a new 'sub' space object

    _function_space(v.v.function_space().extract_sub_space(v.component))

Are there any problems if a FunctionSpace were to 'own' its subspaces (through a shared pointer of course) and generate them on demand? This way different Functions could request a sub space from the space V and they will get the same object (i.e. the same address). This would require changes in FunctionSpace but none in Function. Opinions, objections or suggestions?

Garth



------------------------------------------------------------------------

_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev




References