bool GridField<T>::isUndefined(int i,int j,int k) const{ return i < 0 || i >= xdim() || j < 0 || j >= ydim() || k < 0 || k >= zdim(); }
//Local to... void GridMapping::localToIndex(double l_x, double l_y,double l_z,int &i,int &j,int &k) const{ i = (int)round(l_x*double(xdim()-1)); j = (int)round(l_y*double(ydim()-1)); k = (int)round(l_z*double(zdim()-1)); }
void GridMapping::localToUpperLeftIndex(const double l_x,const double l_y,const double l_z, int &i,int &j,int &k) const{ i = (int)floor(l_x*double(xdim()-1)); j = (int)floor(l_y*double(ydim()-1)); k = (int)floor(l_z*double(zdim()-1)); }
void GridMapping::indexToLocal(int i,int j,int k, double &l_x, double &l_y,double &l_z) const{ l_x = double(i)/double(xdim()-1); l_y = double(j)/double(ydim()-1); l_z = double(k)/double(zdim()-1);//TODO om zdim = 1 så funkar inte detta, en ifsats kan lösa detta }
bool GridMapping::isValid(int i, int j, int k) const{ return ( i >= 0 && i < xdim() && j >= 0 && j < ydim() && k >= 0 && k < zdim()); }
void GridMapping::indexAt(int index, int &i, int &j, int &k) const{ k = index /(xdim()*ydim()); j = (index-(k*xdim()*ydim()))/(xdim()); i = (index-j*xdim()-k*xdim()*ydim()); }
//Funktioner //Index to index int GridMapping::indexAt(int i, int j, int k) const{ return i+(xdim())*j+(xdim()*ydim()*k); }
double GridMapping::local_dy() const{ return 1.0/double(ydim()-1); }