Skip to content

Commit 3b556c6

Browse files
Dont materialize bc expr with uninitialized data
1 parent 6500e01 commit 3b556c6

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

src/Fields/broadcast.jl

+3
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@ function Base.similar(
177177
return Field(similar(todata(bc), Eltype), axes(bc))
178178
end
179179

180+
Base.similar(bc::Base.Broadcast.Broadcasted{<:AbstractFieldStyle}) =
181+
Base.similar(bc, eltype(bc))
182+
180183
@inline function Base.copyto!(
181184
dest::Field,
182185
bc::Base.Broadcast.Broadcasted{<:AbstractFieldStyle},

src/MatrixFields/field_matrix_iterative_solver.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ preconditioner generated by the `PreconditionerAlgorithm` `P_alg` for `A`.
4949
function preconditioner_cache(P_alg, A, b)
5050
is_diagonal(P_alg) && return (;)
5151
lazy_P = lazy_preconditioner(P_alg, A)
52-
P = is_lazy(lazy_P) ? Base.Broadcast.materialize(lazy_P) : lazy_P
52+
P = is_lazy(lazy_P) ? similar(lazy_P) : lazy_P
5353
P_if_needed = is_lazy(lazy_P) ? (; P) : (;)
5454
x = similar_to_x(P, b)
5555
alg = solver_algorithm(P_alg)

src/Operators/finitedifference.jl

+3
Original file line numberDiff line numberDiff line change
@@ -4017,6 +4017,9 @@ function Base.similar(
40174017
return Field(Eltype, sp)
40184018
end
40194019

4020+
Base.similar(bc::Base.Broadcast.Broadcasted{<:AbstractStencilStyle}) =
4021+
Base.similar(bc, eltype(bc))
4022+
40204023
function _serial_copyto!(field_out::Field, bc, Ni::Int, Nj::Int, Nh::Int)
40214024
space = axes(field_out)
40224025
bounds = window_bounds(space, bc)

0 commit comments

Comments
 (0)