Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hessian ad multifield #711

Closed
tmigot opened this issue Nov 12, 2021 · 2 comments
Closed

Hessian ad multifield #711

tmigot opened this issue Nov 12, 2021 · 2 comments

Comments

@tmigot
Copy link
Contributor

tmigot commented Nov 12, 2021

Thank you @amartinhuertas and @fverdugo for fixing the issue with the MultiField autodifferentiation in #687 . I think there is also the hessian function that needs to be fixed. For instance, the following script to get the hessian contribution was working with 0.15.5 but no longer. I tried combining gradient and jacobian, but this also leads too an error. Any idea how to recover this? Thanks!

using Gridap # works with Gridap 0.15.5, but not Gridap 0.17.5

n = 3
domain = (0, 1)

x0 = zeros(2)
xf = π * ones(2)
a = 1
c = 3
  
model = CartesianDiscreteModel(domain, n)
trian = Triangulation(model)
degree = 1
dΩ = Measure(trian, degree)
  
function f(x)
  φ, θ = x
  ∫(a * a * ∇(φ) ⊙ ∇(φ) + (c + a * (cos ∘ φ)) * (c + a * (cos ∘ φ)) * ∇(θ) ⊙ ∇(θ))dΩ
end
  
labels = get_face_labeling(model)
add_tag_from_tags!(labels, "diri1", [2])
add_tag_from_tags!(labels, "diri0", [1])
  
valuetype = Float64
reffe = ReferenceFE(lagrangian, valuetype, 1)
V0 = TestFESpace(
  model,
  reffe;
  conformity = :H1,
  labels = labels,
  dirichlet_tags = ["diri0", "diri1"],
)
V1 = TestFESpace(
  model,
  reffe;
  conformity = :H1,
  labels = labels,
  dirichlet_tags = ["diri0", "diri1"],
)
  
U0 = TrialFESpace(V0, [x0[1], xf[1]])
U1 = TrialFESpace(V0, [x0[2], xf[2]])
V = MultiFieldFESpace([V0, V1])
U = MultiFieldFESpace([U0, U1])
nU0 = Gridap.FESpaces.num_free_dofs(U0)
nU1 = Gridap.FESpaces.num_free_dofs(U1)
xin = zeros(nU0 + nU1)

yu = FEFunction(U, xin)
int = f(yu)
hess = Gridap.FESpaces._hessian(f, yu, int)
@fverdugo
Copy link
Member

I think that hessian can be implemented following the same lines as the Jacobian. See this file: https://github.com/gridap/Gridap.jl/blob/master/src/MultiField/MultiFieldFEAutodiff.jl

@tmigot
Copy link
Contributor Author

tmigot commented Dec 14, 2021

Closed via #731

@tmigot tmigot closed this as completed Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants