From ccc686830afdf9ab8c5153d6d0c4e575f4107e02 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 12 Jan 2021 18:07:58 +0100 Subject: [PATCH 1/8] some more tests for csg2d --- tests/pytest/test_csg2d.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/pytest/test_csg2d.py b/tests/pytest/test_csg2d.py index 204e8ce1..596be0eb 100644 --- a/tests/pytest/test_csg2d.py +++ b/tests/pytest/test_csg2d.py @@ -3,6 +3,19 @@ import pytest import math from pytest import approx + +def check_area(geo, area): + if isinstance(geo, Solid2d): + g = CSG2d() + g.Add(geo) + geo = g + + m = geo.GenerateMesh() + ngs = pytest.importorskip("ngsolve") + mesh = ngs.Mesh(m) + mesh.Curve(5) + assert ngs.Integrate(1.0, mesh) == approx(area) + def test_two_circles(): c1 = Circle(center=(0,0), radius=1) c2 = c1.Rotate(45) @@ -82,6 +95,17 @@ def test_circle_plus_rect1(): mesh.Curve(5) assert ngs.Integrate(1.0, mesh) == approx(math.pi) +def test_circle_and_rect(): + c = Circle(center=(0,0),radius=1) + r = Rectangle((0,0),(1,1)) + + pi = math.pi + check_area(c-r, 3/4*pi) + check_area(c*r, 1/4*pi) + check_area(c+r, 3/4*pi+1) + check_area(r*c, 1/4*pi) + check_area(r+c, 3/4*pi+1) + if __name__ == "__main__": test_two_circles() From 96b9be9f9c8332a5e2c8da462ecc7c598ddcc8d6 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 12 Jan 2021 18:08:39 +0100 Subject: [PATCH 2/8] [WIP] Fix oracle function in csg2d --- libsrc/geom2d/csg2d.cpp | 94 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 84 insertions(+), 10 deletions(-) diff --git a/libsrc/geom2d/csg2d.cpp b/libsrc/geom2d/csg2d.cpp index 09f743b7..6a04f8f3 100644 --- a/libsrc/geom2d/csg2d.cpp +++ b/libsrc/geom2d/csg2d.cpp @@ -422,6 +422,64 @@ bool IsCloseToTrig( const array,3> & t, Point<2> r, double eps=1e-4 ) return IsInsideTrig( t, r ); } +bool IsLeft( const Spline & s, Point<2> p ) +{ + Point<2> a = s.StartPI(); + Point<2> b = s.TangentPoint(); + Point<2> c = s.EndPI(); + + // simple check by approximating spline with segment + bool is_left = Area(p, a, c) > 0.0; + + // not close to spline -> simple check valid + if(!IsCloseToTrig( {a, b, c} , p )) + return is_left; + + // p is control point -> simple check valid + auto bp = p-b; + if(bp.Length2() < EPSILON) + return is_left; + + double sab = Area(p, a, b); + double sbc = Area(p, b, c); + if(fabs(sab) same side of spline as control point, simple test gives correct result + // weight decreases -> opposite side of spline as control point, adding control point to test polygon gives correct result + double old_weight = s.GetWeight(); + auto s_tmp = s; + ComputeWeight( s_tmp, p ); + double new_weight = s_tmp.GetWeight(); + + if(new_weight>old_weight) + return is_left; + + double sabc = Area(a, b, c); + + if (sabc > 0) + { + // chain makes a left turn + if (sab > 0 && sbc > 0) + return true; + else + return false; + } + else + { + // chain makes a right turn (or is straight) + if (sab < 0 && sbc < 0) + return false; + else + return true; + } +} + + IntersectionType IntersectTrig( Point<2> p0, Point<2> p1, const array,3> & trig) { @@ -850,15 +908,26 @@ RelativePositionType oracle(bool prev, Vertex* P1, Vertex* P2, Vertex* P3) Point<2> p2 = *P2; Point<2> p3 = *P3; + double s1, s2, s3; + if(P1->spline) - p1 = P1->spline->TangentPoint(); + { + s1 = IsLeft(*P1->spline, q) ? 1 : -1; + p1 = P1->spline->TangentPoint(); + } + else + s1 = Area( q, p1, p2); + if(P2->spline) - p3 = P2->spline->TangentPoint(); + { + s2 = IsLeft(*P2->spline, q) ? 1 : -1; + p2 = P2->spline->TangentPoint(); + } + else + s2 = Area( q, p2, p3); // check relative position of Q with respect to chain (P1,P2,P3) - double s1 = Area( q, p1, p2); - double s2 = Area( q, p2, p3); - double s3 = Area( p1, p2, p3); + s3 = Area( p1, p2, p3); if (s3 > 0) { @@ -878,6 +947,14 @@ RelativePositionType oracle(bool prev, Vertex* P1, Vertex* P2, Vertex* P3) } } +RelativePositionType oracle(bool prev, Vertex* P2) +{ + Vertex* P1 = P2->prev; + Vertex* P3 = P2->next; + + return oracle(prev, P1, P2, P3); +} + void LabelIntersections(Solid2d & sp, Solid2d & sq, Solid2d & sr, bool UNION) { auto & PP = sp.polys; @@ -890,12 +967,9 @@ void LabelIntersections(Solid2d & sp, Solid2d & sq, Solid2d & sr, bool UNION) { // determine local configuration at this intersection vertex - Vertex* P_m = I->prev; - Vertex* P_p = I->next; - // check positions of Q- and Q+ relative to (P-, I, P+) - RelativePositionType Q_m_type = oracle(true, P_m, I, P_p); - RelativePositionType Q_p_type = oracle(false, P_m, I, P_p); + RelativePositionType Q_m_type = oracle(true, I); + RelativePositionType Q_p_type = oracle(false, I); // check non-overlapping cases if ((Q_m_type == LEFT && Q_p_type == RIGHT) || From 1502fd705e33928aff087366be10c6e87153dc51 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 12 Jan 2021 18:08:51 +0100 Subject: [PATCH 3/8] some debug messages --- libsrc/geom2d/csg2d.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/libsrc/geom2d/csg2d.cpp b/libsrc/geom2d/csg2d.cpp index 6a04f8f3..f489f6fe 100644 --- a/libsrc/geom2d/csg2d.cpp +++ b/libsrc/geom2d/csg2d.cpp @@ -150,6 +150,7 @@ IntersectionType ClassifyNonOverlappingIntersection( double alpha, double beta ) if (alpha_is_0 && beta_is_0) return (V_INTERSECTION); + cout << alpha << ',' << beta << ',' << alpha_is_0 << ',' << beta_is_0 << endl; return NO_INTERSECTION; } @@ -273,6 +274,7 @@ IntersectionType IntersectSplineSegment( const Spline & s, const Point<2> & r0, int dim = fabs(vr[0]) > fabs(vr[1]) ? 0 : 1; beta = 1.0/vr[dim] * (s.GetPoint(t)[dim] - r0[dim]); + cout << "intersect splinesegment " << alpha << ',' << beta << ',' << ClassifyNonOverlappingIntersection(alpha, beta) << endl; return ClassifyNonOverlappingIntersection(alpha, beta); } @@ -339,6 +341,7 @@ IntersectionType IntersectSplineSegment1( const Spline & s, const Point<2> & r0, alpha = valpha[choice]; beta = vbeta[choice]; + cout << "intersect splinesegment1 " << alpha << ',' << beta << ',' << vtype[choice] << endl; return vtype[choice]; } @@ -718,6 +721,7 @@ void AddIntersectionPoint(Edge edgeP, Edge edgeQ, IntersectionType i, double alp I_P = edgeP.v0->Insert(I, alpha); I_Q = edgeQ.v0->Insert(I, beta); I_P->Link(I_Q); + cout << "Add X Intersection " << *I_P << alpha << ',' << beta << endl; break; case X_OVERLAP: @@ -726,23 +730,28 @@ void AddIntersectionPoint(Edge edgeP, Edge edgeQ, IntersectionType i, double alp I_P = edgeP.v0->Insert(*Q1, alpha); I_P->Link( Q1); + cout << "Add X Overlap " << *I_P << alpha << ',' << beta << endl; break; case T_INTERSECTION_Q: case T_OVERLAP_Q: I_Q = edgeQ.v0->Insert(*P1, beta); P1->Link( I_Q); + cout << "Add T int/overlap Q " << *P1 << alpha << ',' << beta << endl; break; case T_INTERSECTION_P: case T_OVERLAP_P: I_P = edgeP.v0->Insert(*Q1, alpha); I_P->Link( Q1); + cout << "Add T int/overlap P " << *I_P << alpha << ',' << beta << endl; break; case V_INTERSECTION: case V_OVERLAP: P1->Link(Q1); + cout << "Add V int/overlap " << *P1 << alpha << ',' << beta << endl; + cout << *P1 << *P1->next << *Q1 << *Q1->next << endl; break; default: break; @@ -812,7 +821,7 @@ void ComputeIntersections(Edge edgeP , Loop & l2) // search for possible second intersection i = intersect(edgeP, edgeQ, alpha1, beta1); - // cout << "second intersection " << i << ',' << alpha1 << ',' << beta1 << ',' << alpha1-alpha << ',' << beta1-beta << endl; + cout << "second intersection " << i << ',' << alpha1 << ',' << beta1 << ',' << alpha1-alpha << ',' << beta1-beta << endl; if(i!=NO_INTERSECTION && alpha+EPSILON 0) { // chain makes a left turn @@ -1004,6 +1016,7 @@ void LabelIntersections(Solid2d & sp, Solid2d & sq, Solid2d & sr, bool UNION) if ( ( (Q_m_type == IS_P_m) && (Q_p_type == LEFT) ) || ( (Q_p_type == IS_P_m) && (Q_m_type == LEFT) ) ) I->label = ON_RIGHT; + cout << "label " << *I << " = " << I->label << endl; } // 2) classify intersection chains @@ -1015,6 +1028,7 @@ void LabelIntersections(Solid2d & sp, Solid2d & sq, Solid2d & sr, bool UNION) if (I->label == LEFT_ON || I->label == RIGHT_ON) { + cout << "intersection chain " << *I << endl; // remember status of the first chain vertex and vertex itself RelativePositionType x; From ba7fc0380084ae064280050d556ea9477822e181 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Wed, 13 Jan 2021 08:40:52 +0100 Subject: [PATCH 4/8] use pytest-check --- tests/dockerfile | 1 + tests/dockerfile_mpi | 2 +- tests/pytest/test_csg2d.py | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/dockerfile b/tests/dockerfile index 383189fd..7c20b027 100644 --- a/tests/dockerfile +++ b/tests/dockerfile @@ -2,4 +2,5 @@ FROM ubuntu:19.10 ENV DEBIAN_FRONTEND=noninteractive MAINTAINER Matthias Hochsteger RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk clang-tidy python3-distutils clang libocct-data-exchange-dev libcgns-dev libhdf5-dev +RUN python3 -m pip install pytest-check ADD . /root/src/netgen diff --git a/tests/dockerfile_mpi b/tests/dockerfile_mpi index 220179a8..c90c0c28 100644 --- a/tests/dockerfile_mpi +++ b/tests/dockerfile_mpi @@ -2,5 +2,5 @@ FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive MAINTAINER Matthias Hochsteger RUN apt-get update && apt-get -y install python3 libpython3-dev python3-pip libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk python3-mpi4py clang-tidy python3-distutils clang libopenmpi-dev openmpi-bin gfortran -RUN python3 -m pip install pytest-mpi +RUN python3 -m pip install pytest-mpi pytest-check ADD . /root/src/netgen diff --git a/tests/pytest/test_csg2d.py b/tests/pytest/test_csg2d.py index 596be0eb..b76e9998 100644 --- a/tests/pytest/test_csg2d.py +++ b/tests/pytest/test_csg2d.py @@ -2,6 +2,7 @@ from netgen.geom2d import * import pytest import math from pytest import approx +from pytest_check import check def check_area(geo, area): @@ -14,7 +15,7 @@ def check_area(geo, area): ngs = pytest.importorskip("ngsolve") mesh = ngs.Mesh(m) mesh.Curve(5) - assert ngs.Integrate(1.0, mesh) == approx(area) + with check: assert ngs.Integrate(1.0, mesh) == approx(area) def test_two_circles(): c1 = Circle(center=(0,0), radius=1) From 12ebcd0d68cd010da6bf9f30a078f70f06b66d92 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 14 Jan 2021 17:11:46 +0100 Subject: [PATCH 5/8] Fix oracle function and intersection bug in csg2d --- libsrc/geom2d/csg2d.cpp | 205 ++++++++++++++++++++++++++-------------- 1 file changed, 134 insertions(+), 71 deletions(-) diff --git a/libsrc/geom2d/csg2d.cpp b/libsrc/geom2d/csg2d.cpp index f489f6fe..99a45b65 100644 --- a/libsrc/geom2d/csg2d.cpp +++ b/libsrc/geom2d/csg2d.cpp @@ -150,7 +150,6 @@ IntersectionType ClassifyNonOverlappingIntersection( double alpha, double beta ) if (alpha_is_0 && beta_is_0) return (V_INTERSECTION); - cout << alpha << ',' << beta << ',' << alpha_is_0 << ',' << beta_is_0 << endl; return NO_INTERSECTION; } @@ -274,7 +273,6 @@ IntersectionType IntersectSplineSegment( const Spline & s, const Point<2> & r0, int dim = fabs(vr[0]) > fabs(vr[1]) ? 0 : 1; beta = 1.0/vr[dim] * (s.GetPoint(t)[dim] - r0[dim]); - cout << "intersect splinesegment " << alpha << ',' << beta << ',' << ClassifyNonOverlappingIntersection(alpha, beta) << endl; return ClassifyNonOverlappingIntersection(alpha, beta); } @@ -295,8 +293,11 @@ IntersectionType IntersectSplineSegment1( const Spline & s, const Point<2> & r0, double c_ = a0; double det = b_*b_ - 4*a_*c_; - if(det<0.0) - return NO_INTERSECTION; + if(det<-EPSILON) + return NO_INTERSECTION; + + if(det & r0, alpha = valpha[choice]; beta = vbeta[choice]; - cout << "intersect splinesegment1 " << alpha << ',' << beta << ',' << vtype[choice] << endl; return vtype[choice]; } @@ -721,7 +721,6 @@ void AddIntersectionPoint(Edge edgeP, Edge edgeQ, IntersectionType i, double alp I_P = edgeP.v0->Insert(I, alpha); I_Q = edgeQ.v0->Insert(I, beta); I_P->Link(I_Q); - cout << "Add X Intersection " << *I_P << alpha << ',' << beta << endl; break; case X_OVERLAP: @@ -730,28 +729,23 @@ void AddIntersectionPoint(Edge edgeP, Edge edgeQ, IntersectionType i, double alp I_P = edgeP.v0->Insert(*Q1, alpha); I_P->Link( Q1); - cout << "Add X Overlap " << *I_P << alpha << ',' << beta << endl; break; case T_INTERSECTION_Q: case T_OVERLAP_Q: I_Q = edgeQ.v0->Insert(*P1, beta); P1->Link( I_Q); - cout << "Add T int/overlap Q " << *P1 << alpha << ',' << beta << endl; break; case T_INTERSECTION_P: case T_OVERLAP_P: I_P = edgeP.v0->Insert(*Q1, alpha); I_P->Link( Q1); - cout << "Add T int/overlap P " << *I_P << alpha << ',' << beta << endl; break; case V_INTERSECTION: case V_OVERLAP: P1->Link(Q1); - cout << "Add V int/overlap " << *P1 << alpha << ',' << beta << endl; - cout << *P1 << *P1->next << *Q1 << *Q1->next << endl; break; default: break; @@ -810,8 +804,8 @@ void ComputeIntersections(Edge edgeP , Loop & l2) { for (Edge edgeQ : l2.Edges(SOURCE)) { - double alpha = 0.0; - double beta = 0.0; + double alpha = -1; + double beta = -1; IntersectionType i = intersect(edgeP, edgeQ, alpha, beta); AddIntersectionPoint(edgeP, edgeQ, i, alpha, beta); if(i==X_INTERSECTION && (edgeP.v0->spline || edgeQ.v0->spline)) @@ -821,7 +815,6 @@ void ComputeIntersections(Edge edgeP , Loop & l2) // search for possible second intersection i = intersect(edgeP, edgeQ, alpha1, beta1); - cout << "second intersection " << i << ',' << alpha1 << ',' << beta1 << ',' << alpha1-alpha << ',' << beta1-beta << endl; if(i!=NO_INTERSECTION && alpha+EPSILON q; - if(prev) - { - Q = P2->neighbour->prev; - q = *Q; - if(Q->spline) - q = Q->spline->TangentPoint(); - } - else - { - Q = P2->neighbour->next; - q = *Q; - if(P2->neighbour->spline) - q = P2->neighbour->spline->TangentPoint(); - } - - // is Q linked to P1 ? - if ( P1->is_intersection && (P1->neighbour == Q) ) - return(IS_P_m); - - // is Q linked to P2 ? - if ( P3->is_intersection && (P3->neighbour == Q) ) - return(IS_P_p); - - Point<2> p1 = *P1; - Point<2> p2 = *P2; - Point<2> p3 = *P3; - - double s1, s2, s3; - - if(P1->spline) - { - s1 = IsLeft(*P1->spline, q) ? 1 : -1; - p1 = P1->spline->TangentPoint(); - } - else - s1 = Area( q, p1, p2); - - if(P2->spline) - { - s2 = IsLeft(*P2->spline, q) ? 1 : -1; - p2 = P2->spline->TangentPoint(); - } - else - s2 = Area( q, p2, p3); - - // check relative position of Q with respect to chain (P1,P2,P3) - s3 = Area( p1, p2, p3); - - cout << "Points for oracle " << q << p1 << p2 << p3 << endl; - cout << "areas " << s1 << ',' << s2 << ',' << s3 << endl; - if (s3 > 0) { // chain makes a left turn @@ -959,14 +899,139 @@ RelativePositionType oracle(bool prev, Vertex* P1, Vertex* P2, Vertex* P3) } } +// no splines involved here +// decides if Point q is left or right of chain (p1,p2,p3) +RelativePositionType oracle_simple(Point<2> q, Point<2> p1, Point<2> p2, Point<2> p3) +{ + double s1 = Area( q, p1, p2); + double s2 = Area( q, p2, p3); + double s3 = Area( p1, p2, p3); + + // check relative position of q with respect to chain (p1,p2,p3) + return oracle_decide(s1, s2, s3); +} + +// (p1,p2) or (p2,p3) is a spline segment, compare with tangent (p1t,p2) instead of Segment (p1,p2) +// BUT take care if tangent is collinear with (q,p2) (then use the segment (p1,p2) again) +RelativePositionType oracle_spline_p(Point<2> q, Point<2> p1, Point<2> p1t, Point<2> p2, Point<2> p3, Point<2> p3t) +{ + double s1 = Area( q, p1t, p2); + double s2 = Area( q, p2, p3t); + + if(fabs(s1) < EPSILON) + { + p1t = p1; + s1 = Area( q, p1t, p2 ); + } + + if(fabs(s2) < EPSILON) + { + p3t = p3; + s2 = Area( q, p2, p3t ); + } + + double s3 = Area( p1t, p2, p3t); + + return oracle_decide(s1, s2, s3); +} + +// (q,p2) is a spline segment, compare with tangent (qt,p2) instead of Segment (q,p2) +// BUT take care if tangent at p2 is collinear with eiter (p1,p2) or (p2,p3) (then use the segment (q,p2) again) +RelativePositionType oracle_spline_q(Point<2> q, Point<2> qt, Point<2> p1, Point<2> p2, Point<2> p3) +{ + double s1 = Area( qt, p1, p2); + double s2 = Area( qt, p2, p3); + double s3 = Area( p1, p2, p3); + + if(fabs(s1) < EPSILON) + s1 = Area( q, p1, p2 ); + + if(fabs(s2) < EPSILON) + s2 = Area( q, p2, p3 ); + + return oracle_decide(s1, s2, s3); +} + +// splines at (Q,P2) and either (P1,P2) or (P2,P3) +// first use tangents to decide local orientation +// if tangents of two splines match, use IsLeft(spline, other end point) +// if tangent of spline and segment match, use simple methond (just end points) +RelativePositionType oracle_spline(bool prev, Vertex *Q, Vertex *P1, Vertex *P2, Vertex *P3) +{ + Point<2> p1t = *P1; + Point<2> p3t = *P3; + + auto sq = prev ? Q->spline : Q->prev->spline; + auto qt = sq->TangentPoint(); + if(P1->spline) p1t = P1->spline->TangentPoint(); + if(P2->spline) p3t = P2->spline->TangentPoint(); + + // Check using tangent directions first + double s1 = Area( qt, p1t, *P2 ); + double s2 = Area( qt, *P2 , p3t); + double s3 = Area( p1t, *P2, p3t); + + // tangents are facing in same direction + if(fabs(s1) < EPSILON) + { + if(P1->spline) + s1 = IsLeft(*P1->spline, *Q) ? 1 : -1; + else + s1 = Area( *Q, *P1, *P2 ); + } + + // tangents are facing in same direction + if(fabs(s2) < EPSILON) + { + if(P2->spline) + s2 = IsLeft(*P2->spline, *Q) ? 1 : -1; + else + s2 = Area( *Q, *P2, *P3 ); + } + + return oracle_decide(s1, s2, s3); +} + + RelativePositionType oracle(bool prev, Vertex* P2) { + auto Q = prev ? P2->neighbour->prev : P2->neighbour->next; + auto sq = prev ? Q->spline : Q->prev->spline; Vertex* P1 = P2->prev; Vertex* P3 = P2->next; - return oracle(prev, P1, P2, P3); + // is Q linked to P1 ? + if ( P1->is_intersection && (P1->neighbour == Q) ) + return(IS_P_m); + + // is Q linked to P2 ? + if ( P3->is_intersection && (P3->neighbour == Q) ) + return(IS_P_p); + + // no splines -> simple variant + if(!P1->spline && !P2->spline && !Q->spline) + return oracle_simple(*Q, *P1, *P2, *P3); + + Point<2> qt=*Q, p1t=*P1, p3t=*P3; + + // splines -> also consider tangent points + if( sq) qt = Q->spline->TangentPoint(); + if(P1->spline) p1t = P1->spline->TangentPoint(); + if(P2->spline) p3t = P2->spline->TangentPoint(); + + // only spline at Q + if(!P1->spline && !P2->spline && Q->spline) + return oracle_spline_q(*Q, qt, *P1, *P2, *P3); + + // only spline at P + if((P1->spline || !P2->spline) && !Q->spline) + return oracle_spline_p(*Q, *P1, p1t, *P2, *P3, p3t); + + // spline at Q and P1 or P2 + return oracle_spline(prev, Q, P1, P2, P3); } + void LabelIntersections(Solid2d & sp, Solid2d & sq, Solid2d & sr, bool UNION) { auto & PP = sp.polys; @@ -1016,7 +1081,6 @@ void LabelIntersections(Solid2d & sp, Solid2d & sq, Solid2d & sr, bool UNION) if ( ( (Q_m_type == IS_P_m) && (Q_p_type == LEFT) ) || ( (Q_p_type == IS_P_m) && (Q_m_type == LEFT) ) ) I->label = ON_RIGHT; - cout << "label " << *I << " = " << I->label << endl; } // 2) classify intersection chains @@ -1028,7 +1092,6 @@ void LabelIntersections(Solid2d & sp, Solid2d & sq, Solid2d & sr, bool UNION) if (I->label == LEFT_ON || I->label == RIGHT_ON) { - cout << "intersection chain " << *I << endl; // remember status of the first chain vertex and vertex itself RelativePositionType x; From b21f04ddcbc5498148af497dec1b2fcd8b08b51a Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 14 Jan 2021 17:37:21 +0100 Subject: [PATCH 6/8] Update Ubuntu for tests to 20.10 --- tests/dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dockerfile b/tests/dockerfile index 7c20b027..8e28c569 100644 --- a/tests/dockerfile +++ b/tests/dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:19.10 +FROM ubuntu:20.10 ENV DEBIAN_FRONTEND=noninteractive MAINTAINER Matthias Hochsteger RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk clang-tidy python3-distutils clang libocct-data-exchange-dev libcgns-dev libhdf5-dev From 6f74a1580bb31057dbdd6c4eb60280eb55b63a20 Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 14 Jan 2021 17:37:38 +0100 Subject: [PATCH 7/8] add test for csg2d, set maxh --- tests/pytest/test_csg2d.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/pytest/test_csg2d.py b/tests/pytest/test_csg2d.py index b76e9998..9e05682b 100644 --- a/tests/pytest/test_csg2d.py +++ b/tests/pytest/test_csg2d.py @@ -11,7 +11,7 @@ def check_area(geo, area): g.Add(geo) geo = g - m = geo.GenerateMesh() + m = geo.GenerateMesh(maxh=0.2) ngs = pytest.importorskip("ngsolve") mesh = ngs.Mesh(m) mesh.Curve(5) @@ -106,6 +106,7 @@ def test_circle_and_rect(): check_area(c+r, 3/4*pi+1) check_area(r*c, 1/4*pi) check_area(r+c, 3/4*pi+1) + check_area(r-c, 1-1/4*pi) if __name__ == "__main__": From 6b41cdac9fca3d69fa4e795112bb36b4b3e6296b Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Thu, 14 Jan 2021 18:18:42 +0100 Subject: [PATCH 8/8] install pytest-check --- .gitlab-ci.yml | 1 + tests/dockerfile | 2 +- tests/dockerfile_mpi | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 0b4c60bc..b5ad6f13 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,6 +70,7 @@ test_win: <<: *win stage: test script: + - pip install pytest-check - cd tests\pytest - cd %NETGEN_BUILD_DIR%\netgen - ctest -C Release -V --output-on-failure diff --git a/tests/dockerfile b/tests/dockerfile index 8e28c569..152aab13 100644 --- a/tests/dockerfile +++ b/tests/dockerfile @@ -1,6 +1,6 @@ FROM ubuntu:20.10 ENV DEBIAN_FRONTEND=noninteractive MAINTAINER Matthias Hochsteger -RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk clang-tidy python3-distutils clang libocct-data-exchange-dev libcgns-dev libhdf5-dev +RUN apt-get update && apt-get -y install python3 python3-pip libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk clang-tidy python3-distutils clang libocct-data-exchange-dev libcgns-dev libhdf5-dev RUN python3 -m pip install pytest-check ADD . /root/src/netgen diff --git a/tests/dockerfile_mpi b/tests/dockerfile_mpi index c90c0c28..a25a96b9 100644 --- a/tests/dockerfile_mpi +++ b/tests/dockerfile_mpi @@ -1,6 +1,6 @@ FROM ubuntu:20.04 ENV DEBIAN_FRONTEND=noninteractive MAINTAINER Matthias Hochsteger -RUN apt-get update && apt-get -y install python3 libpython3-dev python3-pip libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk python3-mpi4py clang-tidy python3-distutils clang libopenmpi-dev openmpi-bin gfortran -RUN python3 -m pip install pytest-mpi pytest-check +RUN apt-get update && apt-get -y install python3 libpython3-dev python3-pip libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-numpy python3-tk python3-mpi4py clang-tidy python3-distutils clang libopenmpi-dev openmpi-bin gfortran +RUN python3 -m pip install pytest-mpi pytest-check pytest ADD . /root/src/netgen