Пример #1
0
        public override object Read(string path)
        {
            var    rawData = new ControlDictData();
            string txt     = Load(path);

            var grammar = new OpenFoamGrammar();
            var parser  = new Parser(grammar);
            var tree    = parser.Parse(txt);

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var identifier = rootEntryNode.GetEntryIdentifier();
                switch (identifier)
                {
                case "application":
                    rawData.application = rootEntryNode.GetBasicValEnum <ApplicationSolver>();
                    break;

                case "startFrom":
                    rawData.startFrom = rootEntryNode.GetBasicValEnum <StartFrom>();
                    break;

                case "startTime":
                    rawData.startTime = rootEntryNode.GetBasicValDecimal();
                    break;

                case "stopAt":
                    rawData.stopAt = rootEntryNode.GetBasicValEnum <StopAt>();
                    break;

                case "endTime":
                    rawData.endTime = rootEntryNode.GetBasicValDecimal();
                    break;

                case "deltaT":
                    rawData.deltaT = rootEntryNode.GetBasicValDecimal();
                    break;

                case "writeControl":
                    rawData.writeControl = rootEntryNode.GetBasicValEnum <WriteControl>();
                    break;

                case "writeInterval":
                    rawData.writeInterval = rootEntryNode.GetBasicValDecimal();
                    break;

                case "purgeWrite":
                    rawData.purgeWrite = rootEntryNode.GetBasicValDecimal();
                    break;

                case "writeFormat":
                    rawData.writeFormat = rootEntryNode.GetBasicValEnum <WriteFormat>();
                    break;

                case "writePrecision":
                    rawData.writePrecision = rootEntryNode.GetBasicValDecimal();
                    break;

                case "writeCompression":
                    rawData.writeCompression = rootEntryNode.GetBasicValEnum <WriteCompression>();
                    break;

                case "timeFormat":
                    rawData.timeFormat = rootEntryNode.GetBasicValEnum <TimeFormat>();
                    break;

                case "timePrecision":
                    rawData.timePrecision = rootEntryNode.GetBasicValDecimal();
                    break;

                case "runTimeModifiable":
                    rawData.runTimeModifiable = rootEntryNode.GetBasicValBool();
                    break;

                case "adjustTimeStep":
                    rawData.adjustTimeStep = rootEntryNode.GetBasicValEnum <FlagYesNo>();
                    break;

                case "maxCo":
                    rawData.maxCo = rootEntryNode.GetBasicValDecimal();
                    break;

                case "maxDeltaT":
                    rawData.maxDeltaT = rootEntryNode.GetBasicValDecimal();
                    break;
                }
            }
            return(rawData);
        }
Пример #2
0
        public override object Read(string path)
        {
            var rawData = new ControlDictData();
            string txt;
            using (var reader = new StreamReader(path))
            {
                txt = reader.ReadToEnd();
            }

            var grammar = new OpenFoamGrammar();
            var parser = new Parser(grammar);
            var tree = parser.Parse(txt);

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var identifier = rootEntryNode.GetEntryIdentifier();
                switch (identifier)
                {
                    case "application":
                        rawData.application = rootEntryNode.GetBasicValEnum<ApplicationSolver>();
                        break;
                    case "startFrom":
                        rawData.startFrom = rootEntryNode.GetBasicValEnum<StartFrom>();
                        break;
                    case "startTime":
                        rawData.startTime = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "stopAt":
                        rawData.stopAt = rootEntryNode.GetBasicValEnum<StopAt>();
                        break;
                    case "endTime":
                        rawData.endTime = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "deltaT":
                        rawData.deltaT = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "writeControl":
                        rawData.writeControl = rootEntryNode.GetBasicValEnum<WriteControl>();
                        break;
                    case "writeInterval":
                        rawData.writeInterval = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "purgeWrite":
                        rawData.purgeWrite = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "writeFormat":
                        rawData.writeFormat = rootEntryNode.GetBasicValEnum<WriteFormat>();
                        break;
                    case "writePrecision":
                        rawData.writePrecision = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "writeCompression":
                        rawData.writeCompression = rootEntryNode.GetBasicValEnum<WriteCompression>();
                        break;
                    case "timeFormat":
                        rawData.timeFormat = rootEntryNode.GetBasicValEnum<TimeFormat>();
                        break;
                    case "timePrecision":
                        rawData.timePrecision = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "runTimeModifiable":
                        rawData.runTimeModifiable = rootEntryNode.GetBasicValEnum<FlagYesNo>();
                        break;
                    case "adjustTimeStep":
                        rawData.adjustTimeStep = rootEntryNode.GetBasicValEnum<FlagYesNo>();
                        break;
                    case "maxCo":
                        rawData.maxCo = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "maxDeltaT":
                        rawData.maxDeltaT = rootEntryNode.GetBasicValDecimal();
                        break;
                }
            }
            return rawData;
        }
Пример #3
0
 private static void InitTimeControl(ControlDictData cd)
 {
     cd.application = ApplicationSolver.pisoFoam;
     cd.startFrom = StartFrom.latestTime;
     cd.startTime = 10m;
     cd.stopAt = StopAt.endTime;
     cd.endTime = 200m;
     cd.deltaT = 0.005m;
     cd.writeControl = WriteControl.timeStep;
     cd.writeInterval = 1000m;
     cd.purgeWrite = 0;
     cd.writeFormat = WriteFormat.ascii;
     cd.writePrecision = 6m;
     cd.writeCompression = WriteCompression.off;
     cd.timeFormat = TimeFormat.general;
     cd.timePrecision = 6m;
     cd.runTimeModifiable = true;
 }