CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Launching OpenFOAM from Matlab standlaone

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 4, 2022, 17:52
Default Launching OpenFOAM from Matlab standlaone
  #1
Member
 
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 57
Rep Power: 11
jairoandres is on a distinguished road
Hello, I have compiled a standalone Matlab executable that calls OpenFOAM commands using system (ej: system('blockMesh'). When run from Matlab (as a script) it works fine. However, as a standalone app, an error message appears in the terminal (for example for blockMesh: "error while loading shared libraries: libblockMesh.so: cannot open shared object file: No such file or directory"

I have opened a forum post in Matlab but none of the solutions posted so far worked. The link is: https://www.mathworks.com/matlabcentral/answers/1678994-system-commands-requiring-libraries-non-matlab-related-do-not-work-when-executed-from-a-standalone?s_tid=srchtitle

I suppose the error is related to the libraries loaded in the .sh file used to launch the standalone file. It reads:

Code:
 echo ---
  LD_LIBRARY_PATH=.:${MCRROOT}/runtime/glnxa64 ;
  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/bin/glnxa64 ;
  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/os/glnxa64;
  LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${MCRROOT}/sys/opengl/lib/glnxa64;
Adding something like:
Code:
LD_LIBRARY_PATH=$"/usr/lib/openfoam/openfoam2012/platforms/linux64GccDPInt32Opt/lib/sys-openmpi"
generates a load error when launching the standalone
"libmwlaunchermain.so not found". This is a Matlab library.

Any ideas to launch OpenFOAM libraries along with the standalone app of Matlab?
jairoandres is offline   Reply With Quote

Old   April 5, 2022, 11:00
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Try using the wrapper script, this is one of the use cases.
For example, assuming that you have the openfoam meta-package active:

Code:
$ openfoam blockMesh
or...
$ openfoam -- blockMesh
or...
$ openfoam  /  blockMesh
or...
$ openfoam  -  blockMesh
or ..
$ openfoam2112 blockMesh
etc..
Should work with a system() call from other programs.
jairoandres likes this.
olesen is offline   Reply With Quote

Old   April 6, 2022, 19:42
Default
  #3
Member
 
Jairo A. Gutiérrez S
Join Date: Nov 2014
Posts: 57
Rep Power: 11
jairoandres is on a distinguished road
Thank you so much. I did not know what the wrapper script was. I executed the system command as "openfoam2012 blockMesh" and worked well. I suppose it should also be the case for any OpenFOAM executable.

Regards,

Jairo
jairoandres is offline   Reply With Quote

Old   April 7, 2022, 11:30
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,686
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by jairoandres View Post
Thank you so much. I did not know what the wrapper script was. I executed the system command as "openfoam2012 blockMesh" and worked well. I suppose it should also be the case for any OpenFOAM executable.

Regards,

Jairo

Yup, try with "openfoam2012 -help" and you will see that you can use it for an interactive shell session, non-interactively to run an OpenFOAM application, can even use the '-c' option and provide it with a shell command to run.


If you want something without specifying a long installation path, you will also notice that there is a template as "bin/tools/openfoam.in" that you can use sed to replace the @PROJECT_DIR@ token and make your own launcher. For the precompiled packages this is what ends up under /usr/bin/openfoam or /usr/bin/openfoam2012 etc.
olesen is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Other] how to convert a mesh drawn in matlab to a format which can be used in OpenFOAM jali OpenFOAM Meshing & Mesh Conversion 3 July 19, 2017 20:16
OpenFOAM Training Beijing 22-26 Aug 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 May 3, 2016 04:57
OpenFOAM command from inside MATLAB sega OpenFOAM Post-Processing 18 September 25, 2012 07:35
Cross-compiling OpenFOAM 1.7.0 on Linux for Windows 32 and 64bits with Mingw-w64 wyldckat OpenFOAM Announcements from Other Sources 3 September 8, 2010 06:25
Modified OpenFOAM Forum Structure and New Mailing-List pete Site News & Announcements 0 June 29, 2009 05:56


All times are GMT -4. The time now is 02:33.