Exemplo n.º 1
0
        public override object Read(string path)
        {
            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);
            var d = new Vertice();

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var identifier = rootEntryNode.GetEntryIdentifier();
                switch (identifier)
                {
                    case "value":
                        d.X = rootEntryNode.GetDictArrayBody().GetArrayOfDecimal()[0];
                        d.Y = rootEntryNode.GetDictArrayBody().GetArrayOfDecimal()[1];
                        d.Z = rootEntryNode.GetDictArrayBody().GetArrayOfDecimal()[2];
                        break;
                }
            }
            return d;
        }
        public override object Read(string path)
        {
            var obj = new AirfoilPropertiesData();
            string text;
            using (var reader = new StreamReader(path))
            {
                text = reader.ReadToEnd();
            }
            var grammar = new OpenFoamGrammar();
            var parser = new Parser(grammar);
            var tree = parser.Parse(text);
            obj.airfoilData = new List<Vertice>();

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var id = rootEntryNode.GetEntryIdentifier();
                if (id == "airfoilData")
                {
                    var dict = rootEntryNode.GetDictContent().ChildNodes[1];
                    for (int i = 0; i < dict.ChildNodes.Count; i++)
                    {
                        var array_head = dict.ChildNodes[i].ChildNodes[0].ChildNodes[1].ChildNodes;
                        var v = new Vertice();
                        v.X = Convert.ToDecimal(array_head[0].ChildNodes[0].Token.Value);
                        v.Y = Convert.ToDecimal(array_head[1].ChildNodes[0].Token.Value);
                        v.Z = Convert.ToDecimal(array_head[2].ChildNodes[0].Token.Value);
                        obj.airfoilData.Add( v );
                    }
                }
            }
            return obj;
        }
        public override object Read(string path)
        {
            var obj = new AirfoilPropertiesInstance();
            string text = Load(path);

            var grammar = new OpenFoamGrammar();
            var parser = new Parser(grammar);
            var tree = parser.Parse(text);
            obj.row = new List<Vertice>();

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var id = rootEntryNode.GetEntryIdentifier();
                if (id == "airfoilData")
                {
                    var dict = rootEntryNode.GetDictContent().ChildNodes[1];
                    foreach (ParseTreeNode t in dict.ChildNodes)
                    {
                        var array_head = t.ChildNodes[0].ChildNodes[1].ChildNodes;
                        var v = new Vertice
                                    {
                                        X = Convert.ToDecimal(array_head[0].ChildNodes[0].Token.Value),
                                        Y = Convert.ToDecimal(array_head[1].ChildNodes[0].Token.Value),
                                        Z = Convert.ToDecimal(array_head[2].ChildNodes[0].Token.Value)
                                    };
                        obj.row.Add( v );
                    }
                }
            }
            obj.airfoilName = FileName;
            return obj;
        }
