Get labels of boundary nodes for P2 elements

Hi everyone!

I use FreeFem++ to get the matrices of a given problem and then solve the system in Matlab for some reason. I build the matrices with P2 elements. However I need to export the label (for boundary elements) of each node of the fespace P2. So far I succeeded to have the region(s) of each nodes, but still have issues to get the label of “boundary nodes”.
Does someone know how to do it?

Thank you for your help!

1 Like

Nodes don’t have a region, they have a label. Triangles/tetrahedra have region. Your question doesn’t make much sense, sorry.

Thank you for your answer. I agree that It wasn’t clear.

Given a boundary label, (label = 1 for instance). Is it possible to export the nodes whose label=1 when dealing with P2 elements. By exporting the node I mean to export the number of the node nb_node such that x[][nb_node] should be its x coordinate.

Best regards.

So, what doesn’t work if you write this down in FreeFEM? It seems like you know what you want to do.

Actually I don’t know how to get “nb_node” for a given label. What I would expect is to make loop over the elements as followed :

for(int i=0 ; i<Th.nt ; i++){
for(int j=0 ; j<Th.ndofK ; j++){
lab = Vh(i,j).label; //equivalent to Th[i][j].label

Obviously it doesn’t work since Vh(i,j) is an integer…

Is there a trick to export the label of a node with P2 ?

mesh Th = square(10, 10);
fespace Vh(Th, P2);
Vh u = label;


export the label of a node with P2

Again, you are asking questions that don’t make sense :confused:

This is a little bit more complexe because a node could be on more the 1 boundary (corner ponts
for examples).

mesh Th=square (10,10);
fespace Vh(Th,P2);

Vh l2 = label;
plot(l2, wait=1);

// it is correct expect on corner ..

// border l;
for(int l=1; l<=4; ++l)
varf vb1(u,v)= on(l,u=1);
Vh l1;
l1[] = vb1(0,Vh,tgv=1);// 1 on l border ..
plot(l1,wait=1,cmm=" border l="+l);
1 Like

Thank you for this help, it is exactly what I was searching for ! Good to see how flexible is FreeFem++ !