# How to define FE basis function in gridap as fields

I am using gridap for TO and like tutorial 18 i have defined o matrix but i am tackling with error that basis functions are not field which ∇ operate on that. evene in tutorial i couldnt find anywhere to define u as field.
this is the code in tutorial

``````function MatrixOf(fem_params)
x0 = VectorValue(0,300)  # Position of the field to be optimized
δ = 1
return assemble_matrix(fem_params.U, fem_params.V) do u, v
∫((x->(1/(2*π)*exp(-norm(x - x0)^2 / 2 / δ^2))) * (∇(u) ⋅ ∇(v)) )fem_params.dΩ_c
end
end
``````

and this is mine

``````function MatrixOf(fem_params)

return assemble_matrix(fem_params.U_Disp, fem_params.V0_Disp) do u, v
∫((0.5*C_mat)*(∇(u).∇(v)))fem_params.dΩ
end
end
``````

and this is the error

``````type SingleFieldFEBasis has no field ∇

Stacktrace:
[1] getproperty(x::Gridap.FESpaces.SingleFieldFEBasis{Gridap.FESpaces.TrialBasis, ReferenceDomain}, sym::Symbol)
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:674
[2] (::var"#155#156"{NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}})(u::Gridap.FESpaces.SingleFieldFEBasis{Gridap.FESpaces.TrialBasis, ReferenceDomain}, v::Gridap.FESpaces.SingleFieldFEBasis{Gridap.FESpaces.TestBasis, ReferenceDomain})
@ Main .\In[72]:4
[3] assemble_matrix(f::var"#155#156"{NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, a::Gridap.FESpaces.GenericSparseMatrixAssembler, U::TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, V::Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:285
[4] assemble_matrix(f::Function, U::TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, V::Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:342
[5] MatrixOf(fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[72]:3
[6] gf_pf(pf_vec::Vector{Float64}; β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[77]:7
[7] rrule(::typeof(gf_pf), pf_vec::Vector{Float64}; β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[77]:15
[8] chain_rrule_kw
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\chainrules.jl:229 [inlined]
[9] macro expansion
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0 [inlined]
[10] _pullback(::Zygote.Context, ::var"#gf_pf##kw", ::NamedTuple{(:β, :η, :fem_params), Tuple{Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_pf), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:9
[11] _pullback
@ .\In[79]:3 [inlined]
[12] _pullback(::Zygote.Context, ::var"##gf_p#176", ::Float64, ::Float64, ::Float64, ::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[13] _pullback
@ .\In[79]:1 [inlined]
[14] _pullback(::Zygote.Context, ::var"#gf_p##kw", ::NamedTuple{(:r, :β, :η, :fem_params), Tuple{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[15] _pullback
@ .\In[79]:8 [inlined]
[16] _pullback(ctx::Zygote.Context, f::var"#178#180"{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[17] _pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:34
[18] pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:40
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:75
[20] gf_p(p0::Vector{Float64}, grad::Vector{Float64}; r::Float64, β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[79]:8
[21] top-level scope
@ In[80]:5

``````

Look carefully at the example. You’re using a different dot.

thank you for your hint. it seems that you are right but now i get different error. in fact assemble matrix make a 3d matrix whereas i am using 2d fe spaces . do you know what is the solution?

``````function MatrixOf(fem_params)

return assemble_matrix(fem_params.U_Disp, fem_params.V0_Disp) do u, v
∫((0.5*C_mat)⊙(∇(u) ⋅ ∇(v)))fem_params.dΩ
end
end
``````

and the error is

``````MethodError: no method matching Float64(::SymTensorValue{2, Float64, 3})
Closest candidates are:
(::Type{T})(::T) where T<:Number at boot.jl:772
(::Type{T})(::AbstractChar) where T<:Union{AbstractChar, Number} at char.jl:50
(::Type{T})(::Base.TwicePrecision) where T<:Number at twiceprecision.jl:266
...

Stacktrace:
[1] convert(#unused#::Type{Float64}, x::SymTensorValue{2, Float64, 3})
@ Base .\number.jl:7
[2] setindex!(A::Vector{Float64}, x::SymTensorValue{2, Float64, 3}, i1::Int64)
@ Base .\array.jl:966
[3] add_entry!(#unused#::typeof(+), a::Gridap.Algebra.InserterCSC{Float64, Int64}, v::SymTensorValue{2, Float64, 3}, i::Int32, j::Int32)
@ Gridap.Algebra C:\Users\marya\.julia\packages\Gridap\971dU\src\Algebra\SparseMatrixCSC.jl:132
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Algebra\AlgebraInterfaces.jl:149 [inlined]
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Algebra\AlgebraInterfaces.jl:127 [inlined]
[6] evaluate!(cache::Nothing, k::Gridap.Arrays.AddEntriesMap{typeof(+)}, A::Gridap.Algebra.InserterCSC{Float64, Int64}, v::Matrix{SymTensorValue{2, Float64, 3}}, i::Vector{Int32}, j::Vector{Int32})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\AlgebraMaps.jl:47
[7] _numeric_loop_matrix!(mat::Gridap.Algebra.InserterCSC{Float64, Int64}, caches::Tuple{Nothing, Tuple{Tuple{Nothing, Tuple{Gridap.Arrays.CachedMatrix{SymTensorValue{2, Float64, 3}, Matrix{SymTensorValue{2, Float64, 3}}}, Gridap.Arrays.CachedVector{Float64, Vector{Float64}}}, Tuple{Tuple{Tuple{Nothing, Gridap.Arrays.CachedArray{SymTensorValue{2, Float64, 3}, 3, Array{SymTensorValue{2, Float64, 3}, 3}}, Tuple{Nothing, Tuple{Tuple{Nothing, Gridap.Arrays.CachedArray{TensorValue{2, 2, Float64, 4}, 3, Array{TensorValue{2, 2, Float64, 4}, 3}}, Tuple{Tuple{Tuple{Nothing, Nothing, Tuple{Tuple{Tuple{Nothing, Gridap.Arrays.CachedMatrix{TensorValue{2, 2, Float64, 4}, Matrix{TensorValue{2, 2, Float64, 4}}}, Tuple{Tuple{Tuple{Nothing, Gridap.Arrays.CachedVector{TensorValue{2, 2, Float64, 4}, Vector{TensorValue{2, 2, Float64, 4}}}, Tuple{Tuple{Tuple{Tuple{Tuple{Nothing, Nothing, Tuple{Tuple{Tuple{Nothing, Nothing, Tuple{Tuple{Tuple{Nothing, Gridap.Arrays.CachedVector{VectorValue{2, Float64}, Vector{VectorValue{2, Float64}}}, Tuple{Gridap.Arrays.CachedVector{Int64, Vector{Int64}}}}, Gridap.Arrays.IndexItemPair{Int64, Vector{VectorValue{2, Float64}}}}, Nothing}}, Gridap.Arrays.IndexItemPair{Int64, TensorValue{2, 2, Float64, 4}}}}}, Gridap.Arrays.IndexItemPair{Int64, ConstantField{TensorValue{2, 2, Float64, 4}}}}, Gridap.Arrays.CachedVector{TensorValue{2, 2, Float64, 4}, Vector{TensorValue{2, 2, Float64, 4}}}, Tuple{Nothing}}, Gridap.Arrays.IndexItemPair{Int64, Vector{TensorValue{2, 2, Float64, 4}}}}}}, Gridap.Arrays.IndexItemPair{Int64, Vector{TensorValue{2, 2, Float64, 4}}}}, Nothing}}, Gridap.Arrays.IndexItemPair{Int64, Matrix{TensorValue{2, 2, Float64, 4}}}}}}, Gridap.Arrays.IndexItemPair{Int64, Gridap.Fields.TransposeFieldIndices{Matrix{TensorValue{2, 2, Float64, 4}}, TensorValue{2, 2, Float64, 4}}}}, Tuple{Tuple{Nothing, Gridap.Arrays.CachedMatrix{TensorValue{2, 2, Float64, 4}, Matrix{TensorValue{2, 2, Float64, 4}}}, Tuple{Tuple{Tuple{Nothing, Gridap.Arrays.CachedVector{TensorValue{2, 2, Float64, 4}, Vector{TensorValue{2, 2, Float64, 4}}}, Tuple{Tuple{Tuple{Tuple{Tuple{Nothing, Nothing, Tuple{Tuple{Tuple{Nothing, Nothing, Tuple{Tuple{Tuple{Nothing, Gridap.Arrays.CachedVector{VectorValue{2, Float64}, Vector{VectorValue{2, Float64}}}, Tuple{Gridap.Arrays.CachedVector{Int64, Vector{Int64}}}}, Gridap.Arrays.IndexItemPair{Int64, Vector{VectorValue{2, Float64}}}}, Nothing}}, Gridap.Arrays.IndexItemPair{Int64, TensorValue{2, 2, Float64, 4}}}}}, Gridap.Arrays.IndexItemPair{Int64, ConstantField{TensorValue{2, 2, Float64, 4}}}}, Gridap.Arrays.CachedVector{TensorValue{2, 2, Float64, 4}, Vector{TensorValue{2, 2, Float64, 4}}}, Tuple{Nothing}}, Gridap.Arrays.IndexItemPair{Int64, Vector{TensorValue{2, 2, Float64, 4}}}}}}, Gridap.Arrays.IndexItemPair{Int64, Vector{TensorValue{2, 2, Float64, 4}}}}, Nothing}}, Gridap.Arrays.IndexItemPair{Int64, Matrix{TensorValue{2, 2, Float64, 4}}}}}}, Gridap.Arrays.IndexItemPair{Int64, Array{TensorValue{2, 2, Float64, 4}, 3}}}}}, Gridap.Arrays.IndexItemPair{Int64, Array{SymTensorValue{2, Float64, 3}, 3}}}, Nothing, Tuple{Tuple{Tuple{Tuple{Nothing, Nothing, Tuple{Tuple{Tuple{Nothing, Nothing, Tuple{Tuple{Tuple{Nothing, Gridap.Arrays.CachedVector{VectorValue{2, Float64}, Vector{VectorValue{2, Float64}}}, Tuple{Gridap.Arrays.CachedVector{Int64, Vector{Int64}}}}, Gridap.Arrays.IndexItemPair{Int64, Vector{VectorValue{2, Float64}}}}, Nothing}}, Gridap.Arrays.IndexItemPair{Int64, TensorValue{2, 2, Float64, 4}}}}}, Gridap.Arrays.IndexItemPair{Int64, ConstantField{TensorValue{2, 2, Float64, 4}}}}, Gridap.Arrays.CachedVector{TensorValue{2, 2, Float64, 4}, Vector{TensorValue{2, 2, Float64, 4}}}, Tuple{Nothing}}, Gridap.Arrays.IndexItemPair{Int64, Vector{TensorValue{2, 2, Float64, 4}}}}}}, Gridap.Arrays.IndexItemPair{Int64, Matrix{SymTensorValue{2, Float64, 3}}}}, Gridap.Arrays.CachedVector{Int32, Vector{Int32}}, Gridap.Arrays.CachedVector{Int32, Vector{Int32}}}, cell_vals::Gridap.Arrays.LazyArray{FillArrays.Fill{IntegrationMap, 1, Tuple{Base.OneTo{Int64}}}, Matrix{SymTensorValue{2, Float64, 3}}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.BroadcastingFieldOpMap{typeof(inner)}, 1, Tuple{Base.OneTo{Int64}}}, Array{SymTensorValue{2, Float64, 3}, 3}, 1, Tuple{Gridap.Arrays.CompressedArray{Vector{SymFourthOrderTensorValue{2, Float64, 9}}, 1, Vector{Vector{SymFourthOrderTensorValue{2, Float64, 9}}}, Vector{Int8}}, Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)}, 1, Tuple{Base.OneTo{Int64}}}, Array{TensorValue{2, 2, Float64, 4}, 3}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.TransposeMap, 1, Tuple{Base.OneTo{Int64}}}, Gridap.Fields.TransposeFieldIndices{Matrix{TensorValue{2, 2, Float64, 4}}, TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)}, 1, Tuple{Base.OneTo{Int64}}}, Matrix{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Broadcasting{typeof(pinvJt)}, 1, Tuple{Base.OneTo{Int64}}}, Vector{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{Gridap.Arrays.LazyArray{FillArrays.Fill{typeof(constant_field), 1, Tuple{Base.OneTo{Int64}}}, ConstantField{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.LinearCombinationMap{Colon}, 1, Tuple{Base.OneTo{Int64}}}, TensorValue{2, 2, Float64, 4}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Broadcasting{Reindex{Vector{VectorValue{2, Float64}}}}, 1, Tuple{Base.OneTo{Int64}}}, Vector{VectorValue{2, Float64}}, 1, Tuple{Gridap.Arrays.Table{Int64, Vector{Int64}, Vector{Int32}}}}, Gridap.Arrays.CompressedArray{Vector{VectorValue{2, Float64}}, 1, Vector{Vector{VectorValue{2, Float64}}}, Vector{Int8}}}}}}, Vector{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.CompressedArray{Vector{VectorValue{2, Float64}}, 1, Vector{Vector{VectorValue{2, Float64}}}, Vector{Int8}}}}}}, Gridap.Arrays.CompressedArray{Matrix{TensorValue{2, 2, Float64, 4}}, 1, Vector{Matrix{TensorValue{2, 2, Float64, 4}}}, Vector{Int8}}}}}}, Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)}, 1, Tuple{Base.OneTo{Int64}}}, Matrix{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Broadcasting{typeof(pinvJt)}, 1, Tuple{Base.OneTo{Int64}}}, Vector{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{Gridap.Arrays.LazyArray{FillArrays.Fill{typeof(constant_field), 1, Tuple{Base.OneTo{Int64}}}, ConstantField{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.LinearCombinationMap{Colon}, 1, Tuple{Base.OneTo{Int64}}}, TensorValue{2, 2, Float64, 4}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Broadcasting{Reindex{Vector{VectorValue{2, Float64}}}}, 1, Tuple{Base.OneTo{Int64}}}, Vector{VectorValue{2, Float64}}, 1, Tuple{Gridap.Arrays.Table{Int64, Vector{Int64}, Vector{Int32}}}}, Gridap.Arrays.CompressedArray{Vector{VectorValue{2, Float64}}, 1, Vector{Vector{VectorValue{2, Float64}}}, Vector{Int8}}}}}}, Vector{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.CompressedArray{Vector{VectorValue{2, Float64}}, 1, Vector{Vector{VectorValue{2, Float64}}}, Vector{Int8}}}}}}, Gridap.Arrays.CompressedArray{Matrix{TensorValue{2, 2, Float64, 4}}, 1, Vector{Matrix{TensorValue{2, 2, Float64, 4}}}, Vector{Int8}}}}}}}}, Gridap.Arrays.CompressedArray{Vector{Float64}, 1, Vector{Vector{Float64}}, Vector{Int8}}, Gridap.Arrays.LazyArray{Gridap.Arrays.LazyArray{FillArrays.Fill{typeof(constant_field), 1, Tuple{Base.OneTo{Int64}}}, ConstantField{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Gridap.Fields.LinearCombinationMap{Colon}, 1, Tuple{Base.OneTo{Int64}}}, TensorValue{2, 2, Float64, 4}, 1, Tuple{Gridap.Arrays.LazyArray{FillArrays.Fill{Broadcasting{Reindex{Vector{VectorValue{2, Float64}}}}, 1, Tuple{Base.OneTo{Int64}}}, Vector{VectorValue{2, Float64}}, 1, Tuple{Gridap.Arrays.Table{Int64, Vector{Int64}, Vector{Int32}}}}, Gridap.Arrays.CompressedArray{Vector{VectorValue{2, Float64}}, 1, Vector{Vector{VectorValue{2, Float64}}}, Vector{Int8}}}}}}, Vector{TensorValue{2, 2, Float64, 4}}, 1, Tuple{Gridap.Arrays.CompressedArray{Vector{VectorValue{2, Float64}}, 1, Vector{Vector{VectorValue{2, Float64}}}, Vector{Int8}}}}}}, cell_rows::Gridap.Arrays.Table{Int32, Vector{Int32}, Vector{Int32}}, cell_cols::Gridap.Arrays.Table{Int32, Vector{Int32}, Vector{Int32}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\SparseMatrixAssemblers.jl:261
[8] numeric_loop_matrix!(A::Gridap.Algebra.InserterCSC{Float64, Int64}, a::Gridap.FESpaces.GenericSparseMatrixAssembler, matdata::Tuple{Vector{Any}, Vector{Any}, Vector{Any}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\SparseMatrixAssemblers.jl:248
[9] assemble_matrix(a::Gridap.FESpaces.GenericSparseMatrixAssembler, matdata::Tuple{Vector{Any}, Vector{Any}, Vector{Any}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\SparseMatrixAssemblers.jl:107
[10] assemble_matrix(f::var"#236#237"{NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, a::Gridap.FESpaces.GenericSparseMatrixAssembler, U::TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, V::Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:285
[11] assemble_matrix
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:342 [inlined]
[12] MatrixOf
@ .\In[99]:3 [inlined]
[13] gf_pf(pf_vec::Vector{Float64}; β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[104]:7
[14] #rrule#244
@ .\In[104]:15 [inlined]
[15] chain_rrule_kw
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\chainrules.jl:229 [inlined]
[16] macro expansion
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0 [inlined]
[17] _pullback(::Zygote.Context, ::var"#gf_pf##kw", ::NamedTuple{(:β, :η, :fem_params), Tuple{Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_pf), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:9
[18] _pullback
@ .\In[106]:3 [inlined]
[19] _pullback(::Zygote.Context, ::var"##gf_p#257", ::Float64, ::Float64, ::Float64, ::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[20] _pullback
@ .\In[106]:1 [inlined]
[21] _pullback(::Zygote.Context, ::var"#gf_p##kw", ::NamedTuple{(:r, :β, :η, :fem_params), Tuple{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[22] _pullback
@ .\In[106]:8 [inlined]
[23] _pullback(ctx::Zygote.Context, f::var"#259#261"{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[24] _pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:34
[25] pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:40
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:75
[27] gf_p(p0::Vector{Float64}, grad::Vector{Float64}; r::Float64, β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[106]:8
[28] top-level scope
@ In[107]:5

``````

This doesn’t look right. The result of this operation is not a scalar if `C_mat` is a matrix (tensor). Hence the error message about failing to convert a tensor to a `Float64` scalar.

It seems like your main difficulty is that you are mis -interpreting the error messages.

you are right. why it should be scalar?
i have changed the operation to make it scalar but there are some other issues.

`````` ∫((0.5 * C_mat) ⋅ (∇(u) ⋅ ∇(v)))fem_params.dΩ
``````

the error is

``````This function is not yet implemented

Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] macro expansion
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Helpers\Macros.jl:21 [inlined]
[3] dot(a::SymFourthOrderTensorValue{2, Float64, 9}, b::TensorValue{2, 2, Float64, 4})
@ Gridap.TensorValues C:\Users\marya\.julia\packages\Gridap\971dU\src\TensorValues\Operations.jl:146
[4] evaluate!(::Nothing, ::Function, ::SymFourthOrderTensorValue{2, Float64, 9}, ::TensorValue{2, 2, Float64, 4})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:93
[5] evaluate
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:87 [inlined]
[6] return_value(::Function, ::SymFourthOrderTensorValue{2, Float64, 9}, ::TensorValue{2, 2, Float64, 4})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:64
[7] return_type(::Function, ::SymFourthOrderTensorValue{2, Float64, 9}, ::Vararg{Any})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:62
[8] return_cache(::Broadcasting{typeof(dot)}, ::Vector{SymFourthOrderTensorValue{2, Float64, 9}}, ::Array{TensorValue{2, 2, Float64, 4}, 3})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:209
[9] return_cache(::Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)}, ::Vector{SymFourthOrderTensorValue{2, Float64, 9}}, ::Array{TensorValue{2, 2, Float64, 4}, 3})
@ Gridap.Fields C:\Users\marya\.julia\packages\Gridap\971dU\src\Fields\FieldArrays.jl:513
[10] evaluate(::Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)}, ::Vector{SymFourthOrderTensorValue{2, Float64, 9}}, ::Array{TensorValue{2, 2, Float64, 4}, 3})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:86
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:90
[12] Gridap.CellData.OperationCellField(::Operation{typeof(dot)}, ::Gridap.CellData.GenericCellField{ReferenceDomain}, ::Vararg{CellField})
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:477
[13] _operate_cellfields(::Operation{typeof(dot)}, ::Gridap.CellData.GenericCellField{ReferenceDomain}, ::Vararg{Any})
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:542
[14] evaluate!(::Nothing, ::Operation{typeof(dot)}, ::SymFourthOrderTensorValue{2, Float64, 9}, ::Gridap.CellData.OperationCellField{ReferenceDomain})
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:443
[15] evaluate(::Operation{typeof(dot)}, ::SymFourthOrderTensorValue{2, Float64, 9}, ::Gridap.CellData.OperationCellField{ReferenceDomain})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:87
[16] (::Operation{typeof(dot)})(::SymFourthOrderTensorValue{2, Float64, 9}, ::Vararg{Any})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:90
[17] dot
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:624 [inlined]
[18] (::var"#374#375"{NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}})(u::Gridap.FESpaces.SingleFieldFEBasis{Gridap.FESpaces.TrialBasis, ReferenceDomain}, v::Gridap.FESpaces.SingleFieldFEBasis{Gridap.FESpaces.TestBasis, ReferenceDomain})
@ Main .\In[137]:4
[19] assemble_matrix(f::var"#374#375"{NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, a::Gridap.FESpaces.GenericSparseMatrixAssembler, U::TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, V::Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:285
[20] assemble_matrix
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:342 [inlined]
[21] MatrixOf
@ .\In[137]:3 [inlined]
[22] gf_pf(pf_vec::Vector{Float64}; β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[140]:7
[23] #rrule#382
@ .\In[140]:15 [inlined]
[24] chain_rrule_kw
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\chainrules.jl:229 [inlined]
[25] macro expansion
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0 [inlined]
[26] _pullback(::Zygote.Context, ::var"#gf_pf##kw", ::NamedTuple{(:β, :η, :fem_params), Tuple{Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_pf), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:9
[27] _pullback
@ .\In[142]:3 [inlined]
[28] _pullback(::Zygote.Context, ::var"##gf_p#395", ::Float64, ::Float64, ::Float64, ::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[29] _pullback
@ .\In[142]:1 [inlined]
[30] _pullback(::Zygote.Context, ::var"#gf_p##kw", ::NamedTuple{(:r, :β, :η, :fem_params), Tuple{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[31] _pullback
@ .\In[142]:8 [inlined]
[32] _pullback(ctx::Zygote.Context, f::var"#397#399"{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[33] _pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:34
[34] pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:40
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:75
[36] gf_p(p0::Vector{Float64}, grad::Vector{Float64}; r::Float64, β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[142]:8
[37] top-level scope
@ In[143]:5

``````

Because it’s the weak form of a PDE. This is generally a scalar-valued quadratic form by definition, and when you evaluate it on the basis functions you get the FEM matrix elements, which are scalars.

This kind of thing is covered in any textbook on finite-element methods. I think the Gridap manual assumes that readers already have a general familiarity with FEM concepts, so you might want to review some background material.

thank you. as you see in my code i need to integrate the material constitutive matrix (c_mat) multiplication by FE basis. how it could be a scalar value. i thought that i can get this by cdot but as it was shown there are errors related to this.

Again, you need to learn about weak forms. What PDE are you trying to solve? Have you tried looking for books or papers explaining how to solve this with FEM, and giving the weak form? You need to understand the math here before you worry about code.

(I’m guessing that your matrix belongs between the two gradients in the inner product, not outside. But I don’t want to guess at what equations you are actually trying to solve.)

ok. thank you for your help

based on your suggestions i reviewed FE books and i found the right equation as below but it is nor a scalar value and as i run it gives me error.

``````function MatrixOf(fem_params)

return assemble_matrix(fem_params.U_Disp, fem_params.V0_Disp) do u, v
0.5*∫((∇(u))' ⋅ C_mat ⋅ ∇(v))fem_params.dΩ
end
end
``````

the error is

``````This function is not yet implemented

Stacktrace:
[1] error(s::String)
@ Base .\error.jl:35
[2] macro expansion
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Helpers\Macros.jl:21 [inlined]
[3] dot(a::TensorValue{2, 2, Float64, 4}, b::SymFourthOrderTensorValue{2, Float64, 9})
@ Gridap.TensorValues C:\Users\marya\.julia\packages\Gridap\971dU\src\TensorValues\Operations.jl:146
[4] evaluate!(::Nothing, ::Function, ::TensorValue{2, 2, Float64, 4}, ::SymFourthOrderTensorValue{2, Float64, 9})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:93
[5] evaluate
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:87 [inlined]
[6] return_value(::Function, ::TensorValue{2, 2, Float64, 4}, ::SymFourthOrderTensorValue{2, Float64, 9})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:64
[7] return_type(::Function, ::TensorValue{2, 2, Float64, 4}, ::Vararg{Any})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:62
[8] return_cache(::Broadcasting{typeof(dot)}, ::Array{TensorValue{2, 2, Float64, 4}, 3}, ::Vector{SymFourthOrderTensorValue{2, Float64, 9}})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:209
[9] return_cache(::Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)}, ::Array{TensorValue{2, 2, Float64, 4}, 3}, ::Vector{SymFourthOrderTensorValue{2, Float64, 9}})
@ Gridap.Fields C:\Users\marya\.julia\packages\Gridap\971dU\src\Fields\FieldArrays.jl:513
[10] evaluate(::Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)}, ::Array{TensorValue{2, 2, Float64, 4}, 3}, ::Vector{SymFourthOrderTensorValue{2, Float64, 9}})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:86
[11] (::Gridap.Fields.BroadcastingFieldOpMap{typeof(dot)})(::Array{TensorValue{2, 2, Float64, 4}, 3}, ::Vararg{Any})
@ Gridap.Arrays C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:90
[12] Gridap.CellData.OperationCellField(::Operation{typeof(dot)}, ::Gridap.CellData.OperationCellField{ReferenceDomain}, ::Vararg{CellField})
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:477
[13] _operate_cellfields(::Operation{typeof(dot)}, ::Gridap.CellData.OperationCellField{ReferenceDomain}, ::Vararg{Any})
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:542
[14] evaluate!(::Nothing, ::Operation{typeof(dot)}, ::Gridap.CellData.OperationCellField{ReferenceDomain}, ::SymFourthOrderTensorValue{2, Float64, 9})
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:443
[15] evaluate
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:87 [inlined]
[16] Map
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\Arrays\Maps.jl:90 [inlined]
[17] dot(a::Gridap.CellData.OperationCellField{ReferenceDomain}, b::SymFourthOrderTensorValue{2, Float64, 9})
@ Gridap.CellData C:\Users\marya\.julia\packages\Gridap\971dU\src\CellData\CellFields.jl:623
[18] (::var"#12#13"{NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}})(u::Gridap.FESpaces.SingleFieldFEBasis{Gridap.FESpaces.TrialBasis, ReferenceDomain}, v::Gridap.FESpaces.SingleFieldFEBasis{Gridap.FESpaces.TestBasis, ReferenceDomain})
@ Main .\In[20]:4
[19] assemble_matrix(f::var"#12#13"{NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, a::Gridap.FESpaces.GenericSparseMatrixAssembler, U::TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, V::Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}})
@ Gridap.FESpaces C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:285
[20] assemble_matrix
@ C:\Users\marya\.julia\packages\Gridap\971dU\src\FESpaces\Assemblers.jl:342 [inlined]
[21] MatrixOf
@ .\In[20]:3 [inlined]
[22] gf_pf(pf_vec::Vector{Float64}; β::Float64, η::Float64, fem_params::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}})
@ Main .\In[22]:7
[23] #rrule#20
@ .\In[22]:15 [inlined]
[24] chain_rrule_kw
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\chainrules.jl:229 [inlined]
[25] macro expansion
@ C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0 [inlined]
[26] _pullback(::Zygote.Context, ::var"#gf_pf##kw", ::NamedTuple{(:β, :η, :fem_params), Tuple{Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_pf), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:9
[27] _pullback
@ .\In[24]:3 [inlined]
[28] _pullback(::Zygote.Context, ::var"##gf_p#33", ::Float64, ::Float64, ::Float64, ::NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[29] _pullback
@ .\In[24]:1 [inlined]
[30] _pullback(::Zygote.Context, ::var"#gf_p##kw", ::NamedTuple{(:r, :β, :η, :fem_params), Tuple{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}}, ::typeof(gf_p), ::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[31] _pullback
@ .\In[24]:8 [inlined]
[32] _pullback(ctx::Zygote.Context, f::var"#35#37"{Float64, Float64, Float64, NamedTuple{(:V0_Disp, :U_Disp, :Q, :P, :Qf, :Pf, :np, :Ω, :dΩ, :dΓ_Load), Tuple{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}, TrialFESpace{Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{VectorValue{2, Int32}}}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Nothing}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Gridap.FESpaces.UnconstrainedFESpace{Vector{Float64}, Gridap.FESpaces.NodeToDofGlue{Int32}}, Int64, BodyFittedTriangulation{2, 2, UnstructuredDiscreteModel{2, 2, Float64, Oriented}, UnstructuredGrid{2, 2, Float64, Oriented, Nothing}, Gridap.Arrays.IdentityVector{Int64}}, Gridap.CellData.GenericMeasure, Gridap.CellData.GenericMeasure}}}, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface2.jl:0
[33] _pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:34
[34] pullback(f::Function, args::Vector{Float64})
@ Zygote C:\Users\marya\.julia\packages\Zygote\IoW2g\src\compiler\interface.jl:40
It sounds like you want `∇(u) ⋅ (C_mat ⋅ ∇(v))` if I understand Gridap’s tensor operations (see listing 7 in this paper) correctly.