CliMA / Oceananigans.jl

🌊 Julia software for fast, friendly, flexible, ocean-flavored fluid dynamics on CPUs and GPUs
https://clima.github.io/OceananigansDocumentation/stable
MIT License
999 stars 196 forks source link

Should the location of the cell center in stretched cells be half way between the faces? #491

Closed ali-ramadhan closed 4 years ago

ali-ramadhan commented 5 years ago

Title sounds ridiculous but @jm-c mentioned that for stretched grids, models (e.g. WRF) usually place the cell center halfway between the two cell faces, but apparently this choice can be relaxed so that you can specify cell centers to be slightly offset from the true center.

I guess they won't be "cell centers" anymore, but just opening an issue in case there's anything to discuss.

Without assuming cell centers are halfway between the two faces then interpolation operators are a bit more complicated

@inline ℑz_aac(i, j, k, grid::VerticallyStretchedCartesianGrid, f) =
    @inbounds ((grid.zC[k] - grid.zF[k]) * f[k, j, i] + (grid.zF[k+1] - grid.zC[k]) * f[k+1, j, i]) / grid.ΔzF[k]

and if we assume e.g. grid.zC[k] - grid.zF[k] = grid.ΔzF[k]/2 then the interpolation operators simplify.

So it seems maybe we should just assume that the cell centers are exactly halfway between the faces, unless there's a good reason or important use case for having custom/offset cell center locations.

johncmarshall54 commented 5 years ago

why wouldn't they be just defined at cell centers? Suggest make that assumption. John

On Mon, Oct 21, 2019 at 2:29 PM Ali Ramadhan notifications@github.com wrote:

Title sounds ridiculous but @jm-c https://github.com/jm-c mentioned that for stretched grids, models (e.g. WRF) usually place the cell center halfway between the two cell faces, but some models relax this choice so that you can specify cell centers to be slightly offset from the true center.

I guess they won't be "cell centers" anymore, but just opening an issue in case there's anything to discuss.

Without assuming cell centers are halfway between the two faces then interpolation operators are a bit more complicated

@inline ℑz_aac(i, j, k, grid::VerticallyStretchedCartesianGrid, f) =

@inbounds ((grid.zC[k] - grid.zF[k]) * f[k, j, i] + (grid.zF[k+1] - grid.zC[k]) * f[k+1, j, i]) / grid.ΔzF[k]

and if we assume e.g. grid.zC[k] - grid.zF[k] = grid.ΔzF[k]/2 then the interpolation operators simplify.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/climate-machine/Oceananigans.jl/issues/491?email_source=notifications&email_token=AKXUEQROF3YBCYTVKZUUNMLQPXYINA5CNFSM4JDC6IX2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4HTI3OWQ, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXUEQQAZQL25R7ZQ4S7J63QPXYINANCNFSM4JDC6IXQ .

--

John Marshall Cecil and Ida Green Professor of Oceanography Massachusetts Institute of Technology http://oceans.mit.edu/JohnMarshall/

ali-ramadhan commented 5 years ago

@johncmarshall54 I agree that makes the most sense. Was just curious about something @jm-c said.

Apparently he was mostly referring to the binary choice between having cell centers be exactly halfway between the cell faces, or having the faces be exactly halfway between the cell "centers".

In general, he says that having custom/offset locations is generally a bad idea, although it has been implemented in MITgcm.

He linked to a couple of older papers where they discuss this:

  1. Yin & Fung (1991). Net diffusivity in ocean general circulation models with nonuniform grids, JGR Oceans 96(C6), 10773-76.
  2. Marti et al. (1992). Comment [on “Net diffusivity in ocean general circulation models with nonuniform grids” by F. L. Yin and I. Y. Fung], JGR Oceans 97(C8), 12763-66.

I'll have a quick look but I agree just having cell centers be halfway between cell faces seems very sensible.

glwagner commented 5 years ago

Is the idea that there is some kind of compromise with putting the u-points at the "center" of the u control volumes, versus putting the tracer points at the center of the tracer control volumes? I see that it is impossible to achieve both.

In other words, certain assumptions about "interpolation" are baked into the interpolation operators (we do not do a true interpolation between the different grids for u, v, w, etc).

johncmarshall54 commented 5 years ago

The basic munerics of oceananigans is the same as MITgcm: we use a scheme which conserves tracer variance: e.g. D/Dt (T**2) = exactly 0 in the absence of sources and sinks. This is ensured by just taking the average of the T between adjacent boxes when one is computing the flux of T across the cell face. This is true even in the vertical when del_z is not constant. John

On Tue, Oct 22, 2019 at 1:41 PM Gregory L. Wagner notifications@github.com wrote:

Is the idea that there is some kind of compromise with putting the u-points at the "center" of the u control volumes, versus putting the tracer points at the center of the tracer control volumes? I see that it is impossible to achieve both.

In other words, certain assumptions about "interpolation" are baked into the interpolation operators (we do not do a true interpolation between the different grids for u, v, w, etc).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/climate-machine/Oceananigans.jl/issues/491?email_source=notifications&email_token=AKXUEQRCTHJHAZRI5GKCT6TQP43NXA5CNFSM4JDC6IX2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEB6S3NQ#issuecomment-545074614, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKXUEQSMDJBGJELHENZ6XVLQP43NXANCNFSM4JDC6IXQ .

--

John Marshall Cecil and Ida Green Professor of Oceanography Massachusetts Institute of Technology http://oceans.mit.edu/JohnMarshall/

ali-ramadhan commented 5 years ago

Is the idea that there is some kind of compromise with putting the u-points at the "center" of the u control volumes, versus putting the tracer points at the center of the tracer control volumes? I see that it is impossible to achieve both.

Yeah it's impossible to have both. Apparently MITgcm offers the two different options, but I'm not sure of their respective merits.

The basic munerics of oceananigans is the same as MITgcm: we use a scheme which conserves tracer variance: e.g. D/Dt (T**2) = exactly 0 in the absence of sources and sinks. This is ensured by just taking the average of the T between adjacent boxes when one is computing the flux of T across the cell face. This is true even in the vertical when del_z is not constant.

I see, @jm-c pointed this out but I didn't realize it was to conserve tracer variance. I'll add this to the documentation once we have a vertically stretched grid.

The interpolation is done in the same way for velocity. Presumably this is to conserve kinetic energy then?

I guess this means you don't want crazy amounts of stretching between adjacent grid cells and might be the reason for @jm-c's rule of thumb for stretching: that adjacent cells shouldn't be stretched by more than √2.

glwagner commented 5 years ago

I think this in some way implies that the location of the tracer point is "arbitrary". As long as it is located somewhere inside the cell, its fine.

ali-ramadhan commented 4 years ago

Cell centers are assumed to lie halfway between the faces.