public void Test2DSurfaceHighOrderRobustnessStructured() { ITestCase testCase = new Smereka2EllipseArcLength(GridSizes.Tiny, GridTypes.Structured); testCase.ScaleShifts(0.5 * testCase.GridSpacing); Program app = new Program(testCase); app.Init(null); app.SetUpEnvironment(); app.SetInitial(); int i = 1; while (testCase.ProceedToNextShift()) { double referenceValue = app.SetUpConfiguration(); var result = app.PerformConfiguration( Modes.HMFClassic, 7, rootFindingAlgorithm: new LineSegment.SafeGuardedNewtonMethod(1e-14)); double relError = Math.Abs(result.Item1 - referenceValue) / testCase.Solution; Assert.That( relError < 1e-4, "Relative error too large for shift number " + i); i++; } }
public void Test2DSurfaceConvergenceStructured() { int[] orders = Enumerable.Range(0, 10).ToArray(); GridSizes[] sizes = new GridSizes[] { GridSizes.Tiny, GridSizes.Small, GridSizes.Normal }; double[,] results = new double[sizes.Length, orders.Length]; var rootFindingAlgorithm = new LineSegment.SafeGuardedNewtonMethod(1e-14); for (int i = 0; i < sizes.Length; i++) { ITestCase testCase = new Smereka2EllipseArcLength(sizes[i], GridTypes.Structured); testCase.ScaleShifts(0.5 * testCase.GridSpacing); Program app = new Program(testCase); app.Init(null); app.SetUpEnvironment(); app.SetInitial(); testCase.ProceedToNextShift(); double referenceValue = app.SetUpConfiguration(); for (int j = 0; j < orders.Length; j++) { var result = app.PerformConfiguration( Modes.HMFClassic, orders[j], rootFindingAlgorithm: rootFindingAlgorithm); results[i, j] = Math.Abs(result.Item1 - referenceValue); } } double[] xValues = sizes.Select(s => - Math.Log(2.0) * (int)s).ToArray(); for (int j = 0; j < orders.Length; j++) { double[] yValues = new double[sizes.Length]; for (int i = 0; i < sizes.Length; i++) { yValues[i] = Math.Log(results[i, j]); } double eoc = Regression(xValues, yValues); Assert.That( eoc > orders[j] + 1, "Convergence order too low for order " + orders[j]); } }