|
1 | 1 | # Preprocessing and postprocessing tools
|
2 | 2 |
|
3 | 3 | This directory contains a collection of helpful preprocessing and
|
4 |
| -postprocessing utilities. |
5 |
| - |
6 |
| -## Preprocessing scripts |
7 |
| - |
8 |
| -### naluwind2amrwind.py |
9 |
| -The [naluwind2amrwind.py](naluwind2amrwind.py) python script allows you to |
10 |
| -convert a Nalu-wind input file to an amr-wind input file. To the best of |
11 |
| -its ability, it will try to take the parameters from Nalu-wind and map them |
12 |
| -to amr-wind. |
13 |
| - |
14 |
| -The basic usage is given by: |
15 |
| -```bash |
16 |
| -usage: naluwind2amrwind.py [-h] [--outfile OUTFILE] yamlfile |
17 |
| - |
18 |
| -Convert Nalu-Wind input file to AMR-wind input file |
19 |
| - |
20 |
| -positional arguments: |
21 |
| - yamlfile |
22 |
| - |
23 |
| -optional arguments: |
24 |
| - -h, --help show this help message and exit |
25 |
| - --outfile OUTFILE write output to this file |
26 |
| -``` |
27 |
| - |
28 |
| -For instance, to convert the Nalu-wind input file `naluwind.yaml`, run |
29 |
| -```bash |
30 |
| -$ ./naluwind2amrwind.py naluwind.yaml |
31 |
| - |
32 |
| -#---------------------------------------# |
33 |
| -# SIMULATION STOP # |
34 |
| -#---------------------------------------# |
35 |
| -time.stop_time = 20000.0 # Max (simulated) time to evolve |
36 |
| -time.max_step = 40000 # Max number of time steps |
37 |
| - |
38 |
| -#---------------------------------------# |
39 |
| -# TIME STEP COMPUTATION # |
40 |
| -#---------------------------------------# |
41 |
| -time.fixed_dt = 0.5 # Use this constant dt if > 0 |
42 |
| -time.cfl = 0.95 # CFL factor |
43 |
| - |
44 |
| -#---------------------------------------# |
45 |
| -# INPUT AND OUTPUT # |
46 |
| -#---------------------------------------# |
47 |
| -time.plot_interval = 1000 # Steps between plot files |
48 |
| -time.checkpoint_interval = 1000 # Steps between checkpoint files |
49 |
| - |
50 |
| -[...snip...] |
51 |
| -``` |
52 |
| -Use the `--outfile` option to write the output to a file instead. Note |
53 |
| -that the `nalu_abl_mesh` and `nalu_preprocess` section should be present |
54 |
| -in the yaml file for it to correctly extract the geometry and the |
55 |
| -inversion layer properties. |
56 |
| - |
57 |
| -## Postprocessing scripts |
58 |
| - |
59 |
| -### postproamrwind.py |
60 |
| - |
61 |
| -The [postproamrwind.py](postproamrwind.py) python provides a quick |
62 |
| -method to time-average and extract data from the `line_plot.txt` |
63 |
| -output. |
64 |
| - |
65 |
| -The major functions in this code are: |
66 |
| -- `loadfile(filename, t1, t2, headerinfo=[])`: Loads the line_plot.txt |
67 |
| - file given by `filename`, for all times between `t1` and `t2`. |
68 |
| -- `timeaverage(dat, t1, t2, Ncells, Ncomp)`: Time averages the |
69 |
| - line_plot data given by `dat`, between times `t1` and `t2`. |
70 |
| -- `avglineplot(filename, t1,t2, headerinfo=[])`: Combines `loadfile()` |
71 |
| - and `timeaverage()`, so it loads the line_plot.txt given by |
72 |
| - `filename`, and averages it between `t1` and `t2`. |
73 |
| -- `extractvars(dat, colheaders, varnames)`: Returns the variable(s) |
74 |
| - matching the variables in varnames |
75 |
| - |
76 |
| -A short example of how to use the code is shown below. In this case, |
77 |
| -we load the `line_plot.txt` file, average from 0 to 100 seconds, and |
78 |
| -plot the averaged U velocity versus z. |
79 |
| - |
80 |
| -```python |
81 |
| -import postproamrwind |
82 |
| -import matplotlib.pylot as plt |
83 |
| -avgdat, headers = postproamrwind.avglineplot('line_plot.txt',0,100) |
84 |
| -amrvars = postproamrwind.extractvars(avgdat, headers, ['z','u_avg']) |
85 |
| -plt.plot(amrvars['u_avg'], amrvars['z']) |
86 |
| -plt.show() |
87 |
| -``` |
| 4 | +postprocessing utilities. Please consult the documentation more information, |
| 5 | +including a brief summary of each one. The source code for tools written in C++ is |
| 6 | +in the utilities directory. These are compiled with AMR-Wind, and their executables |
| 7 | +are written to folders in the same build directory. |
0 commit comments