Dear NGSolve users and developers,

I read the section “Interpolate a CoefficientFunction” of

https://ngsolve.org/docu/nightly/i-tutorials/unit-1.2-coefficient/coefficientfunction.html

and I would like to interpolate a vector expression to a vector function following the same

snippet. How should I do that?

Below you can find a code where I try to

a) interpolate from scalar expression to scalar space: this is working correctly

b) interpolate from scalar expression to each component of vector space: this is working correctly

c) my case, interpolate from vector expression to vector function, and two ways I tried, and the corresponding errors

Thanks,

best regards,

Makis

[code]from ngsolve import *

from netgen.geom2d import unit_square

ngsglobals.msg_level = 0

mesh = Mesh (unit_square.GenerateMesh(maxh=0.2))

myfunc = x*(1-x)

# a) Interpolate from scalar expression to scalar space: working

V1 = H1(mesh, order=1)

u1 = GridFunction(V1)

u1.Set(myfunc)

print(u1.vec.Norm())

# b) Interpolate from scalar expression to each component of vector space: working

V2 = FESpace([V1, V1])

u2 = GridFunction(V2)

u20 = 2*u1
u21 = 3*u1

u2.components[0].Set(u20)

u2.components[1].Set(u21)

print(u2.vec.Norm(), u1.vec.Norm()*sqrt(13))

# c) Interpolate from vector expression to vector function

u3 = GridFunction(V2)

u2_double = 2*u2

# c1)

u3.Set(u2_double) # Segmentation fault

# c2)

u3.components[0].Set(u2_double[0]) # RuntimeError: don’t know my dimension, space is N6ngcomp15CompoundFESpaceE

u3.components[1].Set(u2_double[1])

print(u3.vec.Norm(), u1.vec.Norm()*2)[/code]