Exemplo n.º 1
0
        public void AddDefaults()
        {
            Grid1D       x     = new Grid1D((float)0.2, 2);
            Grid1D       y     = new Grid1D((float)0.2, 2);
            V3DataOnGrid data1 = new V3DataOnGrid("", DateTime.Now, x, y);

            data1.InitRandom(0.25, 0.5);

            Grid1D       x1    = new Grid1D((float)0.0, 0);
            Grid1D       y1    = new Grid1D((float)0.0, 0);
            V3DataOnGrid data2 = new V3DataOnGrid("", DateTime.Now, x1, y1);

            V3DataCollection data3 = new V3DataCollection();

            data3.InitRandom(4, (float)0.4, (float)0.4, 1.25, 0.2);

            V3DataCollection data4 = new V3DataCollection();

            v3Datas.Add(data1);
            v3Datas.Add(data2);
            v3Datas.Add(data3);
            v3Datas.Add(data4);
        }
Exemplo n.º 2
0
 public V3DataOnGrid(string constr_information, DateTime constr_time, Grid1D x0, Grid1D y0) : base(constr_information, constr_time)
 {
     x     = x0;
     y     = y0;
     value = new double[x.node, y.node];
 }
Exemplo n.º 3
0
 public V3DataOnGrid(string filename) // в файле все далее перечисленное на отдельной строке: сначала информация (типа string, для базового класса), время (типа string в формате "MM/dd/yyyy hh:mm", для базового класса), шаг по сетке для оси х (тип float), количество узлов по оси х (тип int), шаг по сетке для оси у (тип float), количество узлов на сетке (тип int), далее на каждой строке значения поля (тип float)
 {
     try
     {
         using (StreamReader sr = new StreamReader(filename))
         {
             string constr_information, constr_time_str, x0_step_str, y0_step_str, x0_node_str, y0_node_str, field;
             constr_information = sr.ReadLine();
             constr_time_str    = sr.ReadLine();
             x0_step_str        = sr.ReadLine();
             x0_node_str        = sr.ReadLine();
             y0_step_str        = sr.ReadLine();
             y0_node_str        = sr.ReadLine();
             CultureInfo provider = new CultureInfo("en-US"); // сделала явными региональные настройки
             //CultureInfo provider = CultureInfo.InvariantCulture;
             DateTime constr_time = DateTime.ParseExact(constr_time_str, "MM/dd/yyyy hh:mm", provider);
             float    x0_step     = float.Parse(x0_step_str, provider);
             int      x0_node     = int.Parse(x0_node_str, provider);
             float    y0_step     = float.Parse(y0_step_str, provider);
             int      y0_node     = int.Parse(y0_node_str, provider);
             Grid1D   x0          = new Grid1D(x0_step, x0_node);
             Grid1D   y0          = new Grid1D(y0_step, y0_node);
             base.information = constr_information;
             base.time        = constr_time;
             x     = x0;
             y     = y0;
             value = new double[x.node, y.node];
             for (int i = 0; i < x.node; i++)
             {
                 for (int j = 0; j < y.node; j++)
                 {
                     field       = sr.ReadLine();
                     value[i, j] = float.Parse(field, provider);
                 }
             }
         }
     }
     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 e)
     {
         Console.WriteLine(e.Message);
     }
 }