Calling OpenFOAM from Scilab
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 Code:
!--error 10000 Thanks in advance, Jefferson V. |
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.
|
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 |
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 |
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 |
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) Code:
|
Found a different solution !
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 |
All times are GMT -4. The time now is 10:10. |