← Back to team overview

dolfin team mailing list archive

Re: Mesh refinement and Functions

 

On Tue, Nov 03, 2009 at 01:00:11AM +0100, Marie Rognes wrote:
> Anders Logg wrote:
> > I've thought some more on the problem of mesh refinement and updating
> > of Functions.
> >
> > The main problem seems to be the following:
> >
> >   mesh.refine()
> >
> > If we want to allow this, then we need to provide some kind of
> > automated updating of functions and function spaces to the new mesh,
> > since this call will otherwise destroy all function spaces and
> > functions that refer to that mesh:
> >
> >   V = FunctionSpace(mesh, "CG", 1)
> >   v = Function(V)
> >   mesh.refine() # V and v no longer make any sense
> >
> > This gives us two options. Either we disallow refinement of a mesh
> > without making a copy. Or we provide automated updating. I think we
> > should do the latter.
> >
> >
>
> I think that I would appreciate both:
>
> (a) Automated updating if mesh.refine()
>
> and
>
> (b) Functionality provided for updating functions to a new mesh if mesh
> = refine(mesh)
>
>
> > What is needed compared to what we have now is to let a call to
> > Mesh::refine trigger a call to FunctionSpace::update for all function
> > spaces defined on the mesh, which in turn will trigger calls to
> > Function::update for all functions defined on the function spaces.
> >
> > We can make the update functions private.
> >
> > Comments or objections? I think I can make this work.
> >
> >
>
> I can imagine that one would like to keep a copy of a function on the
> old mesh if
> one compares solutions from different meshes. Then automated updating could
> be somewhat suboptimal.

If you want to have both u_H and u_h, then you need to do something
like this:

  new_mesh = Mesh(mesh)
  new_mesh.refine()
  new_V = FunctionSpace(new_mesh, ...)
  etc.

So you explicitly make a copy of your old mesh, refine that
copy, and redefine your function space on that refined copy.

Or you can do this:

  old_mesh = Mesh(mesh)
  old_V = FunctionSpace(old_mesh, ...)
  mesh.refine()
  old_u = interpolate(u, old_V)

So you explicitly make a copy of your old mesh, and then refine the
mesh (which updates the function space, the functions and the forms)
and then project your new solution back.

None of these seem to be optimal.

--
Anders

Attachment: signature.asc
Description: Digital signature


References