Esempio n. 1
0
        private static void WriteFrameElement(XmlWriter w, FrameElement2Node elm)
        {
            w.WriteStartElement("FrameElement2Node");

            w.WriteAttributeString("Node1Index", elm.StartNode.Index.ToString());
            w.WriteAttributeString("Node2Index", elm.EndNode.Index.ToString());


            w.WriteAttributeString("Iy", elm.Iy.ToString());
            w.WriteAttributeString("Iz", elm.Iz.ToString());
            w.WriteAttributeString("J", elm.J.ToString());
            w.WriteAttributeString("A", elm.A.ToString());
            w.WriteAttributeString("Ay", elm.Ay.ToString());
            w.WriteAttributeString("Az", elm.Az.ToString());
            w.WriteAttributeString("Density", elm.MassDensity.ToString());

            if (elm.HingedAtStart)
            {
                w.WriteAttributeString("HingedAtStart", "true");
            }
            if (elm.HingedAtEnd)
            {
                w.WriteAttributeString("HingedAtEnd", "true");
            }
            if (elm.ConsiderShearDeformation)
            {
                w.WriteAttributeString("ConsiderShearEffect", "true");
            }
            if (!elm.WebRotation.Equals(0))
            {
                w.WriteAttributeString("WebRoation", elm.WebRotation.ToString());
            }

            w.WriteEndElement();
        }
Esempio n. 2
0
        public static Model GenerateRandomStructure(int nodeCount)
        {
            var rnd = new Random();

            var buf = new Model();

            for (int i = 0; i < nodeCount; i++)
            {
                var nde = new Node()
                {
                    Location = new Point(rnd.NextDouble() * 100, rnd.NextDouble() * 100, rnd.NextDouble() * 100)
                };
                buf.Nodes.Add(nde);
            }


            for (var i = 0; i < nodeCount - 1; i++)
            {
                var framElm = new FrameElement2Node()
                {
                    StartNode = buf.Nodes[i], EndNode = buf.Nodes[i + 1]
                };
                framElm.A  = 0.01;
                framElm.Iy = framElm.Iz = framElm.J = 0.1 * 0.1 * 0.1 * 0.1 / 12;
                framElm.E  = framElm.G = 210e9;

                buf.Elements.Add(framElm);
            }

            return(buf);
        }
Esempio n. 3
0
        /// <summary>
        /// Transforms the force in global coordination system into the local coordination system.
        /// </summary>
        /// <param name="elm">The elm.</param>
        /// <param name="force">The force.</param>
        /// <returns>transformed force</returns>
        public static Force TransformGlobalToLocal(this FrameElement2Node elm, Force force)
        {
            var f = elm.TransformGlobalToLocal(force.Forces);
            var m = elm.TransformGlobalToLocal(force.Moments);

            return(new Force(f, m));
        }
        public static Model GetRandomFrameModel(int n = 50)
        {
            var buf = new Model();

            var nodes = new Node[n];

            for (var i = 0; i < n; i++)
            {
                nodes[i] = new Node(GetRandomNumber(0, 10), GetRandomNumber(0, 10), GetRandomNumber(0, 10));

                nodes[i].Constraints = GetRandomConstraint();
            }

            buf.Nodes.Add(nodes);

            for (var i = 0; i < n; i++)
            {
                for (var j = 0; j < n; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }

                    var elm = new FrameElement2Node(nodes[i], nodes[j]);
                    elm.A  = GetRandomNumber();
                    elm.Iy = GetRandomNumber();
                    elm.Iz = GetRandomNumber();
                    elm.J  = GetRandomNumber();

                    elm.E = GetRandomNumber();
                    elm.G = GetRandomNumber();

                    var ld = new UniformLoad1D(GetRandomNumber(100, 1000), LoadDirection.Z, CoordinationSystem.Global);

                    elm.Loads.Add(ld);

                    buf.Elements.Add(elm);
                }
            }

            for (int i = 0; i < n; i++)
            {
                nodes[i].Loads.Add(new NodalLoad(GetRandomForce(1000, 10000)));
            }

            return(buf);
        }
