|
|
|
#pragma once
|
|
|
|
#include "basedata.h"
|
|
|
|
|
|
|
|
class Simple2DData: public BaseData
|
|
|
|
{
|
|
|
|
real x0 = 0.0, y0 = 0.0;
|
|
|
|
size_t nx = 0, ny = 0;
|
|
|
|
real xstep = 0.0, ystep = 0.0;
|
|
|
|
|
|
|
|
public:
|
|
|
|
Simple2DData() = default;
|
|
|
|
|
|
|
|
Simple2DData(size_t nx_, size_t ny_, real x0_, real y0_, real xs_, real ys_):
|
|
|
|
BaseData(
|
|
|
|
nx_ * ny_, [x0 = x0_, nx = nx_, xstep = xs_](size_t i) -> real { return x0 + (i % nx) * xstep; },
|
|
|
|
[y0 = y0_, nx = nx_, ystep = ys_](size_t i) -> real { return y0 + (i / nx) * ystep; }),
|
|
|
|
x0(x0_),
|
|
|
|
y0(y0_),
|
|
|
|
nx(nx_),
|
|
|
|
ny(ny_),
|
|
|
|
xstep(xs_),
|
|
|
|
ystep(ys_)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const real& V(size_t i) const { return BaseData::V(i); }
|
|
|
|
real& V(size_t i) { return BaseData::V(i); }
|
|
|
|
|
|
|
|
const real& operator()(size_t i) const { return BaseData::V(i); }
|
|
|
|
real& operator()(size_t i) { return BaseData::V(i); }
|
|
|
|
|
|
|
|
const real& V(size_t ix, size_t iy) const { return V(iy * nx + ix); }
|
|
|
|
real& V(size_t ix, size_t iy) { return V(iy * nx + ix); }
|
|
|
|
|
|
|
|
const real& operator()(size_t ix, size_t iy) const { return V(iy * nx + ix); }
|
|
|
|
real& operator()(size_t ix, size_t iy) { return V(iy * nx + ix); }
|
|
|
|
|
|
|
|
size_t Nx() const { return nx; }
|
|
|
|
size_t Ny() const { return ny; }
|
|
|
|
|
|
|
|
real Lon(size_t ix, [[maybe_unused]] size_t iy) const { return x0 + ix * xstep; }
|
|
|
|
real Lat([[maybe_unused]] size_t ix, size_t iy) const { return y0 + iy * ystep; }
|
|
|
|
|
|
|
|
real Lon(size_t i) const { return Lon(i % nx, i / nx); }
|
|
|
|
real Lat(size_t i) const { return Lat(i % nx, i / nx); }
|
|
|
|
};
|