Edge orientation

Is it possible to find the edge orientation on a mesh?

mesh P = square(2,2);
int NbTriangles = P.nt; //number of triangles
plot(P, wait=1);

fespace LambdaH(P, P0edge);
fespace V0(P,P0);

V0 u0;
LambdaH l0;

int nDoFu0 = V0.ndof;
int nDoFl0 = LambdaH.ndof;

int nDoFu0K = V0.ndofK;
int nDoFl0K = LambdaH.ndofK;

V0 uX = x, uY = y;
LambdaH lX = x, lY = y;

real[int,int] CoordDoFl0(nDoFl0,2);

for(int i= 0; i< nDoFu0; i++)
 cout << uX[][i] << " " << uY[][i] << "\n";

for(int i= 0; i <nDoFl0; i++){
 CoordDoFl0(i,0) = lX[][i];
 CoordDoFl0(i,1) = lY[][i];
 cout << CoordDoFl0 << "\n";
 //cout << lX[][i] << " " << lY[][i] << "\n";
}

I’ve built a matrix with the coordinates of each DoF, now I would like to know the edge orientation.

Yes the edge orientation is given by the vertex number go form the lowest vertex number to the biggest vertex number.

Otherwise in intalledge integral the function edgeOrientation get +1 or -1 depending of the orientation.

One more question, for example, I defined the following space:

fespace LambdaH(P, P0edge);

and I have the DoF for each element

8 3	
	   6   9   5
	  12  10   9
	   0   2   1
	   4   6   2
	  11  13  12
	  14  15  13
	   3   7   4
	   8  11   7

I want to build a matrix with the edge orientation, something like:
for element 1: 1 1 -1

Is it possible?

I tried to use the function edgeOriention as shown in the manual, but it is not working. I know the nodes of each element, so for example:

element 1: nodes 0 1 4
the sign of edge from 0 to 1: +1
the sign of edge from 1 to 4: +1
the sign of edge from 4 to 1: -1

those are the values that I want to store in a vector (or matrix)

edgeOrientation

Sign of i−j if the current edge is [qi,qj].

real S = int1d(Th, 1)(edgeOrientation);

Yes the code :

mesh Th=square(4,4);
fespace LambdaH(Th, P0edge);
matrix orient(Th.nt,LambdaH.ndof);
for(int k=0;  k<Th.nt;++k)
  for( int i=0; i<3;++i)
   {
      int j = LambdaH(k,i); 
      int i1 = Th[k][(i+1)%3]; 
      int i2 = Th[k][(i+2)%3]; 
      orient(k,j) = i1 < i2 ? 1 : -1; 
     
}
cout << orient << endl;

I’m getting th following error

Error line number 3, in file C:\Users\LARISS~1\AppData\Local\Temp\.ffcs21024.edp, before  token )

  current line = 3
Compile error : 
	line number :3, )
error Compile error : 
	line number :3, )
 code = 1 mpirank: 0
FreeFem++ returned error 1

You FreeFem version is too old , cf:

tions/FreeFem++.app/Contents/ff-4.10/bin/ffglut’ ;exit;
– FreeFem++ v4.10 (Lun 14 fév 2022 22:27:04 CET - git v4.10-60-g89b58302)
file : bbbbb.edp
Load: lg_fem lg_mesh lg_mesh3 eigenvalue
1 : mesh Th=square(4,4);
2 : fespace LambdaH(Th, P0edge);
3 : matrix orient(Th.nt,LambdaH.ndof);
4 : for(int k=0; k<Th.nt;++k)
5 : for( int i=0; i<3;++i)
6 : {
7 : int j = LambdaH(k,i);
8 : int i1 = Th[k][(i+1)%3];
9 : int i2 = Th[k][(i+2)%3];
10 : orient(k,j) = i1 < i2 ? 1 : -1;
11 :
12 : }
13 : cout << orient << endl; sizestack + 1024 =1384 ( 360 )

– Square mesh : nb vertices =25 , nb triangles = 32 , nb boundary edges 16

HashMatrix Matrix (COO) 0x600000f74000

n m nnz half fortran state

32 56 96 0 0 0 0
0 36 1
0 30 -1
0 29 1

1 Like

I’m using FreeFem++ -cs 14.3

I need the FreeFeM++ version not the version of FreeFem+±cs.

Sorry I think the version is 3.xx for me (too old) except is Antoine do a new version

In the FAQ it say :

Yes, starting from FreeFEM-cs version 15, FreeFEM-cs and FreeFEM are kept in separate packages to allow everyone to pick the versions that they need.

so please use the version 4.10 !!!

1 Like