Commit 69262ba0 authored by frey_m's avatar frey_m
Browse files

SAAMG: unify getCoord + getIdx

parent b2bef3f8
......@@ -247,23 +247,9 @@ inline int ArbitraryDomain::toCoordIdx(int idx, int idy, int idz) {
return (idz * nr_m[1] + idy) * nr_m[0] + idx;
}
// Conversion from (x,y,z) to index on the 3D grid
int ArbitraryDomain::getIdx(int idx, int idy, int idz) {
if(isInside(idx, idy, idz) && idx >= 0 && idy >= 0 && idz >= 0)
return idxMap_m[toCoordIdx(idx, idy, idz)];
else
return -1;
}
// Conversion from a 3D index to (x,y,z)
inline void ArbitraryDomain::getCoord(int idxyz, int &idx, int &idy, int &idz) {
int id = coordMap_m[idxyz];
idx = id % (int)nr_m[0];
id /= nr_m[0];
idy = id % (int)nr_m[1];
id /= nr_m[1];
idz = id;
int ArbitraryDomain::indexAccess(int x, int y, int z) {
return idxMap_m[toCoordIdx(x, y, z)];
}
inline bool ArbitraryDomain::isInside(int idx, int idy, int idz) {
......
......@@ -54,7 +54,7 @@ public:
/// queries if a given (x,y,z) coordinate lies inside the domain
bool isInside(int idx, int idy, int idz);
/// returns number of nodes in xy plane
int getNumXY(int idz);
int getNumXY(int z);
// calculates intersection with rotated and shifted geometry
void compute(Vector_t hr, NDIndex<3> localId);
......@@ -85,10 +85,9 @@ private:
// Conversion from (x,y,z) to index in xyz plane
inline int toCoordIdx(int idx, int idy, int idz);
// Conversion from (x,y,z) to index on the 3D grid
int getIdx(int idx, int idy, int idz);
// Conversion from a 3D index to (x,y,z)
inline void getCoord(int idxyz, int &x, int &y, int &z);
int indexAccess(int x, int y, int z);
// Different interpolation methods for boundary points
void constantInterpolation(int idx, int idy, int idz, StencilValue_t& value,
......
......@@ -154,25 +154,8 @@ private:
}
/// conversion from (x,y,z) to index on the 3D grid
/*inline*/
inline int getIdx(int x, int y, int z) {
if(isInside(x, y, z) && x >= 0 && y >= 0 && z >= 0)
return idxMap_m[toCoordIdx(x, y, z)];
else
return -1;
}
/// conversion from a 3D index to (x,y,z)
inline void getCoord(int idx, int &x, int &y, int &z) {
int idxx = coordMap_m[idx];
x = idxx % (int)nr_m[0];
idxx /= nr_m[0];
y = idxx % (int)nr_m[1];
idxx /= nr_m[1];
z = idxx;
int indexAccess(int x, int y, int z) {
return idxMap_m[toCoordIdx(x, y, z)];
}
/// different interpolation methods for boundary points
......
......@@ -92,19 +92,15 @@ private:
inline int toCoordIdx(int x, int y) { return y * nr_m[0] + x; }
/// conversion from (x,y,z) to index on the 3D grid
inline int getIdx(int x, int y, int z) {
if (isInside(x, y, z))
return idxMap_m[toCoordIdx(x, y)] + (z - 1) * nxy_m;
else
return -1;
int indexAccess(int x, int y, int z) {
return idxMap_m[toCoordIdx(x, y)] + (z - 1) * nxy_m;
}
/// conversion from a 3D index to (x,y,z)
inline void getCoord(int idx, int &x, int &y, int &z) {
void getCoord(int idx, int &x, int &y, int &z) override {
int ixy = idx % nxy_m;
int xy = coordMap_m[ixy];
int inr = (int)nr_m[0];
x = xy % inr;
x = xy % (int)nr_m[0];
y = (xy - x) / nr_m[0];
z = (idx - ixy) / nxy_m + 1;
}
......
......@@ -83,6 +83,22 @@ void IrregularDomain::getNeighbours(int id, StencilIndex_t& index)
}
void IrregularDomain::getCoord(int idx, int& x, int& y, int& z) {
int id = coordMap_m[idx];
x = id % (int)nr_m[0];
id /= nr_m[0];
y = id % (int)nr_m[1];
id /= nr_m[1];
z = id;
}
int IrregularDomain::getIdx(int x, int y, int z) {
if (x < 0 || y < 0 || z < 0 || !isInside(x, y, z))
return -1;
return indexAccess(x, y, z);
}
void IrregularDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
......
......@@ -98,8 +98,11 @@ public:
void getNeighbours(int idx, StencilIndex_t& index);
/// Conversion from a 3D index to (x,y,z)
virtual void getCoord(int idx, int &x, int &y, int &z);
virtual void getCoord(int idx, int &x, int &y, int &z) = 0;
/// Conversion from (x,y,z) to index on the 3D grid
int getIdx(int x, int y, int z);
/// method that checks if a given point lies inside the boundary
/// \param x index of the current element in the matrix
......@@ -127,8 +130,6 @@ public:
void setRangeMin(const Vector_t&);
void setRangeMax(const Vector_t&);
virtual int getIdx(int x, int y, int z) = 0;
bool hasGeometryChanged();
virtual ~IrregularDomain() {};
......@@ -139,6 +140,8 @@ public:
protected:
virtual int indexAccess(int x, int y, int z) = 0;
/// different interpolation methods for boundary points
virtual void constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
......
......@@ -63,17 +63,14 @@ private:
int nxy_m;
/// conversion from (x,y,z) to index on the 3D grid
inline int getIdx(int x, int y, int z) {
if(isInside(x, y, z) && x >= 0 && y >= 0 && z >= 0)
return y * nr_m[0] + x + z * nxy_m;
else
return -1;
int indexAccess(int x, int y, int z) {
return y * nr_m[0] + x + z * nxy_m;
}
/// conversion from a 3D index to (x,y,z)
inline void getCoord(int idx, int &x, int &y, int &z) {
void getCoord(int idx, int &x, int &y, int &z) override {
int ixy = idx % nxy_m;
int inr = nr_m[0];
x = ixy % inr;
x = ixy % (int)nr_m[0];
y = (ixy - x) / nr_m[0];
z = (idx - ixy) / nxy_m;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment