ClimaLand.jl icon indicating copy to clipboard operation
ClimaLand.jl copied to clipboard

Generalize `ldiv!`

Open juliasloan25 opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. #218 introduces functions used for implicit timestepping. These will soon be moved to ClimaTimeSteppers (see https://github.com/CliMA/ClimaCore.jl/issues/1230), but we should still generalize them while they are in ClimaLSM.

ldiv! current accesses x.soil.\vartheta_l, which is hardcoded for RRE. We want this function to work for any problem that may be stepped implicitly. We need to generalize this prognostic variable access, maybe by unpacking x recursively as is done for dss! in #218.

Alternative solution Alternatively, we could have ldiv! dispatch off of concrete TridiagonalW types (so RichardsTridiagonalW for RRE). Then we'll implement one ldiv! function for each model (which isn't ideal), but we would be able to pass the property to access from x and b (so soil.\vartheta_l for RRE) to _ldiv!/ldiv_serial!, and keep _ldiv! and ldiv_serial! general across all AbstractTridiagonalW types.

Additional context Ultimately, these functions will be generalized and moved to ClimaTimeSteppers, so we don't need a super optimized implementation here. See ClimaCore SDI for adding these functions there: https://github.com/CliMA/ClimaCore.jl/issues/1230

juliasloan25 avatar Jun 06 '23 18:06 juliasloan25