예제 #1
0
        public static GreensFunction readGreensfunction(string path)
        {
            FileStream sourceFileStream = File.OpenRead(path);

            System.IO.Compression.GZipStream decompressingStream = new System.IO.Compression.GZipStream(sourceFileStream, System.IO.Compression.CompressionMode.Decompress);

            GreensFunction tmpgf = new GreensFunction();

            using (var re = new StreamReader(decompressingStream))
            {
                tmpgf.grname = re.ReadLine().Trim(); //Header

                string str = null;
                while ((str = re.ReadLine()) != null)
                {
                    // BlockHeader
                    int    ngreen = Convert.ToInt32(str.Substring(0, 1));
                    int    num    = Convert.ToInt32(str.Substring(1, 3));
                    int    ntot   = Convert.ToInt32(str.Substring(4, 4));
                    int    ngr    = Convert.ToInt32(str.Substring(8, 4));
                    double beg    = Convert.ToDouble(str.Substring(12, 10), Constants.NumberFormatEN);
                    double end    = Convert.ToDouble(str.Substring(22, 10), Constants.NumberFormatEN);
                    double spc    = Convert.ToDouble(str.Substring(32, 10), Constants.NumberFormatEN);
                    GreensFunction.FinGrd fingrd = (GreensFunction.FinGrd)Enum.Parse(typeof(GreensFunction.FinGrd), str.Substring(42, 6).Trim()[0].ToString());

                    double[,] grfn = new double[ngr, ngreen];

                    for (int i = 0; i < ngr; i++)
                    {
                        str = re.ReadLine();
                        for (int j = 0; j < ngreen; j++)
                        {
                            double v = double.Parse(str.Substring(j * 13, 13).Trim(), Constants.NumberFormatEN);
                            grfn[i, j] = v;
                        }
                    }
                    tmpgf.AddElementEntry(new GreensFunction.GFelememt(ngreen, num, ntot, ngr, beg, end, spc, fingrd, grfn));
                }
            }
            return(tmpgf);
        }
예제 #2
0
        public static GreensFunction readGreensfunction(string model)
        {
            GreensFunction tmpgf = new GreensFunction();

            FileStream   fs = new FileStream(model, FileMode.Open);
            StreamReader re = new StreamReader(fs);

            string grname = re.ReadLine().Trim(); //Header

            string str = null;

            while ((str = re.ReadLine()) != null)
            {
                // BlockHeader
                int    ngreen = Convert.ToInt32(str.Substring(0, 1));
                int    num    = Convert.ToInt32(str.Substring(1, 3));
                int    ntot   = Convert.ToInt32(str.Substring(4, 4));
                int    ngr    = Convert.ToInt32(str.Substring(8, 4));
                double beg    = Convert.ToDouble(str.Substring(12, 10), Utilities.Utility.NumberFormatEN);
                double end    = Convert.ToDouble(str.Substring(22, 10), Utilities.Utility.NumberFormatEN);
                double spc    = Convert.ToDouble(str.Substring(32, 10), Utilities.Utility.NumberFormatEN);
                string fingrd = str.Substring(42, 6).Trim();

                double[,] grfn = new double[ngr, ngreen];

                for (int i = 0; i < ngr; i++)
                {
                    str = re.ReadLine();
                    for (int j = 0; j < ngreen; j++)
                    {
                        double v = double.Parse(str.Substring(j * 13, 13).Trim(), Utilities.Utility.NumberFormatEN);
                        grfn[i, j] = v;
                    }
                }
                tmpgf.AddElementEntry(new GreensFunction.GFelememt(ngreen, num, ntot, ngr, beg, end, spc, fingrd, grfn));
            }
            re.Close();

            return(tmpgf);
        }