Hi Alistair,


yes thanks that's what was searching for! One just has to make sure to call the corresponding function space from the common hierarchy directly, as in:


mesh=UnitSquareMesh(10,10)
mesh_hierarchy=MeshHierarchy(mesh,1)

fs_hierarchy = tuple([FunctionSpace(m, 'CG', 1) for m in mesh_hierarchy])

fun_fine = Function(fs_hierarchy[1])
fun_fine.dat.data[:] = np.random.normal(0, 1, len(fun_fine.dat.data))

fun_coarse = Function(fs_hierarchy[0])
inject(fun_fine, fun_coarse)


Thanks again,

Tobias



Von: firedrake-bounces@imperial.ac.uk <firedrake-bounces@imperial.ac.uk> im Auftrag von Gregory, Alastair C A <a.gregory14@imperial.ac.uk>
Gesendet: Mittwoch, 11. Januar 2017 13:04
An: firedrake
Betreff: Re: [firedrake] project between mismatching meshes
 
Hi Tobias,

Yes but the meshes have to be part of a MeshHierarchy.

Make mesh=UnitSquareMesh(10,10)

And then mesh_hierarchy=MeshHierarchy(mesh,1).

You can set mesh_coarse=mesh_hierarchy[0] and mesh_fine=mesh_hierarchy[1] and proceed like that.

One can do inject(fun_fine, fun_coarse) to carry out the projection.

Many Thanks,
Ali

Sent from my iPhone

On 11 Jan 2017, at 12:52, Schwedes, Tobias <t.schwedes14@imperial.ac.uk> wrote:

Hi all,


is there a way to project a function defined on a fine mesh onto a functionspace with a coarse mesh? Look at the following exemplary setup:


from firedrake import *

import numpy as np


mesh_fine =  UnitSquareMesh(20,20)

mesh_coarse =  UnitSquareMesh(10,10)


fs_fine  = FunctionSpace(mesh_fine, 'CG', 1)

fs_coarse  = FunctionSpace(mesh_coarse, 'CG', 1)


fun_fine = Function(fs_fine)

fun_fine.dat.data[:] = np.random.normal(0, 1, len(fun_fine.dat.data))


fun_coarse = ?


In this case, perhaps one could inherit overlapping nodes from fine to coarse mesh?

All the best,
Tobias

_______________________________________________
firedrake mailing list
firedrake@imperial.ac.uk
https://mailman.ic.ac.uk/mailman/listinfo/firedrake