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

MPIStateArray revamp #690

Open simonbyrne opened 4 years ago

simonbyrne commented 4 years ago

Currently MPIStateArray is somewhere in between a "pure" array structure and a specialized backing datastore for values on a DiscontinuousSpectralElementGrid. It has a bunch of compromises and assumptions that makes it a bit cumbersome to use.

My current thinking is that we could define a Field object (perhaps there is a better name) that represents a set of numerical quantities that are defined over a spatial domain. In other words, this would be equivalent to a current MPIStateArray + Grid + Vars.

I haven't touched on issues like communication or ghost points, and I know others have opinions, so please chime in with your wishlist below.

blallen commented 4 years ago

Need to think a bit more about it, but I love the idea of splitting out functionality into a Field. This is really the base object we are working with and MPIStateArray is just how the data for it is stored.

jkozdon commented 4 years ago

@lcw and I have been thinking some about this over the past few months.

It seem that we have too many ideas in MPIStateArrays and need to split some out.

It would also be nice to be semi-agnostic about data layout, e.g., do we want state to be fastest, which degree of freedom first (i, j, k), element order, etc.

We've been thinking that a series of wrapper array types could do this for us. Something along the lines of the following

GhostedArray:

StructArray / VarsArray

WeightedArray

MPICommArray

On top of all this

simonbyrne commented 4 years ago

After discussion with @blallen, @sandreza and @leios:

  1. Take #731 and make a new "Field" object basically consisting of

    struct Field{V<:Vars,A,G}
    array::A
    grid::G
    end
  2. Figure out recursive Vars (I have some ideas)

  3. Instead of passing state, aux, diffusive etc to every function, we pass a single NamedTuple containing the Vars objects: this will considerably simply the function signatures, especially now that #658 is merged.

  4. Figure out a way to have a filteredstate inside the main DG loop, that can get passed as another element of the NamedTuple in 3 (related #775).

  5. Be able to set boundary_state! once for all fluxes.

simonbyrne commented 4 years ago

Need to support broadcasting a horizontal-only field into 3D space. Ideally would capture the necessary restrictions in the grid object