This repository has been archived by the owner on Jun 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpPExtractWSSAverageNuUBlunted.sh
executable file
·77 lines (71 loc) · 2.98 KB
/
pPExtractWSSAverageNuUBlunted.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env bash
################################### REFERENCE ################################
#https://unix.stackexchange.com/a/588325/359467
#https://stackoverflow.com/a/61869488/9592557
################################# User_input #################################
#input directory names that need to be processed
STUDYNAME=Alg340kPaBluntedFlowRate
#example of FOLDER value: <PF127*/>
FOLDER=Alg_DP*/
#ouput filenames
WSSMATCH=lowerNozzleWall;#name of the patch to calculate WSS
FLUXMATCH=NONE;
PPWSS=pPWSS_$STUDYNAME;
PPFLUXOUTLET=pPfluxOutlet_$STUDYNAME;
PPAVGNUU=pPAvgNuU_$STUDYNAME;
cd $STUDYNAME || exit;
#############################################################################
# extract the maximum values of wallShearStress at the latest time
while IFS= read -r files; do
# echo $files;
awk -v WSSMATCH="$WSSMATCH" 'NR==FNR && $0 ~ WSSMATCH {LastLine=FNR; next;}
FNR==LastLine {gsub(/\(/,"",$0); gsub(/(\/.+)/,"",FILENAME);
magWSS=(($7**2+$8**2)**0.5)
print FILENAME"\t"$1"\t"$2"\t"magWSS}' "$files" "$files" \
>> $PPWSS.csv;
done < <(\
for d in $FOLDER; do find "$d" -type f -name 'wallShearStress.dat' ;
# -not -name 'wallShearStress.dat' | \
# sort -Vk2 -t.| tail -n 1;
done;)
printf \
"%s\n" $'0a\nMaterial_DP\tRs\tsimulationTime\tWSS_X\tWSS_Y\tmagnitudeWSS(Pa)' \
. x | ex -s $PPWSS.csv;
##############################################################################
# extract the Average values of nu & U from the postProcessing directory at
# all simulationTime
while IFS= read -r DIR; do
echo $DIR;
if [[ $DIR =~ flowRatePatch\(name=outlet\) ]]; then
# echo $'T\n'$dir;
awk 'NR==FNR{LastLine=FNR; next;}
FNR==LastLine {gsub(/\(/,"",$0); gsub(/(\/.+)/,"",FILENAME);
flowRateOut=($2*72*1e9);
print FILENAME"\t\t"$1"\t"$2"\t"flowRateOut}' "$DIR" "$DIR"\
>> $PPFLUXOUTLET.csv;
# elif [[ $DIR =~ flowRatePatch\(name=inlet\) ]]; then
# awk '
# $1 ~ /[0-9]/ && $0 != 0 {gsub(/\(/,"",$0); gsub(/(\/.+)/,"",FILENAME);
# flowRateIn=($2*72*1e9);
# print FILENAME"\t\t"$1"\t"$2"\t"flowRateIn}' "$DIR"
# #>> $pPfluxInlet_DP208.csv;
elif
[[ $DIR =~ \(name=outlet,U,nu\) ]]; then
awk 'NR==FNR{LastLine=FNR; next;}
FNR==LastLine {gsub(/\(|\)/,"",$0); gsub(/(\/.+)/,"",FILENAME);
magU=(($2**2+$3**2)**0.5);
print FILENAME"\t\t"$1"\t"$2"\t"$3"\t"$5"\t"magU}' "$DIR" "$DIR"\
>> $PPAVGNUU.csv;
fi;
done < <(\
for d in $FOLDER; do find "$d" -type f -name 'surfaceFieldValue.dat' \
# -not -name 'surfaceFieldValue.dat' | \
# sort -Vk2 -t.| tail -n 1;
done;) || exit;
printf "%s\n" 0a \
$'Material_DP\tRs\tsimulationTime\tflux(ms-1)\tflowRate(µLs-1)' \
. x | ex -s $PPFLUXOUTLET.csv;
printf "%s\n" 0a \
$'Material_DP\tRs\tsimulationTime\tavgUx(ms-1)\tavgUy(ms-1)\tavgNuOutlet(m2s-1)\tmagAvgUOutlet(ms-1)' \
. x | ex -s $PPAVGNUU.csv;
############################################################################