19#include "pism/inverse/functional/IPGroundedIceH1NormFunctional.hh"
20#include "pism/util/error_handling.hh"
21#include "pism/util/Grid.hh"
22#include "pism/util/pism_utilities.hh"
23#include "pism/util/array/CellType.hh"
24#include "pism/util/fem/DirichletData.hh"
39 double x_q[Nq_max], dxdx_q[Nq_max], dxdy_q[Nq_max];
42 for (
unsigned int k = 0;
k < Nk; ++
k) {
57 for (
int j=ys; j<ys+ym; j++) {
58 for (
int i=xs; i<xs+xm; i++) {
64 if (! all_grounded_ice) {
77 for (
unsigned int q=0; q<Nq; q++) {
79 value += W*(
m_cL2*x_q[q]*x_q[q]+
m_cH1*(dxdx_q[q]*dxdx_q[q]+dxdy_q[q]*dxdy_q[q]));
97 double a_q[Nq_max], dadx_q[Nq_max], dady_q[Nq_max];
102 double b_q[Nq_max], dbdx_q[Nq_max], dbdy_q[Nq_max];
105 for (
unsigned int k = 0;
k < Nk; ++
k) {
119 for (
int j=ys; j<ys+ym; j++) {
120 for (
int i=xs; i<xs+xm; i++) {
126 if (! all_grounded_ice) {
145 for (
unsigned int q=0; q<Nq; q++) {
147 value += W*(
m_cL2*a_q[q]*b_q[q]+
m_cH1*(dadx_q[q]*dbdx_q[q]+dady_q[q]*dbdy_q[q]));
166 double x_q[Nq_max], dxdx_q[Nq_max], dxdy_q[Nq_max];
169 for (
unsigned int k = 0;
k < Nk; ++
k) {
175 double gradient_e[Nk];
186 for (
int j=ys; j<ys+ym; j++) {
187 for (
int i=xs; i<xs+xm; i++) {
193 if (! all_grounded_ice) {
209 for (
unsigned int k=0;
k<Nk;
k++) {
213 for (
unsigned int q=0; q<Nq; q++) {
215 const double &x_qq=x_q[q];
216 const double &dxdx_qq=dxdx_q[q], &dxdy_qq=dxdy_q[q];
217 for (
unsigned int k=0;
k<Nk;
k++) {
236 ierr = MatZeroEntries(form);
250 for (j=ys; j<ys+ym; j++) {
251 for (i=xs; i<xs+xm; i++) {
256 if (! all_grounded_ice) {
274 ierr = PetscMemzero(K,
sizeof(K));
277 for (
unsigned int q=0; q<Nq; q++) {
279 for (
unsigned int k = 0;
k < Nk;
k++) {
281 for (
unsigned int l = 0; l < Nk; l++) {
296 ierr = MatAssemblyBegin(form, MAT_FINAL_ASSEMBLY);
299 ierr = MatAssemblyEnd(form, MAT_FINAL_ASSEMBLY);
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.
bool grounded_ice(int i, int j) const
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.
double weight(unsigned int q) const
Weight of the quadrature point q
const Germ & chi(unsigned int q, unsigned int k) const
unsigned int n_pts() const
Number of quadrature points.
fem::Q1Element2 m_element
fem::ElementIterator m_element_index
std::shared_ptr< const Grid > m_grid
virtual void valueAt(array::Scalar &x, double *OUTPUT)
array::CellType1 & m_ice_mask
virtual void gradientAt(array::Scalar &x, array::Scalar &gradient)
virtual void dot(array::Scalar &a, array::Scalar &b, double *OUTPUT)
Computes the inner product .
virtual void assemble_form(Mat J)
array::Scalar * m_dirichletIndices
#define PISM_CHK(errcode, name)
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 val
Function value.
double dx
Function deriviative with respect to x.
Struct for gathering the value and derivative of a function at a point.