Dual Mesh Feature Support

Hey Salome devs, it’d be awesome if you could add a polyDualMesh feature to generate a dual mesh that can be exported in VTK or another format that supports polyhedra. This would make it way easier to work with polyhedral meshes in CFD and other simulations, similar to how OpenFOAM’s polyDualMesh works. Right now, getting a clean dual mesh out of Salome takes extra steps, and having it built-in would be a huge time saver. Hope you’ll consider it!

the poly dual of salome right now generates way too many ‘extra faces’ as it does not fuse them (similar to what happens in polyDualMesh in OF on the boundary cells), i would not recommend this meshes for CFD, as you losse one of the main benefits of this kind of mesh. I would recommend instead this tool (wich has its own disadvantages but generates more suited CFD meshes) developed by @MRousseau great developper.

@cbourcier any input into how one would import this to newer versions of salome?
I followed the guide on the github but it did not show up in tools/plugings
thanks in advance

Sneaking into this thread. The README about the installation of the tool seems still valid to me. But here is how you can proceed.
I gave it a try with latest SALOME-9.14 on Ubuntu 22.04 - and I believe it should apply to other platforms as well.

  • Install this plugin in a given directory, e.g. /home/salome.
cd /home/salome
git clone https://github.com/MoiseRousseau/SALOME-Voronoi.git
cd SALOME-Voronoi
# ensure that mentioned prerequisites in README are installed!
./install_vorpalite.sh
  • Apply a minor modification to the plugin, to make it portable, namely edit file: Voronoi_converter.py and replace:
    path = '/home/%s/.config/salome/Plugins/SALOME-Voronoi/' %(os.getlogin())

with:

    path= os.getenv('SALOME_VORONOI_ROOT_DIR', '/tmp')
    if not path.endswith('/'): path+='/'
  • Expose Voronoi plugin environment to SALOME. To do this, extract the attached extra.env.d directory in SALOME-9.14.0-native-UB22.04-SRC/extra.env.d. Edit file extra.env.d/9000_voronoiPlugin.py and fix path to SALOME-Voronoi plugin:
  context.setVariable(r'SALOME_VORONOI_ROOT_DIR', r'/home/salome/SALOME-Voronoi', overwrite=True)
  • Edit file: SALOME-9.14.0-native-UB22.04-SRC/BINARIES-UB22.04/SMESH/share/salome/plugins/smesh/smesh_plugins.py and right after meshboolean plugin, add:
try:
  import Voronoi_converter
  from Voronoi_converter import convertForCVTCalculation
  salome_pluginsmanager.AddFunction('Interface between Salome and Vorpalite', 'polyhedral mesh generation.', convertForCVTCalculation)
except Exception as e:
  salome_pluginsmanager.logger.info('ERROR: voronoi plug-in is unavailable: {}'.format(e))
  pass
  • Launch SALOME and activate SMESH, the plugin will show up in list of SMESH plugins.

Enclosed:

  • modified converter which implements the mentioned minor modification.
  • extra.env.d.tar.gz which contains the environment file of this plugin. Fix path in this file.

@cbourcier : approach based on SMESH_PYPLUGIN_DIR environment variable does not seem to work here.

Voronoi_converter.py (6.2 KB)
extra.env.d.tar.gz (410 Bytes)
smesh_plugins.py (6.1 KB)

1 Like

Hello Nabil,
thanks for the help.
I am still having troubles to make it show in salome.
for info, I am using the universal linux distribution.
the steps I followed are:

#go to path of installation of salome
cd $salomeFolderPath/SALOME-9.14.0
#extract the tar file
tar sxzf ~/Desktop/extra.env.d.tar.gz
#replace the necessary things on the extracted file
sed -i "s|context.setVariable(r'SALOME_VORONOI_ROOT_DIR', r'/home/salome/SALOME-Voronoi', overwrite=True)|context.setVariable(r'SALOME_VORONOI_ROOT_DIR', r'$salomeFolderPath/SALOME-Voronoi', overwrite=True)|"  extra.env.d/9000_voronoiPlugin.py
#add extra lines to BINARIES-CO7/SMESH/share/salome/plugins/smesh/smesh_plugins.py 
sed -i "s|^\(\s*\)salome_pluginsmanager.logger.info('ERROR: MeshBoolean plug-in is unavailable: {}'.format(e))|\1salome_pluginsmanager.logger.info('ERROR: MeshBoolean plug-in is unavailable: {}'.format(e))\n\1pass\n\ntry:\n  import Voronoi_converter\n  from Voronoi_converter import convertForCVTCalculation\n  salome_pluginsmanager.AddFunction('Interface between Salome and Vorpalite', 'polyhedral mesh generation.', convertForCVTCalculation)\nexcept Exception as e:\n  salome_pluginsmanager.logger.info('ERROR: voronoi plug-in is unavailable: {}'.format(e))|" BINARIES-CO7/SMESH/share/salome/plugins/smesh/smesh_plugins.py


# go to root of salome installation path
cd $salomeFolderPath
#clone the git
git clone https://github.com/MoiseRousseau/SALOME-Voronoi.git
#enter created folder
cd SALOME-Voronoi
#make executable the .sh
chmod +x ./install_vorpalite.sh
#run the .sh
./install_vorpalite.sh #the compilation went ok
# replace/add the lines to  Voronoi_converter.py
sed -i "s|^\(\s*\)path = '/home/%s/.config/salome/Plugins/SALOME-Voronoi/' %(os.getlogin())|\1path= os.getenv('SALOME_VORONOI_ROOT_DIR', '/tmp')\n\1if not path.endswith('/'): path+='/'|" Voronoi_converter.py

