示例#1
0
        /// <summary>
        /// Convert a Nucleus node to a BFE one
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public static BFE.Node Convert(Node node)
        {
            var result = new BFE.Node(Convert(node.Position))
            {
                Label = node.GUID.ToString(),
            };

            if (node.HasData <NodeSupport>())
            {
                var nS = node.GetData <NodeSupport>();
                result.Constraints = Convert(nS.Fixity);
            }
            return(result);
        }
示例#2
0
        public static Model Generate3DTet4Grid(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);

                        nde.Constraints = Constraint.RotationFixed;

                        nodes[j, i, k] = nde;
                    }
                }
            }


            var elm = new Func <Node, Node, Node, Node, Tetrahedral>((n1, n2, n3, n4) =>
            {
                var buff = new Tetrahedral();

                buff.Nodes[0] = n1;
                buff.Nodes[1] = n2;
                buff.Nodes[2] = n3;
                buff.Nodes[3] = n4;

                buff.E  = 210e9;
                buff.Nu = 0.33;

                return(buff);
            });

            var elms = new List <Element>();

            for (int i = 0; i < m - 1; i++)
            {
                for (int j = 0; j < n - 1; j++)
                {
                    for (int k = 0; k < l - 1; k++)
                    {
                        var ns = new Node[] {
                            nodes[i, j, k],
                            nodes[i + 1, j, k],
                            nodes[i + 1, j + 1, k],
                            nodes[i, j + 1, k],

                            nodes[i, j, k + 1],
                            nodes[i + 1, j, k + 1],
                            nodes[i + 1, j + 1, k + 1],
                            nodes[i, j + 1, k + 1],
                        };


                        elms.Add(elm(ns[0], ns[1], ns[3], ns[4]));
                        elms.Add(elm(ns[2], ns[1], ns[3], ns[6]));
                        elms.Add(elm(ns[1], ns[3], ns[4], ns[6]));

                        elms.Add(elm(ns[4], ns[5], ns[6], ns[1]));
                        elms.Add(elm(ns[4], ns[6], ns[7], ns[3]));
                    }
                }
            }

            buf.Elements.Add(elms.ToArray());

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


            return(buf);
        }
示例#3
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);
        }
示例#4
0
        public static Model Generate3DBarElementGrid(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 BarElement();
                        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 BarElement();
                        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 BarElement();
                        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 BarElement;


                if (framElm == null)
                {
                    continue;
                }

                framElm.Behavior = BarElementBehaviours.FullFrame;

                var sec = (Sections.UniformParametric1DSection)(framElm.Section = new Sections.UniformParametric1DSection());
                var mat = framElm.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(210e9, 0.2);

                sec.A  = 7.64 * 1e-4;                // 0.01;
                sec.Iy = sec.Iz = sec.J = 80 * 1e-8; // 0.1 * 0.1 * 0.1 * 0.1 / 12.0;
            }


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


            return(buf);
        }
        public override void UpdateCalc()
        {
            // Initiating Model, Nodes and Members
            model = new Model();

            double spt = _spacingTop.Value / 2;
            double spb = _spacingBottom.Value / 2;
            double spv = _spacingVertical.Value;

            var n1a = new BriefFiniteElementNet.Node(-spt, 0, spv)
            {
                Label = "1a"
            };
            var n1b = new BriefFiniteElementNet.Node(spt, 0, spv)
            {
                Label = "1b"
            };
            var n2a = new BriefFiniteElementNet.Node(0, -spb, 0)
            {
                Label = "2a"
            };
            var n2b = new BriefFiniteElementNet.Node(0, spb, 0)
            {
                Label = "2b"
            };

            var e1 = new TrussElement2Node(n1a, n2a)
            {
                Label = "e1"
            };
            var e2 = new TrussElement2Node(n1a, n2b)
            {
                Label = "e2"
            };
            var e3 = new TrussElement2Node(n1b, n2a)
            {
                Label = "e3"
            };
            var e4 = new TrussElement2Node(n1b, n2b)
            {
                Label = "e4"
            };
            var e5 = new TrussElement2Node(n1a, n1b)
            {
                Label = "e5"
            };
            var e6 = new TrussElement2Node(n2a, n2b)
            {
                Label = "e6"
            };

            //Note: labels for all members should be unique,
            //else you will receive InvalidLabelException when adding it to model

            e1.A = e2.A = e3.A = e4.A = e5.A = e6.A = 0.009;
            e1.E = e2.E = e3.E = e4.E = e5.E = e6.E = 210e9;

            model.Nodes.Add(n1a, n1b, n2a, n2b);
            model.Elements.Add(e1, e2, e3, e4, e5, e6);

            //Applying restraints

            n1a.Constraints = Constraint.FromString("100111");
            n1b.Constraints = Constraint.FromString("000111");
            n2a.Constraints = Constraint.FromString("111111");
            n2b.Constraints = Constraint.FromString("101111");

            //Applying load
            var forceA   = new Force(0, 0, -_loadA.Value / 2, 0, 0, 0);
            var forceB   = new Force(0, 0, -_loadA.Value / 2, 0, 0, 0);
            var loadCase = new LoadCase("test", LoadType.Live);

            n1a.Loads.Add(new NodalLoad(forceA, loadCase));
            n1b.Loads.Add(new NodalLoad(forceB, loadCase));
            var loadComb = new LoadCombination();

            loadComb.Add(loadCase, 1);

            //Adds a NodalLoad with Default LoadCase

            try
            {
                model.Solve();
                var rA        = n2a.GetSupportReaction(loadCase);
                var rB        = n2b.GetSupportReaction(loadCase);
                var T         = e6.GetInternalForceAt(0.5, loadComb);
                var F1        = e1.GetInternalForceAt(0.5, loadComb);
                var F2        = e3.GetInternalForceAt(0.5, loadComb);
                var Fresolved = F1 + F2;

                _reactionA.Value          = rA.Forces.Z;
                _reactionB.Value          = rB.Forces.Z;
                _strutResolvedForce.Value = Fresolved.Forces.Length;
                _tieForce.Value           = T.Forces.Length;
            }
            catch (Exception)
            {
                _reactionA.Value = double.NaN;
                _reactionB.Value = double.NaN;
            }
        }