← Back to team overview

dolfin team mailing list archive

Re: Restriction of a function to a submesh

 

Hi Jehanzeb,
If you're just trying to "cut out" a piece of a function defined on a submesh, use interpolate (now that you can interpolate between functions on different meshes).

Here's a c++ snippet, assuming you've defined your function spaces appropriately from a .ufl file e.g. P1, and already have defined a mesh and a submesh

P1::FunctionSpace  V(mesh)
P1::FunctionSpace V_sub(submesh)

Function f(V,"some_vector.xml") // here I'm just reading in the vector for f from a file

Function f_sub(V_sub)

f_sub.interpolate(f)  //this will interpolate f onto the submesh

This works very well for me (particularly with a recent bug fix...make sure you use either the latest dolfin development version)

Hope it's what you're looking for
marc


p.s. here's the related file P1.ufl
# Function Space definitions for projecting onto linear triangles
#
# Compile this form with FFC: ffc -l dolfin -O P1.ufl

P1 = FiniteElement("Lagrange", triangle, 1)

u = TrialFunction(P1)
v = TestFunction(P1)
f = Function(P1)

L = v*f*dx
a = v*u*dx

On Sep 15, 2009, at 3:14 PM, Jehanzeb Hameed wrote:

Hello,

I am trying to restrict a function to a submesh, and I am not sure how
to do it. I looked at the restriction example, but that example is
restricts the function space. I want to take a nodal function "f" and
restrict it to a submesh.

One way I can think of is to use eval() to find function values at
nodes of submesh,  but this seems highly inefficient. Any one know how
to go about this?

Thanks,
-Jehanzeb
_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev

----------------------------------------------------
Marc Spiegelman
Lamont-Doherty Earth Observatory
Dept. of Applied Physics/Applied Math
Columbia University
http://www.ldeo.columbia.edu/~mspieg
tel: 845 704 2323 (SkypeIn)
----------------------------------------------------



References