コード例 #1
0
        public void GetGridInfo(MFGrid grid)
        {
            if (File.Exists(FileName))
            {
                StreamReader sr   = new StreamReader(FileName);
                string       line = "";

                while (!sr.EndOfStream)
                {
                    line = sr.ReadLine().ToLower().Trim();
                    if (!line.StartsWith("#"))
                    {
                        break;
                    }
                }

                // 5 150 172 10 4 2 # NLAY, NROW, NCOL, NPER, ITMUNI, LENUNI
                int[] strs = TypeConverterEx.Split <int>(line, 6);
                grid.ActualLayerCount = strs[0];
                grid.RowCount         = strs[1];
                grid.ColumnCount      = strs[2];

                sr.Close();
            }
        }
コード例 #2
0
ファイル: Modflow.cs プロジェクト: zhaowilliam/Visual-HEIFLOW
        public void Extract(string mfn_file, string fs_file, int lurow, int lucol, int rlrow, int rlcol)
        {
            IFeatureSet fs = FeatureSet.Open(fs_file);
            Modflow     mf = new Modflow();

            mf.TimeUnit   = this.TimeUnit;
            mf.LengthUnit = this.LengthUnit;

            MFGrid rawgrid = this.Grid as MFGrid;

            mf.Grid = rawgrid.Extract(fs, lurow, lucol, rlrow, rlcol);
            FileInfo finfo = new FileInfo(mfn_file);
            string   mfn   = Path.GetFileNameWithoutExtension(mfn_file);

            foreach (var pckname in this.Packages.Keys)
            {
                var pck = this.Packages[pckname] as IExtractMFPackage;
                if (pck != null)
                {
                    var newpck = pck.Extract(mf);
                    if (newpck != null)
                    {
                        newpck.FileName = Path.Combine(finfo.DirectoryName, mfn + newpck.PackageInfo.FileExtension);
                        mf.AddInSilence(newpck);
                    }
                }
            }

            foreach (var pck in mf.Packages.Values)
            {
                pck.Save(null);
            }

            _MFNameManager.Save(ControlFileName);
        }
コード例 #3
0
        public override IPackage Extract(Modflow newmf)
        {
            BASPackage bas = new BASPackage();

            bas.HNOFLO = this.HNOFLO;
            bas.Owner  = newmf;
            MFGrid newgrid = newmf.Grid as MFGrid;
            MFGrid rawgrid = Owner.Grid as MFGrid;

            bas.STRT = new DataCube <float>(newgrid.ActualLayerCount, 1, newgrid.ActiveCellCount);
            for (int l = 0; l < newgrid.ActualLayerCount; l++)
            {
                // bas.STRT[l, MyMath.full] = rawgrid.GetSubSerialArray(this.STRT, newgrid, l).Value;
            }
            return(bas);
        }
コード例 #4
0
ファイル: Modflow.cs プロジェクト: zhaowilliam/Visual-HEIFLOW
        public Modflow()
        {
            Name = "Modflow";
            PackageFileNameProvider = new MFPackFileNameProvider(this);
            this.Icon        = Resources.mf16;
            this.TimeService = new TimeService("Subsurface Timeline")
            {
                UseStressPeriods = true
            };
            _MFGrid            = new MFGrid();
            Grid               = _MFGrid;
            _LayerGroupManager = new LayerGroupManager();
            _MFNameManager     = new MFNameManager();
            _IsDirty           = false;

            TimeUnit    = 4;
            LengthUnit  = 2;
            Description = "the U.S. Geological Survey modular finite-difference flow model, which is a computer code that solves the groundwater flow equation.";
        }
