I believe I found!
For a Functional with respective Reduced Functional:
J = Functional(w_e * Energy_dissipation(u, rho) + \
(en_coeff(u, rho)/vort_coeff(u, rho)) * w_v * Vorticity(u,rho) + \
(en_coeff(u, rho)/torq_coeff(u, rho)) * w_t * Torque(u,rho))
m = Control(rho) # Control
Jhat = ReducedFunctional(J, m, eval_cb_post = eval_cb) # Reduced Functional
I am defining the following coefficients:
def en_coeff(u, rho):
(u_tape,p_tape) = split(DolfinAdjointVariable(w).tape_value())
return assemble(Energy_dissipation(u_tape, rho))
def vort_coeff(u, rho):
(u_tape,p_tape) = split(DolfinAdjointVariable(w).tape_value())
return assemble(Vorticity(u_tape, rho))
def torq_coeff(u, rho):
(u_tape,p_tape) = split(DolfinAdjointVariable(w).tape_value())
return assemble(Torque(u_tape, rho))
Code is still a little messy, sorry about that. Could anyone confirm that this really changes during the optimization?