|
[Sponsors] |
August 7, 2014, 11:22 |
Calling OpenFOAM from Scilab
|
#1 |
New Member
Jefferson Vieira
Join Date: Jul 2014
Location: Brazil/Scotland
Posts: 12
Rep Power: 12 |
Hi all,
I'm working on an optimization routine in Scilab that in a certain point calls OpenFOAM to do the simulation. I'm trying to use the unix function in Scilab to do this, but I'm having some problems. At first I tried to call the OpenFOAM function normally e.g. icoFoam, and then: Code:
!--error 10000 unix_w: The command failed with the error code "127" and the following message: sh: 1: icoFoam: not found Code:
!--error 10000 unix_w: The command failed with the error code "127" and the following message: /opt/openfoam230/platforms/linux64GccDPOpt/bin/icoFoam: error while loading shared libraries: libfiniteVolume.so: cannot open shared object file: No such file or directory Thanks in advance, Jefferson V. |
|
August 7, 2014, 11:34 |
|
#2 |
Senior Member
Chris Sideroff
Join Date: Mar 2009
Location: Ottawa, ON, CAN
Posts: 434
Rep Power: 22 |
I've never used scilab before (but know what it is) but my wild stab in the dark is that scilab does not inherit some/any of the shell environment variables from which is was started. Meaning none of the environment variables needed by OpenFOAM (as created by $WM_PROJECT_DIR/etc/bashrc) exist.
|
|
September 24, 2014, 04:34 |
|
#3 |
Member
Julian Langowski
Join Date: May 2011
Location: Bremen, Germany
Posts: 91
Rep Power: 15 |
Dear Jefferson,
a few years ago I did perform an optimisation in Scilab using OpenFOAM and indeed it is possible. As I am currently again working on a combination of Scilab and OF, I will let you know, when I searched through my old project and found the basic instructions. Best regards Julian
__________________
πάντα ῥεῖ - Heraclitus |
|
September 24, 2014, 10:52 |
|
#4 |
New Member
Jefferson Vieira
Join Date: Jul 2014
Location: Brazil/Scotland
Posts: 12
Rep Power: 12 |
Hi Julian,
I've managed to do it. At first I was using a computer running Linux in a virtual machine, but when I tried in another computer without the virtual machine it worked fine using the unix function. Regards, Jefferson |
|
February 5, 2016, 14:31 |
|
#5 |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 12 |
I am having the same issues calling openFOAM operations from Scilab... As you posted before, it returns error 127 when i try to run any openFoam command using host("") or unix("")...
Does anybody know any solution to this since i already invested considerable time writing my code in scilab? I'd gladly appreciate any support |
|
February 5, 2016, 16:49 |
|
#6 |
Senior Member
|
Hi,
To execute OpenFOAM commands you have to set up environment. Either do it by had or use foamExec function. So your Scilab code could look like: Code:
function [rep, stat] = foamExec(cmd, version) [lhs, rhs] = argn(0); if rhs <= 1 then version = '2.4.0' end foam_home = home + '/OpenFOAM/OpenFOAM-' + version foam_exec = foam_home + '/bin/foamExec' cmd_line = foam_exec + ' ' + cmd [rep, stat] = unix_g(cmd_line) endfunction me = getenv('USER'); chdir(home + '/OpenFOAM/' + me + '-2.4.0/run/cavity'); [output, ret_val] = foamExec('blockMesh'); disp(ret_val); [output, ret_val] = foamExec('icoFoam', '2.4.x'); disp(ret_val); disp(output(8)); Code:
0. 0. Build : 2.4.x-eb277aee1088 |
|
February 5, 2016, 17:56 |
Found a different solution !
|
#7 |
Member
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 60
Rep Power: 12 |
Thank you a lot.. however that did not work for me since Scilab shell commands do not recognize openFoam functions (As someone said before the environment variables configured in the bashrc file)... btw I am novice in ubuntu configurations...
After trying different approaches, I found out a way to operate this and make scilab recognize openFOAM using host or unix functions: 1. Open an ubuntu terminal and execute scilab by typing it. 2. Select the $FOAM_RUN directory as the working directory for scilab 3. Force the bashrc configuration to be reloaded it can be used the following: unix("exec $BASH blockMesh -case $FOAM_RUN/cavity") ... I have already tested and it works with paraFoam and the solvers. Thank you a lot for your answers though |
|
Tags |
openfoam, scilab, unix |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Frequently Asked Questions about Installing OpenFOAM | wyldckat | OpenFOAM Installation | 3 | November 14, 2023 12:58 |
OpenFOAM - Validation of Results | Ahmed | OpenFOAM Running, Solving & CFD | 10 | May 13, 2018 19:28 |
OpenFOAM Foundation releases OpenFOAM 2.2.2 | opencfd | OpenFOAM Announcements from ESI-OpenCFD | 0 | October 14, 2013 08:18 |
The OpenFOAM extensions project | mbeaudoin | OpenFOAM | 16 | October 9, 2007 10:33 |
OpenFOAM Training and Workshop | Hrvoje Jasak | Main CFD Forum | 0 | October 7, 2005 08:14 |