Commit 30ff1044 authored by niklas.baumgarten's avatar niklas.baumgarten
Browse files

[Add-PointInCell] implemented PointInCell in Intval and Quadrilateral

parent a15280b6
......@@ -139,4 +139,9 @@ Point Intval::GlobalToLocal(const Point &z) const {
return Point (x,0.0,0.0);
}
bool Intval::PointInCell(const Point &z) const {
return (abs(z[0] - Center()[0]) < 0.5 * abs(Corner(0)[0] - Corner(1)[0]) + GeometricTolerance);
}
......@@ -83,6 +83,9 @@ public:
Point Child(int i) const override;
Point GlobalToLocal(const Point &point) const override;
virtual bool PointInCell(const Point &z) const override;
};
#endif //INTVAL_H
......@@ -4,11 +4,11 @@
Quadrilateral::Quadrilateral(const vector<Point> &z,
short sd,
bool checkOrientation)
: Cell(z, sd), midpoint(0.25 * (corners[0] + corners[1] + corners[2] + corners[3])) {
: Cell(z, sd), midPoint(0.25 * (corners[0] + corners[1] + corners[2] + corners[3])) {
if (checkOrientation) this->checkOrientation(corners);
}
Point Quadrilateral::Center() const { return midpoint; }
Point Quadrilateral::Center() const { return midPoint; }
CELLTYPE Quadrilateral::Type() const { return QUADRILATERAL; }
......@@ -32,8 +32,8 @@ Point Quadrilateral::FaceLocalToGlobal(int face, const Point &local) const {
}
Point Quadrilateral::LocalToGlobal(const Point &z) const {
Point v = corners[0] + z[0] * (corners[1]-corners[0]);
Point w = corners[3] + z[0] * (corners[2]-corners[3]);
Point v = corners[0] + z[0] * (corners[1] - corners[0]);
Point w = corners[3] + z[0] * (corners[2] - corners[3]);
return v + z[1] * (w - v);
//TODO: Compare Performance
......@@ -79,7 +79,8 @@ Point Quadrilateral::Edge(int i) const {
short Quadrilateral::edgecorner(unsigned short i, unsigned short j) const {
if (i < Edges() && j < 2)
return (i + j) % 4;
else THROW("Not Implemented")
else
THROW("Not Implemented")
}
int Quadrilateral::Faces() const { return 4; }
......@@ -103,7 +104,8 @@ short Quadrilateral::FaceCorners(int i) const { return 2; }
short Quadrilateral::facecorner(unsigned short i, unsigned short j) const {
if (i < Faces() && j < FaceCorners(i))
return (i + j) % 4;
else THROW("Not Implemented")
else
THROW("Not Implemented")
}
short Quadrilateral::FaceEdges(int i) const { return 1; }
......@@ -149,7 +151,7 @@ Point Quadrilateral::Child(int i) const {
const Quadrilateral *Quadrilateral::ReferenceQuadrilateral() {
static const Quadrilateral
*refQuad = new Quadrilateral(Points(4, Quadrilateral::LocalCornersQuad()), -1);
*refQuad = new Quadrilateral(Points(4, Quadrilateral::LocalCornersQuad()), -1);
return refQuad;
}
......@@ -178,6 +180,24 @@ const Point *Quadrilateral::LocalCenterQuad() {
return localCenter;
}
bool Quadrilateral::PointInCell(const Point &z) const {
Point diff = Corner(0) - Corner(1);
double edgelength = std::max(abs(diff[0]), abs(diff[1]));
double l1distx = abs(z[0] - midPoint[0]);
double l1radius = edgelength * 0.5;
if (l1distx < l1radius + GeometricTolerance) {
double l1disty = abs(z[1] - midPoint[1]);
if (l1disty < l1radius + GeometricTolerance) {
if (abs(z[2] - midPoint[2]) < l1radius + GeometricTolerance) return true;
else return false;
} else {
return false;
}
}
return false;
}
Point Quadrilateral2::LocalToGlobal(const Point &z) const {
return ((1 - z[0]) * (1 - z[1]) * (1 - 2 * z[0] - 2 * z[1])) * corners[0]
+ (-z[0] * (1 - z[1]) * (1 - 2 * z[0] + 2 * z[1])) * corners[1]
......
......@@ -34,7 +34,7 @@ class Quadrilateral : public Cell {
}
private:
Point midpoint;
Point midPoint;
public:
Quadrilateral(const vector<Point> &z,
......@@ -75,6 +75,8 @@ public:
virtual Point LocalToGlobal(const Point &z) const override;
bool PointInCell(const Point &z) const override;
virtual Transformation GetTransformation(const Point &x) const override;
int Edges() const override;
......
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