|
[Sponsors] |
[Salome] Script for converting a mesh from Salome-Platform to OpenFOAM |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
June 12, 2014, 19:43 |
|
#21 |
Senior Member
|
Hi Nicolas,
I'm facing one more problem with the script; and I can't understand if there's a problem with python: Code:
>>> p, li { white-space: pre-wrap; } execfile(r"/home/michele/Documents/Salome/SalomeToOpenFOAM.py") found selected mesh exporting to //tubo/constant/polyMesh Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/michele/Documents/Salome/SalomeToOpenFOAM.py", line 602, in <module> exportToFoam(mesh,mesh.GetName()) File "/home/michele/Documents/Salome/SalomeToOpenFOAM.py", line 88, in exportToFoam os.makedirs(dirname) File "/home/michele/salome/SALOME-MECA-2014.1-LGPL/prerequisites/Python_273/lib/python2.7/os.py", line 157, in makedirs mkdir(name, mode) OSError: [Errno 13] Permission denied: 'tubo' can you help me? I'm using Salome version 7.3.0 thanks Last edited by student666; June 13, 2014 at 03:09. |
|
June 13, 2014, 07:17 |
|
#22 |
Senior Member
|
Dear Michele,
though not being Nicolas, maybe I have an idea on the reason of the problem. To me the output looks as if you were calling the script from the top of your root directory. Obviously, your system would not let you as a normal user write data into / . Does the problem occur also if you start Salome (if you call the script from within Salome) or the script (if you call it directly from the shell) from your user home folder? A short side remark to Nicolas nevertheless: Would it be painfully difficult to add a routine asking for the place where the folder should be put? The last time I was using that awesome script it put the folder into the directory from which Salome was called... Cheers, Bernhard |
|
June 13, 2014, 07:27 |
|
#23 | ||
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
The error messeage (last two lines) would suggest that you don't have write permission where you wan't to store the mesh. Also note one of the first lines Quote:
To change the path, open the python interpreter and type (you can ignore the lines starting with #. Code:
import os #show the current path os.getcwd() #set it to something sensible os.chdir("/home/user/somefolder") Best of luck Nicolas |
|||
June 13, 2014, 07:29 |
|
#24 |
Senior Member
|
Hi Bernhard,
the problem to me arise from within Salome. I perform: select the mesh --> File --> load script --> select salomeToOpenFoam.py (in home/michele/Documents/salomeToOpenFoam.py Never used the call within the shell. Anyway I fear there's something wrong within python 2.7.3, but I don't know how to check. |
|
June 13, 2014, 07:34 |
|
#25 |
Senior Member
|
Well before you start looking for errors within your Python installation (that definitely would be out of my league, as well), just give it a try if it works when starting Salome from your home folder!
I remember that the location of the script does NOT matter for the position where the mesh folder goes, but the location from which Salome is started definitely does. Try: cd $HOME ; runSalome (or whatever command you use for starting Salome) Let us know if it works, please! |
|
June 13, 2014, 08:04 |
|
#26 | |
Senior Member
|
Bernard, you're right!.
Quote:
Code:
/home/michele/salome/apply_v7_3_0 when I type Code:
import os os.getcwd() |
||
June 13, 2014, 08:18 |
|
#27 |
Senior Member
|
Nicolas was right, too! I just was quicker this one time! ;-)
My opinion: Basically when using applications you never miss root privileges - if they are required, the software is set up wrongly. I strongly suggest not to try anything to breach the root-barrier. It just makes your system more vulnerable. Now comes the part of speculation on my side: Maybe it is possible to change the icon on the desktop in a way it changes to your home directory and starts Salome only after that? How to do that, I would have to experiment, unfortunately. For changing the script or the working directory called from salomeToOpenFOAM.py, I refer to Nicolas. HE is the man concerning the magic script and python. ;-) Cheers, Bernhard |
|
June 13, 2014, 11:35 |
|
#28 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Hi Bernhard!
I guess you posted while I was still typing =). Michele, as Berhard says you should not need root privileges. It sounds like you've opened a separate "terminal". What I meant was to use a the python console inside salome. Code:
os.getcwd() Code:
os.chdir("/home/YOURuserNAME/somepath/polyMesh") Or you can start salome from another directory by providing the full path to runAppli. Code:
/home/michele/salome/apply_v7_3_0/runAppli Nicolas |
|
November 21, 2014, 15:22 |
|
#30 | |
New Member
Fa-Gung Fan
Join Date: Nov 2009
Posts: 8
Rep Power: 17 |
Hi OpenFOAM users,
Do the meshes at the inter-region patches to OpenFOAM have to be conforming? Thanks. - ffan Quote:
|
||
December 12, 2014, 13:27 |
|
#31 |
Member
Pierluigi Cirrottola
Join Date: Jun 2013
Posts: 52
Rep Power: 13 |
Hi Nicolas,
I discovered your contribution while I was searching this Forum for other issues, but I think it can be very useful. A.s.a.p. I will test it, using Salomé 7.4 and oF 2.3. I will write you back my feelings. Ciao Piero |
|
December 12, 2014, 18:54 |
SalomeToOpenFOAM.py with Salome 7.4 and OF 2.3.
|
#32 | |
Senior Member
|
Quote:
But in case you bump into problems, please do post it here! In the worst case you trip a heisenbug, in the best case you help some other users not to repeat avoidable mistakes. ;-) |
||
December 13, 2014, 05:55 |
|
#33 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
I wish you the best of luck. But keep in mind that this script was one of the first things I did in python. It can most definitely be speed up. As Bernhard pointed out at approximately 1M cells the conversion takes really long time. Possibly longer than it took to generate the mesh in the first place. In part this is because it's a python script but mostly because of the algorithm. Every time it converts one face from salome to openfoam it has to check if that face already has been added. So the conversion time is in the order . I've tried to use dictionaries which supposedly are of order but that doesn't seem to be the case when the cell count is large. If you have any suggestions on how to improve the conversion, please let me know. Best Regards Nicolas |
||
December 13, 2014, 07:50 |
just a stupid correction
|
#34 |
Member
Pierluigi Cirrottola
Join Date: Jun 2013
Posts: 52
Rep Power: 13 |
Hi Nicolas,
I'm sending to you a a very small correction I made, because the out directory was not the correct one. For example, if mesh name is Mesh_1, outdir was "(cwd)/Mesh_1" instead of "(cwd)/Mesh_1/constant/polyMesh". Attached you will find source code, with my correction well signaled (-pici-). Thank you for you attention. Bye Piero |
|
December 13, 2014, 11:46 |
Thanks!
|
#35 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
Best Regards Nicolas |
||
December 13, 2014, 13:53 |
Python scripting
|
#36 | |
Member
Pierluigi Cirrottola
Join Date: Jun 2013
Posts: 52
Rep Power: 13 |
Quote:
I'm really a beginner in Python, so I will be obliged if you would explain how is 'different' the manner you used. Many thanks . . . Piero |
||
December 15, 2014, 02:21 |
|
#37 | |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Quote:
Code:
if __name__ == "__main__": Now I moved all the code under "__main__" to it's own function so the variables aren't global and only exits in the namespace of that function. /Nicolas |
||
December 21, 2014, 15:25 |
|
#38 |
Member
Anil Kunwar
Join Date: Jun 2013
Posts: 64
Rep Power: 12 |
Hi Nicolas,
Thank you very much. I am using the salomeToOpenFoam.py script in Salome 7.4.0. Your creative work has helped us a lot. Also, your explanations are lucid. Yours Anil Kunwar |
|
February 2, 2015, 13:49 |
Error while trying the script
|
#39 |
New Member
Ralf Schüßler
Join Date: Feb 2015
Posts: 1
Rep Power: 0 |
Hello,
while I've tried the script I got an error message: >>> execfile(r"/home/user/salomeToOpenFOAM-master/salomeToOpenFOAM.py") Traceback (most recent call last): File "<input>", line 1, in <module> File "/home/user/salomeToOpenFOAM-master/salomeToOpenFOAM.py", line 46, in <module> from salome.smesh import smeshBuilder ImportError: cannot import name smeshBuilder >>> and te script won't continue. My salome-version is 6 / 2013.1 , 32 bit, linux. I would like to know, how to get the script running. Many thanks in advance, Ralf |
|
February 15, 2015, 06:52 |
|
#40 |
Senior Member
Nicolas Edh
Join Date: Mar 2010
Location: Uppsala, Sweden
Posts: 123
Rep Power: 18 |
Hi Ralph,
I've only tried the scripts with salome versions 7.2,7.3 and 7.4. Most likely you need to install a more recent version of Salome. Best Regards Nicolas |
|
Tags |
mesh conversion, openfoam, salome meca |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Salome] how to setFields in openFOAM when you have imported mesh from salome or other package | 13msmemusman | OpenFOAM Meshing & Mesh Conversion | 11 | May 18, 2022 08:30 |
[Salome] import mesh from salome to openfoam | dome90 | OpenFOAM Meshing & Mesh Conversion | 2 | April 21, 2016 00:58 |
[Salome] Step to export mesh from SALOME to OpenFoam for 3D MRF geometry | aminem | OpenFOAM Meshing & Mesh Conversion | 0 | September 16, 2014 11:18 |
[Salome] Mesh Salome 7.3.0 to OpenFoam | Ahadi | OpenFOAM Meshing & Mesh Conversion | 5 | July 1, 2014 11:11 |
Mesh conversion problem from Salome to openfoam | jishnusoni | OpenFOAM | 15 | March 3, 2010 02:53 |