Fenics as Solver

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
nonlimited
Posts: 14
Joined: Thu Dec 01, 2011 10:00 pm

Fenics as Solver

Post by nonlimited »

Hi!

from the wiki I have seen two possible solvers, namely Calculix and Code-Aster. I'm not quite sure if there has been any itegration done yet.

So I just wanted to throw in a third one:

Fenics Project - http://fenicsproject.org/

It has a really great python interface with which you can formulate your PDEs as you would do on paper.
User avatar
jriegel
Founder
Posts: 3369
Joined: Sun Feb 15, 2009 5:29 pm
Location: Ulm, Germany
Contact:

Re: Fenics as Solver

Post by jriegel »

So far I go for Calculix, but the it will be later on easy to incorporate any kind of solver.
Stop whining - start coding!
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Fenics as Solver

Post by looo »

I would like to give this a try. But I need some help to get started. What has to be done to add a new solver.

The fenics solver would be a simple object which has a solver-macro property. The function in the macro gets all the necessary data (mesh, bc, material,...). The computation is then done inside of a function. and the result is returned as a dict (for example).

@Bernd. It would be nice if you can provide some information on the files that have to be written to add a new solver. Also I am interested if such a generic approach would work. At the moment I would like to do this only with 2d fem. But it would be nice if this could work with 3d too.
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Fenics as Solver

Post by HoWil »

I think Code-Aster is not supported but instead Z88 is integrated in parallel to calculix.

There was also some discussion about integrating Openfoam and Elmer into FreeCAD. This simply shows that the interface should be as generic as possible. Help there helps all others and future integration attempts.
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Fenics as Solver

Post by looo »

There are a few different levels of abstraction.... The fenics library is more the mathematical approach. It's nice because it's easy to solve any custom pde. Calculix, code aster ... are on a much higher level. Different abstraction need different interfaces.... But with fenics we could add a really generic interface I think. At least for the use cases I can think of.

I like the idea to simple plug a solver as a python file into freecad. This would need some generic boundary condition as well, but I think the bc allready available will do the job as well.
ickby
Veteran
Posts: 3116
Joined: Wed Oct 05, 2011 7:36 am

Re: Fenics as Solver

Post by ickby »

I use fenics a lot and like it very much. But it is gpl, so cant be shipped with freecad. Of course it would be nice to have some way. to autogenerate fenic sscripts in freecad. But most important imho is to Export Dolphin meshes. They can include defined Mesh Domains which than can easily be used in Dolphin by Name for boundary conditions etc. That would be awesome!
User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Fenics as Solver

Post by saso »

https://fenicsproject.org/about/#license
License
All FEniCS core components are licensed under the GNU LGPL as published by the Free Software Foundation, either version 3 of the license, or (at your option) any later version.

All other FEniCS components are licensed under either the GNU GPL or the GNU LGPL, either version 3 of the license, or (at your option) any later version.

Authors and institutions have given their consent to licensing under these terms.
Their https://femtable.org/ is also quite nice :)
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Fenics as Solver

Post by looo »

to autogenerate fenic sscripts in freecad.
my idea was to have different solvers as python scripts available via the plugin-manager. In the Fem gui one can select one of these solvers. This way there shouldn't be any license problem and also other pde-solvers could be used in the script.
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

Hey guys. I just started with Fenics, played around a little with it and I am very impressed about its flexibility. Although I am not very experienced with it, I would be very interested in coding an interface for FreeCAD. As far as I understood the FEM workbench in its actual state has "only" support for linear static analysis, modal frequencies and thermo-mechanical analysis ("only" in "" because you did a great work with it! :-) ). I think with Fenics one should focus on non-linear PDEs like fluid mechanics or non-linear static structural analysis (like large deformations or fully coupled, maybe transient, thermo-analysis).

Is there anything done, yet? If somebody sets up a github project, please inform me.

Kind regards
Johannes
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Fenics as Solver

Post by looo »

Hmm, I didn't think about non linear analyses yet, but I think we could try to implement a generic interface which let us do this too.

Basically, what I am thinking of is an implementation of the solver where pre and postprocessing is made in a way it can be applied to any pde-solver or if more generic any geometry processing which results in field-data (scalar and vector). So in the preprocessing we apply attributes to geometry entitis and generate a mesh. This then gets wrapped to node or element level and passed to the generic solver class. This solver class is pure python class (no freecad object) and by subclassing this solver any pde solver can be provided. The solver-class can be choosen in the generic solver (freecad object) from a list. Registering a solver simply adds the class to this list, that is stored somewhere in the fem module. This way a new solver can be created as a macro, at startup with an Init.py file or any other way.
The solver does any calculation on the data and return cell / node - scalar / vector data which then can be used for postprocessing. I don't know if the postprocessing allready has an interface for any data, but if not we can also use the existing data-fields to display any result. (vectors as displacement for example)

The ideal case would be if the solver has everything there and only the processing of field-attributes (bc, constraints, material) and the mathematical side has to be implemented in there.
Post Reply