Esempio n. 5
0
        public static Model GenerateSimpleBeam(int nodes)
        {
            var delta = 1.0;

            var buf = new Model();

            for (int i = 0; i < nodes; i++)
            {
                buf.Nodes.Add(new Node()
                {
                    Location = new Point(i * delta, 0, 0)
                });
            }

            for (int i = 0; i < nodes - 1; i++)
            {
                var start = buf.Nodes[i];
                var end   = buf.Nodes[i + 1];
                var elm   = new FrameElement2Node()
                {
                    StartNode = start, EndNode = end
                };
                buf.Elements.Add(elm);
            }

            foreach (var elm in buf.Elements)
            {
                var framElm = elm as FrameElement2Node;

                if (framElm == null)
                {
                    continue;
                }

                framElm.A  = 0.01;
                framElm.Iy = framElm.Iz = 0.1 * 0.1 * 0.1 * 0.1 / 12;
                framElm.J  = 2 * 0.1 * 0.1 * 0.1 * 0.1 / 12;
                framElm.E  = 210e9;
                var no = 0.3;
                framElm.G = framElm.E / (2 * (1 + no));
            }

            buf.Nodes[0].Constraints = Constraint.Fixed;

            TagModel(buf);
            return(buf);
        }
Esempio n. 6
0
        /// <summary>
        /// Applies the release matrix to calculated local end forces.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="localEndForces">The local end forces.</param>
        /// <returns></returns>
        /// <remarks>
        /// When <see cref="FrameElement2Node"/> has one or two hinged ends, then local end forces due to element interior loads (like distributed loads)
        /// will be different than normal ones (both ends fixed). This method will apply end releases...
        /// </remarks>
        /// <exception cref="System.NotImplementedException"></exception>
        public static Force[] ApplyReleaseMatrixToEndForces(FrameElement2Node element, Force[] localEndForces)
        {
            if (localEndForces.Length != 2)
            {
                throw new NotImplementedException();
            }

            var fullLoadVector = new double[12];//for applying release matrix


            {
                fullLoadVector[00] = localEndForces[0].Fx;
                fullLoadVector[01] = localEndForces[0].Fy;
                fullLoadVector[02] = localEndForces[0].Fz;
                fullLoadVector[03] = localEndForces[0].Mx;
                fullLoadVector[04] = localEndForces[0].My;
                fullLoadVector[05] = localEndForces[0].Mz;

                fullLoadVector[06] = localEndForces[1].Fx;
                fullLoadVector[07] = localEndForces[1].Fy;
                fullLoadVector[08] = localEndForces[1].Fz;
                fullLoadVector[09] = localEndForces[1].Mx;
                fullLoadVector[10] = localEndForces[1].My;
                fullLoadVector[11] = localEndForces[1].Mz;
            }

            var ld  = new Matrix(fullLoadVector);
            var rsm = element.GetReleaseMatrix();

            ld = rsm * ld;

            var buf = new Force[2];

            buf[0] = Force.FromVector(ld.CoreArray, 0);
            buf[1] = Force.FromVector(ld.CoreArray, 6);

            return(buf);
        }
