Johan Hake wrote:
> Hello!
> 
> Is it possible to store the internals of BoundaryConditions and its derived 
> classes using shared_ptr?
> 
> This would be nice for the python interface where both Functions and 
> FunctionSpaces are stored using shared_ptr.
> 
> As it is now will following break when the return bc is used.
> 
>    def create_Dirichlet_bc(value):
>        # Define boundary condition in terms of a local variable u0
>        # that goes out of scope when the execution of this function is done
>        u0 = Constant(mesh, value)
>        bc = DirichletBC(V, u0, DirichletBoundary())
>        return bc
> 
> If DirichletBC could store the passed Function using shared_ptr we would 
> avoid 
> this problem. 
> 

Sounds good to me. The problem in the above example is precisely why I 
moved to shared pointers in other classes.

Garth

> It should be straight forward to add shared_ptr constructor for both 
> FunctionSpace and Function, as these are already defined as such in PyDOLFIN. 
> However we should also consider doing the same for SubDomain. This will 
> introduce a new class we need to wrap using shared_ptr in PyDOLFIN.
> 
> Johan
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@fenics.org
> http://www.fenics.org/mailman/listinfo/dolfin-dev

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

Reply via email to