Beispiel #1
0
        public V5DataOnGrid(string filename)
        {
            /*
             * формат ввода построчно:
             *
             * 1) информация для базового класса
             * 2) дата и время для базового класса
             *    формат dd.mm.yy h:m
             * 3) параметр сетки: кол-во шагов по Х
             * 4) параметр сетки: размер шага по Х
             * 5) параметр сетки: кол-во шагов по У
             * 6) параметр сетки: размер шага по У
             * 7) X*Y строк с данными для векторов э/м поля формата:
             *    величина_по_Х величина_по_У (параметры разделены пробелом)
             */
            StreamReader sr = null;

            try
            {
                sr = new StreamReader(filename);

                Info = sr.ReadLine();

                Time = DateTime.Parse(sr.ReadLine());

                Grid2D grid = new Grid2D
                {
                    NumOfNodesX = int.Parse(sr.ReadLine()),
                    StepX       = float.Parse(sr.ReadLine()),
                    NumOfNodesY = int.Parse(sr.ReadLine()),
                    StepY       = float.Parse(sr.ReadLine()),
                };
                Grid   = grid;
                Vector = new Vector2[Grid.NumOfNodesX, Grid.NumOfNodesY];

                for (int i = 0; i < Grid.NumOfNodesX; i++)
                {
                    for (int j = 0; j < Grid.NumOfNodesY; j++)
                    {
                        string[] data = sr.ReadLine().Split(' ');

                        Vector[i, j] = new Vector2(
                            (float)Convert.ToDouble(data[0]),
                            (float)Convert.ToDouble(data[1]));
                    }
                }
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Filename is empty string");
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File is not found");
            }
            catch (DirectoryNotFoundException)
            {
                Console.WriteLine("Directory is not found");
            }
            catch (IOException)
            {
                Console.WriteLine("Unacceptable filename");
            }
            catch (FormatException)
            {
                Console.WriteLine("String could not be parsed");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Dispose();
                }
            }
        }
Beispiel #2
0
 public V4DataOnGrid(string id, double w, Grid2D gr) : base(id, w)
 {
     grid  = gr;
     array = new Complex[grid.num_x, grid.num_y];
 }
Beispiel #3
0
 public V5DataOnGrid(string x1, DateTime x2, Grid2D grid) : base(x1, x2)
 {
     Grid   = grid;
     Vector = new Vector2[Grid.NumOfNodesX, Grid.NumOfNodesY];
 }