Open rybchuk opened 3 days ago
Hi @rybchuk thanks (as always) for the detailed bug report. I would think this isn't due to my recent changes to the boundary planes (that was all native format stuff) but who knows... I will look into it.
I appreciate it, thanks man!
Ok I think I figured it out (?).
This is what your grid looks like at 320 320 240. Notice that dark band? That's level 1 and it is not starting at the bottom of the boundary because your refinement looks like:
1
1
0.0 0.0 100.0 1000.0 1000.0 150.0
If I switch your static box to
1
1
0.0 0.0 0.0 1000.0 1000.0 150.0
then it has no problem writing the netcdf file. Here's the grid:
So why does it work with a lower resolution? It is because you get lucky and it is so coarse that it ends up putting cells all the way down to the bottom of the boundary (due to magic of n_error_buf, grid sizing, etc).
Basically, netcdf does not support having refinement zones that don't start at the bottom. This is due to a indexing thing. It uses the amrex indices for the netcdf buffers writes. When it has a zone that is in the middle of the domain, it starts counting up there and then it hits the "exceeds bounds" error you were seeing (or would have seen on a debug build). We would need to compute an offset to allow for this. I will add documentation that the netcdf path does not allow this. But the native path does.
Did you intend to refine not starting at the bottom? Maybe you did because of the ocean? How bad would it be for your to use the native format? With the new viz thing you might be able to use standard tools to load the data. This is what the boundary plane looks like with the refinement in the middle:
Ahhh okay, thanks for the thorough analysis!
Yeah this scenario popped up because of some offshore ABL work that I'm doing, so I intentionally offset the refinement zone from z=0. My teammate plans to generate multi-level BC data with a machine learning algorithm, and it's my responsibility to get that data into a format that AMR-Wind can read. At this point, it's fairly straightforward for me to take single-level numpy data and reformat it into a netCDF file that AMR-Wind can read. The easiest approach would have been to extend that to multi-level data.
How difficult would it be to add a feature that computes that offset? The other alternative would be for me to put together code that translates from numpy data --> AMReX native BC data, which seems possible but heinous.
Ok cool, thanks for the context. Yeah getting that numpy data into the native format might be a bit painful. Maybe pyamrex would make it easy?
Given that I haven't looked at that bit of code in forever... I can't answer your question. I will dig around ;)
Thanks yeah, let me know. If modifying the netCDF code is too painful, this native writer could be a timely project for me while Kestrel is down next week.
Bug description
I have a simulation with a refinement zone that touches the boundary, and I am write to write out the BCs for this simulation to netCDF, but it's failing. Marc pointed out that there's a regression test that does the same thing, but it succeeds. If I make some reasonable modifications, the simulation fails with the following message:
Here is the
diff
onabl.i
:I've also changed out
static_box.txt
:Side note: It looks weird to me that the original
static_box.txt
has refinement zones that start atx=-100
even thoughxlo=0
in these simulations.Other notes
amr.n_cell = 320 320 240
toamr.n_cell = 48 48 48
, the simulation runs fineABL.bndry_output_format = native
, the simulation runs fineamr.max_level = 0
, the simulation runs finestatic_box.txt
, the simulation runs fineSteps to reproduce
Steps to reproduce the behavior:
Compiler used
Operating system
Hardware:
Machine details (): Kestrel
Input file attachments failed_reg_test.zip
Error (paste or attach): See
fail1.log
in the ZIPIf this is a segfault, a stack trace from a debug build (paste or attach): This looks like a netCDF error?
Expected behavior
The simulation should not crash and should write out a boundary condition file in the netCDF format
AMR-Wind information