/// <summary> 获取当前时间前的所有完井信息 包含最后一个时间的井类型 </summary>
        public List <WellLocation> GetAllLocationOfBeforeTime(string casePath, string caseName, DateTime time = default(DateTime))
        {
            string  schFile = Path.Combine(casePath, caseName + "_SCH.DAT");
            INCLUDE sch     = FileFactoryService.Instance.ThreadLoadFromFile(schFile, SimKeyType.SimON);

            return(SimONDataService.Instance.GetAllLocationOfBeforeTime(sch, time));
        }
        ///// <summary> 从文件读取生产信息 </summary>
        //public INCLUDE RefreshRestartWellLocation(RestartInfoModelSimON restart)
        //{
        //    //  创建关键字
        //    if (restart.WellPath != null && File.Exists(restart.WellPath))
        //    {
        //        INCLUDE include = FileFactoryService.Instance.ThreadLoadFromFile(restart.WellPath, SimKeyType.SimON);
        //        return include;
        //    }
        //    else
        //    {
        //        return restart.Well.Find<INCLUDE>();
        //    }
        //}

        /// <summary> 从文件读取生产信息 </summary>
        public INCLUDE RefreshRestartWellLocation(string wellPath)
        {
            if (string.IsNullOrEmpty(wellPath))
            {
                return(null);
            }
            string oldName = Path.GetFileNameWithoutExtension(wellPath) + (KeyConfiger.oldWellLocationName) + KeyConfiger.SimONExtend;

            string oldFullPath = Path.Combine(Path.GetDirectoryName(wellPath), oldName);


            // HTodo  :兼容老版本 3106_WellLocation.dat 完井格式
            if (File.Exists(oldFullPath) && !File.Exists(wellPath))
            {
                wellPath = oldFullPath;
            }

            //  创建关键字
            if (wellPath != null && (File.Exists(wellPath)))
            {
                INCLUDE include = FileFactoryService.Instance.ThreadLoadFromFile(wellPath, SimKeyType.SimON);
                return(include);
            }
            else
            {
                return(null);
            }
        }
        /// <summary> 由WELL文件生成内存数据 </summary>
        public WELL InitRestartWell(string wellPath, RestartInfoModelSimON model)
        {
            //  创建关键字
            WELL   well   = new WELL("WELL");
            USE_TF use_tf = new USE_TF("USE_TF");

            well.Add(use_tf);
            INCLUDE include = new INCLUDE("INCLUDE");

            include.FileName = model.FileName + "_WELL.DAT";
            include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName;;
            //model.WellPath = include.FilePath;
            well.Add(include);

            INCLUDE lastInclude = this.RefreshRestartWellLocation(wellPath);

            if (lastInclude == null)
            {
                return(well);
            }
            // Todo :将母案例中的Include信息复制到新案例中
            include.ExChangeData(lastInclude);


            return(well);
        }
Example #4
0
        /// <summary> 初始化类(树形结构) </summary>
        protected override void InitializeComponent()
        {
            INCLUDE inclue = new INCLUDE("INCLUDE");

            inclue.BaseFile = this;

            include = FileFactoryService.Instance.ThreadLoadFromFile(inclue, FilePath);

            this.Key.Add(include);
        }
