Mixed elements with two different meshes

Asked by Doug Arnold

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?

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Sat, Dec 19, 2009 at 12:49:19AM -0000, <email address hidden> 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

Revision history for this message
emmanuel.malherbe (emmanuel-malherbe) said :
#2

Hi,

As I was trying to define a mixed function space, I faced the same problem as Anders. Fenics keeps only one mesh (the first).
(as above, but with X=V*W instead of X=V+W)

Just to be sure, different meshes for a mixed space is still not supported on fenics? Would it be supported soon?

Thanks.

Can you help with this problem?

Provide an answer of your own, or ask Doug Arnold for more information if necessary.

To post a message you must log in.