-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboundary_conditions.odin
83 lines (75 loc) · 1.66 KB
/
boundary_conditions.odin
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
package pps
/* dirichlet */
perfect_conductor :: proc(phi: ^Grid) {
phi[0] = 0
phi[gsy-1] = 0
#no_bounds_check for row in 1..<gsy-1 {
phi[row][0] = 0
phi[row][gsx-1] = 0
}
}
charged_plate_on_top :: proc(phi: ^Grid) {
phi[0] = 10 /* potential */
phi[gsy-1] = 0
#no_bounds_check for row in 1..<gsy-1 {
phi[row][0] = 0
phi[row][gsx-1] = 0
}
}
two_charged_plates :: proc(phi: ^Grid) {
phi[0] = 10 /* potential */
phi[gsy-1] = 10
#no_bounds_check for row in 1..<gsy-1 {
phi[row][0] = 0
phi[row][gsx-1] = 0
}
}
/* Von Neumann */
no_outflow :: proc(phi: ^Grid) {
phi[0] = phi[1]
phi[gsy-1] = phi[gsy-2]
#no_bounds_check for row in 1..<gsy-1 {
phi[row][0] = phi[row][1]
phi[row][gsx-1] = phi[row][gsx-2]
}
}
flow_from_top_to_bottom :: proc(phi: ^Grid) {
phi[0] = 20
phi[gsy-1] = 0
#no_bounds_check for row in 1..<gsy-1 {
phi[row][0] = phi[row][1]
phi[row][gsx-1] = phi[row][gsx-2]
}
}
flow_from_topleft_to_bottomright :: proc(phi: ^Grid) {
phi[0] = phi[1]
phi[gsy-1] = phi[gsy-2]
#no_bounds_check for row in 1..<(gsy/2) {
phi[row][0] = ds*3
phi[row][gsx-1] = phi[row][gsx-2]
}
#no_bounds_check for row in (gsy/2)..<(gsy-1) {
phi[row][0] = phi[row][1]
phi[row][gsx-1] = -ds*3
}
}
no_flow_from_topleft_to_bottomright :: proc(phi: ^Grid) {
phi[0] = 0
phi[gsy-1] = 0
#no_bounds_check for row in 1..<(gsy/2) {
phi[row][0] = phi[row][1]
phi[row][gsx-1] = -ds*3
}
#no_bounds_check for row in (gsy/2)..<(gsy-1) {
phi[row][0] = -ds*3
phi[row][gsx-1] = phi[row][gsx-2]
}
}
no_flow_left_to_right :: proc(phi: ^Grid) {
phi[0] = phi[1]
phi[gsy-1] = phi[gsy-2]
#no_bounds_check for row in 1..<gsy-1 {
phi[row][0] = 0
phi[row][gsx-1] = 0
}
}