Define a variable point by point

Hi,

Can someone please help me figure this out:
say

fespace Vh(th,P1);
Vh f=0;

Can I define f at given vertices, such as (x0, y0) which is the coordinate of a vertex.
I tried f(x0,y0)=2*x0+y0, which was illegal.
It seems I can do f[ ][ i ] = … but how I could know the index i ?

Thank you in advance.

Vh f = 2*x+y; // post must be at least 20 characters, so here is a random comment

Or did you mean the following?

fespace Wh(th, [P1, P1]);
Wh [u, v] = [x, y];

Thank you P, but this is not what I intended to do.

I try to define a force f, which is linearly distributed from point (x0, y0) to (x1, y1) – both points are moving.

f is perpendicular to the line determined by these two points., and the magnitude of f = 0 at (x1, y1) and 1 at (x0, y0).

I know the coordinates of vertices between (x0, y0) and (x1, y1), so I try to do this point by point. Do you have a better idea?

Best,
Yongxing.

To day the simple way, is a little tricky, because it integration on meshL of 2d finite element function buggius. so the idea is to build a 2d mesh such that one border is your line.

a example where the segment move on a square …

moveline.edp (746 Bytes)

remark I do not defined f points to points

but you can do :
f=0;
for(int i=0, i<f[].n; ++n)
f[][i] =i;

to see the numbering for example.

Thank you very much! This is really helpful.
YX.