CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM Post-Processing

I want OpenFOAM to email me when it's done, is this too much to ask?!?

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree12Likes

Reply
 
LinkBack Thread Tools Display Modes
Old   May 12, 2013, 04:30
Talking I want OpenFOAM to email me when it's done, is this too much to ask?!?
  #1
Senior Member
 
JR22's Avatar
 
Jose Rey
Join Date: Oct 2012
Posts: 122
Rep Power: 8
JR22 will become famous soon enough
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.
immortality likes this.
JR22 is offline   Reply With Quote

Old   May 12, 2013, 06:45
Default
  #2
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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 mail application can be one of several. In my case, I use the package "bsd-mailx" on Ubuntu.

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
JR22 likes this.
wyldckat is offline   Reply With Quote

Old   May 12, 2013, 12:03
Default
  #3
Senior Member
 
Lieven
Join Date: Dec 2011
Location: Mol, Belgium
Posts: 295
Rep Power: 13
Lieven will become famous soon enough
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
to the run script...

Cheers,

L
wyldckat, romant, kiddmax and 1 others like this.
Lieven is offline   Reply With Quote

Old   May 13, 2013, 09:26
Default
  #4
Senior Member
 
Olivier
Join Date: Jun 2009
Location: France, grenoble
Posts: 235
Rep Power: 9
olivierG is on a distinguished road
hello,

You may also take a look at the function Object "systemCall", which should also work.

regards,
olivier
JR22 likes this.
olivierG is offline   Reply With Quote

Old   May 13, 2013, 17:30
Default
  #5
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
wyldckat is offline   Reply With Quote

Old   May 15, 2013, 17:45
Default
  #6
Assistant Moderator
 
Bernhard Gschaider
Join Date: Mar 2009
Posts: 3,912
Rep Power: 40
gschaider will become famous soon enoughgschaider will become famous soon enough
Quote:
Originally Posted by JR22 View Post
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.
The most failsafe method to get a message even if the run fails is to call the solver from wrapper-script. That script would capture the output of the run and mail the last 100 lines or so to you (like PBS somebody mentioned further down)

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
philippose, immortality and JR22 like this.
__________________
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
gschaider is offline   Reply With Quote

Old   August 30, 2013, 06:38
Default
  #7
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Quote:
Originally Posted by wyldckat View Post
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 mail application can be one of several. In my case, I use the package "bsd-mailx" on Ubuntu.

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
Hi Bruno
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?
Attached Files
File Type: gz runPlot.tar.gz (232 Bytes, 2 views)
__________________
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.
immortality is offline   Reply With Quote

Old   August 31, 2013, 12:24
Default
  #8
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Hi Ehsan,

Quote:
Originally Posted by immortality View Post
I use a script that have set its address in bashrc,how to add this code to that script?
Replace:
Code:
yourname@email.address
with your variable, such as:
Code:
$MY_EMAIL_ADDRESS
I'm assuming of course that you are talking about "~/.bashrc" and that you have a line like this inside it:
Code:
export MY_EMAIL_ADDRESS=yourname@email.address
Quote:
Originally Posted by immortality View Post
and how to use bsd-mailx?
Code:
sudo apt-get install bsd-mailx
Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   September 4, 2013, 07:28
Default
  #9
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
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
but sending email didn't performed,but this error:
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
what files should be use instead of log files?

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.
immortality is offline   Reply With Quote

Old   September 4, 2013, 15:01
Default
  #10
Member
 
Pete Bachant
Join Date: Jun 2012
Location: NH, USA
Posts: 89
Rep Power: 5
pbachant is on a distinguished road
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."
immortality likes this.
pbachant is offline   Reply With Quote

Old   September 4, 2013, 15:48
Default
  #11
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   September 4, 2013, 15:52
Default
  #12
Member
 
Pete Bachant
Join Date: Jun 2012
Location: NH, USA
Posts: 89
Rep Power: 5
pbachant is on a distinguished road
Quote:
Originally Posted by immortality View Post
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
You essentially need to find your mobile provider's SMS gateway and send an email there. First figure out how to send an SMS to your phone via email, and adapt the code to send to that email address. Here's a Wikipedia article that may help:

http://en.wikipedia.org/wiki/List_of_SMS_gateways
pbachant is offline   Reply With Quote

Old   September 4, 2013, 16:13
Default
  #13
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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 "getApplication" function only works when the "RunFunctions" script is sourced.
The "runApplication" function will run the application indicated by "getApplication" and will automatically log the output inside the file "log.$application".

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   September 4, 2013, 16:43
Default
  #14
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   September 4, 2013, 16:48
Default
  #15
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
But... it's so simple to look at the code, compare with what I wrote, and fix it yourself!!
Instead of this:
Quote:
Originally Posted by immortality View Post
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
Use this:
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
See? It's simple!
immortality likes this.
wyldckat is offline   Reply With Quote

Old   September 4, 2013, 17:15
Default
  #16
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   September 4, 2013, 17:24
Default
  #17
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
Dear Bruno I performed a quick run while I've added this to .bashrc:
Code:
export MY_EMAIL_ADDRESS=force.of.love@gmail.com
and the message is happy:
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
but OpenFOAM hasn't sent me an email!
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.
immortality is offline   Reply With Quote

Old   September 7, 2013, 07:07
Default
  #18
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
If this doesn't work, then you should ask about this specific problem elsewhere, since this isn't a problem specific to OpenFOAM related software, nor CFD related .

Best regards,
Bruno
wyldckat is offline   Reply With Quote

Old   September 7, 2013, 07:20
Default
  #19
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16
immortality is on a distinguished road
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.
immortality is offline   Reply With Quote

Old   September 7, 2013, 07:42
Default
  #20
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 8,253
Blog Entries: 34
Rep Power: 84
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
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
Then the emails can be read by running:
Code:
mail
Anything else beyond this is clearly beyond the scope of this forum .
wyldckat is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
gmsh 2.6.0 conversion to OpenFoam 160 rosswin Open Source Meshers: Gmsh, Netgen, CGNS, ... 0 March 5, 2013 08: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 23: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


All times are GMT -4. The time now is 00:03.