|
[Sponsors] | |||||
|
|
|
#1 |
|
Member
K
Join Date: Mar 2018
Posts: 34
Rep Power: 9 ![]() |
Hey Foamers
I am wondering if it is possible to run a python file by modifying OpenFOAM solver source code (like say simpleFOAM). Lets just say the python file forces printing out a random statement during running of the solver. My understanding of PyFOAM is that it is a wrapper around the C++ OpenFOAM source code so it doesn't allow running python script in the solver. Thank you in advance for your comments and thoughts on this!
|
|
|
|
|
|
|
|
|
#2 |
|
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,360
Rep Power: 33 ![]() ![]() |
Hello Kuria,
Why not using the systemCall function object for this ? This function allow to execute shell commands during a run. Code:
Executes system calls, entered in the form of a string lists.
Calls can be made at the following points in the calculation:
- every time step
- every output time
- end of the calculation
I usually use it to execute gnuplot scripts (e.g. to monitor residuals) but running a python script should not be a problem. Cheers, Yann |
|
|
|
|
|
|
|
|
#3 |
|
Senior Member
Carlo_P
Join Date: May 2019
Location: Italy
Posts: 176
Rep Power: 9 ![]() |
Hey Yann,
nice functionObject.. Does it works both with Esi and org foam version? For Kuris: you can simple write "python pythonfile.py > pythonfile.log" in that system call. |
|
|
|
|
|
|
|
|
#4 | |
|
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,360
Rep Power: 33 ![]() ![]() |
Quote:
Yes this is quite an old function object and it exists in both branches! I think it's an overlooked but powerful way to automatize tasks during a run, whether it is about running some shell commands or using other tools such as python or gnuplot. Cheers, Yann |
||
|
|
|
||
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Custom Thermophysical Properties | wsmith02 | OpenFOAM | 4 | June 1, 2023 15:30 |
| [foam-extend.org] problem when installing foam-extend-1.6 | Thomas pan | OpenFOAM Installation | 7 | September 9, 2015 22:53 |
| [Other] Adding solvers from DensityBasedTurbo to foam-extend 3.0 | Seroga | OpenFOAM Community Contributions | 9 | June 12, 2015 18:18 |
| friction forces icoFoam | ofslcm | OpenFOAM | 3 | April 7, 2012 11:57 |
| DecomposePar links against liblamso0 with OpenMPI | jens_klostermann | OpenFOAM Bugs | 11 | June 28, 2007 18:51 |