Beispiel #1
0
        public override object Read(string path)
        {
            var    obj = new FvSchemesData();
            string txt;

            using (var reader = new StreamReader(path))
            {
                txt = reader.ReadToEnd();
            }

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

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var identifier = rootEntryNode.GetEntryIdentifier();
                var dict       = rootEntryNode.GetDictContent();
                switch (identifier)
                {
                case "ddtSchemes":
                    obj.ddtSchemes = dict.DictionaryWalk(NewTimeScheme);
                    break;

                case "gradSchemes":
                    obj.gradSchemes = dict.DictionaryWalk(NewGradientScheme);
                    break;

                case "divSchemes":
                    obj.divSchemes = dict.DictionaryWalk(NewDivergenceScheme);
                    break;

                case "laplacianSchemes":
                    obj.laplacianSchemes = dict.DictionaryWalk(NewLaplacianScheme);
                    break;

                case "interpolationSchemes":
                    obj.interpolationSchemes = dict.DictionaryWalk(NewInterpolationScheme);
                    break;

                case "snGradSchemes":
                    obj.snGradSchemes = dict.DictionaryWalk(NewSNGradScheme);
                    break;

                case "fluxRequired":
                    obj.fluxCalculation = dict.DictionaryWalk(NewFluxCalculation);
                    break;
                }
            }
            return(obj);
        }
        public override object Read(string path)
        {
            var obj = new FvSchemesData();
            string txt;
            using (var reader = new StreamReader(path))
            {
                txt = reader.ReadToEnd();
            }

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

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var identifier = rootEntryNode.GetEntryIdentifier();
                var dict = rootEntryNode.GetDictContent();
                switch (identifier)
                {
                    case "ddtSchemes":
                        obj.ddtSchemes = dict.DictionaryWalk(NewTimeScheme);
                        break;
                    case "gradSchemes":
                        obj.gradSchemes = dict.DictionaryWalk(NewGradientScheme);
                        break;
                    case "divSchemes":
                        obj.divSchemes = dict.DictionaryWalk(NewDivergenceScheme);
                        break;
                    case "laplacianSchemes":
                        obj.laplacianSchemes = dict.DictionaryWalk(NewLaplacianScheme);
                        break;
                    case "interpolationSchemes":
                        obj.interpolationSchemes = dict.DictionaryWalk(NewInterpolationScheme);
                        break;
                    case "snGradSchemes":
                        obj.snGradSchemes = dict.DictionaryWalk(NewSNGradScheme);
                        break;
                    case "fluxRequired":
                        obj.fluxCalculation = dict.DictionaryWalk(NewFluxCalculation);
                        break;
                }
            }
            return obj;
        }
        public Action GetSaveCommand()
        {
            return () =>
                       {
                           var path = _fileHandler.GetPath(_vProject.ProjectDir);
                           var d = new FvSchemesData(true);

                           foreach (var x in schemes.cInterpolation)
                           {
                                d.interpolationSchemes.Add(new InterpolationScheme()
                                {
                                    scheme = x.Scheme,
                                    use_default = (x.Scheme == "default"),
                                    function = x.Function,
                                    interpolation = x.InterpolationType,
                                    view = x.BoundView,
                                    lower_limit = (x.BoundView != BoundView.None) ? x.LowerLimit : 0,
                                    upper_limit = (x.BoundView != BoundView.None) ? x.UpperLimit : 0,
                                    flux = x.Flux,
                                    psi = x.Psi
                                });
                           }
                           foreach (var x in schemes.cSnGrad)
                           {
                                d.snGradSchemes.Add(new SurfaceNormalGradientScheme()
                                {
                                    scheme = x.Scheme,
                                    use_default = (x.Scheme == "default"),
                                    function = x.Function,
                                    type = x.SurfaceNoramGradientType,
                                    psi = x.Psi
                                });
                           }
                           foreach (var x in schemes.cGradient)
                           {
                                d.gradSchemes.Add(new GradientScheme()
                                {
                                    scheme = x.Scheme,
                                    use_default = (x.Scheme == "default"),
                                    function = x.Function,
                                    interpolation = x.InterpolationType,
                                    discretisation = x.DiscretisationType,
                                    limited = x.LimitedType,
                                    psi = x.Psi
                                });
                           }
                           foreach (var x in schemes.cDivergence)
                           {
                                d.divSchemes.Add(new DivergenceScheme()
                                {
                                    scheme = x.Scheme,
                                    use_default = (x.Scheme == "default"),
                                    function = x.Function,
                                    discretisation = x.DiscretisationType,
                                    interpolation = x.InterpolationType,
                                    view = x.BoundView,
                                    lower_limit = (x.BoundView != BoundView.None) ? x.LowerLimit : 0,
                                    upper_limit = (x.BoundView != BoundView.None) ? x.UpperLimit : 0,
                                    psi = x.Psi
                                });
                           }
                           foreach (var x in schemes.cLaplacian)
                           {
                                d.laplacianSchemes.Add(new LaplacianScheme()
                                {
                                    scheme = x.Scheme,
                                    use_default = (x.Scheme == "default"),
                                    function = x.Function,
                                    interpolation = x.InterpolationType,
                                    discretisation = x.DiscretisationType,
                                    snGradScheme = x.SurfaceNoramGradientType,
                                    psi = x.Psi
                                });
                           }
                           foreach (var x in schemes.cTime)
                           {
                                d.ddtSchemes.Add(new TimeScheme()
                                {
                                    scheme = x.Scheme,
                                    use_default = (x.Scheme == "default"),
                                    function = x.Function,
                                    type = x.TimeSchemeType,
                                    psi = x.Psi
                                });
                           }
                           foreach (var x in schemes.cFlux)
                           {
                                d.fluxCalculation.Add(new FluxCalculation()
                                {
                                    flux = x.Flux,
                                    enable = x.Enable
                                });
                           }
                           _fileHandler.Write(path, d);
                           schemes.AcceptChanges();
                       };
        }