Skip to content

Error when evaluating terms on interface-coupled multifield problem #1191

@oriolcg

Description

@oriolcg

I'm getting an error when evaluating multifield components on interfaces. The error only manifests for a specific component (trial left domain against test on the right domain) and only when evaluating the residual and not the jacobian. Does anyone faced similar issue before?

Here is a reproducer of the error:

module REPRODUCER
using Gridap
model = CartesianDiscreteModel((0,1),(2,))
Ω = Interior(model)
mask = [true,false]
Ω1 = Interior(model,mask)
Ω2 = Interior(model,.!mask)
reffe = ReferenceFE(lagrangian,VectorValue{1,Float64},1)
V1 = TestFESpace(Ω1,reffe,dirichlet_tags="boundary")
V2 = TestFESpace(Ω2,reffe,dirichlet_tags="boundary")
U1 = TrialFESpace(V1,VectorValue(0.0))
U2 = TrialFESpace(V2,VectorValue(0.0))
X = MultiFieldFESpace([U1,U2])
Y = MultiFieldFESpace([V1,V2])
u1_basis = get_trial_fe_basis(U1)
u2_basis = get_trial_fe_basis(U2)
v1_basis = get_fe_basis(V1)
v2_basis = get_fe_basis(V2)
op1 = u1_basisv1_basis
op2 = u2_basisv1_basis
op3 = u2_basisv2_basis
op4 = u1_basisv2_basis
println(" op1: ", op1(Point(0.5,)))
println(" op2: ", op2(Point(0.5,)))
println(" op3: ", op3(Point(0.5,)))
println(" op4: ", op4(Point(0.5,)))
u1h = interpolate(x -> VectorValue(2x[1]),U1)
u2h = interpolate(x -> VectorValue(2x[1]),U2)
op1h = u1hv1_basis
op2h = u2hv1_basis
op3h = u2hv2_basis
op4h = u1hv2_basis
println(" op1h: ", op1h(Point(0.5,)))
println(" op2h: ", op2h(Point(0.5,)))
println(" op3h: ", op3h(Point(0.5,)))   
println(" op4h: ", op4h(Point(0.5,)))
end

And this is the error message:

op1: [0.0 0.0; 0.0 1.0]
 op2: Matrix{Float64}(undef, 2, 0)
 op3: [1.0 0.0; 0.0 0.0]
 op4: Matrix{Float64}(undef, 0, 2)
 op1h: [0.0, 1.0]
 op2h: [0.0, 0.0]
 op3h: [1.0, 0.0]
ERROR: LoadError: TypeError: in typeassert, expected Gridap.Fields.OperationField{typeof(LinearAlgebra.dot), Tuple{Gridap.Fields.LinearCombinationField{Vector{Float64}, Gridap.Fields.VoidBasis{Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Gridap.TensorValues.VectorValue{1, Float64}}}, 1, Gridap.Fields.LinearCombinationFieldVector{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Gridap.TensorValues.VectorValue{1, Float64}}}}}, Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Gridap.TensorValues.VectorValue{1, Float64}}}}}, got a value of type Gridap.Fields.OperationField{typeof(LinearAlgebra.dot), Tuple{Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Fields.VoidBasis{Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Gridap.TensorValues.VectorValue{1, Float64}}}, 1, Gridap.Fields.LinearCombinationFieldVector{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Gridap.TensorValues.VectorValue{1, Float64}}}}}, Gridap.Fields.LinearCombinationField{Matrix{Float64}, Gridap.Polynomials.MonomialBasis{1, Gridap.TensorValues.VectorValue{1, Float64}}}}}
Stacktrace:
 [1] testvalue(::Type{Gridap.Fields.OperationField{typeof(LinearAlgebra.dot), Tuple{…}}})
   @ Gridap.Fields ~/.julia/packages/Gridap/dk0DA/src/Fields/FieldsInterfaces.jl:341
 [2] testvalue(::Type{Gridap.Fields.OperationField{Gridap.Fields.OperationField{…}, Tuple{…}}})
   @ Gridap.Fields ~/.julia/packages/Gridap/dk0DA/src/Fields/FieldsInterfaces.jl:329
 [3] testitem
   @ ~/.julia/packages/Gridap/dk0DA/src/Arrays/Interface.jl:154 [inlined]
 [4] return_cache(f::Vector{Gridap.Fields.OperationField{…}}, x::Gridap.TensorValues.VectorValue{1, Float64})
   @ Gridap.Fields ~/.julia/packages/Gridap/dk0DA/src/Fields/FieldArrays.jl:5
 [5] return_cache(a::Gridap.CellData.Interpolable{…}, x::Gridap.TensorValues.VectorValue{…})
   @ Gridap.CellData ~/.julia/packages/Gridap/dk0DA/src/CellData/Interpolation.jl:36
 [6] return_cache
   @ ~/.julia/packages/Gridap/dk0DA/src/CellData/Interpolation.jl:26 [inlined]
 [7] evaluate(f::Gridap.CellData.OperationCellField{…}, x::Gridap.TensorValues.VectorValue{…})
   @ Gridap.Arrays ~/.julia/packages/Gridap/dk0DA/src/Arrays/Maps.jl:86
 [8] (::Gridap.CellData.OperationCellField{…})(x::Gridap.TensorValues.VectorValue{…})
   @ Gridap.CellData ~/.julia/packages/Gridap/dk0DA/src/CellData/CellFields.jl:247
 [9] top-level scope
   @ ~/Progs/git_repos/CMOE/Mooring.jl/reproducer.jl:36

The only difference between expected and received argument type is that one of the entries of the tree is a Vector instead of a Matrix.

Metadata

Metadata

Assignees

No one assigned

    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