22#include "pism/util/array/Array.hh"
23#include "pism/util/array/Array_helpers.hh"
24#include "pism/util/stencils.hh"
36 Array2D(std::shared_ptr<const Grid>
grid,
const std::string &short_name,
44 return reinterpret_cast<T**
>(
m_array);
48 return reinterpret_cast<T const* const*
>(
m_array);
55 return static_cast<T**
>(
m_array)[j][i];
62 return static_cast<T**
>(
m_array)[j][i];
68 inline const T&
N(
int i,
int j)
const {
69 return (*
this)(i, j + 1);
75 inline const T&
E(
int i,
int j)
const {
76 return (*
this)(i + 1, j);
82 inline const T&
S(
int i,
int j)
const {
83 return (*
this)(i, j - 1);
89 inline const T&
W(
int i,
int j)
const {
90 return (*
this)(i - 1, j);
108 const auto &self = *
this;
112 result.
c = self(i,j);
122 const auto &x = *
this;
130 return {x(i, j), x(i,
N), x(
W,
N), x(
W, j), x(
W,
S),
131 x(i,
S), x(
E,
S), x(
E, j), x(
E,
N)};
T const *const * array() const
const T & S(int i, int j) const
const T & operator()(int i, int j) const
Array2D(std::shared_ptr< const Grid > grid, const std::string &short_name, Kind ghostedp, unsigned int stencil_width=1)
const T & W(int i, int j) const
T & operator()(int i, int j)
const T & N(int i, int j) const
void copy_from(const Array2D< T > &source)
stencils::Star< T > star(int i, int j) const
void add(double alpha, const Array2D< T > &x, Array2D< T > &result) const
const T & E(int i, int j) const
stencils::Box< T > box(int i, int j) const
void add(double alpha, const Array2D< T > &x)
A storage vector combining related fields in a struct.
std::shared_ptr< const Grid > grid() const
void set_begin_access_use_dof(bool flag)
unsigned int stencil_width() const
Get the stencil width of the current Array. Returns 0 if ghosts are not available.
void check_array_indices(int i, int j, unsigned int k) const
Check array indices and warn if they are out of range.
Abstract class for reading, writing, allocating, and accessing a DA-based PETSc Vec (2D and 3D fields...
void add(const V &x, double alpha, const V &y, V &result, bool scatter=true)
Computes result = x + alpha * y, where x, y, and z are 2D Arrays (scalar or vector).
void copy(const V &input, V &result, bool scatter=true)
Kind
What "kind" of a vector to create: with or without ghosts.
Star stencil points (in the map-plane).