Closed santiagobadia closed 4 years ago
Just to complement your post. It is not needed to create a new FESpace struct. It is only needed to create a new constructor function that eventually creates a UnconstrainedFESpace
object as it is done in GradConformingFESpace
and DivConformingFESpace
.
Hi @fverdugo
I have been thinking how to implement FEs in the physical space, and create a simple code with what I think we must implement here.
I think that we need a new type of array of shape functions that will involve the computation of the change of basis per cell. We cannot use BasisFromChangeOfBasis
anymore. I have just wrote in this file the steps needed to compute such change of basis function at every cell.
I was wondering which is the best way to implement this new CellBasis
object, probably called CellBasisFromChangeOfBasis
, probably using as much as possible existing code and structs we already have in Gridap
. Another important issue is efficiency, so I think this CellBasis
should be iterable, certainly making use of a cache array, etc.
If you have some time, and you want to tell me what you think should be the best way to implement it, it would be perfect. In any case, I will think about it.
I am not sure if I understand 100% correctly. Your inputs are the arrays cell_prebasis
and cell_dof_basis
, right?.
cell_matrix = evaluate_dof_array(cell_dof_basis,cell_prebasis)
cell_matrix_inv = apply(inv,cell_matrix)
Then, you want to apply all the change of bases in cell_matrix_inv
cell-wise to all the entries in cell_prebasis
.
If you are not worried about performance, this can be done as
cell_shapefuns = apply(change_basis,cell_prebasis,cell_matrix_inv)
If you are worried about performance, instead of applying inv
and change_basis
you need to define two new kernels that better handles the caches.
I'm trying to do what you propose, but there is an error in
https://github.com/gridap/Gridap.jl/blob/a826fc8c4f3cc70cf5956431a1c6b6413adbbdc4/test/FESpacesTests/PhysicalBasesTests.jl#L51
related to the zero
method for the cell_prebasis
type argument.
I have to take a look into this, but it shouldn't be very difficult to fix.
I have fixed this and pushed to the physical-fes
branch.
Hi @fverdugo Can you help me with this error https://github.com/gridap/Gridap.jl/blob/152df55e4ee378827d053e11d315eff4e2f2dee2/test/FESpacesTests/PhysicalBasesTests.jl#L72-L76 I cannot evaluate the gradient in an array of points. I am trying to understand where do I need to implement the gradient method, but the stack is pretty deep and complicated. Any insight that could help me here?
Btw, I have been playing with the Juno debugger, which I think starts to be needed to navigate through the code.
Is this the error you get??
julia> include("test/FESpacesTests/PhysicalBasesTests.jl")
ERROR: LoadError: type Array has no field value
Stacktrace:
[1] getproperty(::Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1}, ::Symbol) at ./Base.jl:20
[2] (::Gridap.Arrays.var"#21#22"{Array{Int8,1},Int64})(::Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1}) at ./none:0
[3] iterate(::Base.Generator{FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}},Gridap.Arrays.var"#21#22"{Array{Int8,1},Int64}}) at ./generator.jl:47
[4] top-level scope at /home/fverdugo/Code/jl/Gridap.jl/test/FESpacesTests/PhysicalBasesTests.jl:70
[5] include at ./boot.jl:328 [inlined]
[6] include_relative(::Module, ::String) at ./loading.jl:1105
[7] include(::Module, ::String) at ./Base.jl:31
[8] include(::String) at ./client.jl:424
[9] top-level scope at REPL[2]:1
in expression starting at /home/fverdugo/Code/jl/Gridap.jl/test/FESpacesTests/PhysicalBasesTests.jl:70
No the error is
julia> include("test/FESpacesTests/PhysicalBasesTests.jl")
ERROR: LoadError: This function belongs to an interface definition and cannot be used.
Stacktrace:
[1] macro expansion at /home/santiago/github-repos/Gridap/Gridap.jl/src/Helpers/Macros.jl:9 [inlined]
[2] gradient_cache(::Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}}, ::Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldInterface.jl:161
[3] gradient_cache(::Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}, ::Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Polynomials/ChangeBasis.jl:63
[4] field_cache at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldInterface.jl:126 [inlined]
[5] evaluate_field(::Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}}, ::Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldInterface.jl:293
[6] field_return_type(::Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}}, ::Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldInterface.jl:102
[7] kernel_return_type(::Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}}, ::Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldInterface.jl:181
[8] Gridap.Arrays.AppliedArray(::Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Arrays/Apply.jl:176
[9] apply(::Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Arrays/Apply.jl:105
[10] _evaluate_field_array(::Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:36
[11] kernel_evaluate(::Gridap.Fields.Grad, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}, ::Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:99
[12] evaluate_field_array(::Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:79
[13] _evaluate_field_arrays(::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}, ::Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Gridap.Fields.AffineMapGrad{1,Float64,1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:51
[14] evaluate_field_arrays(::Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}},FillArrays.Fill{Gridap.Fields.AffineMapGrad{1,Float64,1},1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:47
[15] kernel_evaluate(::Gridap.Fields.Valued{Gridap.Fields.PhysGrad}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}, ::Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Gridap.Fields.AffineMapGrad{1,Float64,1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:274
[16] evaluate_field_array(::Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.PhysGrad,Tuple{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},Gridap.Fields.AffineMapGrad{1,Float64,1}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}},FillArrays.Fill{Gridap.Fields.AffineMapGrad{1,Float64,1},1,Tuple{Base.OneTo{Int64}}}},FillArrays.Fill{Gridap.Fields.Valued{Gridap.Fields.PhysGrad},1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:79
[17] evaluate(::Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.PhysGrad,Tuple{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},Gridap.Fields.AffineMapGrad{1,Float64,1}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.FieldGrad{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Polynomials.BasisFromChangeOfBasis{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},Array{Float64,2}},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}},Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Array{Float64,2},1,Tuple{Gridap.Arrays.AppliedArray{Gridap.Fields.AppliedField{Gridap.Fields.MapGrad,Tuple{MonomialBasis{1,Float64},AffineMap{1,Float64,1}}},1,Tuple{CompressedArray{MonomialBasis{1,Float64},1,Array{MonomialBasis{1,Float64},1},Array{Int8,1}},Gridap.Geometry.CartesianMap{1,Float64,1}},FillArrays.Fill{Gridap.Fields.AddMap,1,Tuple{Base.OneTo{Int64}}}}},CompressedArray{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1,Array{LagrangianDofBasis{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},Int64},1},Array{Int8,1}}}},FillArrays.Fill{typeof(inv),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{typeof(change_basis),1,Tuple{Base.OneTo{Int64}}}}},FillArrays.Fill{Gridap.Fields.Grad,1,Tuple{Base.OneTo{Int64}}}},FillArrays.Fill{Gridap.Fields.AffineMapGrad{1,Float64,1},1,Tuple{Base.OneTo{Int64}}}},FillArrays.Fill{Gridap.Fields.Valued{Gridap.Fields.PhysGrad},1,Tuple{Base.OneTo{Int64}}}}, ::FillArrays.Fill{Array{Gridap.TensorValues.MultiValue{Tuple{1},Float64,1,1},1},1,Tuple{Base.OneTo{Int64}}}) at /home/santiago/github-repos/Gridap/Gridap.jl/src/Fields/FieldArrays.jl:72
[18] top-level scope at /home/santiago/github-repos/Gridap/Gridap.jl/test/FESpacesTests/PhysicalBasesTests.jl:75
[19] include at ./boot.jl:328 [inlined]
[20] include_relative(::Module, ::String) at ./loading.jl:1094
[21] include(::Module, ::String) at ./Base.jl:31
[22] include(::String) at ./client.jl:431
[23] top-level scope at none:0
in expression starting at /home/santiago/github-repos/Gridap/Gridap.jl/test/FESpacesTests/PhysicalBasesTests.jl:75
I have pushed my last version just in case I left some unintended thing.
I copy here the sketch of how to create lagrangian interpolations in the physical space
# Physical cell dof basis
reffes = [LagrangianRefFE(T,p,order) for p in polytopes]
ctype_to_refnodes= map(get_node_coordinates,reffes)
cell_to_refnodes = CompressedArray(ctype_to_refnodes,cell_to_ctype)
cell_physnodes = evaluate(cell_map,cell_to_refnodes)
cell_dof_basis = apply( nodes -> LagrangianDofBasis(T,nodes), cell_physnodes )
# Prebasis
## I think we don't want to attach the cell_map since the distance between
## the nodes at the physical space will already lead to the correct
## gradient wrt the physical coordinate
ctype_to_prebasis= map(get_prebasis,reffes)
cell_prebasis = CompressedArray(ctype_to_prebasis,cell_to_ctype)
# Shape functions (evaluable at physical space)
cell_matrix = evaluate_dof_array(cell_dof_basis,cell_prebasis)
cell_matrix_inv = apply(inv,cell_matrix)
cell_physshapefuns = apply(change_basis,cell_prebasis,cell_matrix_inv)
# Shape functions (evaluable at reference space in order to use standard quadratures)
cell_physshapefuns_evaluable_at_refgp = compose(cell_physshapefuns,cell_map)
Hi @fverdugo
The creation of a FE Space part for DOFs in the physical space is working.
The problem now is
function interpolate(fs::SingleFieldFESpace,object)
cell_map = get_cell_map(fs)
cell_field = convert_to_cell_field(object,cell_map)
# Here we have a problem because the nodes are in the physical space!!!
free_values = compute_free_values(fs,cell_field)
FEFunction(fs,free_values)
end
Do you have an easy CellField
constructor that takes a function as argument, without a cell_map
?
I think we need a new CellField
concrete struct that takes a function in its constructor, infers the result type for a Point
and checks that it is a Field
, and implements all the required methods of a CellFieldLike
.
Another option would be to create a mock CellMap
that would represent the identity. The problem is that it is assumed in the code that a CellField
must have a method that provides a CellMap
.
I have already solved the previous issue by generating new interpolation
methods
The problem is that So far we assume that cell fields are evaluated at the reference space, good for integrating them, but this does not work for interpolation in general as you have noticed when trying to interpolate...
Perhaps we can circunvent the problem with new interpolation methods, but not sure if it will work always...eg with zero mean fe spaces, restricted fe spaces etc.
We need to discuss this face to face since it is not an obvious topic.
Hi @fverdugo
You can check what I have done by comparing branches.
As you will see, I have created a FunctionField
that I have used in the interpolation
methods in the physical space. See
https://github.com/gridap/Gridap.jl/blob/51eda45e59d541ec889d97cff8108f32aed990ac/src/FESpaces/SingleFieldFESpaces.jl#L218
I have also included the dofspace
argument in the FE space factories.
I think that it is still missing
FESpace
called dofs_physical
(or dofs_reference
)?InvKernel()
and implement the Kernel
interface for this type.kernel_evaluate
for typeof{changeofbasis}
apply_gradient
for typeof{changeofbasis}
What else?
closed via PR #216 and PR #218
I want to create a new kind of
FESpace
that does not rely on aReferenceFE
but transforms the prebasis into the FE basis by making use of DOFs defined in the physical space.It seems that we must re-think the function
compute_cell_space
in https://github.com/gridap/Gridap.jl/blob/10b35b22d20f5091eee0f0c95bf59fba0a0de51f/src/FESpaces/ConformingFESpaces.jl#L87-L97and more specifically the part related to
dof_basis
, which should be combined withcell_map