Esempio n. 7
0
        public static Model Generate3DFrameElementGrid(int m, int n, int l)
        {
            var buf = new Model();

            var dx = 1.0;
            var dy = 1.0;
            var dz = 1.0;

            var nodes = new Node[m, n, l];

            for (int k = 0; k < l; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var pos = new Point(i * dx, j * dy, k * dz);
                        var nde = new Node()
                        {
                            Location = pos
                        };
                        buf.Nodes.Add(nde);
                        nodes[j, i, k] = nde;
                    }
                }
            }

            for (int k = 0; k < l - 1; k++)
            {
                for (int i = 0; i < n; i++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var elm = new FrameElement2Node();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j, i, k + 1];
                        buf.Elements.Add(elm);
                    }
                }
            }


            for (int i = 0; i < n - 1; i++)
            {
                for (int k = 0; k < l; k++)
                {
                    for (int j = 0; j < m; j++)
                    {
                        var elm = new FrameElement2Node();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j, i + 1, k];
                        buf.Elements.Add(elm);
                    }
                }
            }

            for (int j = 0; j < m - 1; j++)
            {
                for (int k = 0; k < l; k++)
                {
                    for (int i = 0; i < n; i++)

                    {
                        var elm = new FrameElement2Node();
                        elm.StartNode = nodes[j, i, k];
                        elm.EndNode   = nodes[j + 1, i, k];
                        buf.Elements.Add(elm);
                    }
                }
            }

            foreach (var elm in buf.Elements)
            {
                var framElm = elm as FrameElement2Node;

                if (framElm == null)
                {
                    continue;
                }

                framElm.A           = 7.64 * 1e-4;                        // 0.01;
                framElm.Iy          = framElm.Iz = framElm.J = 80 * 1e-8; // 0.1 * 0.1 * 0.1 * 0.1 / 12.0;
                framElm.E           = framElm.G = 210e9;
                framElm.MassDensity = 7800;
            }


            for (int i = 0; i < n * m; i++)
            {
                buf.Nodes[i].Constraints = Constraint.Fixed;
            }


            return(buf);
        }
Esempio n. 8
0
        /// <summary>
        /// Run an analysis on the specified model
        /// </summary>
        /// <param name="model"></param>
        /// <param name="alertLog"></param>
        /// <returns></returns>
        public ModelResults AnalyseModel(Model.Model model, AnalysisCaseCollection cases, AlertLog alertLog = null)
        {
            alertLog?.RaiseAlert("BLD", "Building analysis model...");

            var results = new ModelResults();

            // Create model:
            var feModel = new BFE.Model();

            // Create nodes:
            var nodesMap = new Dictionary <Guid, BFE.Node>();

            foreach (var node in model.Nodes)
            {
                var bfeNode = ToBFE.Convert(node);
                feModel.Nodes.Add(bfeNode);
                nodesMap.Add(node.GUID, bfeNode);
            }

            // Create materials:

            /*var materialsMap = new Dictionary<Guid, BFE.Materials.BaseMaterial>();
             * foreach (var material in model.Materials)
             * {
             *  var bfeMat = ToBFE.Convert(material);
             *  materialsMap.Add(material.GUID, bfeMat);
             * }*/

            // Create sections:

            /*foreach (var family in model.Families)
             * {
             *  if (family is SectionFamily)
             *  {
             *      SectionFamily section = (SectionFamily)family;
             *      //TODO?
             *  }
             * }*/

            // Create elements:
            var elementMap = new Dictionary <Guid, BFE.FrameElement2Node>();

            foreach (var element in model.Elements)
            {
                if (element is LinearElement)
                {
                    var linEl = (LinearElement)element;
                    if (linEl.StartNode != null && linEl.EndNode != null && linEl.Family != null)
                    {
                        var el = new BFE.FrameElement2Node(
                            nodesMap[linEl.StartNode.GUID], nodesMap[linEl.EndNode.GUID]);
                        //TODO: Releases
                        //TODO: Orientation
                        //TODO: Offsets
                        if (linEl.Family.Profile?.Perimeter != null)
                        {
                            var profile = ToBFE.Convert(linEl.Family.Profile.Perimeter);
                            el.Geometry = profile;
                            el.UseOverridedProperties = false;
                            //TODO: Hollow sections
                        }
                        el.E = linEl.Family.GetPrimaryMaterial()?.GetE(Geometry.Direction.X) ?? 210e9;
                        feModel.Elements.Add(el);
                        elementMap.Add(element.GUID, el);
                    }
                    else
                    {
                        alertLog.RaiseAlert("INCOMPLETE DATA", linEl, "Incomplete data.  Will be excluded from analysis.");
                    }
                }
            }

            //Loading time!
            // TODO: Limit to specific load cases?
            foreach (var load in model.Loads)
            {
                if (load is LinearElementLoad)
                {
                    var lEL = (LinearElementLoad)load;
                    if (lEL.IsMoment)
                    {
                        alertLog.RaiseAlert("MOMENTS UNSUPPORTED", load, "Moment line loads are not supported.", AlertLevel.Error);
                    }
                    else
                    {
                        // TODO: Set load case
                        var bLoad = new BFE.UniformLoad1D(lEL.Value, ToBFE.Convert(lEL.Direction), ToBFE.Convert(lEL.Axes));

                        // TODO: Generalise
                        var elements = lEL.AppliedTo.Items;
                        foreach (var el in elements)
                        {
                            elementMap[el.GUID].Loads.Add(bLoad);
                        }
                    }
                }
                else if (load is NodeLoad)
                {
                    var nL = (NodeLoad)load;
                }
                else
                {
                    alertLog.RaiseAlert("LOAD TYPE UNSUPPORTED", load, "Load type is not supported.", AlertLevel.Error);
                }
            }

            alertLog?.RaiseAlert("BLD", "Analysis model built.");

            alertLog.RaiseAlert("SLV", "Solving...");

            feModel.Solve();

            alertLog.RaiseAlert("SLV", "Solved.");

            foreach (var kvp in nodesMap)
            {
                var disp = kvp.Value.GetNodalDisplacement();
                var nR   = new NodeResults();
                var cNR  = new CaseNodeResults();

                //nR.Add(cNR);
            }

            /*foreach (var element in model.Elements)
             * {
             *  bNS = nodesMap[element]
             * }*/
            return(results);
        }
