|
[Sponsors] |
I want OpenFOAM to email me when it's done, is this too much to ask?!? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 12, 2013, 04:30 |
I want OpenFOAM to email me when it's done, is this too much to ask?!?
|
#1 |
Senior Member
Jose Rey
Join Date: Oct 2012
Posts: 134
Rep Power: 17 |
Hi,
Is it possible to have the computer where your model is running send you an email (text message, or whatever) when either the model finished running, or when it breaks due to an error? I have a desktop computer running my OpenFoam models, and it sometimes takes minutes (when the model breaks) or hours (when the model successfully runs). Thanks P.D. I realize this might be more of a Linux than an OpenFoam question, but I bet it is very relevant to modeling. |
|
May 12, 2013, 06:45 |
|
#2 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Hi Jose,
Well, it all depends on how you ran the case in the first place... if you used an Allrun script, identical to OpenFOAM's tutorials, then you can try adding this to the end of the script: Code:
echo "Sending separate email with the simulation status..." ( echo "Case in question:" head -n 20 log.$application echo echo echo echo echo "Last 100 lines of the output for the solver $application:" echo tail -n 100 log.$application ) | mail -s "Summary Report from the case $PWD" yourname@email.address The "$application" variable is sometimes defined in Allrun scripts... for example in "tutorials/incompressible/pimpleFoam/TJunctionFan/Allrun": https://github.com/OpenFOAM/OpenFOAM...tionFan/Allrun Best regards, Bruno
__________________
|
|
May 12, 2013, 12:03 |
|
#3 |
Senior Member
Lieven
Join Date: Dec 2011
Location: Leuven, Belgium
Posts: 299
Rep Power: 22 |
Just as an addition.
If the system you run the jobs on is working with a resource management system like PBS/Torque, you can add something like Code:
#PBS -m ae -M albert.einstein@princeton.edu Cheers, L |
|
May 13, 2013, 09:26 |
|
#4 |
Senior Member
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 272
Rep Power: 17 |
hello,
You may also take a look at the function Object "systemCall", which should also work. regards, olivier |
|
May 13, 2013, 17:30 |
|
#5 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@Olivier: Nice one! But the downside of the "systemCall" is that it will only work if all goes well... By the way, for anyone who is intrigued by the "systemCall" function object: http://openfoamwiki.net/index.php/Ti...ect_systemCall Best regards, Bruno
__________________
|
|
May 15, 2013, 17:45 |
|
#6 | |
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,225
Rep Power: 51 |
Quote:
That was the objective part. Here comes the advertisement: I implemented a general framework for that in pyFoam (in the runner-utilities to be concrete). If a solver started with one of these utilities stops a number of postRunHooks (which are configured by the user in sections that start with the name postRunHook) are run. Currently the concrete hooks that are implemented are - recording the run in a SQLite database - contacting a webservice at a specific URL and send some information The second one I use regularly. It contacts https://pushover.net and that service sends a message to my phone (which case, whether it ended OK etc). The configuration for that (minus my username and the API-key ) is part of the distribution of pyFoam (you'd just have to insert your username/key and set it to enabled) as an example: it is templatable so any similar webservice could be used. Ah. And BTW: this only sends messages if the run took longer than X seconds. That way my phone doesn't get spammed with runs that don't get past the first timestep Mails could work with these Hooks too, but I haven't had the need for that yet so that is not yet implemented PS: to use pushover you don't have to use pyFoam. That can be easily accessed from shell-scripts too
__________________
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request |
||
August 30, 2013, 06:38 |
|
#7 | |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Quote:
I use a script that have set its address in bashrc,how to add this code to that script? and how to use bsd-mailx?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
||
August 31, 2013, 12:24 |
|
#8 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Hi Ehsan,
Quote:
Code:
yourname@email.address Code:
$MY_EMAIL_ADDRESS Code:
export MY_EMAIL_ADDRESS=yourname@email.address Code:
sudo apt-get install bsd-mailx Bruno
__________________
|
||
September 4, 2013, 07:28 |
|
#9 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi Bruno
I use this script as you mentioned: Code:
#!/bin/bash solver=$2 pyFoamPlotRunner.py --hardcopy --non-persist --with-deltat --with-courant --report-usage --report-analyzed-data --procnr=$1 $solver application=`getApplication` echo "Sending separate email with the simulation status..." ( echo "Case in question:" head -n 20 log.$application echo echo echo echo echo "Last 100 lines of the output for the solver $application:" echo tail -n 100 log.$application ) | mail -s "Summary Report from the case $PWD" $MY_EMAIL_ADDRESS shutdown -h +5 Code:
/home/ehsan/Desktop/codes/runPlot: line 4: getApplication: command not found Sending separate email with the simulation status... head: cannot open `log.' for reading: No such file or directory tail: cannot open `log.' for reading: No such file or directory I found this file containing a log of solution:PyFoamRunner.rhoCentralFoamGasCont.logfil e how can I put it in the code such that the solver read from controlDict instead of explicitly assigned?and why get Application didn't work?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. Last edited by wyldckat; September 4, 2013 at 16:08. |
|
September 4, 2013, 15:01 |
|
#10 |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13 |
I have my cases set up to run a Python script that emails me when a simulation finishes. See http://petebachant.me/automatic-email-openfoam/ for the code I used. I also put lines in the Allrun.pre and Allrun scripts to send desktop notifications when meshing or simulations finish. Example:
Code:
notify-send "OpenFOAM" "Meshing finished." |
|
September 4, 2013, 15:48 |
|
#11 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Thanks a lot,how can make it send SMS?
this link is unfortunately banned here,could you please send me the required texts? http://alextrle.blogspot.com/2011/05...th-python.html
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
September 4, 2013, 15:52 |
|
#12 | |
Senior Member
Pete Bachant
Join Date: Jun 2012
Location: Boston, MA
Posts: 173
Rep Power: 13 |
Quote:
http://en.wikipedia.org/wiki/List_of_SMS_gateways |
||
September 4, 2013, 16:13 |
|
#13 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Greetings to all!
@Ehsan: That's what happens when you don't use the convention used in OpenFOAM's tutorials. An example that can be used in the tutorials is this: Code:
#!/bin/sh # Source tutorial run functions . $WM_PROJECT_DIR/bin/tools/RunFunctions application=`getApplication` runApplication blockMesh runApplication $application The "runApplication" function will run the application indicated by "getApplication" and will automatically log the output inside the file "log.$application". Best regards, Bruno
__________________
|
|
September 4, 2013, 16:43 |
|
#14 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Hi Bruno
but I was using pyFoam for run,which form is suitable for my case? although fortunately the runs are ended successfully.
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
September 4, 2013, 16:48 |
|
#15 | |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
But... it's so simple to look at the code, compare with what I wrote, and fix it yourself!!
Instead of this: Quote:
Code:
#!/bin/bash solver=$2 pyFoamPlotRunner.py --hardcopy --non-persist --with-deltat --with-courant --report-usage --report-analyzed-data --procnr=$1 $solver echo "Sending separate email with the simulation status..." ( echo "Case in question:" head -n 20 PyFoamRunner.rhoCentralFoamGasCont.logfile echo echo echo echo echo "Last 100 lines of the output for the solver $solver:" echo tail -n 100 PyFoamRunner.rhoCentralFoamGasCont.logfile ) | mail -s "Summary Report from the case $PWD" $MY_EMAIL_ADDRESS shutdown -h +5
__________________
|
||
September 4, 2013, 17:15 |
|
#16 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
dear Bruno
you know I wanted a more general form,but never mind,I'm engaging with making a lot of graphs now!
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
September 4, 2013, 17:24 |
|
#17 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
Dear Bruno I performed a quick run while I've added this to .bashrc:
Code:
export MY_EMAIL_ADDRESS=force.of.love@gmail.com Code:
End Finalising parallel run gnuplot> set terminal png small color gnuplot> set terminal png small color ^ line 0: invalid color spec, must be xRRGGBB ^ line 0: invalid color spec, must be xRRGGBB Killing PID 5032 PyFoam WARNING on line 232 of file /usr/local/lib/python2.7/dist-packages/PyFoam/Execution/FoamThread.py : Process 5032 was already dead Used Memory: 0.57421875 MB gnuplot> set terminal png small color ^ line 0: invalid color spec, must be xRRGGBB Sending separate email with the simulation status... Broadcast message from ehsan@Ehsan-com (/dev/pts/2) at 1:44 ... The system is going down for halt in 5 minutes! shutdown: Shutdown cancelled it has forgotten me after one year being friend with me it doesn't send me even an email now! how long it takes to send it?it should be interesting. --------- it seems it hasn't read the file at all because the messages in block aren't shown,right Bruno?
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
September 7, 2013, 07:07 |
|
#18 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Hi Ehsan,
When dealing with programming, you should always test the code before using it in critical deployments. Therefore, try running this from the command line: Code:
echo "Testing emailing functionality" | mail -s "Summary Report from the case $PWD" $MY_EMAIL_ADDRESS Best regards, Bruno
__________________
|
|
September 7, 2013, 07:20 |
|
#19 |
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,208
Rep Power: 26 |
it doesn't complain about something but doesn't send an email.
Code:
ehsan@Ehsan-com:~$ echo "Testing emailing functionality" | mail -s "Summary Report from the case $PWD" $MY_EMAIL_ADDRESS ehsan@Ehsan-com:~$
__________________
Injustice Anywhere is a Threat for Justice Everywhere.Martin Luther King. To Be or Not To Be,Thats the Question! The Only Stupid Question Is the One that Goes Unasked. |
|
September 7, 2013, 07:42 |
|
#20 |
Retired Super Moderator
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 10,975
Blog Entries: 45
Rep Power: 128 |
Well, the only way I could get it to send emails was to send them to the machine I'm working one, like this:
Code:
echo "Testing emailing functionality" | mail -s "Summary Report from the case $PWD" $USER@localhost Code:
__________________
|
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Gmsh] gmsh 2.6.0 conversion to OpenFoam 160 | rosswin | OpenFOAM Meshing & Mesh Conversion | 0 | March 5, 2013 07:34 |
OpenFOAM 1.6.x, 1.7.0 and 1.7.x are not fully prepared to work with gcc-4.5.x | wyldckat | OpenFOAM Bugs | 18 | October 21, 2010 05:51 |
OpenFOAM Message Board Email notification stopped working | mbeaudoin | OpenFOAM Bugs | 3 | January 8, 2009 22:08 |
Summer School on Numerical Modelling and OpenFOAM | hjasak | OpenFOAM | 5 | October 12, 2008 13:14 |
OpenFOAM Debian packaging current status problems and TODOs | oseen | OpenFOAM Installation | 9 | August 26, 2007 13:50 |