gridap / Gridap.jl

Grid-based approximation of partial differential equations in Julia
MIT License
711 stars 97 forks source link

AssertionError triggered in the call path rooted at AppliedArrays: BUG? #323

Closed amartinhuertas closed 4 years ago

amartinhuertas commented 4 years ago

Hi @fverdugo, @santiagobadia,

while working in GridapDistributed.jl, I think I found a BUG in Gridap v.0.12.0 in the call path rooted at function AppliedArray(g::AbstractArray,f::AbstractArray...).

Let me call it BUG from now on, even if we don't still have a confirmation.

This BUG can be reproduced with the following minimal Julia code snippet, that synthetizes an actual call path status in a much more complex scenario (see below for a full Julia script in which this issue is spotted).

using Gridap
using FillArrays

g=FillArrays.Fill(Gridap.Fields.LinCom(),0)

#ptrs
j_to_i=Int64[]
i_to_v=[Int8(1) for i=1:24]
ptrs=Gridap.Arrays.reindex(i_to_v,j_to_i)
#values
values=[[0.7886751345948129 0.21132486540518708; 0.21132486540518713 0.7886751345948129]]
f1=Gridap.Arrays.CompressedArray(values,ptrs)

i_to_v=[[1, 2], [5, 6], [1, 5], [2, 6], [2, 3], [6, 7], [3, 7], [3, 4], [7, 8], [4, 8], [9, 10], [5, 9], [6, 10], [10, 11], [7, 11], [11, 12], [8, 12], [13, 14], [9, 13], [10, 14], [14, 15], [11, 15], [15, 16], [12, 16]]
j_to_i=Int64[]
lid_to_gid=Gridap.Arrays.reindex(i_to_v,j_to_i)
gid_to_val=Gridap.TensorValues.VectorValue{2,Float64}[(0.0, 0.25), (0.25, 0.25), (0.5, 0.25), (0.75, 0.25), (0.0, 0.5), (0.25, 0.5), (0.5, 0.5), (0.75, 0.5), (0.0, 0.75), (0.25, 0.75), (0.5, 0.75), (0.75, 0.75), (0.0, 1.0), (0.25, 1.0), (0.5, 1.0), (0.75, 1.0)]
f2=Gridap.Arrays.LocalToGlobalArray(lid_to_gid,gid_to_val)

Gridap.Arrays.AppliedArray(g,f1,f2)

The BUG comes in the form of an AssertionError triggered in a final node of the call path, namely,

function _lincomb_checks(a,b)
  nb = length(b)
  np, na = size(a)
  s = "lincom: Number of fields in basis needs to be equal to number of coefs."
  @assert nb == na s
end

with nb==0 and na==2.

Tracing back where do a and b come from, it turns out that they come from:

function AppliedArray(g::AbstractArray,f::AbstractArray...)
  gi = testitem(g) #Assumes that all kernels return the same type
  fi = testitems(f...)
  if length(g) == 0
    T = kernel_return_type(gi,fi...)
  else
    T = typeof(apply_kernel_for_cache(gi,fi...))
  end
  AppliedArray(T,g,f...)
end

In particular, with g as above, and f==(f1,f2), then we get

julia> Gridap.Arrays.testitems((f1,f2)...)
([0.7886751345948129 0.21132486540518708; 0.21132486540518713 0.7886751345948129], VectorValue{2,Float64}[])

julia> Gridap.Arrays.testitems((f1,f2)...)[1]
2×2 Array{Float64,2}:
 0.788675  0.211325
 0.211325  0.788675

julia> Gridap.Arrays.testitems((f1,f2)...)[2]
0-element Array{VectorValue{2,Float64},1}

Note that the first entry of the tuple returned by testitems((f1,f2)...) plays the role of the argument a in _lincomb_checks, and thus the error is triggered.

