-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resizing guard celss #78
Comments
Yes, this does seem wrong. The 'new coordinates' ought to be rescaled based on the interval than includes the grid points (not guard points) and 1/2 a grid spacing on either side. Also, this part is not needed any more as Lines 148 to 154 in 1cb6d08
|
I agree with the statement " The 'new coordinates' ought to be rescaled based on the interval than includes the grid points (not guard points)" but I do not understand "and 1/2 a grid spacing on either side" |
Notionally the grid points are in the centre of a cell, which touches the grid on a neighbouring processor (or a physical boundary) at a 'cell face' half way between the adjacent grid points. |
I see, but this is not an issue if I have a single BOUT.restart.0.nc file (1 processor for the all simulation) right? |
Even with one file it's the same thing. Boundary conditions are applied at 'cell faces' so to keep the physical size of your simulation the same, you need to account for the half-grid-spacing distance between the first/last grid point and the 'boundary'. |
I think though this is not an issue with the "nearest" interpolation algorithm as it does not use the co-ordinates? The "linear" method does not work, it yield NaN values. I will try fix this. But what about if I have two guard cells in the x-direction. I assume the second guard cell is now at the next cell face, i.e. a distance dx away from the location of the first guard cell or 2dx? |
Let me try to ASCII-art this...
The distance between adjacent grid points Zooming in near the physical boundary, just to show that the distance between each grid/guard point and the nearest cell face is 0.5*dx
The physical x-coordinate runs between the 'physical domain boundaries' Edited to add: maybe it would be helpful to add, if we took some normalised coordinate X covering the whole domain, we could say X=0 at the left physical boundary and X=1 at the right physical boundary. Then the left-most grid point would be at X=0.5/nx, the next point at X=1.5/nx, etc. The guard points would correspondingly be at X<0 or X>1. |
Just to clarify, is the physical boundary domain Also suppose I specify |
No The z-coordinate is special case as it is always (at least for the moment...) periodic. What did you mean by 'BOUT++ outputs the z-coordinate |
Yeah, sorry. I meant xBOUT.
I would also think it does not matter when looking at a single resolution simulation. But if I am for example doubling the resolution we should preserve the relative position of the grid points between the coarse and the fine resolution. What about the x-coordinate instead? The co-ordinate is at the cell centre correct? |
If you're implementing it can do what you want it to do, just needs documenting what the function does. If someone wants a different implementation in future then they can add an option...
What do you mean? A coordinate is not a thing at a point, it's a continuous thing (not sure what word to use instead of 'thing' - 'property of the space' maybe?). |
Sorry I meant the x grid points. I would like to understand if I double the resolution where are the new grid points placed relative to the old grid points. I would think it would be something like this: Suppose I specify |
Right, yes the grid points are at cell centres (variables can also be defined on staggered grids in BOUT++ but it's fine to ignore that - xBOUT still doesn't have any support for staggered grids). Your example of x-coordinate values of grid points when changing |
But BOUT must create a set of z-values in order to evaluate an initial condition that we specify in |
Ah, the expressions in To answer your question anyway: yes, as you suspected the |
Right, whereas for |
Unfortunately I think the documentation is actually wrong at the moment (going to make a PR to fix this now!)... The |
...hang on, I was checking in order to update the documentation and I'm not sure this is actually true... |
What I wrote above was correct, panic over! I confused myself looking at the output of a test simulation because the boundary points were set by a Neumann boundary condition, so did not contain the negative or >1 values that I'd expected... |
Is there any chance you could point me to where it does this in the code? I would like to convince myself of this too and in particular how BOUT treats non-periodic x and z differently |
If we have |
With 0-value Dirichlet boundary conditions, the first boundary point will be as you say the negative of the first grid point. The second boundary point though should be an extrapolated value (using cubic polynomial interpolation from the first boundary cell and first 2 grid cells). Keeping those boundary cells should be the most consistent/accurate thing to do. Setting the boundary cells to 0 in the input would result in the first one or two grid points having values larger (assuming the input values are positive on the grid points) than they should be in the output - the output would be (more or less) as if you imposed a Dirichlet boundary condition at a location a bit to the left of the actual left boundary (i.e. at the location of the first boundary cell in the input grid). |
I see so I should be fine by keeping the boundary/guard cells and every grid/guard point is a distance |
No, just need to have a consistent definition of the coordinate values at the grid points (as in your comment above #78 (comment)). |
In the boutdata.restart.resize method one can pass in the number of guard cells as argument
boutdata/boutdata/restart.py
Lines 107 to 108 in 1cb6d08
but nothing is done with them in the remaining of the code. It seems that you are resizing guard cells but guard cells should simply be pointing to adjacent grids edges and this not done in the code. What happens when we restart the simulations?
To me, it seems the safest route using this method is to resize a single restart file. In other words, one has to first create a unique restart file from the simulation (BOUT.restart.0.nc) and resize that. Multiple restart files can be created after the resizing method if needed. You should add a warning to users.
The text was updated successfully, but these errors were encountered: