Skip to content

SkeletonTriangulations + MultiField on different triangulations #1145

@zjwegert

Description

@zjwegert

While working on #1136 I found that the following produces an error:

using Gridap,Gridap.Algebra,Gridap.Arrays,Gridap.Geometry,
  Gridap.CellData,Gridap.ReferenceFEs,Gridap.FESpaces,Gridap.MultiField

domain = (0,1,0,1)
partition = (5,5)
model = CartesianDiscreteModel(domain,partition)
Γ = BoundaryTriangulation(model)
Λ = SkeletonTriangulation(model)
dΛ = Measure(Λ,2)
V1 = FESpace(Γ,ReferenceFE(lagrangian,Float64,1))
V2 = FESpace(model,ReferenceFE(lagrangian,Float64,1))
X = MultiFieldFESpace([V1,V2])
a(xh,yh) = (mean(xh[1])*mean(yh[1])+mean(xh[2])*mean(yh[2]))dΛ
assemble_matrix(a,X,X)

I think the issue here is that Γ isn't anywhere part of Λ and this might be creating erroneous cache somewhere.

Note that the workaround is to simply remove the field on Γ from a because it wouldn't contribute anything anyway.

Here is the full error:

ERROR: TypeError: in typeassert, expected Gridap.Fields.OperationField{Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{2, Float64}}, Tuple{Gridap.Fields.LinearCombinationField{Vector{VectorValue{2, Float64}}, Gridap.Fields.VoidBasis{Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Float64}}, 1, Gridap.Fields.LinearCombinationFieldVector{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Float64}}}}}}, got a value of type Gridap.Fields.OperationField{Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{2, Float64}}, Tuple{Gridap.Fields.LinearCombinationField{Matrix{VectorValue{2, Float64}}, Gridap.Fields.VoidBasis{Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Float64}}, 1, Gridap.Fields.LinearCombinationFieldVector{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Float64}}}}}}
Stacktrace:
  [1] testitem
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Interface.jl:154 [inlined]
  [2] return_cache(f::Vector{Gridap.Fields.OperationField{…}}, x::Vector{VectorValue{…}})
    @ Gridap.Fields C:\Users\Zac\Desktop\Repos\Gridap\src\Fields\FieldArrays.jl:39
  [3] return_cache(f::VectorBlock{Vector{Gridap.Fields.OperationField{…}}}, x::Vector{VectorValue{1, Float64}})
    @ Gridap.Fields C:\Users\Zac\Desktop\Repos\Gridap\src\Fields\FieldArrayBlocks.jl:52
  [4] evaluate(f::VectorBlock{Vector{Gridap.Fields.OperationField{…}}}, x::Vector{VectorValue{1, Float64}})
    @ Gridap.Arrays C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:86
  [5] evaluate!(::Nothing, ::Function, ::VectorBlock{Vector{…}}, ::Vector{VectorValue{…}})
    @ Gridap.Arrays C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:93
  [6] evaluate
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:87 [inlined]
  [7] return_value
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:64 [inlined]
  [8] return_type
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:62 [inlined]
  [9] lazy_map(::Function, ::FillArrays.Fill{…}, ::CompressedArray{…})
    @ Gridap.Arrays C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\LazyArrays.jl:57
 [10] evaluate!(cache::Nothing, f::Gridap.CellData.CellFieldAt{…}, x::CellPoint{…})
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:253
 [11] evaluate
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:87 [inlined]
 [12] CellField
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:247 [inlined]
 [13] #7
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:398 [inlined]
 [14] map(f::Gridap.CellData.var"#7#8"{}, t::Tuple{…})
    @ Base .\tuple.jl:356
 [15] evaluate!(cache::Nothing, f::Gridap.CellData.OperationCellField{…}, x::CellPoint{…})
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:398
 [16] evaluate
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:87 [inlined]
 [17] CellField
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:247 [inlined]
 [18] #7
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:398 [inlined]
 [19] map(f::Gridap.CellData.var"#7#8"{}, t::Tuple{…})
    @ Base .\tuple.jl:356
 [20] evaluate!(cache::Nothing, f::Gridap.CellData.OperationCellField{…}, x::CellPoint{…})
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:398
 [21] evaluate
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:87 [inlined]
 [22] CellField
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:247 [inlined]
 [23] #7
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:398 [inlined]
 [24] map(f::Gridap.CellData.var"#7#8"{}, t::Tuple{…})
    @ Base .\tuple.jl:356
 [25] evaluate!(cache::Nothing, f::Gridap.CellData.OperationCellField{…}, x::CellPoint{…})
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:398
 [26] evaluate
    @ C:\Users\Zac\Desktop\Repos\Gridap\src\Arrays\Maps.jl:87 [inlined]
 [27] (::Gridap.CellData.OperationCellField{…})(x::CellPoint{…})
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellFields.jl:247
 [28] integrate(f::Gridap.CellData.OperationCellField{…}, quad::CellQuadrature{…})
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\CellQuadratures.jl:151
 [29] integrate(f::Gridap.CellData.OperationCellField{ReferenceDomain, typeof(+)}, b::Gridap.CellData.GenericMeasure)
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\DomainContributions.jl:164
 [30] *(a::Integrand, b::Gridap.CellData.GenericMeasure)
    @ Gridap.CellData C:\Users\Zac\Desktop\Repos\Gridap\src\CellData\DomainContributions.jl:148
 [31] a(xh::MultiFieldCellField{ReferenceDomain}, yh::MultiFieldCellField{ReferenceDomain})
    @ Main c:\Users\Zac\Desktop\Repos\Gridap\test.jl:12
 [32] assemble_matrix(f::typeof(a), a::GenericSparseMatrixAssembler, U::MultiFieldFESpace{…}, V::MultiFieldFESpace{…})
    @ Gridap.FESpaces C:\Users\Zac\Desktop\Repos\Gridap\src\FESpaces\Assemblers.jl:295
 [33] assemble_matrix(f::Function, U::MultiFieldFESpace{…}, V::MultiFieldFESpace{…})
    @ Gridap.FESpaces C:\Users\Zac\Desktop\Repos\Gridap\src\FESpaces\Assemblers.jl:364
 [34] top-level scope
    @ c:\Users\Zac\Desktop\Repos\Gridap\test.jl:13
Some type information was truncated. Use `show(err)` to see complete types.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions