← Back to team overview

dolfin team mailing list archive

Re: [Question #94542]: Mixed elements with two different meshes

 

On Sat, Dec 19, 2009 at 12:49:19AM -0000, arnold@xxxxxxx wrote:
> New question #94542 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/94542
>
> I am interested in a finite element formulation using two variables, which are sought in finite element spaces with different meshes.
> Here is code for a contrived example:
>
> # coarse mesh space
> mesh = UnitSquare(1,1)
> V = FunctionSpace(mesh, 'CG', 1)
> # fine mesh space
> mesh.refine()
> W = FunctionSpace(mesh, 'CG', 1)
> # product space
> X = V + W
>
> I would have thought that this resulted in a coarse mesh space (dimension 4) for the V variable and a finer mesh space
> (dimension 9) for the W variable, so that the space X would have dimension 13.  However this is not what happens, as
> can be seen by printing the results:
>
> -------> print(V)
> <Function space of dimension 4 (<CG1 on a <triangle of degree 1>>)>
> -------> print(W)
> <Function space of dimension 9 (<CG1 on a <triangle of degree 1>>)>
> -------> print(X)
> <Function space of dimension 18 (<Mixed element: (<CG1 on a <triangle of degree 1>>, <CG1 on a <triangle of degree 1>>)>)>
>
> Is it possible to accomplish what I am trying to do: have mixed elements with different meshes for the different components?

Unfortunately not. It is assumed that all test and trial functions are
defined on the same mesh (although the local function spaces may
vary).

Something that is possible though is to have coefficients defined on
different meshes (other than the one we assemble over). Such
coefficients should be automatically interpolated during assembly.
It might be possible to use this to solve the problem iteratively.

I guess our basic assumption is that assembly is over one fixed mesh.
We might relax this in future versions but it will require a major
effort.

Also note the following new behavior introduced in DOLFIN 0.9.5:

  >> mesh = UnitSquare(1,1)
  >> V = FunctionSpace(mesh, 'CG', 1)
  >> mesh.refine()
  >> print V.dim()
  9

When meshes are refined, all function spaces defined on that mesh are
now automatically "refined" and all functions defined on those
function spaces are automatically interpolated to the new function
space.

If you need to keep a copy of the old mesh before refinement, just do

  mesh_old = Mesh(mesh)
  mesh.refine() # Will not change mesh_old

--
Anders

Attachment: signature.asc
Description: Digital signature


References