Exemplo n.º 4
0
 public VVertice(Vertice p)
 {
     if (p != null)
     {
         X = p.X;
         Y = p.Y;
         Z = p.Z;
         return;
     }
     X = Y = Z = 0;
 }
        public TurbinePropertiesData()
        {
            NumBl = 2;
            TorqueControllerType = ControllerType.none;
            YawControllerType = ControllerType.none;
            PitchControllerType = ControllerType.none;
            airfoilBlade = new List<AirfoilBlade>();

            torqueControllerParams = new TorqueControllerParams();
            pitchControllerParams = new PitchControllerParams();
            airfoilBlade = new List<AirfoilBlade>();
            PreCone = new Vertice();
        }
        public override object Read(string path)
        {
            var obj = new TurbinePropertiesData();
            string text;

            if (!File.Exists(path))
            {
                if (!useDefault) return obj;
                WriteToFile(path, DefaultData);
            }

            using (var reader = new StreamReader(path))
            {
                text = reader.ReadToEnd();
            }
            var grammar = new OpenFoamGrammar();
            var parser = new Parser(grammar);
            var tree = parser.Parse(text);

            foreach (ParseTreeNode rootEntryNode in tree.Root.FindDictEntries(null))
            {
                var identifier = rootEntryNode.GetEntryIdentifier();

                switch ( identifier )
                {
                    case "NumBl":
                        obj.NumBl = rootEntryNode.GetBasicValInt();
                        break;
                    case "TipRad":
                        obj.TipRad = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "HubRad":
                        obj.HubRad = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "UndSling":
                        obj.UndSling = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "OverHang":
                        obj.OverHang = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "TowerHt":
                        obj.TowerHt = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "Twr2Shft":
                        obj.Twr2Shft = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "ShftTilt":
                        obj.ShftTilt = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "PreCone":
                        {
                            var dict = rootEntryNode.GetDictArrayBody();
                            var array = dict.GetArrayOfDecimal();
                            obj.PreCone = new Vertice( array[0], array[1], array[2]);
                        }
                        break;
                    case "GBRatio":
                        obj.GBRatio = rootEntryNode.GetBasicValDecimal();;
                        break;
                    case "GenIner":
                        obj.GenIner = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "HubIner":
                        obj.HubIner = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "BladeIner":
                        obj.BladeIner = rootEntryNode.GetBasicValDecimal();
                        break;
                    case "TorqueControllerType":
                        obj.TorqueControllerType = rootEntryNode.GetBasicValEnum<ControllerType>();
                        break;
                    case "YawControllerType":
                        obj.YawControllerType = rootEntryNode.GetBasicValEnum<ControllerType>();
                        break;
                    case "PitchControllerType":
                        obj.PitchControllerType = rootEntryNode.GetBasicValEnum<ControllerType>();
                        break;
                    case "TorqueControllerParams":
                        obj.torqueControllerParams = TorqueControllerParamsHandler(rootEntryNode.GetDictContent());
                        break;
                    case "PitchControllerParams":
                        obj.pitchControllerParams = PitchControllerParamsHandler(rootEntryNode.GetDictContent());
                        break;
                    case "Airfoils":
                        {
                            var dict = rootEntryNode.GetDictArrayBody();
                            for (int i = 0; i < dict.ChildNodes.Count; i++)
                            {
                                var item = new AirfoilBlade();
                                item.AirfoilName = dict.ChildNodes[i].ChildNodes[0].Token.Text.Replace("\"", "");
                                item.Blade = new List<Vertice>();
                                obj.airfoilBlade.Add(item);
                            }
                        }
                        break;
                    case "BladeData":
                        {
                            var dict = rootEntryNode.GetDictArrayBody();
                            for (int i = 0; i < dict.ChildNodes.Count; i++)
                            {
                                var array_head = dict.ChildNodes[i].ChildNodes[0].ChildNodes[1].ChildNodes;
                                if (array_head.Count > 3)
                                {
                                    var airfoil_id = Convert.ToInt32(array_head[3].ChildNodes[0].Token.Value);
                                    if ((airfoil_id >= 0) && (airfoil_id < obj.airfoilBlade.Count))
                                    {
                                        var blade_prop = new Vertice();
                                        blade_prop.X = Convert.ToDecimal(array_head[0].ChildNodes[0].Token.Value);
                                        blade_prop.Y = Convert.ToDecimal(array_head[1].ChildNodes[0].Token.Value);
                                        blade_prop.Z = Convert.ToDecimal(array_head[2].ChildNodes[0].Token.Value);
                                        obj.airfoilBlade[airfoil_id].Blade.Add(blade_prop);
                                    }
                                }
                            }
                        }
                        break;
                }
            }

            return obj;
        }
Exemplo n.º 7
0
 private string VerticeFormat(Vertice v)
 {
     var s = new StringBuilder();
     s.AppendFormat("({0} {1} {2})", v.X, v.Y, v.Z);
     return s.ToString();
 }
Exemplo n.º 8
0
 public static string WriteVector(this Vertice v)
 {
     return(WriteArray(new[] { v.X, v.Y, v.Z }));
 }
Exemplo n.º 9
0
 public VTurbineInstance()
 {
     baseLocation = new Vertice();
 }