Finite element space on an edge

Dear FreeFem++ community,

For domain decomposition, I need to solve a 2d problem with a given function g on a boundary (thus 1d) obtained with an iterative finite element calculation. g can be, for example, the restriction of a finite element function on a boundary.

In the example below, g is defined in the whole finite element space, I would like to define it only on the top interface. Perhaps with 1d meshL ?


border top(t=0,1){x=t;y=1;}

border right(t=0,1){x=1;y=1-t;}

border bottom(t=0,1){x=1-t;y=0;}

border left(t=0,1){x=0;y=t;}

mesh Th=buildmesh(top(-5)+right(-5)+bottom(-5)+left(-5));

fespace Vh(Th,P1);

Vh g = x*y;

Vh u,v;

solve Prob(u,v)

= int2d(Th)(dx(u)*dx(v) + dy(u)*dy(v))

+ on(right, bottom, left, u=0)

+ on(top, u=g);

plot(u, wait=1, value=1);

1 Like

Hello,

To impose a Dirichlet BC (Boundary condition) in Freefem++, you need to call the label of your boundary in the on function.
For example, if you use the square function to build your mesh, the default labels are 1 for bottom, 2 for right, 3 for top and 4 for left.

In your example, you build your mesh from the top, so the top label is 1, the right label is 2, the bot label is 3 and the left label is 4.

Once you know your labels you write

on(border label, u= value)

in your case :

border top(t=0,1){x=t;y=1;}
border right(t=0,1){x=1;y=1-t;}
border bottom(t=0,1){x=1-t;y=0;}
border left(t=0,1){x=0;y=t;}

mesh Th=buildmesh(top(-5)+right(-5)+bottom(-5)+left(-5));

fespace Vh(Th,P1);

Vh g = x*y;

Vh u,v;

solve Prob(u,v)

= int2d(Th)(dx(u)*dx(v) + dy(u)*dy(v))

+ on(2, 3, 4, u=0)

+ on(1, u=g);

plot(u, wait=1, value=1);

To be sure of the label, you can also give one while you’re creating your border.
example:

border top(t=0,1){x=t;y=1;label = 10;}
border right(t=0,1){x=1;y=1-t; label = 20;}
border bottom(t=0,1){x=1-t;y=0;label = 30;}
border left(t=0,1){x=0;y=t; label = 40;}

Let me know if this answers your question.

Thanks for your answer.

I may not have been clear in my question : I indeed want Dirichlet BC on the top (ie on label=10), but I want the function g to be defined only on the top mesh (in 1d), not on the whole finite element space Vh.
Actually, this is indeed works, but it too slow for my purpose (I exchange g between processors).

Hi, have you found a solution to your problem?