Skip to content

Consider further refactoring of interface for closure relations #72

@bgroenks96

Description

@bgroenks96

There was already some refactoring done on the way closures work in #68. Basically, closure relations have to define three methods:

  • variables (previously closurevar) defining one or more state variables needed for the closure relation; for soil energy, this includes both temperature and the liquid_water_fraction.
  • closure!(state, grid, ::ClosureType, args...) for computing the forward map prognostic -> closure vars
  • invclosure!(state, grid, ::ClosureType, args...) for computing the inverse map closure vars -> prognostic state.

Furthermore, closures are typically defined directly in the prognostic variable declaration, e.g.

prognostic(:internal_energy, XYZ(), closure=energy.closure, ...)

which means that it is not necessary to manually add variables(energy.closure)... to the tuple of vars.

That's all fine, but maybe a bit confusing and overengineered. So maybe we can think about how to further refine this interface to be more consistent, e.g. by making closures simply behave the same way as any parameterization type, where one would write:

variables(energy::SoilEnergyBalance) = (
    prognostic(:internal_energy, XYZ(), ...),
    variables(energy.closure)...,
    ...
)

then we could make closure! and invclosure! just standard process methods that dispatch on their respective internal types (here the closure property) without formally needing the closure type in the interface.

This would a fairly minor change, and I'm not sure it really makes a huge difference in the end.

@maximilian-gelbrecht following up from #68

Metadata

Metadata

Assignees

Labels

refactoringWho needs new features when you can just make the code nicer!

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions