Ejemplo n.º 1
0
        public static Grid Read(BinaryReader reader)
        {
            byte version = reader.ReadByte();

            switch (version)
            {
            case Version0:
            {
                string      title = reader.ReadString();
                SpecGrid    sg    = SpecGrid.Read(reader);
                Coord       c     = Coord.Read(reader);
                Zcorn       z     = Zcorn.Read(reader);
                Actnum      a     = Actnum.Read(reader);
                int         np    = reader.ReadInt32();
                List <Prop> ps    = new List <Prop>();
                for (int p = 0; p < np; ++p)
                {
                    ps.Add(Prop.Read(reader));
                }
                int            nw = reader.ReadInt32();
                List <Compdat> ws = new List <Compdat>();
                for (int w = 0; w < nw; ++w)
                {
                    ws.Add(Compdat.Read(reader));
                }
                return(new Grid(title, sg, c, z, a, ps, ws));
            }

            default:
                return(new Grid());
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
0
 void Clear()
 {
     SpecGrid = new SpecGrid();
     //MapAxes = new MapAxes();
     Coord  = new Coord();
     Zcorn  = new Zcorn();
     Actnum = new Actnum();
     Props  = new List <Prop>();
     Title  = "Grid_" + (Namber++).ToString();
     Wells  = new List <Compdat>();
 }
Ejemplo n.º 5
0
 void Init(string title, SpecGrid sg, Coord c, Zcorn z, Actnum a, List <Prop> ps, List <Compdat> ws)
 {
     Clear();
     Title    = title;
     SpecGrid = sg;
     Coord    = c;
     Zcorn    = z;
     Actnum   = a;
     Props    = ps;
     Wells    = ws;
 }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
0
 bool ReadFromCMG(SpecGrid specGrid, string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             Pillars = new Pillar[specGrid.NX + 1, specGrid.NY + 1];
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (CMGReader.ClearLine(line) == cmg_kw_coord)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             int           valuesNeeded = 6 * (specGrid.NX + 1);
             int           n            = 0;
             for (int j = 0; j < specGrid.NY + 1; ++j)
             {
                 while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null)// add
                 {
                     line = CMGReader.ClearLine(line);
                     if (line != string.Empty)
                     {
                         foreach (string word in line.Split())
                         {
                             values.Add(word);
                         }
                     }
                 }
                 for (int i = 0; i < specGrid.NX + 1; ++i)
                 {
                     double xt = double.Parse(values[n++]);
                     double yt = double.Parse(values[n++]);
                     double zt = double.Parse(values[n++]);
                     double xb = double.Parse(values[n++]);
                     double yb = double.Parse(values[n++]);
                     double zb = double.Parse(values[n++]);
                     Pillars[i, j] = new Pillar(xt, yt, zt, xb, yb, zb);
                 }
                 values.RemoveRange(0, valuesNeeded); // remove
                 n = 0;
             }
             return(true);
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
 }
Ejemplo n.º 8
0
 bool ReadFromCMG(SpecGrid specGrid, string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             Values = new bool[specGrid.NX, specGrid.NY, specGrid.NZ];
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (CMGReader.ClearLine(line) == cmg_kw_actnum)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             int           valuesNeeded = specGrid.NX;
             int           n            = 0;
             for (int k = 0; k < specGrid.NZ; ++k)
             {
                 for (int j = 0; j < specGrid.NY; ++j)
                 {
                     while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null)
                     {
                         line = CMGReader.ClearLine(line);
                         if (line != string.Empty)
                         {
                             foreach (string word in line.Split())
                             {
                                 values.Add(word);
                             }
                         }
                     }
                     for (int i = 0; i < specGrid.NX; ++i)
                     {
                         int value = int.Parse(values[n++]);
                         Values[i, j, k] = (value == 0) ? false : true;
                     }
                     values.RemoveRange(0, valuesNeeded);
                     n = 0;
                 }
             }
             return(true);
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
 }
Ejemplo n.º 9
0
        public bool Read(SpecGrid specGrid, MapAxes mapAxes, string file, FileType type)
        {
            switch (type)
            {
            case FileType.CMG_ASCII:
                return(ReadFromCMG(specGrid, file));

            case FileType.GRDECL_ASCII:
                return(ReadFromGRDECL(specGrid, mapAxes, file));

            default:
                return(false);
            }
        }
Ejemplo n.º 10
0
        public bool Read(string file, FileType type)
        {
            SpecGrid = new SpecGrid(file, type);
            MapAxes ma = new MapAxes(file, type);

            Coord  = new Coord(SpecGrid, ma, file, type);
            Zcorn  = new Zcorn(SpecGrid, file, type);
            Actnum = new Actnum(SpecGrid, file, type);
            if (Specified())
            {
                return(true);
            }
            Clear();
            return(false);
        }
