private static void diffusivity_2d_pwc_contour(int h, int w, double a, double b, double c, double d) //****************************************************************************80 // // Purpose: // // diffusivity_2d_pwc_contour displays a contour plot of a 2D stochastic diffusivity function. // // Discussion: // // The diffusivity function is computed by diffusivity_2d_pwc. // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 16 March 2019 // // Author: // // John Burkardt // { const string command_filename = "diffusivity_2d_pwc_commands.txt"; List <string> command_unit = new(); const string data_filename = "diffusivity_2d_pwc_data.txt"; List <string> data_unit = new(); Console.WriteLine(""); Console.WriteLine("diffusivity_2d_pwc_contour"); Console.WriteLine(" Display contour or surface plots of the stochastic"); Console.WriteLine(" diffusivity function defined by diffusivity_2d_pwc."); Console.WriteLine(""); Console.WriteLine(" Underlying grid is " + w + " elements wide (X) and " + h + " high (Y)"); const int nx = 101; const int ny = 101; // // Set the spatial grid. // double[] xvec = typeMethods.r8vec_linspace_new(nx, a, b); double[] yvec = typeMethods.r8vec_linspace_new(ny, c, d); double[] xmat = new double[nx * ny]; double[] ymat = new double[nx * ny]; typeMethods.r8vec_mesh_2d(nx, ny, xvec, yvec, ref xmat, ref ymat); // // Sample OMEGA. // int seed = 123456789; double[] omega = UniformRNG.r8vec_uniform_ab_new(h * w, 0.5, 1.5, ref seed); int n = nx * ny; // // Compute the diffusivity field. // double[] rho = Stochastic.diffusivity_2d_pwc(h, w, a, b, c, d, omega, n, xmat, ymat); // // Create a data file. // for (int j = 0; j < ny; j++) { for (int i = 0; i < nx; i++) { data_unit.Add(" " + xmat[i + j * nx].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + ymat[i + j * nx].ToString(CultureInfo.InvariantCulture).PadLeft(14) + " " + rho[i + j * nx].ToString(CultureInfo.InvariantCulture).PadLeft(14) + ""); } } File.WriteAllLines(data_filename, data_unit); Console.WriteLine(""); Console.WriteLine(" Created graphics data file '" + data_filename + "'"); // // Create the command file. // command_unit.Add("# " + command_filename + ""); command_unit.Add("#"); command_unit.Add("# Usage:"); command_unit.Add("# gnuplot < " + command_filename + ""); command_unit.Add("#"); command_unit.Add("set term png"); command_unit.Add("set output 'diffusivity_2d_pwc.png'"); command_unit.Add("set xlabel '<---X--->'"); command_unit.Add("set ylabel '<---Y--->'"); command_unit.Add("set zlabel '<---Rho(X,Y)--->'"); command_unit.Add("set title 'PWC Stochastic diffusivity function'"); command_unit.Add("set contour"); command_unit.Add("set timestamp"); command_unit.Add("set cntrparam levels 10"); command_unit.Add("#set view map"); command_unit.Add("set view 75, 75"); command_unit.Add("unset key"); command_unit.Add("splot '" + data_filename + "'"); File.WriteAllLines(command_filename, command_unit); Console.WriteLine(" Created graphics command file '" + command_filename + "'"); }