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

Fix IntegrationMap on empty subds with physical quads #1012

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/FESpaces/Assemblers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ function collect_cell_vector(test::FESpace,a::DomainContribution)
w = []
r = []
for strian in get_domains(a)
num_cells(strian) == 0 && continue
scell_vec = get_contribution(a,strian)
cell_vec, trian = move_contributions(scell_vec,strian)
@assert ndims(eltype(cell_vec)) == 1
Expand Down Expand Up @@ -497,13 +498,15 @@ function _pair_contribution_when_possible(biform,liform)
mat = DomainContribution()
vec = DomainContribution()
for (trian,t) in biform.dict
num_cells(trian) == 0 && continue
if haskey(liform.dict,trian)
matvec.dict[trian] = pair_arrays(t,liform.dict[trian])
else
mat.dict[trian] = t
end
end
for (trian,t) in liform.dict
num_cells(trian) == 0 && continue
if ! haskey(biform.dict,trian)
vec.dict[trian] = t
end
Expand All @@ -516,11 +519,13 @@ function _pair_contribution_when_possible(biform,liform,uhd)
matvec = DomainContribution()
mat = DomainContribution()
for (trian,t) in _matvec.dict
num_cells(trian) == 0 && continue
cellvals = get_cell_dof_values(uhd,trian)
cellmask = get_cell_is_dirichlet(uhd,trian)
matvec.dict[trian] = attach_dirichlet(t,cellvals,cellmask)
end
for (trian,t) in _mat.dict
num_cells(trian) == 0 && continue
cellvals = get_cell_dof_values(uhd,trian)
cellmask = get_cell_is_dirichlet(uhd,trian)
matvec.dict[trian] = attach_dirichlet(t,cellvals,cellmask)
Expand Down
3 changes: 2 additions & 1 deletion src/Fields/FieldArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ end

function evaluate!(cache,k::LinearCombinationMap{<:Integer},v::AbstractArray,fx::AbstractVector)
z = zero(return_type(outer,testitem(fx),testitem(v)))
@check length(fx) == size(v,1)
length(fx) != size(v,1) && return z
@inbounds for i in eachindex(fx)
# We need to do the product in this way
# so that the gradient also works
Expand Down Expand Up @@ -579,6 +579,7 @@ function evaluate!(
nj = size(b,3)
setsize!(cache,(np,ni,nj))
r = cache.array
size(b,1) == 0 && return r
for p in 1:np
for j in 1:nj
bpj = b[p,1,j]
Expand Down
24 changes: 23 additions & 1 deletion src/Fields/FieldsInterfaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,15 @@

struct IntegrationMap <: Map end

function return_value(k::IntegrationMap,ax::AbstractVector,w)
if size(ax,1) == length(w)
evaluate(k,ax,w)
else
T = typeof( testitem(ax)*testitem(w) + testitem(ax)*testitem(w) )
zero(T)

Check warning on line 504 in src/Fields/FieldsInterfaces.jl

View check run for this annotation

Codecov / codecov/patch

src/Fields/FieldsInterfaces.jl#L503-L504

Added lines #L503 - L504 were not covered by tests
end
end

function evaluate!(cache,k::IntegrationMap,ax::AbstractVector,w)
T = typeof( testitem(ax)*testitem(w) + testitem(ax)*testitem(w) )
z = zero(T)
Expand All @@ -518,6 +527,15 @@
z
end

function return_value(k::IntegrationMap,ax::AbstractArray,w)
if size(ax,1) == length(w)
evaluate(k,ax,w)
else
c = return_cache(k,ax,w)
c.array

Check warning on line 535 in src/Fields/FieldsInterfaces.jl

View check run for this annotation

Codecov / codecov/patch

src/Fields/FieldsInterfaces.jl#L534-L535

Added lines #L534 - L535 were not covered by tests
end
end

function return_cache(k::IntegrationMap,ax::AbstractArray,w)
T = typeof( testitem(ax)*testitem(w) + testitem(ax)*testitem(w) )
r = zeros(T,size(ax)[2:end])
Expand Down Expand Up @@ -680,7 +698,11 @@
function return_cache(f::VoidField,x::AbstractVector{<:Point})
c = return_cache(f.field,x)
fx = evaluate!(c,f.field,x)
z = similar(fx)
if(eltype(fx) != Any)
z = similar(fx)
else
z = Float64[]

Check warning on line 704 in src/Fields/FieldsInterfaces.jl

View check run for this annotation

Codecov / codecov/patch

src/Fields/FieldsInterfaces.jl#L704

Added line #L704 was not covered by tests
end
c, CachedArray(z)
end

Expand Down
Loading