Esempio n. 9
0
        public static Model ReadFromXml(Stream stream)
        {
            var doc = new XmlDocument();

            doc.Load(stream);

            var buf = new Model();

            var nodesList       = new List <Node>();
            var nodesDictionary = new Dictionary <string, Node>();

            #region nodes

            var nodes = doc.SelectNodes("Model/Nodes/Node");

            if (nodes == null)
            {
                throw new Exception("Model/Nodes/Node element not found");
            }

            foreach (XmlElement node in nodes)
            {
                var x = node.GetAttributeValue <double>("X");
                var y = node.GetAttributeValue <double>("Y");
                var z = node.GetAttributeValue <double>("Z");

                #region fixity

                var dxFix = node.GetAttributeValue <bool>("DxFix");
                var dyFix = node.GetAttributeValue <bool>("DyFix");
                var dzFix = node.GetAttributeValue <bool>("DzFix");
                var rxFix = node.GetAttributeValue <bool>("RxFix");
                var ryFix = node.GetAttributeValue <bool>("RyFix");
                var rzFix = node.GetAttributeValue <bool>("RzFix");

                var lbl = node.GetAttributeValue("Label");

                var nde = new Node(x.Value, y.Value, z.Value);

                var cns = Constraint.Released;

                if (dxFix.HasValue)
                {
                    cns.DX = dxFix.Value ? DofConstraint.Fixed : DofConstraint.Released;
                }

                if (dyFix.HasValue)
                {
                    cns.DY = dyFix.Value ? DofConstraint.Fixed : DofConstraint.Released;
                }

                if (dzFix.HasValue)
                {
                    cns.DZ = dzFix.Value ? DofConstraint.Fixed : DofConstraint.Released;
                }

                if (rxFix.HasValue)
                {
                    cns.RX = rxFix.Value ? DofConstraint.Fixed : DofConstraint.Released;
                }

                if (ryFix.HasValue)
                {
                    cns.RY = ryFix.Value ? DofConstraint.Fixed : DofConstraint.Released;
                }

                if (rzFix.HasValue)
                {
                    cns.RZ = rzFix.Value ? DofConstraint.Fixed : DofConstraint.Released;
                }

                nde.Constraints = cns;

                #endregion

                #region settlement

                var dxSl = node.GetAttributeValue <double>("DxStl");
                var dySl = node.GetAttributeValue <double>("DxStl");
                var dzSl = node.GetAttributeValue <double>("DxStl");
                var rxSl = node.GetAttributeValue <double>("DxStl");
                var rySl = node.GetAttributeValue <double>("DxStl");
                var rzSl = node.GetAttributeValue <double>("DxStl");

                var settl = new Displacement();

                if (dxSl.HasValue)
                {
                    settl.DX = dxSl.Value;
                }

                if (dySl.HasValue)
                {
                    settl.DY = dySl.Value;
                }

                if (dzSl.HasValue)
                {
                    settl.DZ = dzSl.Value;
                }

                if (rxSl.HasValue)
                {
                    settl.RX = rxSl.Value;
                }

                if (rySl.HasValue)
                {
                    settl.RY = rySl.Value;
                }

                if (rzSl.HasValue)
                {
                    settl.RZ = rzSl.Value;
                }


                nde.Settlements = settl;

                #endregion

                var tag = node.GetAttributeValue("Tag");

                if (tag != null)
                {
                    nde.Tag = tag;
                }


                if (lbl != null)
                {
                    nde.Label = lbl;
                    if (nodesDictionary.ContainsKey(lbl))
                    {
                        throw new Exception("duplicated label for nodes: " + lbl);
                    }
                    nodesDictionary[lbl] = nde;
                }

                nodesList.Add(nde);
            }

            #endregion

            var elementList       = new List <Element>();
            var elementDictionary = new Dictionary <string, Element>();

            var frmElms = doc.SelectNodes("Model/Elements/FrameElement2Node");

            #region frame elements

            if (frmElms != null)
            {
                foreach (XmlElement node in frmElms)
                {
                    var elm = new FrameElement2Node();

                    var n1Index = node.GetAttributeValue <int>("Node1Index");
                    var n2Index = node.GetAttributeValue <int>("Node2Index");

                    var n1Label = node.GetAttributeValue("Node1Label");
                    var n2Label = node.GetAttributeValue("Node2Label");

                    var iy      = node.GetAttributeValue <double>("Iy");
                    var iz      = node.GetAttributeValue <double>("Iz");
                    var j       = node.GetAttributeValue <double>("J");
                    var a       = node.GetAttributeValue <double>("A");
                    var ay      = node.GetAttributeValue <double>("Ay");
                    var az      = node.GetAttributeValue <double>("Az");
                    var density = node.GetAttributeValue <double>("Density");
                    var hing1   = node.GetAttributeValue <bool>("HingedAtStart");
                    var hing2   = node.GetAttributeValue <bool>("HingedAtEnd");
                    var webRot  = node.GetAttributeValue <double>("WebRoation");

                    var label = node.GetAttributeValue("Label");
                    var tag   = node.GetAttributeValue("Tag");


                    var shearEffect = node.GetAttributeValue <bool>("ConsiderShearEffect");

                    if (n1Index == null && n1Label == null)
                    {
                        throw new Exception("Neither Node1Index and Node1Label are defined");
                    }

                    if (n2Index == null && n2Label == null)
                    {
                        throw new Exception("Neither Node2Index and Node2Label are defined");
                    }

                    elm.Iy = iy.Value;
                    elm.Iz = iz.Value;
                    elm.J  = j.Value;
                    elm.A  = a.Value;

                    if (label != null)
                    {
                        elm.Label = label;
                        elementDictionary[label] = elm;
                    }

                    if (tag != null)
                    {
                        elm.Tag = tag;
                    }

                    if (ay.HasValue)
                    {
                        elm.Ay = ay.Value;
                    }

                    if (az.HasValue)
                    {
                        elm.Az = az.Value;
                    }

                    if (hing1.HasValue)
                    {
                        elm.HingedAtStart = hing1.Value;
                    }

                    if (hing2.HasValue)
                    {
                        elm.HingedAtEnd = hing2.Value;
                    }

                    elm.MassDensity = density.Value;

                    elm.UseOverridedProperties = true;

                    if (shearEffect.HasValue)
                    {
                        elm.ConsiderShearDeformation = shearEffect.Value;
                    }

                    if (webRot.HasValue)
                    {
                        elm.WebRotation = webRot.Value;
                    }


                    if (n1Index.HasValue)
                    {
                        elm.StartNode = nodesList[n1Index.Value];
                    }
                    else
                    {
                        if (n1Label == null)
                        {
                            throw new Exception();
                        }

                        if (!nodesDictionary.ContainsKey(n1Label))
                        {
                            throw new Exception("node not exists, label: " + n1Label);
                        }

                        elm.StartNode = nodesDictionary[n1Label];
                    }


                    if (n2Index.HasValue)
                    {
                        elm.EndNode = nodesList[n2Index.Value];
                    }
                    else
                    {
                        if (n2Label == null)
                        {
                            throw new Exception();
                        }

                        if (!nodesDictionary.ContainsKey(n2Label))
                        {
                            throw new Exception("node not exists, label: " + n1Label);
                        }

                        elm.EndNode = nodesDictionary[n2Label];
                    }

                    elementList.Add(elm);
                }
            }

            #endregion

            var rgdElms = doc.SelectNodes("Model/Elements/RigidElement");

            #region rigid elements

            foreach (XmlElement node in rgdElms)
            {
                var rElm = new RigidElement();

                var innerNodes = node.SelectNodes("/Node");

                var label = node.GetAttributeValue("Label");

                if (label != null)
                {
                    rElm.Label = label;
                }

                var tag = node.GetAttributeValue("Tag");

                if (tag != null)
                {
                    rElm.Tag = tag;
                }


                foreach (XmlElement innerNode in innerNodes)
                {
                    var num      = innerNode.GetAttributeValue <int>("Index");
                    var lbl      = innerNode.GetAttributeValue("Label");
                    var isCenter = innerNode.GetAttributeValue <bool>("IsCenter");

                    if (lbl == null && !num.HasValue)
                    {
                        continue;
                    }

                    Node targetNode;

                    if (num.HasValue)
                    {
                        rElm.Nodes.Add(targetNode = nodesList[num.Value]);
                    }
                    else
                    {
                        if (!nodesDictionary.ContainsKey(lbl))
                        {
                            throw new Exception("Invalid node label: " + lbl);
                        }

                        rElm.Nodes.Add(targetNode = nodesDictionary[lbl]);
                    }


                    if (isCenter.HasValue)
                    {
                        if (isCenter.Value)
                        {
                            rElm.CentralNode = targetNode;
                        }
                    }
                }

                var useForAllLoads = node.GetAttributeValue <bool>("UseForAllLoads");

                if (useForAllLoads.HasValue)
                {
                    rElm.UseForAllLoads = useForAllLoads.Value;
                }


                var appliedLoadCases = node.SelectNodes("RigidElement/AppliedLoadCases/LoadCase");

                #region cases

                foreach (XmlElement item in appliedLoadCases)
                {
                    var name = item.GetAttributeValue("Name");
                    var type = item.GetAttributeValue("Type");

                    if (name == null || type == null)
                    {
                        throw new Exception("RigidElement/AppliedLoadCases/LoadCase should have both Type and Title");
                    }

                    LoadType loadTp;

                    if (type.IsNumber())
                    {
                        loadTp = (LoadType)int.Parse(type);
                    }
                    else
                    {
                        loadTp = (LoadType)Enum.Parse(typeof(LoadType), type);
                    }


                    var lcase = new LoadCase(name, loadTp);
                    rElm.AppliedLoadCases.Add(lcase);
                }

                #endregion


                var appliedLoadTypes = node.SelectNodes("RigidElement/AppliedLoadTypes/LoadType");

                #region types

                foreach (XmlElement item in appliedLoadTypes)
                {
                    var type = item.GetAttributeValue("Type");

                    if (type == null)
                    {
                        throw new Exception("RigidElement/AppliedLoadCases/LoadCase should have both Type and Title");
                    }

                    LoadType loadTp;

                    if (type.IsNumber())
                    {
                        loadTp = (LoadType)int.Parse(type);
                    }
                    else
                    {
                        loadTp = (LoadType)Enum.Parse(typeof(LoadType), type);
                    }


                    rElm.AppliedLoadTypes.Add(loadTp);
                }

                #endregion
            }



            #endregion

            #region loads

            {
//reading loads

                var loadSets = doc.SelectNodes("Model/LoadSet");

                foreach (XmlElement xelm in loadSets)
                {
                    var loadCaseType = xelm.GetAttributeValue("LoadCaseType");
                    var loadCaseName = xelm.GetAttributeValue("LoadCaseName");


                    var loads = xelm.SelectNodes("/");

                    foreach (XmlElement loadElm in loads)
                    {
                        if (loadElm.Name == "NodalLoad")
                        {
                            #region nodal load

                            var nodeIndex = xelm.GetAttributeValue <int>("NodeIndex");
                            var nodeLabel = xelm.GetAttributeValue("NodeLabel");

                            var fx = xelm.GetAttributeValue <double>("Fx");
                            var fy = xelm.GetAttributeValue <double>("Fy");
                            var fz = xelm.GetAttributeValue <double>("Fz");
                            var mx = xelm.GetAttributeValue <double>("Mx");
                            var my = xelm.GetAttributeValue <double>("My");
                            var mz = xelm.GetAttributeValue <double>("Mz");

                            var load = new NodalLoad();

                            var force = new Force();

                            force.Fx = fx ?? 0;
                            force.Fy = fy ?? 0;
                            force.Fz = fz ?? 0;
                            force.Mx = mx ?? 0;
                            force.My = my ?? 0;
                            force.Mz = mz ?? 0;

                            load.Case  = new LoadCase(loadCaseName, GetLoadType(loadCaseType));
                            load.Force = force;

                            if (nodeIndex.HasValue)
                            {
                                nodesList[nodeIndex.Value].Loads.Add(load);
                            }
                            else if (nodeLabel != null)
                            {
                                nodesDictionary[nodeLabel].Loads.Add(load);
                            }
                            else
                            {
                                throw new Exception("neither node index and label are defined");
                            }

                            #endregion
                        }

                        else if (loadElm.Name == "UniformLoad")
                        {
                            #region uniform load

                            var elmIndex = xelm.GetAttributeValue <int>("NodeIndex");
                            var elmLabel = xelm.GetAttributeValue("NodeLabel");

                            var magnitude = xelm.GetAttributeValue <double>("Magnitude");
                            var dir       = xelm.GetAttributeValue("Direction");
                            var sys       = xelm.GetAttributeValue("CoordinationSystem");

                            var load = new UniformLoad1D();

                            load.Magnitude = magnitude ?? magnitude.Value;

                            load.Case               = new LoadCase(loadCaseName, GetLoadType(loadCaseType));
                            load.Direction          = (LoadDirection)Enum.Parse(typeof(LoadDirection), dir);
                            load.CoordinationSystem = (CoordinationSystem)Enum.Parse(typeof(CoordinationSystem), sys);

                            if (elmIndex.HasValue)
                            {
                                elementList[elmIndex.Value].Loads.Add(load);
                            }
                            else if (elmLabel != null)
                            {
                                elementDictionary[elmLabel].Loads.Add(load);
                            }
                            else
                            {
                                throw new Exception("neither node index and label are defined");
                            }

                            #endregion
                        }

                        else
                        {
                            throw new Exception(string.Format("Element Type {0} not supported!", loadElm.Name));
                        }
                    }
                }
            }

            #endregion


            throw new NotImplementedException();
        }
Esempio n. 10
0
        public static Vector TransformGlobalToLocal(this FrameElement2Node elm, Vector vec)
        {
            var f = elm.TransformGlobalToLocal(vec);

            return(f);
        }