Closed oriolcg closed 2 years ago
Unfortunately, it is not so straightforward since you don't want to implement this for fe functions only, and you also want that your transient type behavies like a cell field.
I would try something like this:
struct TransientCellField{A,B} <: CellField
cellfield::A
derivatives::T
end
# Make this object behave like a CellField
# by delegating the methods to the internal cellfield
# e.g.
get_data(f::FEBasis) = get_data(f.cellfield)
DomainStyle(::Type{<:TransientCellField{A}}) where A = DomainStyle(A)
# Idem for
get_triangulation(f::TransientCellField)
gradient(a::TransientCellField)
∇∇(a::TransientCellField)
change_domain(a::TransientCellField,trian::Triangulation,target_domain::DomainStyle)
#Time derivative
# ∂t can be called in the resulting object until we run out of
# derivatives
function ∂t(f::TransientCellField)
cellfield, derivatives = first_and_tail(f.derivatives)
TransientCellField(cellfield,derivatives)
end
I am not sure if this will work when the cell field is a basis. I believe that the proper way to handle basis is to use the abstract type FEBasis
introduced in the mixed_dims
branch and implement also this type
struct TransientFEBasis{A,B} <: FEBasis
febasis::A
derivatives::T
end
which should implement the same methods as TransientCellField
plus these extra one:
BasisStyle(::Type{<:TransientFEBasis{A}}) where A = BasisStyle(A)
@fverdugo, @santiagobadia The new API is working in the branch https://github.com/gridap/GridapODEs.jl/tree/new_API_transient_fe_operators. I'll wait for the PR until the branch update_to_Gridap_0_16
is merged, which is ready and waiting for Gridap@0.16 to be registered.
After these merges, I think it should be a good point to release GridapODEs@0.7
Great! Does this work also for mixed-dimensional PDEs ? I think it's the more problematic case...
Good point, I haven't tried. I'll add a test for that.
As @fverdugo suggested, it would be nice to have this API
instead of
That should be easy to do by defining a new struct (or similar) such as
and implementing the functions:
∂t(u::TransientFEFunction)=u.x[2]
and∂tt(u::TransientFEFunction)=u.x[3]
. However, there is the issue of what to do for the 0-th time derivative, i.e. ina(u,v)
, since now this will contain a tuple. We should use some operator to get the first entry likea(∂(u),v)
with∂(u::TransientFEFunction)=u.x[1]
. Any suggestion on the notation or other approaches, @santiagobadia @fverdugo ?