def test_fixed_disp_adj(space): """Verify that the adjoint of LinDeformFixedDisp is correct.""" # Set up template and displacement field template = space.element(template_function) disp_field = space.real_space.tangent_bundle.element( disp_field_factory(space.ndim)) # Calculate result deform_op = LinDeformFixedDisp(disp_field, templ_space=space) deformed_templ_adj = deform_op.adjoint(template) # Calculate the analytic result true_deformed_templ_adj = space.element(inv_deformed_template) exp_div = space.element(exp_div_inv_disp) true_deformed_templ_adj *= exp_div # Verify that the result is within error limits error = (deformed_templ_adj - true_deformed_templ_adj).norm() rel_err = error / true_deformed_templ_adj.norm() assert rel_err < error_bound(space.interp) # Verify the adjoint definition <Ax, x> = <x, A^* x> deformed_templ = deform_op(template) inner1 = deformed_templ.inner(template) inner2 = template.inner(deformed_templ_adj) assert almost_equal(inner1, inner2, places=1)