-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiteration_conditions.odin
More file actions
56 lines (52 loc) · 1.52 KB
/
Copy pathiteration_conditions.odin
File metadata and controls
56 lines (52 loc) · 1.52 KB
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
package pps
simplest_iter_condition :: proc(phi: ^Grid, i: int) -> bool {
iteration_limit :: 3000
return i < iteration_limit
}
settable_iteration_limit := 0
settable_iter_condition :: proc(phi: ^Grid, i: int) -> bool {
return i < settable_iteration_limit
}
conv_prev_phi: ^Grid
conv_first := true
convergence_iter_condition :: proc(phi: ^Grid, i: int) -> bool {
err_target :: 1e-6
iteration_limit :: 10_000_000
if conv_first {
conv_prev_phi = new(Grid) if conv_prev_phi == nil else conv_prev_phi
copy(conv_prev_phi[:], phi[:])
conv_first = false
return true
}
max_err := float(0)
#no_bounds_check for row in 0..<gsy do for col in 0..<gsx {
max_err = max(max_err, abs(conv_prev_phi[row][col] - phi[row][col]))
}
copy(conv_prev_phi[:], phi[:])
condition := i > iteration_limit || max_err > err_target
if !condition do conv_first = true
return condition
}
et_prev_phi: ^Grid
et_first := true
et_errors := make([dynamic]float)
errortracking_iter_condition :: proc(phi: ^Grid, i: int) -> bool {
err_target :: 1e-6
iteration_limit :: 10_000_000
if et_first {
et_prev_phi = new(Grid) if et_prev_phi == nil else et_prev_phi
copy(et_prev_phi[:], phi[:])
clear(&et_errors)
et_first = false
return true
}
max_err := float(0)
#no_bounds_check for row in 0..<gsy do for col in 0..<gsx {
max_err = max(max_err, abs(et_prev_phi[row][col] - phi[row][col]))
}
copy(et_prev_phi[:], phi[:])
append(&et_errors, max_err)
condition := i > iteration_limit || max_err > err_target
if !condition do et_first = true
return condition
}