コード例 #5
0
        public override IPackage Extract(Modflow newmf)
        {
            LPFPackage lpf = new LPFPackage();

            lpf.Owner  = newmf;
            lpf.ILPFCB = this.ILPFCB;
            lpf.HDRY   = this.HDRY;
            lpf.NPLPF  = this.NPLPF;
            lpf.IPHDRY = this.IPHDRY;
            lpf.LAYTYP = this.LAYTYP;
            lpf.LAYAVG = this.LAYAVG;
            lpf.CHANI  = this.CHANI;
            lpf.LAYVKA = this.LAYVKA;
            lpf.LAYWET = this.LAYWET;
            lpf.WETFCT = this.WETFCT;
            lpf.IWETIT = this.IWETIT;
            lpf.IHDWET = this.IHDWET;

            MFGrid newgrid = newmf.Grid as MFGrid;
            MFGrid rawgrid = Owner.Grid as MFGrid;

            lpf.HK     = new DataCube <float>(newgrid.ActualLayerCount, 1, newgrid.ActiveCellCount);
            lpf.HANI   = new DataCube <float>(newgrid.ActualLayerCount, 1, newgrid.ActiveCellCount);
            lpf.VKA    = new DataCube <float>(newgrid.ActualLayerCount, 1, newgrid.ActiveCellCount);
            lpf.SS     = new DataCube <float>(newgrid.ActualLayerCount, 1, newgrid.ActiveCellCount);
            lpf.SY     = new DataCube <float>(newgrid.ActualLayerCount, 1, newgrid.ActiveCellCount);
            lpf.WETDRY = new DataCube <float>(newgrid.ActualLayerCount, 1, newgrid.ActiveCellCount);
            for (int l = 0; l < newgrid.ActualLayerCount; l++)
            {
                //lpf.HK[l, 0] = rawgrid.GetSubSerialArray<float>(this.HK, newgrid, l).Value;
                //lpf.HANI[l, 0] = rawgrid.GetSubSerialArray<float>(this.HANI, newgrid, l).Value;
                //lpf.VKA[l, 0] = rawgrid.GetSubSerialArray<float>(this.VKA, newgrid, l).Value;
                //lpf.SS[l, 0] = rawgrid.GetSubSerialArray<float>(this.SS, newgrid, l).Value;
                //if (lpf.LAYTYP[l] != 0)
                //    lpf.SY[l, 0] = rawgrid.GetSubSerialArray<float>(this.SY, newgrid, l).Value;
                //if (LAYTYP[l] != 0 && LAYWET[l] != 0)
                //    lpf.WETDRY[l, 0] = rawgrid.GetSubSerialArray<float>(this.WETDRY, newgrid, l).Value;
            }

            return(lpf);
        }
コード例 #6
0
 public MFFlowField(MFGrid grid)
 {
     mfgrid = grid;
 }
コード例 #7
0
ファイル: MFGrid.cs プロジェクト: zhaowilliam/Visual-HEIFLOW
        /// <summary>
        /// Extract a sub grid from exsiting grid. All the index starts from 0
        /// </summary>
        /// <param name="lurow"></param>
        /// <param name="lucol"></param>
        /// <param name="rlrow"></param>
        /// <param name="rlcol"></param>
        /// <returns></returns>
        public IRegularGrid Extract(IFeatureSet fs, int lurow, int lucol, int rlrow, int rlcol)
        {
            MFGrid newgrid = new MFGrid();
            int    nrow    = rlrow - lurow + 1;
            int    ncol    = rlcol - lucol + 1;

            newgrid.ActualLayerCount = this.ActualLayerCount;
            newgrid.IBound           = new DataCube <float>(this.ActualLayerCount, nrow, ncol);
            newgrid.RowCount         = nrow;
            newgrid.ColumnCount      = ncol;
            newgrid.BBox             = this.BBox;
            newgrid.DELR             = this.DELR;
            newgrid.DELC             = this.DELC;

            var dt   = fs.DataTable.AsEnumerable();
            var nact = (from dr in dt where dr.Field <Int16>("Extraction") != 0 select dr).Count();

            newgrid.ActiveCellCount = nact;
            _ExtractedCellIndex     = new int[newgrid.ActiveCellCount];


            int index = 0;

            for (int l = 0; l < this.ActualLayerCount; l++)
            {
                foreach (var dr in dt)
                {
                    int r        = (int)dr.Field <Int64>("ROW") - 1;
                    int c        = (int)dr.Field <Int64>("COLUMN") - 1;
                    var isactive = dr.Field <Int16>("Extraction");

                    if (isactive != 0)
                    {
                        newgrid.IBound[l, r - lurow, c - lucol] = isactive;
                    }
                }
            }

            index = 0;
            for (int r = 0; r < nrow; r++)
            {
                for (int c = 0; c < ncol; c++)
                {
                    if (newgrid.IBound[0, r, c] != 0)
                    {
                        _ExtractedCellIndex[index] = this.Topology.GetIndex(r + lurow, c + lucol);
                        index++;
                    }
                }
            }

            // newgrid.Elevations = MyMath.zeros<float>(this.LayerCount, newgrid.ActiveCellCount);
            newgrid.Elevations = new DataCube <float>(this.LayerCount, 1, newgrid.ActiveCellCount);

            for (int l = 0; l < this.LayerCount; l++)
            {
                //var mat = GetSubSerialArray<float>(this.Elevations, newgrid, l);
                //newgrid.Elevations[l, 0] = mat.Value;
            }

            return(newgrid);
        }