Hello,
I am trying to find a way of using adaptive mesh refinement in Dolfin-adjoint, but I couldn’t find any resource. Can you please help me with this?
For example, I have attached the below code, and I want to use auto adaptive mesh refinement on this code:
import numpy as np
import matplotlib.pyplot as plt
from dolfin import *
from dolfin_adjoint import *
import moola
n = 10
mesh = RectangleMesh(Point(-1,-1),Point(1,1), n, n)
V = FunctionSpace(mesh, "CG", 1)
u = Function(V)
v = TestFunction(V)
S0 = Constant(1)
bc = DirichletBC(V, 1, "on_boundary")
v = project(u, V, bcs=bc)
J = assemble((0.5*inner(grad(v), grad(v)) - v*S0)*dx)
J_hat = ReducedFunctional(J, Control(u))
u_opt = minimize(J_hat, method = "L-BFGS-B", options = {"gtol": 1e-16, "ftol": 1e-16})
J_hat(u_opt)
u = project (u_opt, V, bcs=bc)
fileU = File("temp.pvd");
fileU << u
Thank you so much for your help!