## fcFEM - FEA from start to finish

About the development of the FEM module/workbench.

Moderator: bernd

HarryvL
Posts: 1071
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

### Re: fcFEM - FEA from start to finish

So that wasn't too hard. SImply put the compiled ".so" file in the .FreeCAD/Macro directory and import the relevant function from that. For the first 10 load steps of the plate with hole (my defacto benchmark) I get a marginal improvement in speed over the dense matrix Cholesy solver in SciPy. Next I will experiment with Reverse Cuthill McKee to see how I can reduce the bandwidth and its effect on banded solver speed.
HarryvL
Posts: 1071
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

### Re: fcFEM - FEA from start to finish

Urrrrr, I just calculated the number of degrees of freedom (DOF) and the band width (BW) for the plate with hole and find they are almost equal: DOF = 2990 and BW = 2970. Clearly the node numbering is hugely inefficient. I don't understand why GMSH doesn't produce a more efficient numbering. Anyway, this explains why use of sparsity doesn't matter and give hope that pre-conditioning (reverse Cuthill McKee) will help a lot.
Jee-Bee
Posts: 2145
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: fcFEM - FEA from start to finish

Could it be that the node numbering have something to do with 'c' numbering or 'f'(fortran) numbering? I guess that's true also with cxx...
see numpy example https://docs.scipy.org/doc/numpy/refere ... shape.html
HarryvL
Posts: 1071
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

### Re: fcFEM - FEA from start to finish

It’s simpler than that @Jee-Bee. The structure of the global stiffness matrix is S[3*i,3*j], which is 0 except when i and j are nodes that belong to the same element. So it is essential to number the nodes such that the difference between node numbers within one element is minimal. The smaller the bandwidth=3*max(j-i) the better for storage and speed. I am surprised that GMSH doesn’t optimize node numbering in such away.
bernd
Posts: 10951
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

### Re: fcFEM - FEA from start to finish

HarryvL wrote:
Tue Apr 02, 2019 6:11 am
It’s simpler than that @Jee-Bee. The structure of the global stiffness matrix is S[3*i,3*j], which is 0 except when i and j are nodes that belong to the same element. So it is essential to number the nodes such that the difference between node numbers within one element is minimal. The smaller the bandwidth=3*max(j-i) the better for storage and speed. I am surprised that GMSH doesn’t optimize node numbering in such away.
Best to ask in the mailing list. The main developer arre there too. They will for sure give a reason or tell us a meshing parameter we need tu use to archive this. I understand what you mean but it is difficault do explain to others.
Walgri
Posts: 32
Joined: Sat May 09, 2015 10:16 pm

### Re: fcFEM - FEA from start to finish

It looks like GMSH is left without node reordering by design: http://onelab.info/pipermail/gmsh/2008/003717.html
Plus, partially offtopic, is see no trace of node reordering in the OOFEM manual.

Mhmmm, maybe we need a general node reordering intermediate step before writing input files and reading back the results ?

Edit: April 30, 2019
OOFem DOES node reordering either by a command line switch, or by an option in the input file, ref: http://www.oofem.org/forum/viewtopic.php?pid=334#p334 and http://www.oofem.org/resources/doc/oofe ... node8.html .

Strangely enough, a Google search for the keyword renumber in the entire Oofem website brings zero results.
Last edited by Walgri on Tue Apr 30, 2019 7:14 am, edited 1 time in total.
HarryvL
Posts: 1071
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

### Re: fcFEM - FEA from start to finish

I am pretty sure CCX reorders “under the hood”. Anyway, I thought of a simple way to do so and will work on implementing this.
Jee-Bee
Posts: 2145
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

### Re: fcFEM - FEA from start to finish

HarryvL
Posts: 1071
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

### Re: fcFEM - FEA from start to finish

Interesting. I hit the same problem. Hence, this renumbering in my code: https://github.com/HarryvL/fcFEM/blob/c ... #L244-L254
HarryvL
Posts: 1071
Joined: Sat Jan 06, 2018 7:38 pm
Location: Netherlands

### Re: fcFEM - FEA from start to finish

HarryvL wrote:
Mon Apr 01, 2019 7:47 pm
Urrrrr, I just calculated the number of degrees of freedom (DOF) and the band width (BW) for the plate with hole and find they are almost equal: DOF = 2990 and BW = 2970. Clearly the node numbering is hugely inefficient. I don't understand why GMSH doesn't produce a more efficient numbering. Anyway, this explains why use of sparsity doesn't matter and give hope that pre-conditioning (reverse Cuthill McKee) will help a lot.
Well, I managed to reduce the bandwidth by a factor of 5 with reverse Cuthill McKee, but I doesn’t make any difference for the solution time . The search continues.