Пример #1
0
        static void Main(string[] args)
        {
            if (args.Length < 6)
            {
                PrintUsage();
                Pause();
                return;
            }

            string output;
            double xs, ys, h;
            int    xd, yd;

            try
            {
                output = args[0];
                xs     = double.Parse(args[1]);
                ys     = double.Parse(args[2]);
                h      = double.Parse(args[3]);
                xd     = int.Parse(args[4]);
                yd     = int.Parse(args[5]);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while parsing arguments: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Stack trace:");
                Console.WriteLine(e.StackTrace);
                Console.Write("Passed arguments: ");
                foreach (var arg in args)
                {
                    Console.Write($"{arg} ");
                }
                Console.WriteLine();
                PrintUsage();
                Pause();
                return;
            }

            Console.WriteLine($"Generating grid {xd} by {yd} starting from ({xs}; {ys}) with cell size {h} ...");
            GridData res = GridData.AllocateNew(new GridSize(xd, yd));

            for (int xi = 0; xi < xd; xi++)
            {
                for (int yi = 0; yi < yd; yi++)
                {
                    double x = xs + xi * h;
                    double y = ys + yi * h;

                    res[xi, yi] = Function(x, y);
                }
            }

            Console.WriteLine($"Writing result to {output} ...");

            CsvUtil.ExportToFile(res, output);

            Console.WriteLine("Done.");
            Pause();
        }
Пример #2
0
        protected override GridData Simulate(IEnumerable <GridIndex> mask)
        {
            var maskList = mask.ToList();

            if (maskList.Count == 0)
            {
                maskList.AddRange(m_EdgeData.Inaccessable.EnumerateRegion());
            }

            GridData res = GridData.AllocateNew(m_EdgeData.Size);

            int totalCells = maskList.Count;
            int doneCells  = 0;

            maskList.ForEach(
                p =>
            {
                res[p.I, p.J] = CalcCell(p);

                doneCells++;
                ReportProgress((int)((double)doneCells / totalCells * 100));
            });


            return(res);
        }
Пример #3
0
 public PrSimulator(SimulationOptions options)
 {
     Size                  = options.Size;
     StartLocation         = options.StartLocation;
     m_Data                = GridData.AllocateNew(Size);
     m_Data[StartLocation] = 1;
     Step                  = 0;
     TotalSimTime          = 0;
     SimulationInfo        = new PrSimulationInfo(Step, TotalSimTime, 1, 0, 1);
 }