Commit 4feb5575 authored by frey_m's avatar frey_m
Browse files

SAAMG: clean up use of getBoundaryStencil

parent cf1b8bfb
......@@ -376,27 +376,6 @@ int ArbitraryDomain::getNumXY(int z) {
return numXY[z];
}
void ArbitraryDomain::getBoundaryStencil(int idx, int idy, int idz,
StencilValue_t& value, double &scaleFactor)
{
scaleFactor = 1.0;
// determine which interpolation method we use for points near the boundary
switch(interpolationMethod_m){
case CONSTANT:
constantInterpolation(idx,idy,idz,value,scaleFactor);
break;
case LINEAR:
linearInterpolation(idx,idy,idz,value,scaleFactor);
break;
case QUADRATIC:
// QuadraticInterpolation(idx,idy,idz,value,scaleFactor);
break;
}
// stencil center value has to be positive!
assert(value.center > 0);
}
void ArbitraryDomain::constantInterpolation(int idx, int idy, int idz,
StencilValue_t& value, double& /*scaleFactor*/)
{
......
......@@ -55,10 +55,6 @@ public:
~ArbitraryDomain();
/// returns discretization at (x,y,z)
void getBoundaryStencil(int idx, int idy, int idz, StencilValue_t& value,
double &scaleFactor);
/// 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
......@@ -127,13 +123,10 @@ private:
// Different interpolation methods for boundary points
void constantInterpolation(int idx, int idy, int idz, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
void linearInterpolation(int idx, int idy, int idz, StencilValue_t& value,
double &scaleFactor);
void quadraticInterpolation(int idx, int idy, int idz, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
// Rotate positive axes with quaternion -DW
inline void rotateWithQuaternion(Vector_t &v, Quaternion_t const quaternion);
......
......@@ -138,26 +138,6 @@ void BoxCornerDomain::compute(Vector_t hr, NDIndex<3> /*localId*/){
*/
}
void BoxCornerDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t& value, double &scaleFactor) {
// determine which interpolation method we use for points near the boundary
switch(interpolationMethod_m) {
case CONSTANT:
constantInterpolation(x, y, z, value, scaleFactor);
break;
case LINEAR:
linearInterpolation(x, y, z, value, scaleFactor);
break;
case QUADRATIC:
quadraticInterpolation(x, y, z, value, scaleFactor);
break;
}
// stencil center value has to be positive!
assert(value.center > 0);
}
void BoxCornerDomain::constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
......
......@@ -90,9 +90,6 @@ public:
std::string interpl);
~BoxCornerDomain();
/// returns discretization at (x,y,z)
void getBoundaryStencil(int x, int y, int z, StencilValue_t& value, double &scaleFactor);
/// we do not need this
int getNumXY(int /*z*/) { return -1;}
......@@ -192,13 +189,13 @@ private:
/// different interpolation methods for boundary points
void constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
void linearInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
void quadraticInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
};
......
......@@ -154,28 +154,6 @@ void EllipticDomain::resizeMesh(Vector_t& origin, Vector_t& hr, const Vector_t&
hr[i] = (mymax[i] - origin[i]) / nr_m[i];
}
void EllipticDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
scaleFactor = 1.0;
// determine which interpolation method we use for points near the boundary
switch (interpolationMethod_m) {
case CONSTANT:
constantInterpolation(x, y, z, value, scaleFactor);
break;
case LINEAR:
linearInterpolation(x, y, z, value, scaleFactor);
break;
case QUADRATIC:
quadraticInterpolation(x, y, z, value, scaleFactor);
break;
}
// stencil center value has to be positive!
assert(value.center > 0);
}
void EllipticDomain::constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
......
......@@ -47,10 +47,6 @@ public:
~EllipticDomain();
/// returns discretization at (x,y,z)
void getBoundaryStencil(int x, int y, int z, StencilValue_t& values,
double &scaleFactor);
/// queries if a given (x,y,z) coordinate lies inside the domain
inline bool isInside(int x, int y, int z) {
double xx = getXRangeMin() + hr_m[0] * (x + 0.5);
......@@ -115,13 +111,13 @@ private:
/// different interpolation methods for boundary points
void constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
void linearInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
void quadraticInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
double &scaleFactor) override;
/// function to handle the open boundary condition in longitudinal direction
void robinBoundaryStencil(int z, double &F, double &B, double &C);
......
......@@ -27,6 +27,8 @@
#include "Solvers/IrregularDomain.h"
#include "Utilities/OpalException.h"
#include <cassert>
IrregularDomain::IrregularDomain(const Vector_t& nr, const Vector_t& hr,
const std::string& interpl)
: nr_m(nr)
......@@ -72,6 +74,7 @@ void IrregularDomain::getNeighbours(int x, int y, int z, StencilIndex_t& index)
index.back = getIdx(x, y, z + 1);
}
void IrregularDomain::getNeighbours(int id, StencilIndex_t& index)
{
int x = 0, y = 0, z = 0;
......@@ -80,6 +83,29 @@ void IrregularDomain::getNeighbours(int id, StencilIndex_t& index)
}
void IrregularDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
scaleFactor = 1.0;
// determine which interpolation method we use for points near the boundary
switch (interpolationMethod_m) {
case CONSTANT:
constantInterpolation(x, y, z, value, scaleFactor);
break;
case LINEAR:
linearInterpolation(x, y, z, value, scaleFactor);
break;
case QUADRATIC:
quadraticInterpolation(x, y, z, value, scaleFactor);
break;
}
// stencil center value has to be positive!
assert(value.center > 0);
}
void IrregularDomain::getBoundaryStencil(int id, StencilValue_t& value,
double &scaleFactor)
{
......@@ -96,4 +122,28 @@ void IrregularDomain::resizeMesh(Vector_t& origin, Vector_t& hr,
origin = min_m;
for (int i = 0; i < 3; i++)
hr[i] = (max_m[i] - min_m[i]) / nr_m[i];
};
\ No newline at end of file
};
void IrregularDomain::constantInterpolation(int /*idx*/, int /*idy*/, int /*idz*/,
StencilValue_t& /*value*/, double &/*scaleFactor*/)
{
throw OpalException("IrregularDomain::constantInterpolation()",
"No constant interpolation method Implemented!");
}
void IrregularDomain::linearInterpolation(int /*idx*/, int /*idy*/, int /*idz*/,
StencilValue_t& /*value*/, double &/*scaleFactor*/)
{
throw OpalException("IrregularDomain::linearInterpolation()",
"No linear interpolation method Implemented!");
}
void IrregularDomain::quadraticInterpolation(int /*idx*/, int /*idy*/, int /*idz*/,
StencilValue_t& /*value*/, double &/*scaleFactor*/)
{
throw OpalException("IrregularDomain::quadraticInterpolation()",
"No quadratic interpolation method Implemented!");
}
\ No newline at end of file
......@@ -79,9 +79,9 @@ public:
/// \param z index of the current element in the matrix
/// \param values of stencil element
/// \param scaleFactor of stencil values
virtual void getBoundaryStencil(int x, int y, int z,
void getBoundaryStencil(int x, int y, int z,
StencilValue_t& value,
double &scaleFactor) = 0;
double &scaleFactor);
/// method to calculate the stencil at a boundary points
/// \param id index of the current element in the matrix
......@@ -148,6 +148,17 @@ public:
protected:
/// different interpolation methods for boundary points
virtual void constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
virtual void linearInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
virtual void quadraticInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor);
// a irregular domain is always defined on a grid
/// number of mesh points in each direction
Vector_t nr_m;
......
......@@ -45,8 +45,8 @@ int RectangularDomain::getNumXY(int /*z*/) {
return nxy_m;
}
void RectangularDomain::getBoundaryStencil(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
void RectangularDomain::constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor)
{
//scaleFactor = 1.0;
......
......@@ -48,9 +48,6 @@ public:
/// returns number of nodes in xy plane (here independent of z coordinate)
int getNumXY(int z);
/// 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)
using IrregularDomain::getNeighbours;
......@@ -83,6 +80,8 @@ private:
z = (idx - ixy) / nxy_m;
}
void constantInterpolation(int x, int y, int z, StencilValue_t& value,
double &scaleFactor) override;
};
#endif
......
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