public void Grid() { double maxRes = 1.0; double maxRatio = 1.5; List <double> mesh; List <double> smoothMesh; List <string> referenceMesh; // #1 mesh = new List <double> { 0, 3 }; smoothMesh = RectilinearGrid.SmoothLines(mesh, maxRes, maxRatio); referenceMesh = new List <string> { "0.00", "1.00", "2.00", "3.00" }; //Console.Write("Original mesh: "); //Console.WriteLine(String.Join(", ", mesh.Select(i => String.Format("{0:f2}", i)).ToArray())); Assert.True(CompareGrid(referenceMesh, smoothMesh)); Console.WriteLine(); // #2 mesh = new List <double> { 0, 0.01, 3 }; smoothMesh = RectilinearGrid.SmoothLines(mesh, maxRes, maxRatio); referenceMesh = new List <string> { "0.00", "0.01", "0.03", "0.05", "0.08", "0.13", "0.21", "0.32", "0.49", "0.75", "1.13", "1.71", "2.35", "3.00" }; //Console.Write("Original mesh: "); //Console.WriteLine(String.Join(", ", mesh.Select(i => String.Format("{0:f2}", i)).ToArray())); Assert.True(CompareGrid(referenceMesh, smoothMesh)); /* * Console.WriteLine(); * * mesh = new List<double> { 0, 0.01, 2.99, 3 }; * smoothMesh = RectilinearGrid.SmoothLines(mesh, maxRes, maxRatio); * referenceMesh = new List<string> { * "0.00", "0.01", "0.03", "0.05", "0.08", "0.13", "0.21", "0.32", * "0.49", "0.75", "0.94", "1.12", "1.31", "1.87", "2.25", "2.51", * "2.68", "2.79", "2.87", "2.92", "2.95", "2.98", "2.99", "3.00" }; * * Console.WriteLine("maxRes = {0} ratio = {1}", maxRes, maxRatio); * Console.WriteLine("Original mesh:"); * Console.WriteLine(String.Join(", ", mesh.Select(i => String.Format("{0:f2}", i)).ToArray())); * * Assert.True(CompareGrid(referenceMesh, smoothMesh)); */ }
static void TestGrid() { double maxRes; double ratio; List <double> mesh; List <double> smoothMesh; List <string> referenceMesh; // #1 maxRes = 1; ratio = 1.5; mesh = new List <double> { 0, 3 }; smoothMesh = RectilinearGrid.SmoothLines(mesh, maxRes, ratio); referenceMesh = new List <string> { "0.00", "1.00", "2.00", "3.00" }; Console.WriteLine("maxRes = {0} ratio = {1}", maxRes, ratio); Console.WriteLine("Original mesh:"); Console.WriteLine(String.Join(", ", mesh.Select(i => String.Format("{0:f2}", i)).ToArray())); EvalGridTest(smoothMesh, referenceMesh); Console.WriteLine(); // #2 mesh = new List <double> { 0, 0.01, 3 }; smoothMesh = RectilinearGrid.SmoothLines(mesh, maxRes, ratio); referenceMesh = new List <string> { "0.00", "0.01", "0.03", "0.05", "0.08", "0.13", "0.21", "0.32", "0.49", "0.75", "1.13", "1.71", "2.35", "3.00" }; Console.WriteLine("maxRes = {0} ratio = {1}", maxRes, ratio); Console.WriteLine("Original mesh:"); Console.WriteLine(String.Join(", ", mesh.Select(i => String.Format("{0:f2}", i)).ToArray())); EvalGridTest(smoothMesh, referenceMesh); Console.WriteLine(); maxRes = 1; ratio = 1.5; mesh = new List <double> { 0, 0.01, 2.99, 3 }; smoothMesh = RectilinearGrid.SmoothLines(mesh, maxRes, ratio); referenceMesh = new List <string> { "0.00", "0.01", "0.03", "0.05", "0.08", "0.13", "0.21", "0.32", "0.49", "0.75", "0.94", "1.12", "1.31", "1.87", "2.25", "2.51", "2.68", "2.79", "2.87", "2.92", "2.95", "2.98", "2.99", "3.00" }; Console.WriteLine("maxRes = {0} ratio = {1}", maxRes, ratio); Console.WriteLine("Original mesh:"); Console.WriteLine(String.Join(", ", mesh.Select(i => String.Format("{0:f2}", i)).ToArray())); EvalGridTest(smoothMesh, referenceMesh); }