public void Test2DVolumeHighOrderRobustnessUnstructured() { ITestCase testCase = new MinGibou1EllipseArea(GridSizes.Tiny, GridTypes.PseudoStructured); 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, 6, rootFindingAlgorithm: new LineSegment.SafeGuardedNewtonMethod(1e-14)); double relError = Math.Abs(result.Item1 - referenceValue) / testCase.Solution; Console.WriteLine(relError); Assert.That( relError < 1e-6, "Relative error too large for shift number " + i); i++; } }
public void Test2DVolumeConvergenceUnstructured() { int[] orders = Enumerable.Range(0, 6).ToArray(); GridSizes[] sizes = new GridSizes[] { GridSizes.Small, GridSizes.Normal, GridSizes.Large }; 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 MinGibou1EllipseArea(sizes[i], GridTypes.PseudoStructured); 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); Console.WriteLine(eoc); Assert.That( eoc > orders[j] + 1, "Convergence order too low for order " + orders[j]); } }