Fenics as Solver

About the development of the FEM module/workbench.
qingfeng.xia
Posts: 107
Joined: Tue Sep 22, 2015 1:47 pm
Location: Oxford Uk
Contact:

Re: Fenics as Solver

Postby qingfeng.xia » Tue Feb 28, 2017 11:17 am

joha2 wrote:Ah OK, I wasn't aware of that. So it would make sense, to export them as the appropriate function also in some XML file. I will think about it. Are these mesh groups just groups of nodes or is it possible to associate some function value with them? I interpreted them as groups of nodes which tell the mesh where to increase sampling density.


Is that possible to export boundary condition/FemConstraint selected surface (could also defined by gmsh mesh group) into separated XML mesh files together with 3D volume mesh?
I heard gmsh will convert each region into a separate xml file? I am not sure how those meshes are linked/related by cellId, facetId, etc. :roll:
Ubuntu 0.17-dev OpenFOAM + FreeCAD
joha2
Posts: 65
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Postby joha2 » Tue Feb 28, 2017 7:16 pm

I am not sure if I understood correctly: I try to export a netgen/gmsh mesh generated by FreeCAD into XML meshs for fenics. As far as I know fenics users also need the "tagging" of certain mesh regions by certain element functions. I also would try to implement this. I don't know if these are the same XML files which are exported by gmsh.

Best wishes Johannes

Edit: I found no XML export in gmsh. Where are these regions converted into XML files?

Edit2: For code review please have a look at: https://github.com/joha2/FreeCAD/blob/f ... icsMesh.py

Edit3: For defining mesh related materials the mesh region and mesh group commands need OCC 6.9.0?

Edit4:
Import of death star mesh from http://www.logg.org/anders/2016/06/02/m ... in-fenics/ :mrgreen: :mrgreen:
deathstar.jpg
deathstar.jpg (700.57 KiB) Viewed 255 times
User avatar
bernd
Posts: 3869
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Fenics as Solver

Postby bernd » Thu Mar 02, 2017 12:11 pm

joha2 wrote:Edit3: For defining mesh related materials the mesh region and mesh group commands need OCC 6.9.0?
yes. Which OS are you on?

@joha2:
Would it be possible to update the documentation in the regard of your export module https://www.freecadweb.org/wiki/FEM_Mes ... in_FreeCAD. You get wiki edit permission here: viewtopic.php?f=21&t=6830

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

Re: Fenics as Solver

Postby joha2 » Thu Mar 02, 2017 10:31 pm

Hi bernd,

yes, I will improve documentation, thanks for the links!
I did not know that such a mesh documentation exists.
If I would have known it, maybe I had not asked so much dumb questions :mrgreen: :mrgreen:

Edit: I updated the element documentation in the wiki. If there are questions do not hessitate to ask me.

My OS information is:
OS: Ubuntu 16.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10287 (Git)
Build type: Unknown
Branch: fenics_export
Hash: 352393b01423724edd5892dc9a4fb1ae1a16f49d
Python version: 2.7.12
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
User avatar
bernd
Posts: 3869
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Fenics as Solver

Postby bernd » Fri Mar 03, 2017 9:45 am

joha2 wrote:OCC version: 6.8.0.oce-0.17
You could compile OCCT 7.1 yourself ... For some hints see viewtopic.php?f=4&t=18967 but the netgen part of the script is broken at the moment. :(

Ahh ppa in changing too, see viewtopic.php?f=4&t=17501
User avatar
sgrogan
Posts: 2985
Joined: Wed Oct 22, 2014 5:02 pm

Re: Fenics as Solver

Postby sgrogan » Sat Mar 04, 2017 7:31 pm

bernd wrote:You could compile OCCT 7.1 yourself ... For some hints see viewtopic.php?f=4&t=18967 but the netgen part of the script is broken at the moment. :(

Did you try blacey's patch?
http://forum.freecadweb.org/viewtopic.php?f=4&t=18967&start=40#p160041
User avatar
bernd
Posts: 3869
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland

Re: Fenics as Solver

Postby bernd » Sun Mar 05, 2017 8:19 am

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

Re: Fenics as Solver

Postby joha2 » Sun Mar 05, 2017 9:35 am


Ah nice! Thanks bernd for your support regarding the implementation. First part of communication with Fenics done :mrgreen: .
I just deleted my local feature branch. The next feature would be the implementation of cell and facet functions which are created by FreeCAD.

I saw that we have already NodeSet, Mesh Group and Mesh Region. They are all for marking some specific part of the mesh by hand, aren't they? But do they support an assignment from e.g. element to real/bool/int valued function? Mesh Group and Mesh Region furthermore are only available for gmsh meshs? And NodeSet only marks nodes, but you cannot mark them with some certain value.

I for myself thought about a fourth alternative: What about marking meshs by some "tool" parts? For this I would use the inside check of the Shape of a part. The mesh itself is given and these tool parts are only for marking the nodes/elements, but I think it is a good way to do it in a easy-to-use manner. (One of the main advantages is, that you still could do something with an external given mesh, without having the base geometry. Or the other way around you could generate some more or less good overlap with the mesh to generate an appropriate base geometry.)

mark_with_parts.png
mark_with_parts.png (72.76 KiB) Viewed 145 times


Edit1: I would like to hear your comments on this :mrgreen:

Edit2: Is there any possibility to draw only certain elements (i.e. to switch "off" the others in the ViewObject)?

Best wishes
Johannes
HoWil
Posts: 375
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Fenics as Solver

Postby HoWil » Mon Mar 06, 2017 7:13 am

Hi Johannes,
Really nice work!
Sidenote: is the conversion of 1st order to 2nd order elements still a topic? When I look at your work I think it would be a good opportunity to contact developers at fenics to maybe gain some support from within fenics.
BR,
Howil
joha2
Posts: 65
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Postby joha2 » Mon Mar 06, 2017 5:14 pm

Hi HoWil,

thanks for the compliment! :mrgreen:
The conversion from 1st to 2nd order elements is still a topic. As far as I know, Fenics only can read 1st order elements from its mesh format. Afterwards you may convert the elements to second order by the step, you suggested. Anyway, there is still the possibility to at least reduce a 2nd order mesh to first order. (But the user maybe should be warned.)

Yeah you're right about the support from the Fenics community. I opened this question https://fenicsproject.org/qa/12599/what ... n-elements a few days ago and it seems that the guy there knows a lot about Fenics. Let's see what he further can tell me about meshing with Fenics.

Best wishes
Johannes