Finally, this scenario was originally triggered from the following Gridap driver that solves the stokes problem. Note that the boundary triangulation has 0 faces (i.e., it is void) as there are not faces that belong to entity 10 (as this entity does not exist). The same situation happens in parallel for those subdomains which are not in contact with the Neumman boundary. So it seems the code is not handling correctly this corner case.

Can you please confirm whether this is a BUG? I am not sure about the solution ... I dont feel myself confident enough with the side-effects that a hack to fix this partciular scenario could have for the global consistency of the project.

module XXX

#md # !!! note
#
#     This tutorial is under construction, but the code below is already functional.
#
# Driver that computes the lid-driven cavity benchmark at low Reynolds numbers
# when using a mixed FE Q(k)/Pdisc(k-1).

# Load Gridap library
using Gridap
using LinearAlgebra

# Discrete model
n = 4
domain = (0,1,0,1)
partition = (n,n)
model = CartesianDiscreteModel(domain, partition)

# Define Dirichlet boundaries
labels = get_face_labeling(model)
add_tag_from_tags!(labels,"diri1",[1,2,3,4,6,7,8])
add_tag_from_tags!(labels,"diri0",[1,2,3,4,6,7,8])
add_tag!(labels,"neumann",[10])

ux(x)=2*x[1]*x[2]
uy(x)=-x[2]^2
u(x)=VectorValue(ux(x),uy(x))
f(x)=VectorValue(1.0,3.0)
p(x)=x[1]+x[2]
sx(x)=-2.0*x[1]
sy(x)=2
s(x)=VectorValue(sx(x),sy(x))
#ux(x)=1
#uy(x)=1
#u(x)=VectorValue(ux(x),uy(x))
#f(x)=VectorValue(0.0,0.0)
#p(x)=1

# Define test FESpaces (Q2/P1(disc) pair)
V = TestFESpace(
  reffe=:QLagrangian, conformity=:H1, valuetype=VectorValue{2,Float64},
  model=model, labels=labels, order=2, dirichlet_tags=["diri0","diri1"])
Q = TestFESpace(
  reffe=:PLagrangian, conformity=:L2, valuetype=Float64,
  model=model, order=1)
Y = MultiFieldFESpace([V,Q])

# Define trial FESpaces from Dirichlet values
U = TrialFESpace(V,[u,u])
P = TrialFESpace(Q)
X = MultiFieldFESpace([U,P])

# Define integration mesh and quadrature
trian = get_triangulation(model); degree = 2
quad = CellQuadrature(trian,degree)

btrian=BoundaryTriangulation(model,"neumann")
bquad=CellQuadrature(btrian,degree)

# Define and solve the FE problem
function a(x,y)
  v,q = y
  u,p = x
  ∇(v)⊙∇(u) - (∇⋅v)*p + q*(∇⋅u)
end
function l(y)
   v,q = y
   f⋅v
end
function lΓ(y)
  v,q = y
  s⋅v
end

t_Ω = AffineFETerm(a,l,trian,quad)
t_Γ = FESource(lΓ,btrian,bquad)
op = AffineFEOperator(X,Y,t_Ω,t_Γ)

uh, ph = solve(op)

e = u - uh
println(e)
function l2(u)
  println(u)
  u ⋅ u
end
h1(u) = u ⋅ u + ∇(u) ⊙ ∇(u)
e_l2 = sum(integrate(l2(e), trian, quad))
e_h1 = sum(integrate(h1(e), trian, quad))
println(e_l2, " XXX ", e_h1)

# Export results to vtk
writevtk(trian,"results",order=2,cellfields=["uh"=>uh,"ph"=>ph])

end
fverdugo commented 4 years ago

@amartinhuertas This looks like there is a 0-lengh array degenerated case that is not properly handled in the code, right?

amartinhuertas commented 4 years ago

Yes, it is definitely a corner case. Reproduced whenever you try to evaluate a SourceFETerm on a void boundary mesh.

fverdugo commented 4 years ago

