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

Auto restart of crashing simulations in OpenFOAM

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 1, 2017, 07:36
Default Auto restart of crashing simulations in OpenFOAM
  #1
New Member
 
Vijaya Kumar. G
Join Date: Jun 2016
Location: Chennai, India & Aachen, Germany
Posts: 20
Rep Power: 10
VIJAYA KUMAR is on a distinguished road
I use 'chtMultiRegionFoam' solver on a big geometry (60 m3). Sometimes the solver crashes with 'Floating point Exception error' during parallel run (mpirun). But when I restart the same, the simulation run continues without any issue. This is definitely not a case of diverging solution, as I have good pretty good match with experimental data.

This problem becomes a nuisance because I cannot give a simulation to a HPC and just relax for a day or two, the simulation would have broken down in between resulting in idle time of HPC.

I then decided to use a python script, which itself kills a process every 1 hour and then restarts it. By this way I can restrict the idle time of the systems.

python script: cycle.py
# Start of script
#!/usr/bin/env python3
import subprocess
import time
import sys

force = False
args = sys.argv[1:]; app = args[0].replace("'", "")
proc = app.split()[0].split("/")[-1]
cycle = int(args[1])*60; run = int(args[2])*60

try:
if args[3] == "force":
force = True
except IndexError:
pass

def get_pid(proc_name):
try:
return subprocess.check_output(
["pgrep", proc_name]
).decode("utf-8").strip()
except subprocess.CalledProcessError:
pass

def kill(pid, force):
if force == False:
subprocess.Popen(["kill", "-s", "TERM", pid])
elif force == True:
subprocess.Popen(["kill", pid])

while True:
subprocess.Popen(["/bin/bash", "-c", app])
time.sleep(run)
pid = get_pid(proc)
if pid != None:
kill(pid, force)
time.sleep(cycle - run)
#End of script

The script works with python3 and the command is as follows
python3 <script> <command_to_run_application> <cycle_time> <application_run_time>

<script> - Name of the python script
<command_to_run_application> - chtMultiRegionFoam (or any solver)
<cycle_time> - Periodic interval for restart
<application_run_time> - Time till which the application runs



I have tested the script with 'firefox' browser and it does the intended job. But when I tried this script with OpenFOAM it is restarting as specified by <cycle_time> but it is not killing the process as specified by the <application_run_time>. Which means the new process starts wihtout closing the old one.

I suppose this has to do something with the 'controlDict'. The application run time is dictated by the 'contolDict' file which overrides the application run time given in the python script.

Any help would be welcome.


Regards
Vijaya Kumar G
Ph.D Student
IIT Madras
India
VIJAYA KUMAR is offline   Reply With Quote

Reply

Tags
auto restart after crash., chtmultiregionfoam, openfoam 4.0, simulation crash


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
Simulations are not converging in OpenFOAM for many elements (more than 1 000 000) silvai OpenFOAM Running, Solving & CFD 6 April 3, 2017 09:33
OpenFOAM Training: Programming CFD Course 12-13 and 19-20 April 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 January 14, 2016 11:19
OpenFOAM v3.0.1 Training, London, Houston, Berlin, Jan-Mar 2016 cfd.direct OpenFOAM Announcements from Other Sources 0 January 5, 2016 04:18
Suggestion for a new sub-forum at OpenFOAM's Forum wyldckat Site Help, Feedback & Discussions 20 October 28, 2014 10:04
OpenFOAM Training and Workshop Zagreb 2628Jan2006 hjasak OpenFOAM 1 February 2, 2006 22:07


All times are GMT -4. The time now is 17:13.