On 15 May 2013 12:42, Jan Blechta <[email protected]> wrote: > On Wed, 15 May 2013 11:40:25 +0100 > "Garth N. Wells" <[email protected]> wrote: >> On 15 May 2013 11:23, Anders Logg <[email protected]> wrote: >> > On Wed, May 15, 2013 at 10:48:31AM +0100, Garth N. Wells wrote: >> >> Chris and I are working on IO (including parallel) via HDF5 for >> >> mesh data structures. An issue that I've run into before and which >> >> is making things complicated now are the circular dependences in >> >> the Mesh class. >> >> >> >> Every Mesh has a MeshDomains object and a MeshData object. >> >> MeshDomains stores a reference to its Mesh, and it stores >> >> MeshFunctions, that hold a shared_ptr to a Mesh (it also has >> >> MeshValueCollections which we'll probably also let store a pointer >> >> to the Mesh). >> > >> > We should strive to avoid this (the owned object having a pointer to >> > the owner), but it often creeps in for convenience. >> > >> >> This all makes memory management complicated because the objects >> >> are constructed with the Mesh '*this' object, and leads to a lot >> >> of 'no deleter' shared pointers. Since MeshDomains are always >> >> associates with a Mesh and a Mesh always has a MeshDomains object, >> >> any objections to just using plain STL vectors to hold the >> >> MeshDomain data? >> > >> > What would the changes be in the interface? >> > >> >> There will be some internal changes, but I expect very little or >> nothing that the user will see. The only visible changes will be in >> the MeshDomains interface, which I've never used directly from >> application-level code. > > What about > facet_domains = mesh.domains().facet_domains() > to access facet markers stored within mesh? >
This can just be a std::vector holding the markers. We could generate MeshFunctions for the stored data, if needed The above code also illustrates one of the present problems. If the mesh object goes out of scope, facet_domain will have a dangling reference to a Mesh. We can't resolve this with shared_ptr because the mesh itself creates the MeshDomains object. Longer term, the need for returning domains from the mesh via MeshDomains will be obviated by the flexibility of the HDF5 format which will allow a user to pull all sorts of mesh-related data from a single file. Garth > Jan > >> >> Garth >> >> > -- >> > Anders >> _______________________________________________ >> fenics mailing list >> [email protected] >> http://fenicsproject.org/mailman/listinfo/fenics > _______________________________________________ fenics mailing list [email protected] http://fenicsproject.org/mailman/listinfo/fenics
