コード例 #1
0
        public static void SetRandomiseSections(Model mdl)
        {
            foreach (var ele in mdl.Elements)
            {
                if (ele is Elements.BarElement)
                {
                    var br = ele as Elements.BarElement;

                    var sec = new Sections.UniformParametric1DSection();

                    var b = RandomStuff.GetRandomNumber(0.03, 0.05);
                    var h = RandomStuff.GetRandomNumber(0.03, 0.05);

                    sec.A  = b * h;
                    sec.Iy = b * b * b * h / 12;
                    sec.Iz = h * h * h * b / 12;
                    sec.J  = (sec.Iy + sec.Iz) / 2;//!!!

                    br.Section = sec;
                }

                if (ele is Elements.TriangleElement)
                {
                    var tri = ele as Elements.TriangleElement;

                    var sec = new Sections.UniformParametric2DSection();

                    var t = RandomStuff.GetRandomNumber(0.03, 0.05);
                    sec.T = t;

                    tri.Section = sec;
                }
            }
        }
コード例 #2
0
 public static void AddRandomiseNodalLoads(Model mdl, params LoadCase[] cases)
 {
     foreach (var nde in mdl.Nodes)
     {
         foreach (var cse in cases)
         {
             nde.Loads.Add(new NodalLoad(RandomStuff.GetRandomForce(-1000, 1000), cse));
         }
     }
 }
コード例 #3
0
        public static void AddRandomiseBeamUniformLoads(Model mdl, params LoadCase[] cases)
        {
            foreach (var elm in mdl.Elements)
            {
                foreach (var cse in cases)
                {
                    var ul = new Loads.UniformLoad();

                    ul.Direction = RandomStuff.GetRandomVector(-10, 10);

                    ul.CoordinationSystem = RandomStuff.GetRandomBool() ?
                                            CoordinationSystem.Local :
                                            CoordinationSystem.Global;

                    ul.Magnitude = RandomStuff.GetRandomNumber(-100, 100);

                    elm.Loads.Add(ul);
                }
            }
        }
コード例 #4
0
        public static void SetRandomiseMaterial(Model mdl)
        {
            var e  = RandomStuff.GetRandomNumber(0.9, 1.1) * 210e9;
            var nu = RandomStuff.GetRandomNumber(0.25, 0.3);

            foreach (var ele in mdl.Elements)
            {
                if (ele is Elements.BarElement)
                {
                    var br = ele as Elements.BarElement;


                    br.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);
                }

                if (ele is Elements.TriangleElement)
                {
                    var tri = ele as Elements.TriangleElement;

                    tri.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);
                }
            }
        }
