Commit c098ae20 authored by frey_m's avatar frey_m
Browse files

SAAMG: remove duplicated getNeighbours function

parent 74dde0f2
......@@ -522,36 +522,6 @@ void ArbitraryDomain::linearInterpolation(int idx, int idy, int idz,
value.center += (dz_f + dz_b) * (dx_w + dx_e) * (dy_n + dy_s) / m2;
}
void ArbitraryDomain::getNeighbours(int idx, int idy, int idz, StencilIndex_t& index)
{
index.west = getIdx(idx - 1, idy, idz);
index.east = getIdx(idx + 1, idy, idz);
index.north = getIdx(idx, idy + 1, idz);
index.south = getIdx(idx, idy - 1, idz);
index.front = getIdx(idx, idy, idz - 1);
index.back = getIdx(idx, idy, idz + 1);
if(!isInside(idx+1,idy,idz))
index.east = -1;
if(!isInside(idx-1,idy,idz))
index.west = -1;
if(!isInside(idx,idy+1,idz))
index.north = -1;
if(!isInside(idx,idy-1,idz))
index.south = -1;
if(!isInside(idx,idy,idz-1))
index.front = -1;
if(!isInside(idx,idy,idz+1))
index.back = -1;
}
inline void ArbitraryDomain::crossProduct(double A[], double B[], double C[]) {
C[0] = A[1] * B[2] - A[2] * B[1];
C[1] = A[2] * B[0] - A[0] * B[2];
......
......@@ -59,9 +59,6 @@ public:
void getBoundaryStencil(int idx, int idy, int idz, StencilValue_t& value,
double &scaleFactor);
/// returns index of neighbours at (x,y,z)
void getNeighbours(int idx, int idy, int idz, StencilIndex_t& index);
/// returns type of boundary condition
std::string getType() {return "Geometric";}
/// queries if a given (x,y,z) coordinate lies inside the domain
......
......@@ -174,37 +174,6 @@ void BoxCornerDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t& va
assert(value.center > 0);
}
void BoxCornerDomain::getNeighbours(int x, int y, int z, StencilIndex_t& index) {
if(x > 0)
index.west = getIdx(x - 1, y, z);
else
index.west = -1;
if(x < nr[0] - 1)
index.east = getIdx(x + 1, y, z);
else
index.east = -1;
if(y < nr[1] - 1)
index.north = getIdx(x, y + 1, z);
else
index.north = -1;
if(y > 0)
index.south = getIdx(x, y - 1, z);
else
index.south = -1;
if(z > 0)
index.front = getIdx(x, y, z - 1);
else
index.front = -1;
if(z < nr[2] - 1)
index.back = getIdx(x, y, z + 1);
else
index.back = -1;
}
void BoxCornerDomain::constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
......
......@@ -80,9 +80,6 @@ public:
/// returns discretization at (x,y,z)
void getBoundaryStencil(int x, int y, int z, StencilValue_t& value, double &scaleFactor);
/// returns index of neighbours at (x,y,z)
void getNeighbours(int x, int y, int z, StencilIndex_t& index);
/// returns type of boundary condition
std::string getType() {return "BoxCorner";}
......
......@@ -201,41 +201,6 @@ void EllipticDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t& val
assert(value.center > 0);
}
void EllipticDomain::getNeighbours(int x, int y, int z,
StencilIndex_t& index)
{
if (x > 0)
index.west = getIdx(x - 1, y, z);
else
index.west = -1;
if (x < nr[0] - 1)
index.east = getIdx(x + 1, y, z);
else
index.east = -1;
if (y < nr[1] - 1)
index.north = getIdx(x, y + 1, z);
else
index.north = -1;
if (y > 0)
index.south = getIdx(x, y - 1, z);
else
index.south = -1;
if (z > 0)
index.front = getIdx(x, y, z - 1);
else
index.front = -1;
if (z < nr[2] - 1)
index.back = getIdx(x, y, z + 1);
else
index.back = -1;
}
void EllipticDomain::constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
......
......@@ -58,9 +58,6 @@ public:
void getBoundaryStencil(int x, int y, int z, StencilValue_t& values,
double &scaleFactor);
/// returns index of neighbours at (x,y,z)
void getNeighbours(int x, int y, int z, StencilIndex_t& index);
/// returns type of boundary condition
std::string getType() {return "Elliptic";}
......
......@@ -26,6 +26,35 @@
#include "Solvers/IrregularDomain.h"
void IrregularDomain::getNeighbours(int x, int y, int z, StencilIndex_t& index)
{
index.west = -1;
index.east = -1;
index.south = -1;
index.north = -1;
index.front = -1;
index.back = -1;
if (x > 0 && isInside(x - 1, y, z))
index.west = getIdx(x - 1, y, z);
if (x < nr[0] - 1 && isInside(x + 1, y, z))
index.east = getIdx(x + 1, y, z);
if (y > 0 && isInside(x, y - 1, z))
index.south = getIdx(x, y - 1, z);
if (y < nr[1] - 1 && isInside(x, y + 1, z))
index.north = getIdx(x, y + 1, z);
if (z > 0 && isInside(x, y, z - 1))
index.front = getIdx(x, y, z - 1);
if (z < nr[2] - 1 && isInside(x, y, z + 1))
index.back = getIdx(x, y, z + 1);
}
void IrregularDomain::getNeighbours(int id, StencilIndex_t& index)
{
int x = 0, y = 0, z = 0;
......
......@@ -90,7 +90,7 @@ public:
/// \param y index of the current element in the matrix
/// \param z index of the current element in the matrix
/// \param index stencil indices of an element
virtual void getNeighbours(int x, int y, int z, StencilIndex_t& index) = 0;
void getNeighbours(int x, int y, int z, StencilIndex_t& index);
void getNeighbours(int idx, StencilIndex_t& index);
......
......@@ -133,36 +133,6 @@ void RectangularDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t&
#endif
}
void RectangularDomain::getNeighbours(int x, int y, int z, StencilIndex_t& index) {
if(x > 0)
index.west = getIdx(x - 1, y, z);
else
index.west = -1;
if(x < nr[0] - 1)
index.east = getIdx(x + 1, y, z);
else
index.east = -1;
if(y < nr[1] - 1)
index.north = getIdx(x, y + 1, z);
else
index.north = -1;
if(y > 0)
index.south = getIdx(x, y - 1, z);
else
index.south = -1;
if(z > 0)
index.front = getIdx(x, y, z - 1);
else
index.front = -1;
if(z < nr[2] - 1)
index.back = getIdx(x, y, z + 1);
else
index.back = -1;
}
/*
void MGPoissonSolver::getNeighbours(const int idx, int& W, int& E, int& S, int& N, int& F, int& B, int& numOutOfDomain)
{
......
......@@ -52,7 +52,6 @@ public:
/// returns index of neighbours at (x,y,z)
using IrregularDomain::getNeighbours;
void getNeighbours(int x, int y, int z, StencilIndex_t& index);
/// returns type of boundary condition
std::string getType() {return "Rectangular";}
/// queries if a given (x,y,z) coordinate lies inside the domain
......
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