19 #include "pism/inverse/functional/IPTotalVariationFunctional.hh"
20 #include "pism/util/Grid.hh"
21 #include "pism/util/pism_utilities.hh"
22 #include "pism/util/array/Scalar.hh"
28 double c,
double exponent,
double eps,
30 IPFunctional<array::Scalar>(grid), m_dirichletIndices(dirichletLocations),
31 m_c(c), m_lebesgue_exp(exponent), m_epsilon_sq(eps*eps) {
44 double x_q[Nq_max], dxdx_q[Nq_max], dxdy_q[Nq_max];
57 for (
int j = ys; j < ys + ym; j++) {
58 for (
int i = xs; i < xs + xm; i++) {
68 for (
unsigned int q = 0; q < Nq; q++) {
88 double x_q[Nq_max], dxdx_q[Nq_max], dxdy_q[Nq_max];
90 double gradient_e[Nk];
103 for (
int j = ys; j < ys + ym; j++) {
104 for (
int i = xs; i < xs + xm; i++) {
118 for (
unsigned int k = 0;
k < Nk;
k++) {
122 for (
unsigned int q = 0; q < Nq; q++) {
124 const double &dxdx_qq = dxdx_q[q], &dxdy_qq = dxdy_q[q];
125 for (
unsigned int k = 0;
k < Nk;
k++) {
Makes sure that we call begin_access() and end_access() for all accessed array::Arrays.
void set(double c)
Result: v[j] <- c for all j.
void enforce_homogeneous(const Element2 &element, double *x_e)
void constrain(Element2 &element)
Constrain element, i.e. ensure that quadratures do not contribute to Dirichlet nodes by marking corre...
void evaluate(const T *x, T *vals, T *dx, T *dy)
Given nodal values, compute the values and partial derivatives at the quadrature points.
void reset(int i, int j)
Initialize the Element to element (i, j) for the purposes of inserting into global residual and Jacob...
void add_contribution(const T *local, T **y_global) const
Add the values of element-local contributions y to the global vector y_global.
void nodal_values(const array::Scalar &x_global, int *result) const
Get nodal values of an integer mask.
int xm
total number of elements to loop over in the x-direction.
int lym
total number local elements in y direction.
int lxm
total number local elements in x direction.
int lxs
x-index of the first local element.
int ym
total number of elements to loop over in the y-direction.
int ys
y-coordinate of the first element to loop over.
int lys
y-index of the first local element.
int xs
x-coordinate of the first element to loop over.
const Germ & chi(unsigned int q, unsigned int k) const
int n_pts() const
Number of quadrature points.
double weight(unsigned int q) const
Weight of the quadrature point q
fem::Q1Element2 m_element
fem::ElementIterator m_element_index
std::shared_ptr< const Grid > m_grid
Abstract base class for functions from ice model vectors to .
virtual void valueAt(array::Scalar &x, double *OUTPUT)
Computes the value of the functional at the vector x.
virtual void gradientAt(array::Scalar &x, array::Scalar &gradient)
Computes the gradient of the functional at the vector x.
array::Scalar * m_dirichletIndices
IPTotalVariationFunctional2S(std::shared_ptr< const Grid > grid, double c, double q, double eps, array::Scalar *dirichletLocations=NULL)
const unsigned int MAX_QUADRATURE_SIZE
void GlobalSum(MPI_Comm comm, double *local, double *result, int count)
double dy
Function derivative with respect to y.
double dx
Function deriviative with respect to x.