-
Notifications
You must be signed in to change notification settings - Fork 9
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
Define zero on some MatrixField types #2140
Conversation
src/MatrixFields/field_name_dict.jl
Outdated
function Base.zero(dict::FieldMatrix) | ||
entries = unrolled_map(values(dict)) do entry | ||
entry isa UniformScaling ? entry : zero(entry) | ||
end | ||
return FieldNameDict(keys(dict), entries) | ||
end | ||
|
||
Base.zero(dict::FieldNameDict) = | ||
FieldNameDict(keys(dict), map(zero, values(dict))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
function Base.zero(dict::FieldMatrix) | |
entries = unrolled_map(values(dict)) do entry | |
entry isa UniformScaling ? entry : zero(entry) | |
end | |
return FieldNameDict(keys(dict), entries) | |
end | |
Base.zero(dict::FieldNameDict) = | |
FieldNameDict(keys(dict), map(zero, values(dict))) | |
function Base.zero(dict::FieldNameDict) | |
entries = unrolled_map(values(dict)) do entry | |
entry isa UniformScaling ? entry : zero(entry) | |
end # TODO: Replace UniformScaling with mutable Ref to make this consistent | |
return FieldNameDict(keys(dict), entries) | |
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the matrix-field method was needed after all: https://buildkite.com/clima/climaatmos-ci/builds/22412#01949b97-4f3c-477b-8ea5-b0a0e49491d7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, wait, that build shows that it's not using the latest ClimaCore.
4eefa45
to
e11d2fd
Compare
Define zero for some MatrixField structs
e11d2fd
to
a32ab63
Compare
Thanks for the suggestions, @dennisYatunin! It looks like these changes worked in ClimaTimesteppers CI 🙂 |
This should allow us to use
zero
in ClimaTimesteppers, resulting in safer initialization. xref.Does this need exercised anywhere else? I think this should work since it's recursive. I'm able to run CTS unit tests with this.