コード例 #5
0
        public static void AddRandomiseLoading(Model mdl, bool addNodalLoads, bool addElementLoads,
                                               params LoadCase[] cases)
        {
            if (addNodalLoads)
            {
                foreach (var nde in mdl.Nodes)
                {
                    foreach (var cse in cases)
                    {
                        nde.Loads.Add(new NodalLoad(RandomStuff.GetRandomForce(-1000, 1000), cse));
                    }
                }
            }

            if (addElementLoads)
            {
                foreach (var elm in mdl.Elements)
                {
                    foreach (var cse in cases)
                    {
                        var uniformLoad =
                            new UniformLoad1D(rnd.GetRandomNumber(-1000, 1000), LoadDirection.X,
                                              CoordinationSystem.Global,
                                              cse);

                        var l = (elm.Nodes[0].Location - elm.Nodes[1].Location).Length;

                        var concenstratedLoad = new ConcentratedLoad1D(rnd.GetRandomForce(-1000, 1000),
                                                                       rnd.GetRandomNumber(0, l), CoordinationSystem.Global, cse);


                        elm.Loads.Add(uniformLoad);
                        elm.Loads.Add(concenstratedLoad);
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="m">number of levels in X direction</param>
        /// <param name="n">number of levels in Y direction</param>
        /// <param name="l">number of levels in Z direction</param>
        /// <returns></returns>
        public static Model Generate3DTriangleElementGrid(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 i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    for (int k = 0; k < l; k++)
                    {
                        var pos = new Point(j * dx, i * dy, k * dz);
                        var nde = new Node()
                        {
                            Location = pos
                        };
                        buf.Nodes.Add(nde);
                        nodes[i, j, k] = nde;
                    }
                }
            }

            //elements parallel to XZ
            for (int j = 0; j < n; j++)
            {
                for (int i = 0; i < m - 1; i++)
                {
                    for (int k = 0; k < l - 1; k++)
                    {
                        {
                            var elm2 = new TriangleElement();
                            elm2.Nodes[0] = nodes[i, j, k];
                            elm2.Nodes[1] = nodes[i, j, k + 1];
                            elm2.Nodes[2] = nodes[i + 1, j, k];

                            buf.Elements.Add(elm2);
                        }

                        {
                            var elm2 = new TriangleElement();
                            elm2.Nodes[0] = nodes[i + 1, j, k + 1];
                            elm2.Nodes[1] = nodes[i, j, k + 1];
                            elm2.Nodes[2] = nodes[i + 1, j, k];

                            buf.Elements.Add(elm2);
                        }
                    }
                }
            }


            //elements parallel to YZ
            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n - 1; j++)
                {
                    for (int k = 0; k < l - 1; k++)
                    {
                        {
                            var elm2 = new TriangleElement();
                            elm2.Nodes[0] = nodes[i, j, k];
                            elm2.Nodes[1] = nodes[i, j, k + 1];
                            elm2.Nodes[2] = nodes[i, j + 1, k];

                            buf.Elements.Add(elm2);
                        }

                        {
                            var elm2 = new TriangleElement();
                            elm2.Nodes[0] = nodes[i, j + 1, k + 1];
                            elm2.Nodes[1] = nodes[i, j, k + 1];
                            elm2.Nodes[2] = nodes[i, j + 1, k];

                            buf.Elements.Add(elm2);
                        }
                    }
                }
            }

            //elements parallel to XY
            for (int k = 0; k < l; k++)
            {
                for (int j = 0; j < n - 1; j++)
                {
                    for (int i = 0; i < m - 1; i++)
                    {
                        {
                            var elm2 = new TriangleElement();
                            elm2.Nodes[0] = nodes[i, j, k];
                            elm2.Nodes[1] = nodes[i + 1, j, k];
                            elm2.Nodes[2] = nodes[i, j + 1, k];

                            buf.Elements.Add(elm2);
                        }

                        {
                            var elm2 = new TriangleElement();
                            elm2.Nodes[0] = nodes[i + 1, j + 1, k];
                            elm2.Nodes[1] = nodes[i + 1, j, k];
                            elm2.Nodes[2] = nodes[i, j + 1, k];

                            buf.Elements.Add(elm2);
                        }
                    }
                }
            }


            foreach (var elm in buf.Elements)
            {
                var triElm = elm as TriangleElement;


                if (triElm == null)
                {
                    continue;
                }

                triElm.Behavior = TriangleElementBehaviours.Shell;



                var h = RandomStuff.GetRandomNumber(0.01, 0.1);
                var w = RandomStuff.GetRandomNumber(0.01, 0.1);

                var e  = RandomStuff.GetRandomNumber(100e9, 200e9);
                var nu = RandomStuff.GetRandomNumber(0.2, 0.3);

                var sec = (Sections.UniformParametric2DSection)(triElm.Section = new Sections.UniformParametric2DSection());

                var mat = triElm.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);

                sec.T = 0.1;
            }


            for (int i = 0; i < m; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    nodes[i, j, 0].Constraints = Constraint.Fixed;
                }
            }



            return(buf);
        }
コード例 #7
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 h = RandomStuff.GetRandomNumber(0.01, 0.1);
                var w = RandomStuff.GetRandomNumber(0.01, 0.1);

                var a  = h * w;
                var iy = h * h * h * w / 12;
                var iz = w * w * w * h / 12;
                var j  = iy + iz;
                var e  = RandomStuff.GetRandomNumber(100e9, 200e9);
                var nu = RandomStuff.GetRandomNumber(0.2, 0.3);

                var sec = (Sections.UniformParametric1DSection)(framElm.Section = new Sections.UniformParametric1DSection());
                var mat = framElm.Material = Materials.UniformIsotropicMaterial.CreateFromYoungPoisson(e, nu);

                sec.A  = a;
                sec.Iy = iy;
                sec.Iz = iz;
                sec.J  = j;
            }


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


            return(buf);
        }