19 #include "pism/inverse/functional/IPLogRelativeFunctional.hh"
20 #include "pism/util/Grid.hh"
21 #include "pism/util/array/Vector.hh"
22 #include "pism/util/array/Scalar.hh"
23 #include "pism/util/pism_utilities.hh"
40 double scale_sq = scale*scale;
50 for (
auto p =
m_grid->points(); p; p.next()) {
51 const int i = p.i(), j = p.j();
55 w = (*m_weights)(i, j);
57 double obsMagSq = (u_obs_ij.
u*u_obs_ij.
u + u_obs_ij.
v*u_obs_ij.
v) +
m_eps*
m_eps;
58 value += log(1 + w*scale_sq/obsMagSq);
76 for (
auto p =
m_grid->points(); p; p.next()) {
77 const int i = p.i(), j = p.j();
82 w = (*m_weights)(i, j);
84 double obsMagSq = (u_obs_ij.
u*u_obs_ij.
u + u_obs_ij.
v*u_obs_ij.
v) +
m_eps*
m_eps;
85 value += log(1 + w*(x_ij.
u*x_ij.
u + x_ij.
v*x_ij.
v)/obsMagSq);
103 for (
auto p =
m_grid->points(); p; p.next()) {
104 const int i = p.i(), j = p.j();
109 w = (*m_weights)(i, j);
111 double obsMagSq = u_obs_ij.
u*u_obs_ij.
u + u_obs_ij.
v*u_obs_ij.
v +
m_eps*
m_eps;
112 double dJdxsq = w/(obsMagSq + w*(x_ij.
u*x_ij.
u + x_ij.
v*x_ij.
v));
This class represents a 2D vector field (such as ice velocity) at a certain grid point.
void add(const PetscAccessible &v)
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void add(double alpha, const Array2D< T > &x)
void set(double c)
Result: v[j] <- c for all j.
std::shared_ptr< const Grid > m_grid
virtual void normalize(double scale)
Determine the normalization constant for the functional.
virtual void valueAt(array::Vector &x, double *OUTPUT)
Computes the value of the functional at the vector x.
array::Scalar * m_weights
virtual void gradientAt(array::Vector &x, array::Vector &gradient)
Computes the gradient of the functional at the vector x.
array::Vector & m_u_observed
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)