Ejemplo n.º 11
0
 public void Write(BinaryWriter writer)
 {
     writer.Write(Version0);
     writer.Write(Title);
     SpecGrid.Write(writer);
     Coord.Write(writer);
     Zcorn.Write(writer);
     Actnum.Write(writer);
     writer.Write(Props.Count);
     foreach (Prop p in Props)
     {
         p.Write(writer);
     }
     writer.Write(Wells.Count);
     foreach (Compdat well in Wells)
     {
         well.Write(writer);
     }
 }
Ejemplo n.º 12
0
 public Zcorn(SpecGrid specGrid, string file, FileType type)
 {
     Init();
     Read(specGrid, file, type);
 }
Ejemplo n.º 13
0
 public Coord(SpecGrid specGrid, MapAxes mapAxes, string file, FileType type)
 {
     Init();
     Read(specGrid, mapAxes, file, type);
 }
Ejemplo n.º 14
0
 public Actnum(SpecGrid specGrid, string file, FileType type)
 {
     Init();
     Read(specGrid, file, type);
 }
Ejemplo n.º 15
0
 public Grid(string title, SpecGrid sg, Coord c, Zcorn z, Actnum a, List <Prop> ps, List <Compdat> ws)
 {
     Init(title, sg, c, z, a, ps, ws);
 }
Ejemplo n.º 16
0
 bool ReadFromCMG(SpecGrid specGrid, string file)
 {
     try
     {
         using (StreamReader sr = new StreamReader(file))
         {
             Items = new ZcornItem[specGrid.NX, specGrid.NY, specGrid.NZ];
             string line;
             while ((line = sr.ReadLine()) != null)
             {
                 if (CMGReader.ClearLine(line) == cmg_kw_zcorn)
                 {
                     break;
                 }
             }
             List <string> values       = new List <string>();
             int           valuesNeeded = 2 * specGrid.NX;
             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)
                 {
                     while (values.Count < valuesNeeded && (line = sr.ReadLine()) != null) // add
                     {
                         line = CMGReader.ClearLine(line);
                         if (line != string.Empty)
                         {
                             foreach (string word in line.Split())
                             {
                                 values.Add(word);
                             }
                         }
                     }
                     for (int i = 0; i < specGrid.NX; ++i)
                     {
                         for (int c = c_last - 2; c < c_last; ++c)
                         {
                             Items[i, j, k].Corners[c] = double.Parse(values[n++]);
                         }
                     }
                     values.RemoveRange(0, valuesNeeded); // remove
                     n = 0;
                     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);
         }
     }
     catch (Exception)
     {
         Init();
         return(false);
     }
 }
Ejemplo n.º 17
0
        /*
         * public Cell GlobalCell(int i, int j, int k)
         * {
         *  //float[,] matrix = MapAxes.Matrix();
         *  Cell cell = new Cell();
         *  cell.Act = Actnum.Values[i, j, k];
         *  cell.Corners[0] = Coord.GlobalPillar(i + 0, j + 0).Point3D(Zcorn.Items[i, j, k].Corners[0]);
         *  cell.Corners[1] = Coord.GlobalPillar(i + 1, j + 0).Point3D(Zcorn.Items[i, j, k].Corners[1]);
         *  cell.Corners[2] = Coord.GlobalPillar(i + 0, j + 1).Point3D(Zcorn.Items[i, j, k].Corners[2]);
         *  cell.Corners[3] = Coord.GlobalPillar(i + 1, j + 1).Point3D(Zcorn.Items[i, j, k].Corners[3]);
         *  cell.Corners[4] = Coord.GlobalPillar(i + 0, j + 0).Point3D(Zcorn.Items[i, j, k].Corners[4]);
         *  cell.Corners[5] = Coord.GlobalPillar(i + 1, j + 0).Point3D(Zcorn.Items[i, j, k].Corners[5]);
         *  cell.Corners[6] = Coord.GlobalPillar(i + 0, j + 1).Point3D(Zcorn.Items[i, j, k].Corners[6]);
         *  cell.Corners[7] = Coord.GlobalPillar(i + 1, j + 1).Point3D(Zcorn.Items[i, j, k].Corners[7]);
         *  return cell;
         * }
         */



        public bool Specified()
        {
            return(SpecGrid.Specified() && Coord.Specified() && Zcorn.Specified() && Actnum.Specified());
        }