This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

FreeCAD + FEniCS

0 votes

My workflow at the moment is as follows:

  1. Use GMSH to define a geometry (2D or 3D) and to create a mesh. This
    also includes the definition of physical surfaces and physical
    regions
    that I need for my program.
  2. Convert with dolfin-convert and do the finite-element parts in
    FEniCS
  3. Visualize the results in Paraview

Now I would like to replace the first step with FreeCAD for the geometry and Netgen for the meshing. Reasons include license (LPGL), and in case of FreeCAD, a more useful GUI compared to GMSH to create more complex geometries. Also the fact that, just like FEniCS and Paraview, there is an Python API available would be useful to me.

I wondered if anyone has tried this succesfully? The closest I found was this:
https://en.wikiversity.org/wiki/CAD_to_FEniCS_example

In particular, I wonder:

  • How to include something like GMSH's physical surfaces and regions?
  • Which file format to use as intermediate step?
  • Etc.

In short, any useful tips here are welcome.

Thanks!

asked May 19, 2016 by maartent FEniCS User (3,910 points)

1 Answer

0 votes

FreeCAD supports the off format which may be directly loaded
into mshr for use in FEniCS. It is an alternative which may
simplify your pipeline.

answered May 22, 2016 by Kent-Andre Mardal FEniCS Expert (14,380 points)

That is an option, thanks! Do you know of any tutorials/examples that use this approach and include the definition of regions / surfaces that can later be used in FEniCS (eg. to define boundary conditions)? mshr's documentation is rather sparse.

Subdomains, regions is being added to mshr as we speak.
Can you send me a simple example?

As a simple example of what I want to do, see my answer to this question (2nd answer):
http://fenicsproject.org/qa/9760/what-is-the-best-approach-to-mesh-refinement-on-boundary

In GMSH, it is easy to define eg. Physical Line(1) in the geo-file and use the same labeling later on in FEniCS, as in the line

bcs = [DirichletBC(V, Constant(0), boundaries, 1)]

At the moment I don't know too much about the file formats and their implementation, but I assume that an .off format also has an option to include this kind of information. It would be helpful to see an example like in the link I provided, but where a CAD program is used instead off GMSH.

...