Example #5
0
        /// <summary> 从文件读取生产信息 </summary>
        public SCHEDULE RefreshRestartSchdule(RestartInfoModel restart)
        {
            //  创建关键字
            SCHEDULE schedule = new SCHEDULE("SCHEDULE");

            if (restart.SchPath != null && File.Exists(restart.SchPath))
            {
                INCLUDE include = FileFactoryService.Instance.ThreadLoadFromFile(restart.SchPath);
                schedule.Add(include);
            }
            else
            {
                return(restart.Schedule);
            }

            return(schedule);
        }
        /// <summary> 通过模型创建初始化文件 </summary>
        public SOLUTION InitRestartSolution(string parentFileName, RestartInfoModelSimON mode, DateTime time, int index)
        {
            SOLUTION solution = new SOLUTION("SOLUTION");
            INCLUDE include = new INCLUDE("INCLUDE");
            include.FileName = mode.FileName + "_INIT.DAT";
            include.FilePath = mode.FilePath + "\\" + include.FileName;
            solution.Add(include);

            RegisterKeys.SimON.RESTART r = new RegisterKeys.SimON.RESTART("RESTART");
            r.Filename = parentFileName;
            r.StepCount = index.ToString();

            include.Add(r);

            mode.InitPath = include.FilePath;

            return solution;
        }
        /// <summary> 通关生产数据创建生产数据 </summary>
        public SCHEDULE InitRestartSchdule(SCHEDULE sch, RestartInfoModelSimON model, string name, DateTime time)
        {
            //  创建关键字
            SCHEDULE schedule = new SCHEDULE("SCHEDULE");
            INCLUDE  include  = new INCLUDE("INCLUDE");

            include.FileName = name + "_SCH.DAT";
            include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName;
            model.SchPath    = include.FilePath;
            schedule.Add(include);

            //int findIndex = ds.FindIndex(l => (l.Date.Date - time.Date).TotalDays == 0);

            //if (findIndex == -1)
            //{
            //    throw new Exception("SimalorManager.InitRestartSchdule:没有对应日期的时间步:" + time.ToShortDateString());
            //}

            sch.DeleteAll <TIME>(l => l.Date.Date < time.Date);


            List <VFPINJ> Vins = sch.FindAll <VFPINJ>();

            List <VFPPROD> Vpns = sch.FindAll <VFPPROD>();

            //ds.RemoveRange(0, findIndex);

            if (Vins.Count > 0)
            {
                include.AddRange(Vins);
            }

            if (Vpns.Count > 0)
            {
                include.AddRange(Vpns);
            }

            //  处理井数据
            List <TIME> ds = sch.FindAll <TIME>();

            include.AddRange(ds);

            return(schedule);
        }
Example #8
0
        /// <summary> 通过模型创建初始化文件 </summary>
        public SOLUTION InitRestartSolution(RestartInfoModel parent, RestartInfoModel mode, string name, DateTime time, int index)
        {
            SOLUTION solution = new SOLUTION("SOLUTION");
            INCLUDE  include  = new INCLUDE("INCLUDE");

            include.FileName = name + "_init.inc";
            include.FilePath = parent.FilePath + "\\" + include.FileName;
            solution.Add(include);

            RESTART restart = new RESTART("RESTART");

            RESTART.Item item = new RESTART.Item();
            item.fwjm0 = parent.FileName;
            item.cqss1 = (index).ToString();
            restart.Items.Add(item);
            include.Add(restart);

            mode.InitPath = include.FilePath;

            return(solution);
        }
Example #9
0
        /// <summary> 格式化关键字格式 </summary>
        public virtual void Standardized()
        {
            //  构建INCLUDE
            string filename = this.BaseFile.FileName.GetFileNameWithoutExtension();

            INCLUDE include = new INCLUDE("INCLUDE");

            string tempExtend = this.Name.Substring(0, 3);

            include.FileName = string.Format("{0}_{1}.INC", filename, tempExtend);

            include.BaseFile = this.BaseFile;

            //  将所有关键字合并到一个INCLUDE中
            List <BaseKey> allKeys = IncludeKeyService.Instance.ConvertToInclue(this.Keys);

            include.AddRange <BaseKey>(allKeys);

            //  清理原有节点
            this.Clear();

            //  增加INLCUDE
            this.Add(include);
        }
