Esempio n. 1
0
        /// <summary>
        /// Loads the mesh
        /// </summary>
        private void Load()
        {
            //now read input file
            using (ReaderUtilities sr = new ReaderUtilities(FileName))
            {
                while (!sr.EndOfStream)
                {
                    string line = sr.ReadLine();

                    if (line.StartsWith("ROCKS"))
                    {
                        Rocks = new Rocks();
                        Rocks.ReadFromStream(sr);

                        foreach (Element e in Elements)
                        {
                            e.rock = Rocks[e.Material - 1];
                        }
                    }
                    else if (line.StartsWith("INCON"))
                    {
                        while ((line = sr.ReadLine().TrimEnd()) != String.Empty)
                        {
                            if (line.StartsWith("+++"))
                            {
                                break;
                            }

                            string elname = line.Substring(0, 5);

                            if (Elements.Contains(elname))
                            {
                                Elements[elname].Porosity = ReaderUtilities.SplitIntoDoubles(line, 15, 15)[0];

                                if (line.Length > 31)
                                {
                                    Elements[elname].PrimaryVariablesIndex = int.Parse(line.Substring(31, 1));
                                }

                                Elements[elname].PrimaryVaribles = ReaderUtilities.SplitIntoDoubles(sr.ReadLine(), 0, 20);
                            }
                        }
                    }
                    else if (line.StartsWith("PARAM"))
                    {
                        sr.ReadLine();
                        sr.ReadLine();
                        sr.ReadLine();
                        sr.ReadLine();
                        line = sr.ReadLine();
                        var arr = ReaderUtilities.SplitIntoDoubles(line, 0, 20);

                        foreach (var el in Elements)
                        {
                            if (el.PrimaryVaribles == null)
                            {
                                el.PrimaryVaribles = arr.ToArray();
                            }
                        }
                    }
                    else if (line.StartsWith("TSXCD"))
                    {
                        var arr  = sr.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                        var ints = arr.Select(var => int.Parse(var));

                        foreach (var i in ints.Skip(1))
                        {
                            if (i <= Elements.Count)
                            {
                                detailedTimeSeries.Add(Elements[i - 1]);
                            }
                        }
                    }
                    else if (line.StartsWith("GENER"))
                    {
                        Wells = new Gener();
                        Wells.ReadFromStream(sr);
                    }
                }
                FileContent = sr.FileContent.ToString();
            }
            NotifyPropertyChanged("FileContent");
            NotifyPropertyChanged("DetailedTimeSeries");
        }
Esempio n. 2
0
    /// <summary>
    /// Loads the mesh
    /// </summary>
    private void Load()
    {
      //now read input file
      using (ReaderUtilities sr = new ReaderUtilities(FileName))
      {
        while (!sr.EndOfStream)
        {
          string line = sr.ReadLine();

          if (line.StartsWith("ROCKS"))
          {
            Rocks = new Rocks();
            Rocks.ReadFromStream(sr);

            foreach (Element e in Elements)
            {
              e.rock = Rocks[e.Material-1];
            }
          }
          else if (line.StartsWith("INCON"))
          {
            while ((line = sr.ReadLine().TrimEnd()) != String.Empty)
            {
              if (line.StartsWith("+++"))
                break;

              string elname = line.Substring(0,5);
              
              if (Elements.Contains(elname))
              {
                Elements[elname].Porosity = ReaderUtilities.SplitIntoDoubles(line, 15, 15)[0];

                if (line.Length > 31)
                  Elements[elname].PrimaryVariablesIndex = int.Parse(line.Substring(31, 1));

                Elements[elname].PrimaryVaribles = ReaderUtilities.SplitIntoDoubles(sr.ReadLine(), 0, 20);
              }
            }
          }
          else if (line.StartsWith("PARAM"))
          {
            sr.ReadLine();
            sr.ReadLine();
            sr.ReadLine();
            sr.ReadLine();
            line = sr.ReadLine();
            var arr = ReaderUtilities.SplitIntoDoubles(line, 0, 20);

            foreach (var el in Elements)
            {
              if (el.PrimaryVaribles == null)
                el.PrimaryVaribles = arr.ToArray();
            }
          }
          else if (line.StartsWith("TSXCD"))
          {
            var arr = sr.ReadLine().Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
            var ints = arr.Select(var => int.Parse(var));

            foreach (var i in ints.Skip(1))
            {
              if (i<=Elements.Count)
                detailedTimeSeries.Add(Elements[i - 1]);
            }
          }
          else if (line.StartsWith("GENER"))
          {
            Wells = new Gener();
            Wells.ReadFromStream(sr);
          }
        }
        FileContent = sr.FileContent.ToString();
      }
      NotifyPropertyChanged("FileContent");
      NotifyPropertyChanged("DetailedTimeSeries");
    }