gridap / GridapODEs.jl

Time stepping for Gridap
MIT License
33 stars 7 forks source link

more flexible transient fe term constructors #22

Closed santiagobadia closed 2 years ago

santiagobadia commented 4 years ago

@fverdugo and @oriolcg

In GridapODEs we have lots of possible options to define terms (linear or nonlinear syntax; vector, stiffness matrix or mass matrix, etc). I propose the following:

function TransientAffineFETerm(trian,quad;rhs=nothing,mass=nothing,stiffness=nothing)

   t_Ω = TransientAffineFETerm(m,stiffness,rhs,trian,quad)
   # Internally deal with nothing

end

function TransientFETerm(trian,quad;residual=nothing,jacobian=nothing,jacobian_t=nothing)

   t_Ω = TransientAffineFETerm(residual,jacobian,jacobian_t,rhs,trian,quad)
   # Internally deal with nothing

end

to add to the alrady existing terms and deal internally with nothing for some terms in an efficient way.

Any suggestion?

santiagobadia commented 4 years ago

The reason is that e.g. for boundary or skeleton terms, you do not have a mass matrix and/or stiffness matrix. Now @oriolcg is using the solution 0.0*u*v

santiagobadia commented 4 years ago

Now we have

function get_cell_residual(tr::TransientFETermFromIntegration,t::Real,uh,uh_t,v)
  @assert is_a_fe_function(uh)
  @assert is_a_fe_function(uh_t)
  @assert is_a_fe_cell_basis(v)
  _v = restrict(v,tr.trian)
  _uh = restrict(uh,tr.trian)
  _uh_t = restrict(uh_t,tr.trian)
  integrate(tr.res(t,_uh,_uh_t,_v),tr.trian,tr.quad)
end

something like this

function get_cell_residual(tr::TransientFETermFromIntegration,t::Real,uh,uh_t,v)
  @assert is_a_fe_function(uh)
  @assert is_a_fe_function(uh_t)
  @assert is_a_fe_cell_basis(v)
  _v = restrict(v,tr.trian)
  _uh = restrict(uh,tr.trian)
  _uh_t = restrict(uh_t,tr.trian)
if tr.res == nothing
  # Create a trivial method that can deal with what comes next
else
  integrate(tr.res(t,_uh,_uh_t,_v),tr.trian,tr.quad)
end

is this acceptable? How to define the nothing-like object that will be cheap (almost do-nothing) and will not return errors later?

fverdugo commented 4 years ago

is this acceptable? How to define the nothing-like object that will be cheap (almost do-nothing) and will not return errors later?

At this level you can do almost anything you like without worrying about performance

fverdugo commented 4 years ago

to add to the alrady existing terms and deal internally with nothing for some terms in an efficient way. Any suggestion?

This is a way of doing it. The other option would be to have a syntax in the line of the issue https://github.com/gridap/Gridap.jl/issues/265. But, this is something that needs to be further explored.