19 #include "pism/inverse/functional/IPLogRatioFunctional.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"
47 for (
auto p =
m_grid->points(); p; p.next()) {
48 const int i = p.i(), j = p.j();
51 w = (*m_weights)(i, j);
55 double obsMagSq = u_obs_ij.
u*u_obs_ij.
u + u_obs_ij.
v*u_obs_ij.
v +
m_eps*
m_eps;
57 double modelMagSq = scale*scale*(u_obs_ij.
u*u_obs_ij.
u + u_obs_ij.
v*u_obs_ij.
v) +
m_eps*
m_eps;
59 double v = log(modelMagSq/obsMagSq);
79 for (
auto p =
m_grid->points(); p; p.next()) {
80 const int i = p.i(), j = p.j();
83 w = (*m_weights)(i, j);
88 double obsMagSq = u_obs_ij.
u*u_obs_ij.
u + u_obs_ij.
v*u_obs_ij.
v +
m_eps*
m_eps;
90 double modelMagSq = (u_model_ij.
u*u_model_ij.
u + u_model_ij.
v*u_model_ij.
v)+
m_eps*
m_eps;
91 double v = log(modelMagSq/obsMagSq);
111 for (
auto p =
m_grid->points(); p; p.next()) {
112 const int i = p.i(), j = p.j();
115 w = (*m_weights)(i, j);
119 Vector2d u_model_ij = x_ij+u_obs_ij;
121 double obsMagSq = u_obs_ij.
u*u_obs_ij.
u + u_obs_ij.
v*u_obs_ij.
v +
m_eps*
m_eps;
122 double modelMagSq = (u_model_ij.
u*u_model_ij.
u + u_model_ij.
v*u_model_ij.
v)+
m_eps*
m_eps;
123 double v = log(modelMagSq/obsMagSq);
124 double dJdw = 2*w*v/modelMagSq;
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.
array::Vector & m_u_observed
array::Scalar * m_weights
virtual void valueAt(array::Vector &x, double *OUTPUT)
Computes the value of the functional at the vector x.
virtual void gradientAt(array::Vector &x, array::Vector &gradient)
Computes the gradient of the functional at the vector x.
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)