when I open salome it prints ‘Setting SALOME-Voronoi environment’ but it is not shown on the SMESH plugings
also I double checked the results of the sed commands in case there were some errors but the result is okey

To launch the plugin interface, once SMESH activated, in the main menu bar, select Mesh, then click SMESH Plugins and finally select : Interface between Salome and Vorpalite.
I just tried your commands and it’s OK.

1 Like

sorry i was looking in tools/plugings instead of mesh/SMESH plugings

@NabiiG

So are you running this in linux Ubuntu 22.04, or Ubuntu wsl 22.04?

I attempted to install it, but could not do it. Maybe the developers can update it and install it directly?

Please, describe what you did and which SALOME version you used (Ubuntu 22,24, universal linux or windows ) with the error messages if any. Community can then help
Regards.

So I am trying to install it on wsl2 ubuntu 20.04, following these instructions from the authors instructions,

I was trying to get it to work with the linux universal version of SALOME.

I have tried to get it working many times, but I cannot get the plugin to pop up in the tools > plugins drop down

What do you suggest? I think the community should post generic instructions that will work, but it is a bit out of date.

Did you try this. If yes, share error messages if any.

So I was actually able to install it. I can install it on SALOME-9.9.0 and SALOME-9.14.0. I think I used the salomeToOpenFoam.py script once and successfully got a valid polyMesh file of the converted tetrahedral. Then my script went awol, and I cannot get a valid mesh file anymore with a good checkMesh in openFoam. Is there any other way to get that Voronoi mesh?

I understand that it is not anymore a question about installing and running the plugin, but more a question of reproducing some previous result. Concerning the second part, it is beyond my knowledge.

Note that If you still do have the original tetrahedral mesh you can try to share it such that other people can have a look and may provide some support.

1 Like

You’re right, I will do that in a new post. For now here is the instructions for installing that Voronoi for everyone else.

===================== This is the instructions for installing the SALOME-Vornoi for SALOME 9.14 ======================================

NOTE: Download the latest SALOME of your choice, for my example I used the SALOME-9.14.0 Universal Linux Package

NOTE: Make sure to update the user name with your ‘user’, where you would find your directory, you can always use the ‘whoami’ command to see what your user is

tar -xzf SALOME-9.14.0.tar.gz
cd SALOME-9.14.0/
git clone GitHub - MoiseRousseau/SALOME-Voronoi: Interface between Salome and Vorpalite for polyhedral mesh generation
cd SALOME-Voronoi
chmod 700 *
./install_vorpalite.sh
cd …/
mkdir extra.env.d
cd extra.env.d/
nano 9000_voronoiPlugin.py

== paste text in file ================================
import os

def init(context, root_dir):
print(“Setting SALOME-Voronoi environment”)
context.setVariable(‘SALOME_VORONOI_ROOT_DIR’, ‘/home/(your user)/SALOME-9.14.0/SALOME-Voronoi’, overwrite=True)
context.addToPythonPath(“${SALOME_VORONOI_ROOT_DIR}”)
context.addToPath(“${SALOME_VORONOI_ROOT_DIR}/geogram_1.8.2/bin”)
context.addToLdLibraryPath(“${SALOME_VORONOI_ROOT_DIR}/geogram_1.8.2/lib”)

path = os.getenv('SALOME_VORONOI_ROOT_DIR', '/tmp')
if not path.endswith('/'):
    path += '/'

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

chmod 700 9000_voronoiPlugin.py
cd …/
cp -pr extra.env.d ~/SALOME-9.14.0/BINARIES-CO7/
nano ~/SALOME-9.14.0/BINARIES-CO7/SMESH/share/salome/plugins/smesh/smesh_plugins.py

== paste at bottom of list ===========================

try:
import Voronoi_converter
from Voronoi_converter import convertForCVTCalculation
salome_pluginsmanager.AddFunction(
‘Interface between Salome and Vorpalite’,
‘Polyhedral mesh generation.’,
convertForCVTCalculation
)

except Exception as e:
salome_pluginsmanager.logger.info(‘ERROR: Voronoi plug-in is unavailable: {}’.format(e))
pass

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

export PYTHONPATH=$PYTHONPATH:/home/(your user)/SALOME-9.14.0/SALOME-Voronoi
echo ‘export PYTHONPATH=$PYTHONPATH:/home/(your user)/SALOME-9.14.0/SALOME-Voronoi’ >> ~/.bashrc
source ~/.bashrc
cd SALOME-Voronoi/
nano Voronoi_converter.py

NOTE Replace this text line: path = ‘/home/%s/.config/salome/Plugins/SALOME-Voronoi/’ %(os.getlogin())

== paste with ===========================

path = ‘/home/{}/.config/salome/Plugins/SALOME-Voronoi/’.format(os.environ.get(“USER”, “(your user)”))

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

cd …/
mkdir -p ~/.config/salome/Plugins/SALOME-Voronoi/
chmod 755 ~/.config/salome/Plugins/SALOME-Voronoi/
./salome

NOTE: I was able to install this using the “Universal Linux” Salome package using WSL2 Ubuntu 20.04.

1 Like