Skip to content

Commit

Permalink
Merge pull request #554 from gridap/bugfix_broadcasting_gradgrad
Browse files Browse the repository at this point in the history
Fixing return_value for Broadcasting(∇∇)
  • Loading branch information
fverdugo authored Mar 5, 2021
2 parents ddb7684 + 7f9398a commit 923852a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Fields/FieldArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ function return_value(k::Broadcasting{typeof(∇)},a::AbstractArray{<:Field})
evaluate(k,a)
end

function return_value(k::Broadcasting{typeof(∇∇)},a::AbstractArray{<:Field})
evaluate(k,a)
end

@inline function evaluate!(cache,k::Broadcasting{typeof(∇)},a::AbstractArray{<:Field})
FieldGradientArray{1}(a)
end
Expand Down
10 changes: 7 additions & 3 deletions test/FieldsTests/FieldArraysTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -259,13 +259,17 @@ f = transpose(a)

fp = transpose(evaluate(a,p))
∇fp = transpose(evaluate(Broadcasting(∇)(a),p))
∇∇fp = transpose(evaluate(Broadcasting(∇∇)(a),p))

test_field_array(f,p,fp)
test_field_array(f,p,fp,grad=∇fp)
test_field_array(f,p,fp,grad=∇fp,gradgrad=∇∇fp)
test_field_array(f,x,result(f,x))
test_field_array(f,x,result(f,x),grad=result(.(f),x))
test_field_array(f,x,result(f,x),grad=result(.(f),x),gradgrad=result(∇∇.(f),x))
test_field_array(f,z,result(f,z))
test_field_array(f,z,result(f,z),grad=result(.(f),z))
test_field_array(f,z,result(f,z),grad=result(.(f),z),gradgrad=result(∇∇.(f),z))

test_map(evaluate(Broadcasting(∇),a),Broadcasting(∇),a)
test_map(evaluate(Broadcasting(∇∇),a),Broadcasting(∇∇),a)

#using BenchmarkTools
#
Expand Down

0 comments on commit 923852a

Please sign in to comment.