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

Shell script to handle Segmentation faults arising from execFlowFunctionObjects

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 22, 2015, 14:20
Lightbulb Shell script to handle Segmentation faults arising from execFlowFunctionObjects
  #1
Member
 
Pruthvi
Join Date: Feb 2014
Posts: 41
Rep Power: 12
pruthvi1991 is on a distinguished road
Hello foamers!

I frequently face segmentation faults and corrupted double linked list errors when using execFlowFunctionObjects for post processing. I get this error when I run cases with pmpleDyMFoam solver.

As a work around for this problem I wrote a simple shell script which will find out the time at which execFlowFunctionObjects crashed and makes it restart from that point. This is not an elegant way of fixing the problem but it works

The code is on github

Code:
#!/bin/bash

echo "This script will call execFlowFunctionObjects to integrate the pressure and viscous forces over the chosen patches. 
This function may take a few minutes to execute, please be patient. Make sure you entered the desired function object 
in system/controlDict. For Eg: #include "forceCoeffs" . If the function is commented this script will not work"

sleep 2

echo "Deleting log files from previous runs. You have 8 seconds to abort by holding ctrl-c"

sleep 8
#mkdir previous_data
rm log.forces # ./previous_data/
rm -r postProcessing # ./previous_data/

endTime=$(grep -w 'endTime' ./system/controlDict | grep '[0-9]' | sed 's/;//g' | awk '{print$2}')	# Gets endTime value from controlDict
intendTime=$(grep -w 'endTime' ./system/controlDict | grep '[0-9]' | sed 's/;//g' | awk '{print$2*1000}')       # Multiplying by 1000 to convert to integer in case endTime is float
writeTime=$(grep -w 'writeInterval' ./system/controlDict | grep '[0-9]' | sed 's/;//g' | awk '{print$2}') # Gets writeInterval from controlDict
execFlowFunctionObjects >> log.forces &		# Executes the function execFlowFunctionObjects and writes output to log.forces

sleep 15	# If there is no sleep time, bash proceeds to the next command before execFlowFunctionObjects is run. Increase this if your simulation is large

presentTime=$(tail -22 log.forces | grep Time | awk '{print$3}' | awk NR==1)	# Checks for many time steps the function ran and gets the last time value
intpresentTime=$(tail -22 log.forces | grep Time | awk '{print$3*1000}' | awk NR==1)	# Converting a possible float to integer

echo "endTime = $endTime, presentTime = $presentTime, Integer endTime = $intendTime, Integer presentTime = $intpresentTime, writeInterval = $writeTime"

echo "Entering Loop at $presentTime"

while [ $intpresentTime -lt $intendTime ];		# If the function failed to execute at some point this loop will make it start again
do
#	startTime=$(python -c print " $presentTime + $writeTime ")  # Finds time from which the function must start again
	startTime=$(echo "$presentTime+$writeTime" | bc)  # Finds time from which the function must start again
	echo "Crashed at $presentTime, re-starting from $startTime"
	execFlowFunctionObjects -time $startTime: >> log.forces &
	sleep 10	# Waits for 15 seconds before executing next command. This is necessary to ensure execFlowFunctionObjects is not re-run midway
	presentTime=$(tail -22 log.forces | grep Time | awk '{print$3}' | awk NR==1)
	echo $presentTime
	intpresentTime=$(tail -22 log.forces | grep Time | awk '{print$3*1000}' | awk NR==1)
done
		
echo "Finally reached $presentTime"
After the script is run, numerous force/ forceCoeffs files will be generated in the postProcessing directory. I wrote another script to merge them together and parse the data. Here is the github link.

Thanks,
Pruthvi.
pruthvi1991 is offline   Reply With Quote

Reply

Tags
corrupted list, execflowfunctionobjects, pimpledymfoam, post procesing, segmentation fault


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
OF-2.3.x: Get "latestTime" in a shell script? A_Pete OpenFOAM Programming & Development 4 September 29, 2020 04:19
paraView in shell mode (python script running) Prosiaczek OpenFOAM 2 March 19, 2012 07:54


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