project mesh function into FunctionSpace

Asked by Lars on 2010-06-29

Hello,
how can I project/interpolate a discrete vector gamma, defined on each vertex of a triangular mesh, into a FunctionSpace V?

I have to solve a laplace equation with variable diffusivity as in the following bilinear form:
a = dot(grad(u), gamma* grad(v))*d

The solution is not possible if gamma is an array or a MeshFunction. What is the correct transformation?

Thanks
Lars

Question information

Language:
English Edit question
Status:
Solved
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Solved by:
Lars
Solved:
2010-06-29
Last query:
2010-06-29
Last reply:
2010-06-29
Anders Logg (logg) said : #1

On Tue, Jun 29, 2010 at 04:11:50PM -0000, Lars wrote:
> New question #116141 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/116141
>
> Hello,
> how can I project/interpolate a discrete vector gamma, defined on each vertex of a triangular mesh, into a FunctionSpace V?
>
> I have to solve a laplace equation with variable diffusivity as in the following bilinear form:
> a = dot(grad(u), gamma* grad(v))*d
>
> The solution is not possible if gamma is an array or a MeshFunction. What is the correct transformation?
>
> Thanks
> Lars

Just create function on a vector-valued piecewise linear space and set
the dofs in the vector:

V = VectorFunctionSpace(mesh, "CG", 1)
gamma = Function(V)
dofs = gamma.vector()
dofs[:] = ...

The dofs are ordered [vx1 vx2 ... vy1 vy2 ...]

--
Anders

Lars (lars-g-m-x) said : #2

Thank you very much!