Fenics as Solver

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fenics as Solver

Post by bernd »

joha2 wrote:Edit2: Is there any possibility to draw only certain elements (i.e. to switch "off" the others in the ViewObject)?
As far as I know only by the use of the clipping plane tool. But you never know there might be some never used method inside FEM API like the NodeSet tool we encountered just a few days ago. Here you can see all implemented Python methods for the mesh view provider. https://github.com/FreeCAD/FreeCAD/blob ... MeshPy.xml may be you could use this ... https://github.com/FreeCAD/FreeCAD/blob ... Py.xml#L57
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

Hi bernd,

yeah I searched the ViewObjects methods and variables for an appropriate function, but I didn't find something. I know the following request is a huge amount of work, but I will ask you anyway :mrgreen: : Is it possible to add this functionality at the C++ code level to the FemMesh object? :D
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fenics as Solver

Post by bernd »

joha2 wrote:Hi bernd,

yeah I searched the ViewObjects methods and variables for an appropriate function, but I didn't find something. I know the following request is a huge amount of work, but I will ask you anyway :mrgreen: : Is it possible to add this functionality at the C++ code level to the FemMesh object? :D
Extending the mesh view provider to allow such stuff is for sure on my TODO. But this will not happen soon (implemented by me, may be some other will give it a try). There are other things which I'm not able to use other tools like GMSH for. Thus I will implement them first.

BTW: What I do at the moment is use GMSH for all kind of display tools in the regard of a FEM mesh.
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

bernd wrote: BTW: What I do at the moment is use GMSH for all kind of display tools in the regard of a FEM mesh.
So you export the mesh into a format readable by GMSH and do the visualization there? I thought about using GMSH either, but from my first impression the GMSH gui behaves strange ;-) Although GMSH would be my next choice after FreeCAD to generate a FEM mesh.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fenics as Solver

Post by bernd »

joha2 wrote:
bernd wrote: BTW: What I do at the moment is use GMSH for all kind of display tools in the regard of a FEM mesh.
So you export the mesh into a format readable by GMSH and do the visualization there? I thought about using GMSH either, but from my first impression the GMSH gui behaves strange ;-) Although GMSH would be my next choice after FreeCAD to generate a FEM mesh.
If I need some tools which are not available in FreeCAD at the moment like elementface numbers and node numbers. Both needs work araounds in FreeCAD. In GMSH it is just an checkbox and all nodes or elementfaces have numbers. As exchange format I use unv or med.

bernd
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

Hey bernd,

I just coded a mesh export for Fenics for a new format (.xdmf, which is state of the art) in a macro and I saw that there is a lot of stuff to be done which is the same like for the .xml. Other stuff is very different, though. For the implementation in the source tree I would like to separate the import/export stuff for those two file formats (and also the helper functions) into different files. Is there some best practice way to do this (file naming, necessary sub directories, ...)?

My suggestion would something like:
importFenicsXML.py
exportFenicsXML.py
importFenicsXDMF.py
exportFenicsXDMF.py
FEMfenicsMeshHelpers.py

Edit: I saw that netgen and gmsh mesh objects have different interfaces. Is it possible to unify the interfaces in some sense to make exports and imports more easy?

Best wishes
Johannes
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fenics as Solver

Post by bernd »

joha2 wrote: My suggestion would something like:
importFenicsXML.py
exportFenicsXML.py
importFenicsXDMF.py
exportFenicsXDMF.py
sounds good to me.
joha2 wrote:FEMfenicsMeshHelpers.py
Are the helpers really Fenics specific? there is a module for import / export helpers already. see importToolsFem.py https://github.com/FreeCAD/FreeCAD/blob ... oolsFem.py
joha2 wrote:Edit: I saw that netgen and gmsh mesh objects have different interfaces.
What do you mean with this ? They have different interfaces in sense of getting the mesh, but for export import the data model behind is important. They both are based on the same FemMesh class object. It should not make a difference on export. On import you would not create either of them because you would just create a Fem.FemMesh() .

bernd
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

bernd wrote: sounds good to me.
Should I put these into another sub directory or should they stay at the import/export file location?
bernd wrote: Are the helpers really Fenics specific?
Some of them are, some are not. OK, I will first check whether there are Fenics specific helpers. If not I will implement the helpers into the file you mentioned.
bernd wrote: What do you mean with this ? They have different interfaces in sense of getting the mesh, but for export import the data model behind is important. They both are based on the same FemMesh class object. It should not make a difference on export. On import you would not create either of them because you would just create a Fem.FemMesh() .
bernd
To be more specific: For the Fenics export, I asked the FreeCAD object whether the geometric elements are second order.
For netgen this is a boolean variable and for gmsh it is string ('1st', '2nd'). So from your answer I take away, that it is bad practise to rely code functionality on the underlying FreeCAD object?

Best wishes and thanks for your fast answer :-)
Johannes
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Fenics as Solver

Post by bernd »

joha2 wrote:
bernd wrote: sounds good to me.
Should I put these into another sub directory or should they stay at the import/export file location?
No, not another sub directory, just src/Mod/Fem/*.py
joha2 wrote:
bernd wrote: What do you mean with this ? They have different interfaces in sense of getting the mesh, but for export import the data model behind is important. They both are based on the same FemMesh class object. It should not make a difference on export. On import you would not create either of them because you would just create a Fem.FemMesh() .
bernd
To be more specific: For the Fenics export, I asked the FreeCAD object whether the geometric elements are second order.
For netgen this is a boolean variable and for gmsh it is string ('1st', '2nd'). So from your answer I take away, that it is bad practise to rely code functionality on the underlying FreeCAD object?
These both properties are passed to the mesher to create first order or second order FEM mesh, they do not say anything about the order of the mesh which has been passed back from the mesher ! BTW What would you do if the mesh is non of both! See attached file with simple either first order and second order femmesh ... :mrgreen:
Attachments
simple_femmesh_class.fcstd
(5.1 KiB) Downloaded 37 times
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

Ah I see your point :mrgreen:. Thanks for the file! So in principal I have to check for the second order elements to be sure whether there is a second order mesh or not.

Best wishes Johannes
Post Reply