示例#1
0
        public void ReadFromStream(StreamReader Input)
        {
            string sr = "";

            while ((sr = Input.ReadLine().TrimEnd()) != string.Empty)
            {
                Rock rock = new Rock();
                rock.Name = sr.Substring(0, 5);
                int ReadMore = int.Parse(sr.Substring(5, 5));
                rock.Density             = Double.Parse(sr.Substring(10, 10));
                rock.Porosity            = Double.Parse(sr.Substring(20, 10));
                rock.PermX               = Double.Parse(sr.Substring(30, 10));
                rock.PermY               = Double.Parse(sr.Substring(40, 10));
                rock.PermZ               = Double.Parse(sr.Substring(50, 10));
                rock.WetHeatConductivity = Double.Parse(sr.Substring(60, 10));
                rock.HeatCapacity        = Double.Parse(sr.Substring(70, 10));

                sr = Input.ReadLine();
                rock.Compressibility = Double.Parse(sr.Substring(0, 10));

                if (ReadMore >= 1)
                {
                    sr = Input.ReadLine().TrimEnd();
                    rock.RelativePermeabilityModel     = int.Parse(sr.Substring(0, 5));
                    rock.RelativePermebilityParameters = ReaderUtilities.SplitIntoDoubles(sr, 10, 10);
                }
                if (ReadMore >= 2)
                {
                    sr = Input.ReadLine().TrimEnd();
                    rock.CapillaryPressureModel      = int.Parse(sr.Substring(0, 5));
                    rock.CapillaryPressureParameters = ReaderUtilities.SplitIntoDoubles(sr, 10, 10);
                }

                this.Add(rock);
            }
        }
示例#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");
        }