Function vector for spesific elements

Hello,

I transform a function ‘sol’ into a vector and I multiply it by a factor f1 as

sol.vector()[:] *= f1

How can I multiply the first 10 elements by f1 and the others by f2, because something like this is wrong

sol.vector()[0:9] *= f1
sol.vector()[10:] *= f2

You can do:

array = u.vector().get_local()
array[:10] *= f1
array[10:] *= f2
u.vector()[:] = array
1 Like