It's definitively a bug. I am fixing it. As you very well noticed, it is related with testitem

amartinhuertas commented 4 years ago

It's definitively a bug. I am fixing it. As you very well noticed, it is related with testitem

Great! Thanks! Note that there is a reproducer above to simplify things up.

Some day (not urgent) I would like that you give me some keys on the machinery that is in charge of the lazy evaluation of FETerms ... I think if I could grasp better what the code is doing, I could debug it myself, and better understand the side-effects.

fverdugo commented 4 years ago

Some day (not urgent) I would like that you give me some keys on the machinery that is in charge of the lazy evaluation of FETerms ... I think if I could grasp better what the code is doing, I could debug it myself, and better understand the side-effects.

yes sure!

fverdugo commented 4 years ago

solved via #329

amartinhuertas commented 4 years ago

Hi @fverdugo,

Thanks for your work!

Let me just note that, after pulling your bug fix, I am still having issues with DistributedStokesTests.jl. I just found the error, and have to dig deeper into into. However, it wouldn't be mad to claim that it might be related to this thread, because the error message triggered is the same as the one that we had so far. Interestingly enough, it happens during the second execution to run (https://github.com/gridap/GridapDistributed.jl/blob/66e4ada6c3aaf0c4848bfc55ed2088f91bab5afb/test/DistributedStokesTests.jl#L150), that uses OwnedCellsStrategy. The only difference of OwnedCellsStrategy w.r.t. RowsComputedLocally is that the former restricts (a void) boundary triangulation to the cells owned by the processor (remove_ghost_cells_if_needed). Does it tell you anything? If not, I will try to debug the code and find a reproducer in order to find where the source of the error can come from.

Thanks!

