fcFEM - FEA from start to finish

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
HarryvL
Posts: 1042
Joined: Sat Jan 06, 2018 7:38 pm

Re: fcFEM - FEA from start to finish

Postby HarryvL » Mon Apr 01, 2019 7:40 pm

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.
User avatar
HarryvL
Posts: 1042
Joined: Sat Jan 06, 2018 7:38 pm

Re: fcFEM - FEA from start to finish

Postby HarryvL » 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.
Jee-Bee
Posts: 1913
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: fcFEM - FEA from start to finish

Postby Jee-Bee » Tue Apr 02, 2019 5:30 am

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
User avatar
HarryvL
Posts: 1042
Joined: Sat Jan 06, 2018 7:38 pm

Re: fcFEM - FEA from start to finish

Postby HarryvL » 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.
User avatar
bernd
Posts: 8023
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: fcFEM - FEA from start to finish

Postby bernd » Tue Apr 02, 2019 2:00 pm

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

Postby Walgri » Tue Apr 02, 2019 4:51 pm

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.
User avatar
HarryvL
Posts: 1042
Joined: Sat Jan 06, 2018 7:38 pm

Re: fcFEM - FEA from start to finish

Postby HarryvL » Tue Apr 02, 2019 7:17 pm

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: 1913
Joined: Tue Jun 16, 2015 10:32 am
Location: Netherlands

Re: fcFEM - FEA from start to finish

Postby Jee-Bee » Tue Apr 02, 2019 7:54 pm

User avatar
HarryvL
Posts: 1042
Joined: Sat Jan 06, 2018 7:38 pm

Re: fcFEM - FEA from start to finish

Postby HarryvL » Tue Apr 02, 2019 10:20 pm

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

Re: fcFEM - FEA from start to finish

Postby HarryvL » Wed Apr 03, 2019 7:30 pm

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.