2 # This script reads the log file then extracts result data and
3 # plots relation graphs in MoFEM fracture module.
4 # Plot setttings can be changed by modifying the gnuplot script get_graphs.gnu
11 # displacement_loadFactor_crackArea_energy.csv
14 if [[ "$1" == "-h" || "$1" == "--help" ]]; then
15 echo 'Plotting script for MoFEM Fracture Module
17 plotting_data.sh Create and open graphs from log file
18 plotting_data.sh -s Create only, do not open graphs. Silent
19 plotting_data.sh -d Delete all output files of non-converged steps
20 plotting_data.sh -d out_skin Delete out_skin* files of non-converged steps
25 # Create raw data file of displacement - loadFactor - crack area - energy
26 # from log file (append 'TODELETE' to end of line with 'Not Converged')
27 grep -E "(Propagation step|F_lambda2|Crack surface area)" log | \
28 perl -pe 's/\e\[[0-9;]*m//g' | \
29 awk '{$1=""; $2=""; sub(" ", " "); print}' | awk '{$1=$1;print}' | \
30 sed 'N; s/\nCrack//;P;D'| sed '/Not Converged/ s/$/ TODELETE/' | \
31 sed 's/Not Converged //g'| \
32 awk 'BEGIN {print "-1 0 0 0 0 0"} /F_lambda2 / { lambda = $NF } \
33 /Propagation step/ { F=lambda; print $3 "\t" 2*$9/F "\t" F "\t" $13 "\t" $9 "\t" $NF}'| \
36 # Keep unique updated data only (in case of restart from previous steps)
37 cat data_raw.dat | sed '1!G;h;$!d' | sort -u -n | tee unique_analysis_steps.dat
39 # Remove unused last column data 'TODELETE', and write to a text file
40 cat unique_analysis_steps.dat | grep -v "TODELETE" | \
41 sed 's/[[:space:]]\{1,\}[^[:space:]]\{1,\}$//' | \
42 tee displacement_loadFactor_crackArea_energy.txt
45 printf "%14s %14s %14s %14s %14s\n" \
46 $(cat displacement_loadFactor_crackArea_energy.txt) > temp_file; \
47 mv temp_file displacement_loadFactor_crackArea_energy.txt
50 awk '{print $1","$2","$3","$4","$5}' displacement_loadFactor_crackArea_energy.txt| \
51 tee displacement_loadFactor_crackArea_energy.csv
53 # Print final data file to console
54 cat displacement_loadFactor_crackArea_energy.txt
57 rm displacement_loadFactor_crackArea_energy.txt
59 # Make graphs using gnuplot. Note: ignore the first row of zeros when plotting
61 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
62 gnuplot -e "load '$DIR/get_graphs.gnu'; quit"
64 # Convert graphs on .ps to .pdf
65 for i in `ls *.ps`; do
68 # echo 'Converted $i into pdf, deleted original file.';
71 # Delete output files of non-converged steps if '-d' option is used
72 if [[ $1 = "-d" ]]; then
73 echo -e "\nDeleting output files $2* associated with non-converged steps"
74 cat unique_analysis_steps.dat | grep TODELETE | awk '{print $1}' | \
75 tee non_converged_steps.txt
77 # echo "Non-converged step: $p"
79 done <non_converged_steps.txt
86 if [[ ${machine} = "Darwin" && "$1" != "-s" ]]
88 # echo "This is a Mac computer"
91 echo "PDF graphs are ready to open."
94 # Remove unnecessary files