Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add implementation #1

Merged
merged 1 commit into from
Jan 31, 2025
Merged

Add implementation #1

merged 1 commit into from
Jan 31, 2025

Conversation

charleskawczynski
Copy link
Member

@charleskawczynski charleskawczynski commented Jan 31, 2025

The idea here is that, when we start using LazyBroadcast in ClimaAtmos, we'll use the Absent type, so that broadcasting will entirely skip arithmetic operations against them. In this implementation, I've also defined a helper that we should be able to use, skip_materialize, that we can use to even completely elide operations in cases where we have expressions like @. x += Absent()-- we can make materialize!(dest, ::Base.Broadcasted{<:AbsentStyle}) = nothing here.

For example, in CliMA/ClimaAtmos.jl#3540, we'll be able to use:

viscous_sponge_tendency_ρe_tot(ᶜρ, ᶜh_tot, ::Nothing) = Absent()

There are a few advantages of doing this:

I added LazyBroadcast to the test dependencies here for convenience, but we could remove it.

Credit to @dennisYatunin, for most of the implementation in CliMA/ClimaTimeSteppers.jl#264

@charleskawczynski
Copy link
Member Author

By the way, everything that is not in this PR was automatically generated using https://github.com/CliMA/ClimaPackageTemplates.jl (I've made some updates):

using Revise;
import ClimaPackageTemplates as CPT
CPT.make_package(;
    pkg_dir=pwd(),
    pkgname="AbsentTypes.jl"
)

(after cloning an empty repo from github)

@charleskawczynski
Copy link
Member Author

This is working, so I'm going to merge and change the name to NullBroadcasted, it's technically a broadcasted object, so I think that it's more descriptive, and I think null is a more common name / concept than absent.

@charleskawczynski charleskawczynski merged commit d35d52a into main Jan 31, 2025
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant