CliMA / ClimateMachine.jl

Climate Machine: an Earth System Model that automatically learns from data
https://clima.github.io/ClimateMachine.jl/latest/
Other
451 stars 78 forks source link

Pass coordinates to flux/source #1956

Open simonbyrne opened 3 years ago

simonbyrne commented 3 years ago

At the moment these are only passed to init_aux, but it would be useful if these could be accessed directly from the flux & source functions, particularly for the FV case where fluxes should probably be evaluated at the element edges (instead of the centroids).

The main challenge is that for FV, we don't store the element edge coordinates anywhere, so they will have to be computed from the centroids + cell heights: what's the best way to do this?

charleskawczynski commented 3 years ago

Meaning x,y,z? We have access to orientation::Orientation, param_set::APS, aux::Vars inside, so we can call latitude/longitude/altitude

simonbyrne commented 3 years ago

The problem is the ones in aux may not be correct in the FV setting.

simonbyrne commented 3 years ago

One thing I'm not sure about is how to compute the coordinates in FV. Based on this comment: https://github.com/CliMA/ClimateMachine.jl/blob/master/src/Numerics/DGMethods/DGFVModel_kernels.jl#L1005-L1023 it looks like we can use the JcV field to get half the element height: I guess if we multiply it by the face normal vector, so something like (x1 + JcV*n1, x2 + JcV*n2, x3 + JcV*n3)?

cc: @Zhengyu-Huang @jkozdon

jkozdon commented 3 years ago

I think that this could work / be reasonable. I would think that this should be accurate enough for FVM (but I could be wrong).

The other option would be a store it in some other array that gets passed around, as we do compute these face values in the computation of the grid metrics. (Some sort of boundary surface geometry array.)