19 #ifndef PISM_ARRAY2D_H
20 #define PISM_ARRAY2D_H
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];
80 const auto &
self = *
this;
85 result.
e =
self(i+1,j);
86 result.
w =
self(i-1,j);
87 result.
n =
self(i,j+1);
88 result.
s =
self(i,j-1);
94 const auto &x = *
this;
102 return {x(i, j), x(i, N), x(W, N), x(W, j), x(W,
S),
103 x(i,
S), x(E,
S), x(E, j), x(E, N)};
T const *const * array() const
const T & operator()(int i, int j) const
stencils::Box< T > box(int i, int j) const
Array2D(std::shared_ptr< const Grid > grid, const std::string &short_name, Kind ghostedp, unsigned int stencil_width=1)
void copy_from(const Array2D< T > &source)
stencils::Star< T > star(int i, int j) const
T & operator()(int i, int j)
void add(double alpha, const Array2D< T > &x, Array2D< T > &result) 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).
static double S(unsigned n)