julia> include("test/DistributedStokesTests.jl")
1.3061638074924613e-30 < 1.0e-9
ERROR: LoadError: AssertionError: lincom: Number of fields in basis needs to be equal to number of coefs.
Stacktrace:
 [1] _lincomb_checks(::Array{Float64,2}, ::Array{Gridap.TensorValues.VectorValue{2,Float64},1}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/Lincomb.jl:38
 [2] kernel_cache(::Gridap.Fields.LinCom, ::Array{Float64,2}, ::Array{Gridap.TensorValues.VectorValue{2,Float64},1}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/Lincomb.jl:25
 [3] kernel_testitem(::Gridap.Fields.LinCom, ::Array{Float64,2}, ::Vararg{Any,N} where N) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Arrays/Kernels.jl:179
 [4] Gridap.Arrays.AppliedArray(::FillArrays.Fill{Gridap.Fields.LinCom,1,Tuple{Base.OneTo{Int64}}}, ::Gridap.Arrays.CompressedArray{Array{Float64,2},1,Array{Array{Float64,2},1},Array{Int8,1}}, ::Vararg{AbstractArray,N} where N) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Arrays/Apply.jl:176
 [5] apply at /home/amartin/.julia/packages/Gridap/XnE1b/src/Arrays/Apply.jl:105 [inlined]
 [6] apply at /home/amartin/.julia/packages/Gridap/XnE1b/src/Arrays/Apply.jl:61 [inlined]
 [7] apply_lincomb at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/Lincomb.jl:115 [inlined]
 [8] kernel_evaluate(::Gridap.Fields.LinComValued, ::Gridap.Arrays.CompressedArray{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1,Array{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1},Gridap.Arrays.Reindexed{Int8,1,Gridap.Arrays.Reindexed{Int8,1,Array{Int8,1},Array{Int64,1}},Array{Int64,1}}}, ::Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}}, ::Gridap.Arrays.Reindexed{Array{Gridap.TensorValues.VectorValue{2,Float64},1},1,Gridap.Geometry.FaceCellCoordinates{2,Float64,true},Array{Int64,1}}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/Lincomb.jl:107
 [9] evaluate_field_array at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:79 [inlined]
 [10] kernel_evaluate(::Gridap.Fields.CompFieldArray, ::Gridap.Arrays.CompressedArray{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1,Array{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1},Gridap.Arrays.Reindexed{Int8,1,Gridap.Arrays.Reindexed{Int8,1,Array{Int8,1},Array{Int64,1}},Array{Int64,1}}}, ::Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Geometry.CartesianMap{2,Float64,4},Array{Int64,1}},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}, ::Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Array{Gridap.TensorValues.VectorValue{2,Float64},1},1,Gridap.Geometry.FaceCellCoordinates{2,Float64,true},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/Compose.jl:109
 [11] evaluate_field_array(::Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.CompField{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}}},Tuple{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Geometry.CartesianMap{2,Float64,4},Array{Int64,1}},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Array{Gridap.TensorValues.VectorValue{2,Float64},1},1,Gridap.Geometry.FaceCellCoordinates{2,Float64,true},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.CompFieldArray,1,Tuple{Base.OneTo{Int64}}}}, ::Gridap.Arrays.CompressedArray{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1,Array{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1},Gridap.Arrays.Reindexed{Int8,1,Gridap.Arrays.Reindexed{Int8,1,Array{Int8,1},Array{Int64,1}},Array{Int64,1}}}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:79
 [12] _evaluate_field_arrays at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:57 [inlined]
 [13] evaluate_field_arrays at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:47 [inlined]
 [14] _evaluate_field_arrays at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:52 [inlined]
 [15] evaluate_field_arrays(::Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.Comp{Main.DistributedStokesTests.var"#s#13"{Main.DistributedStokesTests.var"#sx#11",Main.DistributedStokesTests.var"#sy#12"}},Tuple{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.LocalToGlobalArray{Gridap.TensorValues.VectorValue{2,Float64},1,1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Table{Int64,Int32},Array{Int64,1}},Array{Int64,1}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Valued{Gridap.Fields.Comp{Main.DistributedStokesTests.var"#s#13"{Main.DistributedStokesTests.var"#sx#11",Main.DistributedStokesTests.var"#sy#12"}}},1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.CompField{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}}},Tuple{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Geometry.CartesianMap{2,Float64,4},Array{Int64,1}},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Array{Gridap.TensorValues.VectorValue{2,Float64},1},1,Gridap.Geometry.FaceCellCoordinates{2,Float64,true},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.CompFieldArray,1,Tuple{Base.OneTo{Int64}}}}}, ::Gridap.Arrays.CompressedArray{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1,Array{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1},Gridap.Arrays.Reindexed{Int8,1,Gridap.Arrays.Reindexed{Int8,1,Array{Int8,1},Array{Int64,1}},Array{Int64,1}}}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:47
 [16] kernel_evaluate(::Gridap.Fields.Valued{Gridap.Fields.FieldBinOp{typeof(LinearAlgebra.dot)}}, ::Gridap.Arrays.CompressedArray{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1,Array{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1},Gridap.Arrays.Reindexed{Int8,1,Gridap.Arrays.Reindexed{Int8,1,Array{Int8,1},Array{Int64,1}},Array{Int64,1}}}, ::Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.Comp{Main.DistributedStokesTests.var"#s#13"{Main.DistributedStokesTests.var"#sx#11",Main.DistributedStokesTests.var"#sy#12"}},Tuple{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.LocalToGlobalArray{Gridap.TensorValues.VectorValue{2,Float64},1,1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Table{Int64,Int32},Array{Int64,1}},Array{Int64,1}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Valued{Gridap.Fields.Comp{Main.DistributedStokesTests.var"#s#13"{Main.DistributedStokesTests.var"#sx#11",Main.DistributedStokesTests.var"#sy#12"}}},1,Tuple{Base.OneTo{Int64}}}}, ::Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.CompField{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}}},Tuple{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Geometry.CartesianMap{2,Float64,4},Array{Int64,1}},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Array{Gridap.TensorValues.VectorValue{2,Float64},1},1,Gridap.Geometry.FaceCellCoordinates{2,Float64,true},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.CompFieldArray,1,Tuple{Base.OneTo{Int64}}}}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:274
 [17] evaluate_field_array at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/FieldArrays.jl:79 [inlined]
 [18] integrate(::Gridap.Arrays.AppliedArray{Gridap.Geometry.UnimplementedField,1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.Comp{Main.DistributedStokesTests.var"#s#13"{Main.DistributedStokesTests.var"#sx#11",Main.DistributedStokesTests.var"#sy#12"}},Tuple{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.LocalToGlobalArray{Gridap.TensorValues.VectorValue{2,Float64},1,1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Table{Int64,Int32},Array{Int64,1}},Array{Int64,1}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Valued{Gridap.Fields.Comp{Main.DistributedStokesTests.var"#s#13"{Main.DistributedStokesTests.var"#sx#11",Main.DistributedStokesTests.var"#sy#12"}}},1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.CompField{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}}},Tuple{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},Gridap.Fields.AffineMap{2,Float64,4}}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{2,Gridap.TensorValues.VectorValue{2,Float64}},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Arrays.Reindexed{Gridap.Fields.AffineMap{2,Float64,4},1,Gridap.Geometry.CartesianMap{2,Float64,4},Array{Int64,1}},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1,Array{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}},1},Array{Int8,1}},Gridap.Arrays.Reindexed{Array{Gridap.TensorValues.VectorValue{2,Float64},1},1,Gridap.Geometry.FaceCellCoordinates{2,Float64,true},Array{Int64,1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.CompFieldArray,1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Valued{Gridap.Fields.FieldBinOp{typeof(LinearAlgebra.dot)}},1,Tuple{Base.OneTo{Int64}}}}, ::Gridap.Arrays.CompressedArray{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1,Array{Array{Gridap.TensorValues.VectorValue{1,Float64},1},1},Gridap.Arrays.Reindexed{Int8,1,Gridap.Arrays.Reindexed{Int8,1,Array{Int8,1},Array{Int64,1}},Array{Int64,1}}}, ::Gridap.Arrays.CompressedArray{Array{Float64,1},1,Array{Array{Float64,1},1},Gridap.Arrays.Reindexed{Int8,1,Gridap.Arrays.Reindexed{Int8,1,Array{Int8,1},Array{Int64,1}},Array{Int64,1}}}, ::Gridap.Arrays.AppliedArray{Gridap.Fields.LinComField{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}},1,Tuple{Gridap.Arrays.CompressedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}}},1,Array{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Polynomials.MonomialBasis{1,Float64},Array{Float64,2}}},1},Array{Int8,1}},Gridap.Arrays.LocalToGlobalArray{Gridap.TensorValues.VectorValue{2,Float64},1,1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Reindexed{Array{Int64,1},1,Gridap.Arrays.Table{Int64,Int32},Array{Int64,1}},Array{Int64,1}},Array{Gridap.TensorValues.VectorValue{2,Float64},1}}},FillArrays.Fill{Gridap.Fields.LinComValued,1,Tuple{Base.OneTo{Int64}}}}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/Fields/Integrate.jl:17
 [19] integrate(::Gridap.FESpaces.GenericCellBasis{false,true}, ::Gridap.Geometry.TriangulationPortion{1,2,Gridap.Geometry.GenericBoundaryTriangulation{1,2,Gridap.Geometry.TriangulationPortion{1,2,Gridap.Geometry.UnstructuredGrid{1,2,Float64,false}},Gridap.Geometry.CartesianGrid{2,Float64,typeof(identity)},true,Int64}}, ::Gridap.Geometry.CellQuadrature) at /home/amartin/.julia/packages/Gridap/XnE1b/src/FESpaces/CellBases.jl:358
 [20] integrate(::Gridap.MultiField.CellBasisWithFieldID{false,true}, ::Gridap.Geometry.TriangulationPortion{1,2,Gridap.Geometry.GenericBoundaryTriangulation{1,2,Gridap.Geometry.TriangulationPortion{1,2,Gridap.Geometry.UnstructuredGrid{1,2,Float64,false}},Gridap.Geometry.CartesianGrid{2,Float64,typeof(identity)},true,Int64}}, ::Gridap.Geometry.CellQuadrature) at /home/amartin/.julia/packages/Gridap/XnE1b/src/MultiField/MultiFieldCellBases.jl:175
 [21] get_cell_vector(::Gridap.FESpaces.FESourceFromIntegration, ::Gridap.MultiField.MultiCellBasis{false,true}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/FESpaces/FETerms.jl:394
 [22] _get_cell_vector_tmp_hack at /home/amartin/.julia/packages/Gridap/XnE1b/src/FESpaces/FETerms.jl:114 [inlined]
 [23] get_cell_matrix_and_vector(::Gridap.FESpaces.FESourceFromIntegration, ::Gridap.MultiField.MultiFieldFEFunction, ::Gridap.MultiField.MultiCellBasis{true,true}, ::Gridap.MultiField.MultiCellBasis{false,true}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/FESpaces/FETerms.jl:108
 [24] collect_cell_matrix_and_vector(::Gridap.MultiField.MultiFieldFEFunction, ::Gridap.MultiField.MultiCellBasis{true,true}, ::Gridap.MultiField.MultiCellBasis{false,true}, ::Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}) at /home/amartin/.julia/packages/Gridap/XnE1b/src/FESpaces/FETerms.jl:236
 [25] (::GridapDistributed.var"#145#146")(::Int64, ::Gridap.MultiField.MultiFieldFEFunction, ::Gridap.MultiField.MultiCellBasis{true,true}, ::Gridap.MultiField.MultiCellBasis{false,true}, ::Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}) at /home/amartin/git-repos/GridapDistributed.jl/src/DistributedFETerms.jl:33
 [26] (::GridapDistributed.var"#7#9"{GridapDistributed.var"#145#146",GridapDistributed.SequentialCommunicator,Tuple{GridapDistributed.DistributedFEFunction{Array{Float64,1}},GridapDistributed.DistributedCellBasis,GridapDistributed.DistributedCellBasis,GridapDistributed.SequentialDistributedData{Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}}}})(::Int64) at ./array.jl:0
 [27] iterate at ./generator.jl:47 [inlined]
 [28] collect_to!(::Array{Tuple{Tuple{Array{Any,1},Array{Any,1},Array{Any,1}},Tuple{Array{Any,1},Array{Any,1},Array{Any,1}},Tuple{Array{Any,1},Array{Any,1}}},1}, ::Base.Generator{UnitRange{Int64},GridapDistributed.var"#7#9"{GridapDistributed.var"#145#146",GridapDistributed.SequentialCommunicator,Tuple{GridapDistributed.DistributedFEFunction{Array{Float64,1}},GridapDistributed.DistributedCellBasis,GridapDistributed.DistributedCellBasis,GridapDistributed.SequentialDistributedData{Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}}}}}, ::Int64, ::Int64) at ./array.jl:710
 [29] collect_to_with_first!(::Array{Tuple{Tuple{Array{Any,1},Array{Any,1},Array{Any,1}},Tuple{Array{Any,1},Array{Any,1},Array{Any,1}},Tuple{Array{Any,1},Array{Any,1}}},1}, ::Tuple{Tuple{Array{Any,1},Array{Any,1},Array{Any,1}},Tuple{Array{Any,1},Array{Any,1},Array{Any,1}},Tuple{Array{Any,1},Array{Any,1}}}, ::Base.Generator{UnitRange{Int64},GridapDistributed.var"#7#9"{GridapDistributed.var"#145#146",GridapDistributed.SequentialCommunicator,Tuple{GridapDistributed.DistributedFEFunction{Array{Float64,1}},GridapDistributed.DistributedCellBasis,GridapDistributed.DistributedCellBasis,GridapDistributed.SequentialDistributedData{Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}}}}}, ::Int64) at ./array.jl:689
 [30] collect(::Base.Generator{UnitRange{Int64},GridapDistributed.var"#7#9"{GridapDistributed.var"#145#146",GridapDistributed.SequentialCommunicator,Tuple{GridapDistributed.DistributedFEFunction{Array{Float64,1}},GridapDistributed.DistributedCellBasis,GridapDistributed.DistributedCellBasis,GridapDistributed.SequentialDistributedData{Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}}}}}) at ./array.jl:670
 [31] GridapDistributed.DistributedData(::Function, ::GridapDistributed.SequentialCommunicator, ::GridapDistributed.DistributedFEFunction{Array{Float64,1}}, ::Vararg{Any,N} where N) at /home/amartin/git-repos/GridapDistributed.jl/src/SequentialDistributedData.jl:19
 [32] GridapDistributed.DistributedData(::Function, ::GridapDistributed.DistributedFEFunction{Array{Float64,1}}, ::Vararg{Any,N} where N) at /home/amartin/git-repos/GridapDistributed.jl/src/DistributedData.jl:31
 [33] collect_cell_matrix_and_vector(::GridapDistributed.DistributedFEFunction{Array{Float64,1}}, ::GridapDistributed.DistributedCellBasis, ::GridapDistributed.DistributedCellBasis, ::GridapDistributed.SequentialDistributedData{Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}}) at /home/amartin/git-repos/GridapDistributed.jl/src/DistributedFETerms.jl:32
 [34] Gridap.FESpaces.AffineFEOperator(::GridapDistributed.DistributedAssembler{SparseArrays.SparseMatrixCSC{Float64,Int64},Array{Float64,1},GridapDistributed.OwnedCellsStrategy{false}}, ::GridapDistributed.SequentialDistributedData{Tuple{Gridap.FESpaces.AffineFETermFromIntegration,Gridap.FESpaces.FESourceFromIntegration}}) at /home/amartin/git-repos/GridapDistributed.jl/src/DistributedFEOperators.jl:12
 [35] run(::GridapDistributed.SequentialCommunicator, ::Tuple{Int64,Int64}, ::String, ::Bool) at /home/amartin/git-repos/GridapDistributed.jl/test/DistributedStokesTests.jl:122
 [36] (::Main.DistributedStokesTests.var"#23#24")(::GridapDistributed.SequentialCommunicator) at /home/amartin/git-repos/GridapDistributed.jl/test/DistributedStokesTests.jl:150
 [37] GridapDistributed.SequentialCommunicator(::Main.DistributedStokesTests.var"#23#24", ::Tuple{Int64,Int64}) at /home/amartin/git-repos/GridapDistributed.jl/src/SequentialCommunicators.jl:8
 [38] top-level scope at /home/amartin/git-repos/GridapDistributed.jl/test/DistributedStokesTests.jl:148
 [39] include(::String) at ./client.jl:439
 [40] top-level scope at REPL[1]:1
in expression starting at /home/amartin/git-repos/GridapDistributed.jl/test/DistributedStokesTests.jl:148
fverdugo commented 4 years ago

Yes, it is related with the degenerated case of triangulations with 0 cells. In PR #329, I have added some methods in the Kernel interface in order to handle these cases, but as you can see, I have not implemented them for all the specializations of Kernel we have in the library (I implemented only the ones needed for your previous reproducers.). Implementing it for the LinCom kernel should be easy.

fverdugo commented 4 years ago

Hope this fixes it: PR #331

amartinhuertas commented 4 years ago

Hope this fixes it: PR #331

Seems that implementing the methods for the appropriate realization of Kernel solves the issue:

https://travis-ci.com/github/gridap/GridapDistributed.jl/jobs/364455303#L918

Thanks! Closing the issue.