Edge mesh on FreeFem++

Hi guys, is it possible to build a edge mesh on FreeFem++?

For example, given a triangle, I wish to partition each edge in 2 and build a FEM space on each piece.

buildmeshL and then use periodic boundary conditions ?

https://doc.freefem.org/documentation/mesh-generation.html

I’ve tried like this:

load "msh3"

mesh Th = square(3,3);

meshL ThEdge = extract(Th);

but I can’t quite figure it out how to split ThEdge.

The extract function doesn’t extract the internal edges, is that right?

This came up with 12 dofs although I’m not sure if there is just someway to
save a meshL. Curious though if you wanted an actual closed rung.
That is, what would eigenvalues look like for some problem? Derivatives
zero at ends or merely solution same at both ends?

lari.edp (215 Bytes)


-- FreeFem++ v4.12 (Sat 20 May 2023 07:29:03 PM EDT - git no git)
   file : lari.edp
 Load: lg_fem lg_mesh lg_mesh3 eigenvalue 
    1 : load "msh3"
    2 : mesh Th = square(3,3);
    3 : meshL ThEdge = extract(Th);
    4 : fespace Vh(ThEdge,P1);
    5 : Vh vx=x;
    6 : Vh vy=y;
    7 : Vh vz=z;
    8 : for(int i=0; i<vx[].n; ++i)
    9 : {
   10 : cout<<i<<" "<<vx[][i]<<" "<<vy[][i]<<" "<<vz[][i]<<endl;
   11 : 
   12 : }
   13 : cout.flush;
   14 :  sizestack + 1024 =1816  ( 792 )

  -- Square mesh : nb vertices  =16 ,  nb triangles = 18 ,  nb boundary edges 12
 empty list label, extract all boundaries
  -- FESpace: Nb of Nodes 12 Nb of DoF 12
0 0 0 0
1 0.333333 0 0
2 0.666667 0 0
3 1 0 0
4 1 0.333333 0
5 1 0.666667 0
6 1 1 0
7 0 1 0
8 0.333333 1 0
9 0.666667 1 0
10 0 0.333333 0
11 0 0.666667 0
times: compile 0.003532s, execution 0.000165s,  mpirank:0
 CodeAlloc : nb ptr  3839,  size :513424 mpirank: 0
Ok: Normal End

But when it creates the mshL, it just extracts the square and not the inner boundary.
Is there some way to get all of then?

for example, I need a mesh with all five edges

Probably mesh Th=square(1,1) would work.

I’ve tried with square(1,1) but no luck. I can only get external boundaries

load "msh3"

mesh Th = square(1,1);

meshL ThEdge = extract(Th);
ThEdge = trunc(ThEdge, 1, split=1);

plot(ThEdge, wait=1);

fespace Eh(ThEdge, P0);
Eh xx = x, yy=y;

int nDoFl0 = Eh.ndof;
int nDoFl0K = Eh.ndofK;

cout << nDoFl0 << "\n";

What problem are you trying to solve? I guess you could start with something
close and modify the matrix by hand.

I’m trying to implement a method to solve the Darcy equation
I’m gonna solve the Darcy equation on each element of the mesh and then assemble to the global mesh, but I need to build the location Matrix
For that, I need the global DoF numbers, so I can find the right places to assemble the values

The example you posted earlier gets the dof coords and for boundaries
in the 2d case you just used int1d over the labelled boundary. There
are a lot of examples for that.

Yes, but in thar example I can only get 4 boundaries, the ones that form the square
I need all five of them, the 4 boundaries from the square and the middle one

I guess you could add something like this to the mesh

border ba(t=0, 1){x=t; y=t; label=1;}
and then every element edge is a boundary.

or there is the “intAllEdge” if that helps.