Computes the gradient of the functional at the vector x.
On an \(m\times n\) Grid, an array::Array \(x\) with \(d\) degrees of freedom will be \(d m n\)-dimensional with components \(x_i\). The gradient computed here is the vector of directional derivatives \(\nabla J\) of the functional \(J\) with respect to \(x\). Concretely, the \(i^{\rm th}\) component of \(\nabla J\) is
\[ \nabla J_i = \frac{\partial}{\partial x_i} J(x). \]
This vector is returned as gradient
.
Implements pism::inverse::IPFunctional< array::Scalar >.
Definition at line 125 of file IP_H1NormFunctional.cc.
References pism::fem::Element2::add_contribution(), pism::array::Array2D< T >::array(), pism::fem::Element::chi(), pism::fem::DirichletData::constrain(), pism::fem::Germ::dx, pism::fem::Germ::dy, pism::fem::DirichletData_Scalar::enforce_homogeneous(), pism::fem::Element2::evaluate(), pism::k, m_cH1, m_cL2, m_dirichletIndices, pism::inverse::IPFunctional< array::Scalar >::m_element, pism::inverse::IPFunctional< array::Scalar >::m_element_index, pism::fem::MAX_QUADRATURE_SIZE, pism::fem::q1::n_chi, pism::fem::Element::n_pts(), pism::fem::Element2::nodal_values(), pism::fem::Element2::reset(), pism::array::Array::set(), pism::fem::Germ::val, pism::fem::Element::weight(), pism::fem::ElementIterator::xm, pism::fem::ElementIterator::xs, pism::fem::ElementIterator::ym, and pism::fem::ElementIterator::ys.