Exemplo n.º 1
0
        bool ReadFromGRDECL(SpecGrid specGrid, MapAxes mapAxes, string file)
        {
            double[] values = GRDECLReader.Array(file, grdecl_kw_coord);
            if (values.Count() == 0)
            {
                return(false);
            }
            if (values.Count() != 2 * 3 * (specGrid.NX + 1) * (specGrid.NY + 1))
            {
                return(false);
            }
            //Init(specGrid.NX, specGrid.NX, 50f, 50f);
            Pillars = new Pillar[specGrid.NX + 1, specGrid.NY + 1];
            int n = 0;

            for (int j = 0; j < specGrid.NY + 1; ++j)
            {
                for (int i = 0; i < specGrid.NX + 1; ++i)
                {
                    double xt = values[n++];
                    double yt = values[n++];
                    double zt = values[n++];
                    double xb = values[n++];
                    double yb = values[n++];
                    double zb = values[n++];
                    Pillars[i, j] = new Pillar(xt, yt, zt, xb, yb, zb);
                }
            }
            MapAxes = mapAxes;
            return(true);
        }
Exemplo n.º 2
0
 bool ReadFromGRDECL(string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (GRDECLReader.ClearLine(line) == grdecl_kw_specgrid)
                 {
                     line = sr.ReadLine();
                     line = GRDECLReader.ClearLine(line);
                     string[] split = line.Split();
                     NX        = int.Parse(split[0]);
                     NY        = int.Parse(split[1]);
                     NZ        = int.Parse(split[2]);
                     NumRes    = int.Parse(split[3]);
                     CoordType = char.Parse(split[4]);
                     return(true);
                 }
             }
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
     return(false);
 }
Exemplo n.º 3
0
        bool ReadFromGRDECL(SpecGrid specGrid, string file)
        {
            double[] values = GRDECLReader.Array(file, grdecl_kw_actnum);
            if (values.Count() == 0)
            {
                return(false);
            }
            if (values.Count() != specGrid.NX * specGrid.NY * specGrid.NZ)
            {
                return(false);
            }
            Init(specGrid.NX, specGrid.NY, specGrid.NZ);
            int n = 0;

            for (int k = 0; k < specGrid.NZ; ++k)
            {
                for (int j = 0; j < specGrid.NY; ++j)
                {
                    for (int i = 0; i < specGrid.NX; ++i)
                    {
                        Values[i, j, k] = (values[n++] == 0f) ? false : true;
                    }
                }
            }
            return(true);
        }
Exemplo n.º 4
0
        bool ReadGRDECL(int nx, int ny, int nz, string kw, string file)
        {
            Title = kw;
            double[] values = GRDECLReader.Array(file, kw);
            if (values.Count() == 0)
            {
                return(false);
            }
            if (values.Count() != nx * ny * nz)
            {
                return(false);
            }
            Values = new double[nx, ny, nz];
            int n = 0;

            for (int k = 0; k < nz; ++k)
            {
                for (int j = 0; j < ny; ++j)
                {
                    for (int i = 0; i < nx; ++i)
                    {
                        Values[i, j, k] = values[n++];
                    }
                }
            }
            UpdateScale();
            return(true);
        }
Exemplo n.º 5
0
        bool ReadFromGRDECL(SpecGrid specGrid, string file)
        {
            double[] values = GRDECLReader.Array(file, grdecl_kw_zcorn);
            if (values.Count() == 0)
            {
                return(false);
            }
            if (values.Count() != 2 * specGrid.NX * 2 * specGrid.NY * 2 * specGrid.NZ)
            {
                return(false);
            }
            Init(specGrid.NX, specGrid.NY, specGrid.NZ);
            int n      = 0;
            int c_last = 2;
            int jloop  = 1;
            int kloop  = 1;

            for (int k = 0; k < specGrid.NZ; ++k)
            {
                for (int j = 0; j < specGrid.NY; ++j)
                {
                    for (int i = 0; i < specGrid.NX; ++i)
                    {
                        for (int c = c_last - 2; c < c_last; ++c)
                        {
                            Items[i, j, k].Corners[c] = values[n++];
                        }
                    }
                    if (jloop == 1)
                    {
                        jloop   = 2;
                        c_last += 2;
                        --j;
                    }
                    else
                    {
                        jloop   = 1;
                        c_last -= 2;
                    }
                }
                if (kloop == 1)
                {
                    kloop   = 2;
                    c_last += 4;
                    --k;
                }
                else
                {
                    kloop   = 1;
                    c_last -= 4;
                }
            }
            return(true);
        }
Exemplo n.º 6
0
 bool ReadFromGRDECL(string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (GRDECLReader.ClearLine(line) == grdecl_kw_mapaxes)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             const int     valuesNeeded = 6;
             while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null)
             {
                 line = GRDECLReader.ClearLine(line);
                 if (line != string.Empty)
                 {
                     foreach (string word in line.Split())
                     {
                         values.Add(word);
                     }
                 }
             }
             X1 = double.Parse(values[0]);
             Y1 = double.Parse(values[1]);
             X2 = double.Parse(values[2]);
             Y2 = double.Parse(values[3]);
             X3 = double.Parse(values[4]);
             Y3 = double.Parse(values[5]);
             return(true);
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
 }
Exemplo n.º 7
0
 public static double[] Array(string file, string kw)
 {
     try
     {
         List <double> result = new List <double>();
         using (StreamReader sr = new StreamReader(file))
         {
             kw = ClearLine(kw);
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (GRDECLReader.ClearLine(line) == kw)
                 {
                     break;
                 }
             }
             bool stop = false;
             while (!stop && (line = sr.ReadLine()) != null)
             {
                 string[] words = GRDECLReader.ClearWords(line);
                 foreach (string word in words)
                 {
                     if (word == terminator)
                     {
                         stop = true;
                         break;
                     }
                     else
                     {
                         result.Add(double.Parse(word));
                     }
                 }
             }
         }
         return(result.ToArray());
     }
     catch (Exception)
     {
         return(new double[0]);
     }
 }