← Back to team overview

dolfin team mailing list archive

Re: Mesh refine

 

On Thu, Feb 03, 2011 at 08:26:14PM +0000, Garth N. Wells wrote:
> I haven't looked at the new mesh refine code, but I'm not too keen on
> the interface. It was neat to do
>
>   Mesh mesh("lshape.xml.gz");
>   mesh = refine(mesh);
>
> Doing the above, there is no compile time error, but there is a runtime
> error. Now we have to do
>
>   Mesh mesh0("lshape.xml.gz");
>   Mesh& mesh = refine(mesh0);

The above is not possible. You have to do

  Mesh mesh0("lshape.xml.gz");
  const Mesh& mesh = refine(mesh0);

(const since the returned mesh has access to mesh0 which is a const
argument of refine)

Alternatively, as I've done in the Navier-Stokes demo, you can do

  Mesh mesh0("lshape.xml.gz");
  refine(mesh0);
  Mesh& mesh = mesh0.child(); // no const here

> which I think is a bit clumsy. How can I refine a mesh easily if I'm not
> interested in keeping a hierarchy?

I agree it's more clumsy.

I don't know what the best solution is. Perhaps one could have a
global parameter "store_hierarchy" which defaults to False in
combination with return by value in the refine functions.

Assignment would then only work when the depth of the hierarchy is 1
(when no hierarchy is stored).

Another option would be to allow assignment from the returned
reference but then make sure that whenever we assign to an object that
is a member of a hierarchy, we destroy the (entire) hierarchy. This
might be cleaner since we don't need the parameter.

--
Anders



Follow ups

References