Example #10
0
        /// <summary> 利用数模文件异步创建指定大小栈的内存模型 </summary>
        public INCLUDE ThreadLoadFromFile(INCLUDE include, string pfilePath, SimKeyType keyType = SimKeyType.Eclipse, int stactSize = 4194304)
        {
            include.FileName = Path.GetFileName(pfilePath);

            include.FilePath = pfilePath;

            if (include.BaseFile == null)
            {
                if (keyType == SimKeyType.Eclipse)
                {
                    EclipseData ecl = new EclipseData();
                    include.BaseFile = ecl;
                }
                else if (keyType == SimKeyType.SimON)
                {
                    SimONData simon = new SimONData();
                    include.BaseFile = simon;
                }
            }


            Thread thread = new Thread(() => include.ReadFromStream(), stactSize);// 4mb栈

            thread.Start();

            while (true)
            {
                if (thread.ThreadState == ThreadState.Stopped)
                {
                    break;
                }
            }


            return(include);
        }
        /// <summary> 通关生产数据创建生产数据(目前只应用在FieldGoal案例重启)  </summary>
        public SCHEDULE InitRestartSchduleRestartCase(SCHEDULE sch, RestartInfoModelSimON model, string name, DateTime time, DateTime endtime, Dictionary <string, double> wellProducts, int datype)
        {
            //  创建关键字
            SCHEDULE schedule = new SCHEDULE("SCHEDULE");
            INCLUDE  include  = new INCLUDE("INCLUDE");

            include.FileName = name + "_SCH.DAT";
            include.FilePath = Path.GetDirectoryName(model.ResultFilePath) + "//" + include.FileName;
            model.SchPath    = include.FilePath;
            schedule.Add(include);

            include.Add(new USESTARTTIME("USESTARTTIME"));
            include.Add(new RECURRENT("WELLSCHED"));
            TIME start = new TIME("TIME", time);

            foreach (var item in wellProducts)
            {
                WELLCTRL well = new WELLCTRL("WELLCTRL");
                well.WellName0 = item.Key;
                well.ProType   = datype == 0 ? SimONProductType.GRAT : datype == 1? SimONProductType.ORAT: SimONProductType.LRAT;
                well.Jcyblxz2  = item.Value.ToString();
                start.Add(well);
            }

            TIME startAdd = new TIME("TIME", time.AddDays(1));

            TIME end = new TIME("TIME", endtime);

            end.Add(new RegisterKeys.SimON.STEPRST("STEPRST"));

            List <VFPINJ> Vins = sch.FindAll <VFPINJ>();

            List <VFPPROD> Vpns = sch.FindAll <VFPPROD>();

            if (Vins.Count > 0)
            {
                include.AddRange(Vins);
            }

            if (Vpns.Count > 0)
            {
                include.AddRange(Vpns);
            }

            include.Add(start);

            if (startAdd.Date < end.Date)
            {
                include.Add(startAdd);
            }

            if (end.Date.Date == start.Date.Date)
            {
                include.Add(startAdd);
            }
            else
            {
                include.Add(end);
            }



            // HTodo  :保存生产文件
            include.Save();

            return(schedule);


            // HTodo  :示例如下
            //USESTARTTIME
            //WELLSCHED
            //TIME    20140209D
            //       WELL   'PROD1'   4   9000   1500
            //       WELL   'INIJ1'   5   6000   NA

            //TIME    20140210D

            //TIME    20140309D
            //RESTART
        }
