You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to start using automatic diff for computing differential operators over analytical functions. We should think how to implement this within Gridap. I would use ForwardDiff, which provides what we need. The following example goes beyond Gridap, since it also includes transient problems. The transient part will go to GridapODEs.
using ForwardDiff
u(t::Real) = x ->u(x,t)
∇u(x,t) =VectorValue(ForwardDiff.gradient(u(t),x)...)
∇u(x::Gridap.TensorValues.MultiValue,t) =∇u(x.array,t)
∇u(t::Real) = x ->∇u(x,t)
_∇u(x,t) = ForwardDiff.gradient(u(t),x)
_∇u(t::Real) = x -> ForwardDiff.gradient(u(t),x)
Δu(x,t) =tr(ForwardDiff.jacobian(_∇u(t),x))
Δu(x::Gridap.TensorValues.MultiValue,t) =Δu(x.array,t)
Δu(t::Real) = x ->Δu(x,t)
v(x) = t ->u(x,t)
∂tu(t) = x -> ForwardDiff.derivative(v(x),t)
∂tu(x,t) =∂tu(t)(x)
∂t(::typeof(u)) = ∂tu
∇(::typeof(u)) = ∇u
The text was updated successfully, but these errors were encountered:
@santiagobadia Could you write the wanted API for a stady-state problem?
I have the feeling (just an intuition) that it will be easier to use ForwardDiff to compute time derivatives than to compute spatial gradients or jacobians of residuals
@fverdugo not sure I understand, I am already doing the space diff in the example above. The space-only case is a simplification of the one above. I am not sure about performance, but I can easily check... In any case, for the moment, I am just considering to use it for analytical functions, relieving the user from computing them manually for code validation in manufactured solutions, which is very prompt to error. Not for the residual, jacobian, yet.
I would like to start using automatic diff for computing differential operators over analytical functions. We should think how to implement this within
Gridap
. I would useForwardDiff
, which provides what we need. The following example goes beyondGridap
, since it also includes transient problems. The transient part will go toGridapODEs
.The text was updated successfully, but these errors were encountered: