Exemple #1
0
        public static void testInternalForce_Console()
        {
            var model = new Model();
            var ndes  = new Node[] { new Node(0, 0, 0), new Node(3, 0, 0) };

            var h = UnitConverter.In2M(4);
            var w = UnitConverter.In2M(4);

            var e = UnitConverter.Psi2Pas(20e4);

            var a  = h * w;
            var iy = h * h * h * w / 12;
            var iz = w * w * w * h / 12;
            var j  = iy + iz;

            var sec = new Sections.UniformParametric1DSection(a = 1, iy = 1, iz = 1, j = 1);
            var mat = UniformIsotropicMaterial.CreateFromYoungPoisson(e = 1, 0.25);

            var elm = new BarElement(ndes[0], ndes[1])
            {
                Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame
            };

            //var elm2 = new BarElement(ndes[1], ndes[2]) { Material = mat, Section = sec, Behavior = BarElementBehaviours.FullFrame };

            model.Elements.Add(elm);
            model.Nodes.Add(ndes);

            ndes[0].Constraints = Constraints.Fixed;

            ndes[1].Loads.Add(new NodalLoad(new Force(1, 0, 1, 0, 0, 0)));

            model.Solve_MPC();

            var tr = elm.GetTransformationManager();

            var d1 = tr.TransformLocalToGlobal(elm.GetInternalDisplacementAt(1 - 1e-10, LoadCase.DefaultLoadCase));
            var d2 = ndes[1].GetNodalDisplacement(LoadCase.DefaultLoadCase);


            var frc = elm.GetInternalForceAt(-1, LoadCase.DefaultLoadCase);

            var gfrc = elm.GetTransformationManager().TransformLocalToGlobal(frc);

            var f0 = ndes[0].GetSupportReaction();
        }
Exemple #2
0
        public static ValidationResult TestFixedEndMoment_uniformLoad()
        {
            var buff = new ValidationResult();

            buff.Title = "Test #1 for UniformLoad on BarElement";
            buff.Span.Add("p").Text("endforce from uniformload should be statically in equiblirium with uniform load");


            var elm = new BarElement(new Node(0, 0, 0), new Node(8.66, 0, 5));

            elm.Behavior = BarElementBehaviours.FullFrame;

            var ld = new Loads.UniformLoad();

            ld.Magnitude          = 1;//*Math.Sqrt(2);
            ld.Direction          = Vector.K;
            ld.CoordinationSystem = CoordinationSystem.Global;
            elm.Loads.Add(ld);

            var loads = elm.GetGlobalEquivalentNodalLoads(ld);

            {//test 1 : static balance
                var l = (elm.Nodes[1].Location - elm.Nodes[0].Location);

                var totEndForces = new Force();

                for (int i = 0; i < loads.Length; i++)
                {
                    totEndForces += loads[i].Move(elm.Nodes[i].Location, elm.Nodes[0].Location);
                }

                var d = l / 2;

                var gDir = ld.Direction;

                if (ld.CoordinationSystem == CoordinationSystem.Local)
                {
                    gDir = elm.GetTransformationManager().TransformLocalToGlobal(ld.Direction);
                }

                var cos = (1 / (d.Length * gDir.Length)) * Vector.Dot(d, gDir);

                var f_mid = gDir * ld.Magnitude * (l.Length);//uniform load as concentrated load at middle
                var m     = Vector.Cross(d, f_mid);

                var expectedForce = new Force(f_mid, m);
                var zero          = totEndForces - expectedForce;

                buff.ValidationFailed = !zero.Forces.Length.FEquals(0, epsilon) || !zero.Moments.Length.FEquals(0, epsilon);
            }


            return(buff);
        }
Exemple #3
0
        private void AddBarElementLoad(MeshBuilder bldr, BarElement elm, Point[] localPoints)
        {
            var n = SamplingCount;

            var diagramPoints     = new Point[n]; //Y=Fx or Fy or etc
            var baseDiagramPoints = new Point[n]; //Y=0



            #region calculating the graph nodes

            var delta = (elm.EndNode.Location - elm.StartNode.Location).Length / (SamplingCount - 1);

            var xs = Enumerable.Range(0, SamplingCount).Select(i => i * delta).ToList();

            var st = elm.StartNode.Location;

            var tr = elm.GetTransformationManager();

            for (var i = 0; i < n; i++)
            {
                var x           = delta * i;
                var localPoint  = localPoints[i];//new Vector(x, y*scale, z*scale);
                var globalPoint = st + tr.TransformLocalToGlobal((Vector)localPoint);

                var globalBase = st + tr.TransformLocalToGlobal(new Vector(x, 0, 0));

                diagramPoints[i]     = globalPoint;
                baseDiagramPoints[i] = globalBase;
            }


            #endregion

            for (var i = 0; i < n - 1; i++)
            {
                var p1 = baseDiagramPoints[i];
                var p2 = baseDiagramPoints[i + 1];
                var p3 = diagramPoints[i];
                var p4 = diagramPoints[i + 1];

                var p13d = new Point3D(p1.X, p1.Y, p1.Z);
                var p23d = new Point3D(p2.X, p2.Y, p2.Z);
                var p33d = new Point3D(p3.X, p3.Y, p3.Z);
                var p43d = new Point3D(p4.X, p4.Y, p4.Z);


                bldr.AddTriangle(p13d, p23d, p33d);
                bldr.AddTriangle(p33d, p23d, p43d);
            }
        }
Exemple #4
0
        private void AddBarElement(MeshBuilder bldr, BarElement elm)
        {
            PolygonYz section = null;

            var r = ElementVisualThickness / 2;


            if (elm.Section is Sections.UniformParametric1DSection)
            {
                section = new PolygonYz(
                    new PointYZ(-r, -r),
                    new PointYZ(-r, r),
                    new PointYZ(r, r),
                    new PointYZ(r, -r),
                    new PointYZ(-r, -r));
            }
            else
            {
                section = new PolygonYz((elm.Section as Sections.UniformGeometric1DSection).Geometry);
            }

            var tr = elm.GetTransformationManager();


            for (var i = 0; i < section.Count - 1; i++)
            {
                var v1 = new Vector(0, section[i].Y, section[i].Z);
                var v2 = new Vector(0, section[i + 1].Y, section[i + 1].Z);

                var p1 = elm.StartNode.Location + tr.TransformLocalToGlobal(v1);
                var p2 = elm.StartNode.Location + tr.TransformLocalToGlobal(v2);

                var v = elm.EndNode.Location - elm.StartNode.Location;

                if (Math.Abs(v.Z) < 0.01)
                {
                    Guid.NewGuid();
                }

                var p3 = p1 + v;
                var p4 = p2 + v;

                var p13d = new Point3D(p1.X, p1.Y, p1.Z);
                var p23d = new Point3D(p2.X, p2.Y, p2.Z);
                var p33d = new Point3D(p3.X, p3.Y, p3.Z);
                var p43d = new Point3D(p4.X, p4.Y, p4.Z);

                bldr.AddTriangle(p13d, p33d, p23d);
                bldr.AddTriangle(p43d, p23d, p33d);
            }
        }