← Back to team overview

dolfin team mailing list archive

Re: MeshDomain

 

On 02/11/2013 01:09 PM, Martin Sandve Alnæs wrote:
> Because of the circular depencency and reference counts not becoming
> zero? It could be a weak pointer:
> http://www.boost.org/doc/libs/1_53_0/libs/smart_ptr/weak_ptr.htm

To use weak pointers one need the shared_ptr first, right? Because
MeshDomains are created withing the constructor of Mesh you do not have
that.

A way to "solve" this is to just store a reference to the mesh, similar
to what is done in MeshData. This is of course not bullet proof as one
easily can make it blow up by:

from dolfin import *
m = UnitSquareMesh(2,2)
md = m.data()
del m
md.create_mesh_function("boom", 0)

Any nice fixes for this situation you C++ guros out there?

Johan


> Martin
> 
> 
> On 11 February 2013 13:02, Anders Logg <logg@xxxxxxxxx
> <mailto:logg@xxxxxxxxx>> wrote:
> 
>     On Mon, Feb 11, 2013 at 09:00:20AM +0100, Johan Hake wrote:
>     > I am adding some functionality to MeshDomains, (actually to SubMesh,
>     > which soon also propagates MeshDomains to the new mesh), and wonder if
>     > there where any good reasons why a MeshDomain does not have a
>     pointer to
>     > the parent mesh?
>     > If such was provided during construction we could skip the
>     annoying mesh
>     > argument in:
>     >  facets_domains = mesh.domains().facet_domains(mesh)
> 
>     Feel free to add it if it is useful. At the time of implementation, I
>     wanted to avoid a pointer to the parent to keep the number of pointers
>     floating around at a minimum (especially in this case since it can't
>     be a shared pointer).
> 
>     --
>     Anders
> 
>     _______________________________________________
>     Mailing list: https://launchpad.net/~dolfin
>     Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
>     <mailto:dolfin@xxxxxxxxxxxxxxxxxxx>
>     Unsubscribe : https://launchpad.net/~dolfin
>     More help   : https://help.launchpad.net/ListHelp
> 
> 



Follow ups

References