xml import/export for fenics mesh
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
xml import/export for fenics mesh
Hey guys,
first of all thanks for your great work with FreeCAD! I am interested in FEM and discussed a few things already in the FEM section of this forum. In particular I am interested in an easy-to-use interface of the FEM workbench to fenics (https://fenicsproject.org/) which is a very sophisticated and general tool for the solution of partial differential equations. For using fenics as part of the FEM workbench HoWil suggested to implement a stable import/export code for the fenics mesh format. Since this format is xml I want to ask if there is anything (read/write code) already implemented in Python in the code base which I could use. The second option would be to use a standard library for Python. Which one would you suggest? The third option would be to code an xml reader/writer for myself, but I think this makes no sense.
Thanks in advance!
Best wishes
Johannes
first of all thanks for your great work with FreeCAD! I am interested in FEM and discussed a few things already in the FEM section of this forum. In particular I am interested in an easy-to-use interface of the FEM workbench to fenics (https://fenicsproject.org/) which is a very sophisticated and general tool for the solution of partial differential equations. For using fenics as part of the FEM workbench HoWil suggested to implement a stable import/export code for the fenics mesh format. Since this format is xml I want to ask if there is anything (read/write code) already implemented in Python in the code base which I could use. The second option would be to use a standard library for Python. Which one would you suggest? The third option would be to code an xml reader/writer for myself, but I think this makes no sense.
Thanks in advance!
Best wishes
Johannes
- kkremitzki
- Veteran
- Posts: 2517
- Joined: Thu Mar 03, 2016 9:52 pm
- Location: Illinois
Re: xml import/export for fenics mesh
Out of interest, why are you going for direct xml export and don't use the dolfin Mesh for setting up the mesh directly? This can than be saved easily.
Anyway, as I use fenics quite intensively I'm looking very much forward to the export
Anyway, as I use fenics quite intensively I'm looking very much forward to the export
Re: xml import/export for fenics mesh
I am really not sure which way to incorporation of fenics is the best. HoWil suggested the mesh export/import and I think this is a good starting point. There are two possibilities: Either the xml import/export between FC and fenics or a direct convesion from one mesh structure into the other. I saw that you followed the discussion in the "fenics as a solver" thread: If it is not possible to incorporate fenics directly into FC (license issues) maybe we have to use a file transfer and an external process like in the calculix case. I think the file import/export is the most straightforward and flexible way to use fenics in the future.ickby wrote:Out of interest, why are you going for direct xml export and don't use the dolfin Mesh for setting up the mesh directly? This can than be saved easily.
Anyway, as I use fenics quite intensively I'm looking very much forward to the export
May I ask: For which kind of problems you use fenics? Can you suggest any documentation about the dolfin xml format? I only know the dolfin-convert script and I have printed a few pages from chapter 10 of the book. But there I cannot see, e.g., how to distinguish between tet4 and tet10 elements.
Which features do you miss in the scripted fenics most, which should be included into a possible FC fenics solver first? We also need a formula input for: the weak formulation, the bcs, the source functions, ...; any suggestions for this problem? Is the expression structure usable for this? (I think not ).
BTW: kkremitzki thanks for the suggestions, I will have a look.
Edit: I found a nice paper for the mesh structure in fenics https://arxiv.org/abs/1205.3081
Best wishes
Johannes
Last edited by joha2 on Wed Feb 22, 2017 7:24 am, edited 1 time in total.
Re: xml import/export for fenics mesh
Other possibilities are dom, etree, and sax. From a quick google it seems there are potential security vulnerabilities and lacking features compared to lxml, the advantage is that they are part of most standard Python distributions (including FreeCAD's Python on Win)joha2 wrote:BTW: kkremitzki thanks for the suggestions, I will have a look.
"fight the good fight"
Re: xml import/export for fenics mesh
I used lxml for a first macro implementation. The parsing works well and I copied the creation of the FemMesh object from the Z88 code. But it seems that the mesh is still not correctly generated. (I am not sure whether if I read tet4 elements and their nodes from the XML file I still have to generate the edges and faces myself or if the FemMesh object takes care of that.)
Edit: Thanks for all your input! I think lxml is a good choice and who is still interested in this topic, I will discuss this stuff further in the FEM section https://forum.freecadweb.org/viewtopic. ... 7&start=60
Best wishes and good night
Johannes
Edit: Thanks for all your input! I think lxml is a good choice and who is still interested in this topic, I will discuss this stuff further in the FEM section https://forum.freecadweb.org/viewtopic. ... 7&start=60
Best wishes and good night
Johannes
Re: xml import/export for fenics mesh
joha2 wrote:May I ask: For which kind of problems you use fenics?[\quote]
Mostly Piezoelectric/Electrostrictive problems (coupled electrostatic and linear elastisity problems) and electromagnetic calculations.
unfortunately not, I never found a documentationCan you suggest any documentation about the dolfin xml format?
Which features do you miss in the scripted fenics most, which should be included into a possible FC fenics solver first?
Honestly I will always stay at the script level, as this is the flexibility I like and need. The current problem with fenics is the meshing and domain definition, that takes most of the work and is cumbersome. So I would love to define meshs and subdomains in FreeCAD, so that I can simply load the xml file and access all subdomains. The rest I will do in my scripts anyway.
Re: xml import/export for fenics mesh
Ah do you have any good literature on electromagnetics FEM? In particular the treatment of rot rot problems is interesting (harmonic analysis of EM fields or magneto statics). I see your point for the scripting interface of fenics, but maybe a FC interface simplifies the formulation of "standard" problems and/or could help to implement multiphysics problems. For me at least the goal is to learn fenics
Could you provide some example meshs (some complicated meshs would be good as test cases). Do you know whether the boundary conditions or cell/facet/... functions are also saved in the XML files?
Best wishes
Johannes
Could you provide some example meshs (some complicated meshs would be good as test cases). Do you know whether the boundary conditions or cell/facet/... functions are also saved in the XML files?
Best wishes
Johannes
Re: xml import/export for fenics mesh
Sorry, all my work is done for my company and I can't share anything. But for a comprehensive text about electro-magnetics and FEM I can recommend http://maxwell.sze.hu/docs/C4.pdf
Not simple, but detailled!
Not simple, but detailled!
Re: xml import/export for fenics mesh
Thanks for the script! I totally understood that it is not possible to reveal the stuff from your company. Thanks anyway!ickby wrote:Sorry, all my work is done for my company and I can't share anything. But for a comprehensive text about electro-magnetics and FEM I can recommend http://maxwell.sze.hu/docs/C4.pdf
Not simple, but detailled!
Best wishes
Johannes