From 56ad80e09aaef978dc30b6c758c35908fbf5f32b Mon Sep 17 00:00:00 2001 From: Joachim Schoeberl Date: Fri, 24 Jul 2009 23:14:31 +0000 Subject: [PATCH] 2d examples --- libsrc/geom2d/spline.cpp | 8 ++++---- libsrc/geom2d/spline.hpp | 19 +++++++++++-------- libsrc/geom2d/splinegeometry.cpp | 16 +++++++++------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/libsrc/geom2d/spline.cpp b/libsrc/geom2d/spline.cpp index 6597474b..7f458e64 100644 --- a/libsrc/geom2d/spline.cpp +++ b/libsrc/geom2d/spline.cpp @@ -264,8 +264,8 @@ namespace netgen - void CalcPartition (double l, double h, double r1, double r2, - double ra, double elto0, Array & points) + void CalcPartition (double l, double h, double h1, double h2, + double hcurve, double elto0, Array & points) { int i, j, n, nel; double sum, t, dt, fun, fperel, oldf, f; @@ -279,7 +279,7 @@ namespace netgen t = 0.5 * dt; for (i = 1; i <= n; i++) { - fun = min3 (h/ra, t/elto0 + h/r1, (l-t)/elto0 + h/r2); + fun = min3 (hcurve, t/elto0 + h1, (l-t)/elto0 + h2); sum += dt / fun; t += dt; } @@ -294,7 +294,7 @@ namespace netgen t = 0.5 * dt; for (j = 1; j <= n && i < nel; j++) { - fun = min3 (h/ra, t/elto0 + h/r1, (l-t)/elto0 + h/r2); + fun = min3 (hcurve, t/elto0 + h1, (l-t)/elto0 + h2); f = oldf + dt / fun; diff --git a/libsrc/geom2d/spline.hpp b/libsrc/geom2d/spline.hpp index 15c6f18d..5a84fafc 100644 --- a/libsrc/geom2d/spline.hpp +++ b/libsrc/geom2d/spline.hpp @@ -8,8 +8,8 @@ /**************************************************************************/ -void CalcPartition (double l, double h, double r1, double r2, - double ra, double elto0, Array & points); +void CalcPartition (double l, double h, double h1, double h2, + double hcurve, double elto0, Array & points); /* Spline curves for 2D mesh generation @@ -23,7 +23,8 @@ class GeomPoint : public Point public: /// refinement factor at point double refatpoint; - + /// max mesh-size at point + double hmax; /// hp-refinement bool hpref; @@ -49,6 +50,8 @@ public: int rightdom; /// refinement at line double reffak; + /// maximal h; + double hmax; /// boundary condition number int bc; /// copy spline mesh from other spline (-1.. do not copy) @@ -297,7 +300,7 @@ void SplineSeg :: Partition (double h, double elto0, Mesh & mesh, Point3dTree & searchtree, int segnr) const { int i, j; - double l, r1, r2, ra; + double l; // , r1, r2, ra; double lold, dt, frac; int n = 100; Point p, pold, mark, oldmark; @@ -305,12 +308,12 @@ void SplineSeg :: Partition (double h, double elto0, double edgelength, edgelengthold; l = Length(); - r1 = StartPI().refatpoint; - r2 = EndPI().refatpoint; - ra = reffak; + double h1 = min (StartPI().hmax, h/StartPI().refatpoint); + double h2 = min (EndPI().hmax, h/EndPI().refatpoint); + double hcurve = min (hmax, h/reffak); // cout << "Partition, l = " << l << ", h = " << h << endl; - CalcPartition (l, h, r1, r2, ra, elto0, curvepoints); + CalcPartition (l, h, h1, h2, hcurve, elto0, curvepoints); // cout << "curvepoints = " << curvepoints << endl; dt = 1.0 / n; diff --git a/libsrc/geom2d/splinegeometry.cpp b/libsrc/geom2d/splinegeometry.cpp index 90b2c023..3d65de38 100644 --- a/libsrc/geom2d/splinegeometry.cpp +++ b/libsrc/geom2d/splinegeometry.cpp @@ -13,11 +13,13 @@ namespace netgen { - //using namespace netgen; + template void SplineGeometry :: LoadDataV2 ( ifstream & infile ) -{ +{ + // new parser by Astrid Sinwel + PrintMessage (1, "Load 2D Geometry V2"); int nump, leftdom, rightdom; Point x; @@ -114,6 +116,7 @@ void SplineGeometry :: LoadDataV2 ( ifstream & infile ) infilepoints.Append ( GeomPoint(x, hd) ); infilepoints.Last().hpref = flags.GetDefineFlag ("hpref"); + infilepoints.Last().hmax = flags.GetNumFlag ("maxh", 1e99); TestComment(infile); infile.get(ch); @@ -246,8 +249,8 @@ void SplineGeometry :: LoadDataV2 ( ifstream & infile ) int (flags.GetDefineFlag ("hprefright")); splines.Last()->copyfrom = int (flags.GetNumFlag ("copy", -1)); splines.Last()->reffak = flags.GetNumFlag ("ref", 1 ); - if ( hd != 1 ) - splines.Last()->reffak = hd; + splines.Last()->hmax = flags.GetNumFlag ("maxh", 1e99 ); + if ( hd != 1 ) splines.Last()->reffak = hd; if ( flags.StringFlagDefined("bcname") ) { @@ -414,9 +417,7 @@ template SplineGeometry :: ~SplineGeometry() { for(int i=0; i :: LoadDataNew ( ifstream & infile ) int (flags.GetDefineFlag ("hprefright")); splines.Last()->copyfrom = int (flags.GetNumFlag ("copy", -1)); splines.Last()->reffak = flags.GetNumFlag ("ref", 1 ); + splines.Last()->hmax = flags.GetNumFlag ("maxh", 1e99 ); if ( flags.StringFlagDefined("bcname") ) {