File size: 2,418 Bytes
5a600cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
cd "${0%/*}" || exit 1    # Run from this directory

# Source tutorial run functions
. "$WM_PROJECT_DIR/bin/tools/RunFunctions"

usage () {
    exec 1>&2
    while [ "$#" -ge 1 ]; do echo "$1"; shift; done
    cat <<USAGE

Usage: ${0##*/} [OPTIONS]
options:
  -d | -distort        distort the mesh
  -h | -help           help
  -p | -pBC <type>     set BC for p on the atmosphere patch
  -U | -UBC <type>     set BC for U on the atmosphere patch

CFD simulation to demonstrate boundary conditions at a patch with mixed inflow
and outflow. The user can set the boundary condition on the atmosphere patch
with options:
+ p: totalPressure (default) or fixedValue
+ U: pressureInletOutletVelocity (default) or zeroGradient

USAGE
    exit 1
}

distort () {
    wmake distortMesh
    runApplication distortMesh
    rm 0/meshPhi;
    mv 0/polyMesh/points constant/polyMesh
    rm -rf 0/polyMesh
}

setAtmosphereBC () {
    _field="$1"
    _BC="$2"

    echo "Setting $_field BC on atmosphere patch to $_BC"

    runApplication -a foamDictionary \
        -entry boundaryField/atmosphere/type \
        -set "$_BC" \
        "0/$_field" > /dev/null 2>&1
}

# VARIABLES
distort=""
pBC=""
UBC=""

# OPTIONS
while [ "$#" -gt 0 ]
do
    case "$1" in
    -d | -distort)
        distort="yes"
        shift
        ;;
    -h | -help)
        usage
        ;;
    -p | -pBC)
        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
        pBC="$2"
        shift 2
        ;;
    -U | -UBC)
        [ "$#" -ge 2 ] || usage "'$1' option requires an argument"
        UBC="$2"
        shift 2
        ;;
    -test)
        shift
        ;;
    -*)
        usage "Invalid option '$1'"
        ;;
    *)
        break
        ;;
    esac
done

case "$pBC" in
    totalPressure|fixedValue|"") ;;
    *)
      usage "Invalid boundary condition '$pBC' for p."\
            "Valid options: 'totalPressure', 'fixedValue'."
      ;;
esac

case "$UBC" in
    pressureInletOutletVelocity|zeroGradient|"") ;;
    *)
      usage "Invalid boundary condition '$UBC' for U."\
            "Valid options: 'pressureInletOutletVelocity', 'zeroGradient'."
      ;;
esac

runApplication blockMesh
[ "$distort" ] && distort
runApplication extrudeMesh

[ "$pBC" ] && setAtmosphereBC p "$pBC"
[ "$UBC" ] && setAtmosphereBC U "$UBC"

runApplication foamRun

#------------------------------------------------------------------------------