Example #12
0
        /// <summary> 格式化文件 </summary>
        public void Format()
        {
            RUNSPEC runspec = this.Key.CreateSingle <RUNSPEC>("RUNSPEC");

            REGIONS region = this.Key.CreateSingle <REGIONS>("REGIONS");

            if (region != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_REG.INC";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                region.Add(include);
            }

            GRID grid = this.Key.CreateSingle <GRID>("GRID");

            var includesOld = grid.FindAll <INCLUDE>();

            if (grid != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GOPP.INC";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GGO.INC";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                #region - ggo -
                var echo = this.Key.FindAll <ECHO>();
                if (echo != null)
                {
                    grid.DeleteAll <ECHO>();
                    include.AddRange(echo);
                }

                var mapaxes = this.Key.FindAll <MAPAXES>();
                if (mapaxes != null)
                {
                    grid.DeleteAll <MAPAXES>();
                    include.AddRange(mapaxes);
                }


                var gridunit = this.Key.FindAll <GRIDUNIT>();
                if (gridunit != null)
                {
                    grid.DeleteAll <GRIDUNIT>();
                    include.AddRange(gridunit);
                }

                var coordsys = this.Key.FindAll <COORDSYS>();
                if (coordsys != null)
                {
                    grid.DeleteAll <COORDSYS>();
                    include.AddRange(coordsys);
                }

                var mapunits = this.Key.FindAll <MAPUNITS>();
                if (mapunits != null)
                {
                    grid.DeleteAll <MAPUNITS>();
                    include.AddRange(mapunits);
                }


                var noecho = this.Key.FindAll <NOECHO>();
                if (noecho != null)
                {
                    grid.DeleteAll <NOECHO>();
                    include.AddRange(noecho);
                }



                var coord = this.Key.FindAll <COORD>();
                if (coord != null)
                {
                    grid.DeleteAll <COORD>();
                    include.AddRange(coord);
                }



                var zcorn = this.Key.FindAll <ZCORN>();
                if (zcorn != null)
                {
                    grid.DeleteAll <ZCORN>();
                    include.AddRange(zcorn);
                }
                //  清空原有INCLUDE
                foreach (var v in includesOld)
                {
                    grid.Delete(v);
                }
                #endregion

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GPRO.INC";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GOTH.INC";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                ECHO echo1 = grid.Find <ECHO>();
                if (echo1 != null)
                {
                    grid.DeleteAll <ECHO>();
                    include.Add(echo1);
                }

                List <FAULTS> faults = grid.FindAll <FAULTS>();
                if (faults != null)
                {
                    grid.DeleteAll <FAULTS>();
                    foreach (var v in faults)
                    {
                        include.Add(v);
                    }
                }

                MULTFLT multflt = grid.Find <MULTFLT>();
                if (multflt != null)
                {
                    grid.DeleteAll <MULTFLT>();
                    include.Add(multflt);
                }
            }


            END end = this.Key.CreateSingle <END>("END");
        }
Example #13
0
        /// <summary> 清理父节点 </summary>
        public void InitParentKey()
        {
            RUNSPEC runspec = this.Key.CreateSingle <RUNSPEC>("RUNSPEC");

            GRID grid = this.Key.CreateSingle <GRID>("GRID");

            if (grid != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_grid.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                INCLUDE include1 = new INCLUDE("INCLUDE");
                include1.FileName = this.FileName.GetFileNameWithoutExtension() + "_faults.inc";
                include1.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName;
                grid.Add(include1);

                INCLUDE include2 = new INCLUDE("INCLUDE");
                include2.FileName = this.FileName.GetFileNameWithoutExtension() + "_aquifer.inc";
                include2.FilePath = this.FilePath.GetDirectoryName() + "\\" + include1.FileName;
                grid.Add(include2);
            }

            EDIT edit = this.Key.Find <EDIT>();

            if (edit != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_edit.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                edit.Add(include);
            }



            PROPS props = this.Key.CreateSingle <PROPS>("PROPS");

            if (props != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_pvt.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_rp.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);
            }


            SOLUTION solution = this.Key.CreateSingle <SOLUTION>("SOLUTION");

            if (solution != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_init.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                solution.Add(include);
            }



            REGIONS region = this.Key.CreateSingle <REGIONS>("REGIONS");

            if (region != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_regs.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                region.Add(include);
            }

            SUMMARY summary = this.Key.CreateSingle <SUMMARY>("SUMMARY");

            if (summary != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sum.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                summary.Add(include);

                //if (include.Keys.Count == 0)
                //{
                //    ALL all = new ALL("ALL");
                //    include.Add(all);
                //}
            }

            SCHEDULE schedule = this.Key.CreateSingle <SCHEDULE>("SCHEDULE");

            if (schedule != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sch.inc";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                schedule.Add(include);
            }


            END end = this.Key.CreateSingle <END>("END");
        }
