← Back to team overview

dolfin team mailing list archive

Re: BoundaryConditions and shared_ptr constructor

 

On Friday 14 August 2009 13:45:14 Johan Hake wrote:
> On Friday 14 August 2009 13:40:49 Garth N. Wells wrote:
> > 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.
>
> Ok, I can take a look at it.
>
> I see that the FunctionSpace in BoundaryCondition is already stored using
> shared_ptr, but there's no constructor for passing one :P.

I have now added shared_ptr contructors for Function, FunctionSpace and 
SubDomains. I have also declared SubDomain a shared_ptr class in PyDOLFIN.

I will soon update the compiled_subdomain function.

Johan

> Johan
>
> > 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@xxxxxxxxxx
> > > http://www.fenics.org/mailman/listinfo/dolfin-dev
>
> _______________________________________________
> DOLFIN-dev mailing list
> DOLFIN-dev@xxxxxxxxxx
> http://www.fenics.org/mailman/listinfo/dolfin-dev


Follow ups

References