# BoundaryMesh projection

Hi everyone,

I'd like to project a function defined on a function space over a boundary mesh to a function space defined over the full mesh.
I thought this could be achieved by integrating over the boundary of the full mesh but I get 'matrices are not alligned error '.
The error can be reproduced by the code below.

from dolfin import *

mesh = UnitSquareMesh(4,4)
V = FunctionSpace(mesh,'CG',1)

mesh_e = BoundaryMesh(mesh,'exterior')
V_e = FunctionSpace(mesh_e,'CG',1)
v_e = Function(V_e)

v = TrialFunction(V)
u = TestFunction(V)

L = v_e*u*ds
assemble(L)

In terms of math, I think the integral makes sense, as both v_e and u are defined over the domain of intergration. Is there a
way to achieve this? Thanks for help, Miro

## Question information

Language:
English Edit question
Status:
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
2013-03-14
2013-03-14
 Mikael Mortensen (mikael-mortensen) said on 2013-03-14: #1

Hi,

Not sure what's the best way to do this, but here's a hard and not so
elegant way:-)

from dolfin import *

mesh = UnitSquareMesh(4,4)
V = FunctionSpace(mesh,'CG',1)

mesh_e = BoundaryMesh(mesh,'exterior')
V_e = FunctionSpace(mesh_e,'CG',1)
v_e = interpolate(Expression("x"), V_e)

v = TrialFunction(V)
u = TestFunction(V)

V_dofmap = V.dofmap()
u = Function(V)
for facet in facets(mesh):
if facet.exterior():
c = Cell(mesh, facet.entities(2))
local_facet = V_dofmap.tabulate_facet_dofs(c.index(facet))
facet_coors = V_dofmap.tabulate_coordinates(c)[local_facet]
facet_dofs = V_dofmap.cell_dofs(c.index())[local_facet]
for x, dof in zip(facet_coors, facet_dofs):
u.vector()[dof] = v_e(x)

plot(u)

Mikael

On 14 March 2013 14:11, Miro <email address hidden> wrote:

> New question #224282 on DOLFIN:
>
> Hi everyone,
>
> I'd like to project a function defined on a function space over a boundary
> mesh to a function space defined over the full mesh.
> I thought this could be achieved by integrating over the boundary of the
> full mesh but I get 'matrices are not alligned error '.
> The error can be reproduced by the code below.
>
> from dolfin import *
>
> mesh = UnitSquareMesh(4,4)
> V = FunctionSpace(mesh,'CG',1)
>
> mesh_e = BoundaryMesh(mesh,'exterior')
> V_e = FunctionSpace(mesh_e,'CG',1)
> v_e = Function(V_e)
>
> v = TrialFunction(V)
> u = TestFunction(V)
>
> L = v_e*u*ds
> assemble(L)
>
> In terms of math, I think the integral makes sense, as both v_e and u are
> defined over the domain of intergration. Is there a
> way to achieve this? Thanks for help, Miro
>
> --
> You received this question notification because you are a member of
> DOLFIN Team, which is an answer contact for DOLFIN.
>