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

Call foam solver from qt

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 4, 2013, 21:06
Default Call foam solver from qt
  #1
Member
 
Fatih Ertinaz
Join Date: Feb 2011
Location: Istanbul
Posts: 64
Rep Power: 15
fertinaz is on a distinguished road
Hi all. This is not directly a problem related with openfoam programming but might still be interesting for OF developers.

I am trying to develop a gui using qt that runs openfoam behind. tried to call simpleFoam using qprocess:

Code:
solverProcess = new QProcess(this);

solverBin = "/OF_APPBIN/simpleFoam";

testDir = "/fullPathTestDir";
args << "-case" << testDir;

solverProcess->start(solverBin, args);

    if (solverProcess->waitForStarted())
        // done
This code does not produce any errors and ends successfully however runs nothing. When I use startDetached instead of start I get the following interesting err msg:

simpleFoam: error while loading shared libraries: libincompressibleRASModels.so: cannot open shared object file: No such file or directory

There is nothing wrong with the full path of the solver and test directory. I printed their values and could run manually on a terminal without any problems.

The test case is pitzDaily. I am using (still) OF 1.6.x on an Ubuntu machine.

Any help is appreciated.
fertinaz is offline   Reply With Quote

Old   December 8, 2013, 07:26
Default
  #2
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Very quick answer:
  1. Advanced tips for working with the OpenFOAM shell environment
  2. http://qt-project.org/doc/qt-4.8/qpr...essEnvironment
wyldckat is offline   Reply With Quote

Old   December 11, 2013, 17:06
Default
  #3
Member
 
Fatih Ertinaz
Join Date: Feb 2011
Location: Istanbul
Posts: 64
Rep Power: 15
fertinaz is on a distinguished road
I checked the links above. not much new to me, but they're quite useful. thanks.

I moved the installation of Openfoam from my home directory to /opt and changed the code a little bit. It seems to work now. However I don't want to do it this way. Here is the new code snippet:

Code:
solverProcess->setStandardOutputFile("/myTestDir/test.out", QIODevice::Append);

solverProcess->start("/bin/sh", QStringList() << "/myTestDir/test.sh");

if (solverProcess->waitForStarted()) {
  if (m_SolverProcess->state() == QProcess::Running) {
    QMessageBox::information(NULL, "runSolver", "Done");
  }
}
As you see instead of a direct call for the openfoam solver, I run a shell script where the call for the solver is included:

Code:
#!/bin/bash

echo "some messages"

source openfoam

echo "Check isSourced successfully: "
echo $WM_PROJECT_DIR

/FOAM_APPBIN/simpleFoam -case /myTestDir > /myTestDir/log
This method works perfectly fine.

However if I try to call simpleFoam directly using qprocess as in the very first post, I get the following err msg:

Code:
qDebug() << "STDERR: " << m_SolverProcess->readAllStandardError();
STDERR: /FOAM_APPBIN/simpleFoam:
             error while loading shared libraries:
             libincompressibleTurbulenceModel.so:
             cannot open shared object file: No such file or directory
This is somehow related to assigning environment variables correctly I presume. I must be doing sth wrong somewhere. The code below does not run as well:

Code:
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();

env.insert("PATH", 
          env.value("Path")+openfoamPath+"/platforms/"+openfoamArch+"/bin/");

solverProcess->setProcessEnvironment(env);
solverProcess->start("simpleFoam -case /fullPathTestDir/");
I can’t seem to understand how to deal with the error "error while loading shared libraries: libincompressibleTurbulenceModel.so: cannot open shared object file".

Any ideas are very welcome.

Note: OpenFoam is sourced by default in .bashrc
fertinaz is offline   Reply With Quote

Old   December 12, 2013, 11:23
Default
  #4
New Member
 
Join Date: Nov 2013
Posts: 20
Rep Power: 12
Jakob1 is on a distinguished road
Hey fertinaz,
can t help you with your specific problem, but do you know about PyFoam? Let s you handle Foaming in a Python environment. I used that to write a simple GUI (with wx, but you can just as well use qt) and some control/analysis functions. Works really nicely.
Jakob1 is offline   Reply With Quote

Old   December 15, 2013, 09:36
Default
  #5
Retired Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128
wyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to allwyldckat is a name known to all
Greetings to all!

@Fatih: on Linux/POSIX systems, usually it's case-sensitive, where "PATH" and "Path" are not the thing.

In addition, there are several environment variables that are modified and added when the OpenFOAM environment is sourced into the shell environment. Try this:
  1. Comment out the line in ".bashrc" related to OpenFOAM.
  2. Start a new terminal.
  3. Run:
    Code:
    export > environment.before.txt
  4. Activate the OpenFOAM environment (run the original string you had in ".bashrc").
  5. Run:
    Code:
    export > environment.after.txt
  6. And compare the two files. You can use diff:
    Code:
    diff -Nur environment.before.txt environment.after.txt
Best regards,
Bruno
__________________
wyldckat is offline   Reply With Quote

Old   June 15, 2018, 09:02
Default
  #6
New Member
 
JSousa
Join Date: Jun 2018
Posts: 2
Rep Power: 0
JVRS is on a distinguished road
Hello,
Did you managed to solve that problem?
I'm also facing the same type of problem.
I want to run a solver through a pushbutton on qt and it doen's start.
If I type the command on the commandline it works perfectly.
Don't know how to solve this...
If you managed to solve this please let me know how...

regards,
Jsousa
JVRS 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
FEM solver in FOAM Hrvoje Jasak (Hjasak) OpenFOAM 2 March 31, 2013 12:52
Divergence problem Smaras FLUENT 13 February 21, 2013 05:03
[Other] cgnsToFoam problems with "QUAD_4" cells lentschi OpenFOAM Meshing & Mesh Conversion 1 March 9, 2011 04:49
Working directory via command line Luiz CFX 4 March 6, 2011 20:02
[Gmsh] Import problem ARC OpenFOAM Meshing & Mesh Conversion 0 February 27, 2010 10:56


All times are GMT -4. The time now is 20:14.