Example #14
0
        /// <summary> 清理父节点 </summary>
        public void InitParentKey(bool isCoal = false)
        {
            this.Key.Clear();

            this.Key.CreateSingle <SIMSET>("SIMSET");

            GRID grid = this.Key.CreateSingle <GRID>("GRID");

            if (grid != null)
            {
                //  增加屏显
                ECHO_OFF echo_off = new ECHO_OFF("ECHO_OFF");
                grid.Add(echo_off);

                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_REG.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GPRO.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GGO.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_GOTH.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                grid.Add(include);

                //  关闭屏显
                ECHO_ON echo_on = new ECHO_ON("ECHO_ON");
                grid.Add(echo_on);
            }

            this.Key.CreateSingle <MODIFY>("MODIFY");

            WELL well = this.Key.CreateSingle <WELL>("WELL");

            USE_TF use_tf = new USE_TF("USE_TF");

            if (well != null)
            {
                well.Add(use_tf);

                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_WELL.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                well.Add(include);
            }



            PROPS props = this.Key.CreateSingle <PROPS>("PROPS");

            if (props != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_SAT.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_PVT.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                props.Add(include);
            }
            if (isCoal)
            {
                ADSORB adsorb = this.Key.CreateSingle <ADSORB>("ADSORB");

                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_ADS.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                adsorb.Add(include);
            }


            SOLUTION solution = this.Key.CreateSingle <SOLUTION>("SOLUTION");

            if (solution != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_INI.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                solution.Add(include);

                include          = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_AQU.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                solution.Add(include);
            }

            TUNESET tuneset = this.Key.CreateSingle <TUNESET>("TUNESET");


            SOLVECTRL solvectrl = new SOLVECTRL("SOLVECTRL");

            tuneset.Add(solvectrl);

            //if (solvectrl != null)
            //{
            //    INCLUDE include = new INCLUDE("INCLUDE");
            //    include.FileName = this.FileName.GetFileNameWithoutExtension() + "_TUN.DAT";
            //    include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
            //    solvectrl.Add(include);
            //}

            //SUMMARY summary = this.Key.CreateSingle<SUMMARY>("SUMMARY");
            //if (summary != null)
            //{
            //    INCLUDE include = new INCLUDE("INCLUDE");
            //    include.FileName = this.FileName.GetFileNameWithoutExtension() + "_sum.inc";
            //    include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
            //    summary.Add(include);

            //    //if (include.Keys.Count == 0)
            //    //{
            //    //    ALL all = new ALL("ALL");
            //    //    include.Add(all);
            //    //}
            //}

            SCHEDULE schedule = this.Key.CreateSingle <SCHEDULE>("SCHEDULE");

            if (schedule != null)
            {
                INCLUDE include = new INCLUDE("INCLUDE");
                include.FileName = this.FileName.GetFileNameWithoutExtension() + "_SCH.DAT";
                include.FilePath = this.FilePath.GetDirectoryName() + "\\" + include.FileName;
                schedule.Add(include);
            }


            //END end = this.Key.CreateSingle<END>("END");

            //  输出关键字
            OUTSCHED rptsched = new OUTSCHED("RPTSCHED");

            this.Key.Add(rptsched);
        }
Example #15
0
        /// <summary> 利用数模文件异步创建指定大小栈的内存模型 </summary>
        public INCLUDE ThreadLoadFromFile(string pfilePath, SimKeyType keyType = SimKeyType.Eclipse, int stactSize = 4194304)
        {
            INCLUDE include = new INCLUDE("INCLUDE");

            return(ThreadLoadFromFile(include, pfilePath, keyType, stactSize));
        }