export salome mesh to FeNICS mesh

copyright (C) qingfeng Xia 2011-2020 CC-BY-NC 4.0

Salome installation

  1. download

Salome platform 8.5 binary for Ubuntu 16.04 (64bit)

Salome-meca is the combination of salome and code_aster (FEA), it is also possible to manually add the Code_saturne plugin for CFD

  1. installation

extract this compressed file to a position like /opt, it has its own python2.7 and most not-so-common dependent packages Do read the readme to check if you have installed all the essential packages.

  1. run the program

run the program in a terminal (to catch output/error message) /path_to/salome.py which set env var.


Start SALOME, elapsed time :   2.1 seconds

Fatal Python error: Py_Initialize: Unable to get the locale encoding

  File "/opt/SALOME-8.5.0-UB16.04-SRC/BINARIES-UB16.04/Python/lib/python2.7/encodings/__init__.py", line 123

    raise CodecRegistryError,\

to fix this error on my machine, I need unset PYTHONPATH in my “~/.bashrc”

BTW, 3D The hardware acceleration is disable in my virtualbox,

“~/.bashrc”

#3D window is not working if 3D accel is turned on for vbox

export LIBGL_ALWAYS_SOFTWARE=1

  1. macro recording function

The operation within GUI can be recorded into python script by “File-> dump study”, this saved python script can be loaded later, or adapted for used in batch mode.

  1. NoteBook variables

variale can only be simple math expression, math.pi math.sin() are not supported.

  1. partition, group and save multi-zone mesh

submesh is used

=============================================================

mesh conversion from salome to Fenics

meshio-convert (from meshio package) can translate the salome Med format into dolfin format, however, it seems boundary and subdomains are not converted.

Here is another route: Salome>Gmsh>Fenics, inspired by [I was finally able to import an assembly mesh into OpenFOAM format with the following Salome>Gmsh>OpenFOAM process]https://www.cfd-online.com/Forums/openfoam-meshing/82210-importing-multiple-meshes.html


-Using Salome:

1. Within the Geometry module explode surfaces needed for Boundary Conditions and renamed them

2. Fused all parts together into a single assembly

3. Partitioned this assembly using each of the parts included

4. Created 'Volume Groups' for each partitioned part

5. Move to the Meshing module and mesh the whole partitioned assembly (optional: make sub-meshes of the parts to better control mesh sizing)

6. Make 'Volume Groups' of each part within the mesh

7. Make 'Surface Groups' for all the boundary conditions

8. Export mesh as MED file (need to check 'Automatically Create Groups' box)



-Using Gmsh

9. Open mesh file in Gmsh and 'Save As' Gmsh mesh file (.msh file extension, make sure file is saved as Version 2.0 ACSII and un-check all check boxes)

10. Move Gmsh mesh file into an empty case file (make sure to have constant->polyMesh (empty) and system folder with necessary files)



-OpenFOAM mesh conversion/manipulation tools

11. Run [>> gmshToFoam] in OpenFOAM terminal within the case directory

12. Run [>> splitMeshRegions -cellZonesOnly -overwrite] (this is only used if there are multiple parts (volumes) to be split up)



 

To export dolfin meshing, using dolfin-convert your_gmsh.msh your_dolfin.xml

Extra notes:

  1. In Salome-mesh export, Med version should select the lowest, however, gmsh may still complain the med lib version is too high. I use the gmsh 4 to read the med mesh sucessfully.

2. Make sure the gmsh “expert mode” is enabled in preference, so “gmsh v2 ASCII” option can be selected in gmsh export dialog.   It seems quad mesh cells are not supported in `dolfin-convert`



CC-BY-NC 4.0 licensed free for non-commercial usage
Author: Qingfeng XIA
copyright (C) 2011-2020
http://www.iesensor.com
please keep the original link in your reference.
http://www.iesensor.com/blog/2018/09/24/export-salome-mesh-to-fenics-mesh/
This entry was posted in Programming. Bookmark the permalink.