|
4 | 4 |
|
5 | 5 | runs AFEM loop for stochastic Poisson problem |
6 | 6 | |
7 | | -main usage: |
| 7 | +usage: |
8 | 8 | - run experiment: run(; problem = problem, kwargs...) |
9 | 9 | - load results : show_results(; kwargs...) |
10 | 10 | - produce plots : produce_plots(; kwargs...) |
@@ -78,6 +78,42 @@ default_args = Dict( |
78 | 78 | ) |
79 | 79 |
|
80 | 80 |
|
| 81 | +## that is the main function to run and save results |
| 82 | +function run(; force = false, kwargs...) |
| 83 | + data = deepcopy(default_args) |
| 84 | + |
| 85 | + for (k, v) in kwargs |
| 86 | + data[String(k)] = v |
| 87 | + end |
| 88 | + Plotter = data["Plotter"] |
| 89 | + |
| 90 | + ## load/produce data |
| 91 | + data, ~ = produce_or_load(_main, data, filename = filename, force = force) |
| 92 | + |
| 93 | + ## plot final solution |
| 94 | + results = data["results"] |
| 95 | + sol = data["solution"] |
| 96 | + multi_indices = data["multi_indices"] |
| 97 | + repair_grid!(sol.FES_space[1].xgrid) |
| 98 | + if Plotter === nothing |
| 99 | + for j in 1:num_multiindices(sol) |
| 100 | + @show extrema(view(sol[j])) |
| 101 | + println(stdout, unicode_scalarplot(sol[j]; title = "MI $(multi_indices[j])")) |
| 102 | + end |
| 103 | + else |
| 104 | + plot_modes(sol; Plotter = Plotter, ncols = 4) |
| 105 | + end |
| 106 | + |
| 107 | + @info "final multi_indices = " |
| 108 | + for m in multi_indices |
| 109 | + println("$m") |
| 110 | + end |
| 111 | + @show results |
| 112 | + return data |
| 113 | +end |
| 114 | + |
| 115 | + |
| 116 | +# loads (or produces) a result file and prints the data |
81 | 117 | function show_results(; force = false, mode_history_up_to_level = 15, kwargs...) |
82 | 118 | data = deepcopy(default_args) |
83 | 119 |
|
@@ -113,8 +149,9 @@ function show_results(; force = false, mode_history_up_to_level = 15, kwargs...) |
113 | 149 | return data |
114 | 150 | end |
115 | 151 |
|
116 | | - |
117 | | -function main( |
| 152 | +# the main AFEM loop for the given problem and data |
| 153 | +# (this function does not check for existing results, better use run !) |
| 154 | +function _main( |
118 | 155 | data = nothing; |
119 | 156 | debug = false, |
120 | 157 | plot_solution = false, |
@@ -396,40 +433,6 @@ function main( |
396 | 433 | end |
397 | 434 |
|
398 | 435 |
|
399 | | -function run(; force = false, kwargs...) |
400 | | - data = deepcopy(default_args) |
401 | | - |
402 | | - for (k, v) in kwargs |
403 | | - data[String(k)] = v |
404 | | - end |
405 | | - Plotter = data["Plotter"] |
406 | | - |
407 | | - ## load/produce data |
408 | | - data, ~ = produce_or_load(main, data, filename = filename, force = force) |
409 | | - |
410 | | - ## plot final solution |
411 | | - results = data["results"] |
412 | | - sol = data["solution"] |
413 | | - multi_indices = data["multi_indices"] |
414 | | - repair_grid!(sol.FES_space[1].xgrid) |
415 | | - if Plotter === nothing |
416 | | - for j in 1:num_multiindices(sol) |
417 | | - @show extrema(view(sol[j])) |
418 | | - println(stdout, unicode_scalarplot(sol[j]; title = "MI $(multi_indices[j])")) |
419 | | - end |
420 | | - else |
421 | | - plot_modes(sol; Plotter = Plotter, ncols = 4) |
422 | | - end |
423 | | - |
424 | | - @info "final multi_indices = " |
425 | | - for m in multi_indices |
426 | | - println("$m") |
427 | | - end |
428 | | - @show results |
429 | | - return data |
430 | | -end |
431 | | - |
432 | | - |
433 | 436 | function produce_plots(; |
434 | 437 | order = default_args["order"], |
435 | 438 | decay = default_args["decay"], |
|
0 commit comments