Fenics as Solver

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
saso
Veteran
Posts: 1920
Joined: Fri May 16, 2014 1:14 pm
Contact:

Re: Fenics as Solver

Post by saso »

@bernd With win dev build 10276 I am getting this error when trying to make a mesh with gmsh. Is this an known problem or am I doing something wrong?

Code: Select all

Traceback (most recent call last):
  File "C:\Users\saso\Desktop\FreeCAD_0.17.10276_x64_dev_win\Mod\Fem\PyGui\_ViewProviderFemMeshGmsh.py", line 55, in setEdit
    import PyGui._TaskPanelFemMeshGmsh
  File "C:\Users\saso\Desktop\FreeCAD_0.17.10276_x64_dev_win\Mod\Fem\PyGui\_TaskPanelFemMeshGmsh.py", line 32, in <module>
    import _FemMeshGmsh
<type 'exceptions.ImportError'>: No module named _FemMeshGmsh
OS: Windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.10276 (Git)
Build type: Release
Branch: master
Hash: 10191e90861cf0c87d24c1980761fd1c7f3cdde4
Python version: 2.7.8
Qt version: 4.8.7
Coin version: 4.0.0a
OCC version: 7.0.0
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 »

saso wrote:@bernd With win dev build 10276 I am getting this error when trying to make a mesh with gmsh.
Thanks for reporting. On linux it works but it is an error. Will be fixed in my next PR. You can fix it yourself for you if you need meshing. See https://github.com/berndhahnebach/FreeC ... it/d083c7a
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

@bernd I read the mentioned tips & tricks section for git development in the master branch. When I work on the FEM part I just have to fork from your fork and work on a feature branch like before and then just PR (after announcing the PR in the FEM section) to your fork (instead of the master branch to the femdev branch)? Is this the correct way of development for the FEM section?

Another question: to be useful for fenics, maybe cell functions, facet functions and things like that should also be formulated within FreeCAD. For a proper visualization of these things, the fancy color effects like for the results are also useful. Is there a quick tutorial how to do them?

Best wishes (and sorry for my many questions with maybe obvious answers :-( )
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 »

- fork freecad master
- do your development
- make your development public at the forum for others to discuss and may be find issues
- in FEM we try to stick to flake8 for python development

- if everything works out well you could go for a PR, but to minimize work for Yorik and Werner collected the PR off different FEM developer in my femdev branch and made a PR with this. Thus it is much more less work for them, because they are not really involved in FEM development. If you gone make a PR they do not know if your code was reviewed and tested by the community.

My advice, close the PR and fix all issues. Let FEM people test your module. If your module is ready for a PR go for a PR or if you would like to I include it in my femdev branch and thus it is included in my next PR.

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:Another question: to be useful for fenics, maybe cell functions, facet functions and things like that should also be formulated within FreeCAD. For a proper visualization of these things, the fancy color effects like for the results are also useful. Is there a quick tutorial how to do them?
What exactly do you mean by cell functions, facet functions ?

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

Re: Fenics as Solver

Post by joha2 »

These are functions in Fenics which are defined cell-wise or facet-wise which are one possibility to use different materials (cell-functions with changing values) or different boundary contributions to the weak formulation of the PDE (facet-functions) or adaptive mesh refinement (boolean cell functions). Long story short: They are functions which together with the mesh help the user of Fenics to use it more easily. I will send you a Paraview picture in the evening.

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:These are functions in Fenics which are defined cell-wise or facet-wise which are one possibility to use different materials (cell-functions with changing values) or different boundary contributions to the weak formulation of the PDE (facet-functions) or adaptive mesh refinement (boolean cell functions). Long story short: They are functions which together with the mesh help the user of Fenics to use it more easily. I will send you a Paraview picture in the evening.
It is implemented in FreeCAD already. It is called groups of faces or groups of nodes. There is a object in FreeCAD FEM which can make groups of everything: nodes, edges, faces, volumes. This way you can group what you want. The tool is called FEM mesh group. You need to select the mesh first ...
joha2
Posts: 303
Joined: Tue Oct 11, 2016 9:48 pm

Re: Fenics as Solver

Post by joha2 »

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.

This is a cell function which takes the value 0 for y <= 0.5 and 1 for y >= 0.5 on the mesh.
cell_function.jpg
cell_function.jpg (331.73 KiB) Viewed 1924 times
The corresponding fenics code is well-known from the tutorial, but it's useful for illustration purposes:

Code: Select all

tol = 1e-14
mesh = UnitSquareMesh(16, 16)
class Omega_0(SubDomain):
    def inside(self, x, on_boundary):
        return x[1] <= 0.5 + tol
class Omega_1(SubDomain):
    def inside(self, x, on_boundary):
        return x[1] >= 0.5 - tol
materials = CellFunction('size_t', mesh)
subdomain0 = Omega_0()
subdomain1 = Omega_1()
subdomain0.mark(materials, 0)
subdomain1.mark(materials, 1)
File('materials.xml') << materials
Best wishes
Johannes
HoWil
Veteran
Posts: 1279
Joined: Sun Jun 14, 2015 7:31 pm
Location: Austria

Re: Fenics as Solver

Post by HoWil »

Hi Johannes,
This possibility in fenics sound/looks interesting, but I think you can/should do all this selecting of mesh-groups in FC.
Bend introduced mesh-groups especially for that. These groups are for instance also exported to .unv files.

BR,
HoWil
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 »

Post Reply