Exemple #1
0
        public void DoesModelSolve()
        {
            spring1.ToSharpElement(model);

            nodeSupport1.ToSharpSupport(model);
            nodeSupport2.ToSharpSupport(model);
            nodalLoad1.ToSharpLoad(model);

            model.Solve();
        }
        public void Truss()
        {
            model = new GH_Model(ModelType.Full3D);

            GH_CrossSection crossSection = new GH_RectangularCrossSection(100, 100);
            GH_Material     material     = new GH_ElasticMaterial(100, 100, 100, 100);


            Point3d p1 = new Point3d(-10, 0, 0);
            Point3d p2 = new Point3d(0, 0, 0);
            Point3d p3 = new Point3d(10, 0, 0);
            Point3d p4 = new Point3d(-10, 0, 10);
            Point3d p5 = new Point3d(0, 0, 10);
            Point3d p6 = new Point3d(10, 0, 10);



            model.Elements.Add(new GH_Beam(p1, p2, crossSection, material));
            model.Elements.Add(new GH_Beam(p2, p3, crossSection, material));
            model.Elements.Add(new GH_Beam(p4, p5, crossSection, material));
            model.Elements.Add(new GH_Beam(p5, p6, crossSection, material));
            model.Elements.Add(new GH_Beam(p1, p4, crossSection, material));
            model.Elements.Add(new GH_Beam(p2, p5, crossSection, material));
            model.Elements.Add(new GH_Beam(p3, p6, crossSection, material));
            model.Elements.Add(new GH_Beam(p4, p2, crossSection, material));
            model.Elements.Add(new GH_Beam(p2, p6, crossSection, material));
            model.Supports.Add(new GH_NodeSupport(p1, true, true, true, true, true, true));
            model.Supports.Add(new GH_NodeSupport(p3, true, true, true, true, true, true));
            model.Loads.Add(new GH_NodalLoad(p5, new Vector3d(0, 0, -1000), new Vector3d(0, 0, 0)));

            model.AssembleSharpModel();


            Assert.AreEqual(9, model.Model.ElementCount);

            model.Solve();


            Assert.NotNull(model.Results);



            Vector3d displacement = model.GetNodeDisplacement(1);                             //Displacement at point2 (index 1)

            Assert.NotNull(displacement);
            Assert.AreEqual(0.0, displacement.X, 0.001);
            Assert.AreEqual(0.0, displacement.Y, 0.001);
            Assert.AreNotEqual(0.0, displacement.Z);             //TODO Calculate real value
        }
        public void DoesModelSolve()
        {
            beam1.ToSharpElement(model);
            beam2.ToSharpElement(model);
            beam3.ToSharpElement(model);

            nodeSupport1.ToSharpSupport(model);
            nodeSupport2.ToSharpSupport(model);


            IFiniteElementNode node1 = model.Model.FindNodeNearTo(point1);

            Assert.IsTrue(model.Model.IsConstrained(node1, DegreeOfFreedom.X));
            Assert.IsTrue(model.Model.IsConstrained(node1, DegreeOfFreedom.Y));
            Assert.IsTrue(model.Model.IsConstrained(node1, DegreeOfFreedom.Z));
            Assert.IsTrue(model.Model.IsConstrained(node1, DegreeOfFreedom.XX));
            Assert.IsTrue(model.Model.IsConstrained(node1, DegreeOfFreedom.YY));
            Assert.IsTrue(model.Model.IsConstrained(node1, DegreeOfFreedom.ZZ));

            IFiniteElementNode node4 = model.Model.FindNodeNearTo(point4);

            Assert.IsTrue(model.Model.IsConstrained(node4, DegreeOfFreedom.X));
            Assert.IsTrue(model.Model.IsConstrained(node4, DegreeOfFreedom.Y));
            Assert.IsTrue(model.Model.IsConstrained(node4, DegreeOfFreedom.Z));
            Assert.IsTrue(model.Model.IsConstrained(node4, DegreeOfFreedom.XX));
            Assert.IsTrue(model.Model.IsConstrained(node4, DegreeOfFreedom.YY));
            Assert.IsTrue(model.Model.IsConstrained(node4, DegreeOfFreedom.ZZ));

            nodalLoad1.ToSharpLoad(model);

            Assert.AreEqual(3, model.Model.ElementCount);

            model.Solve();

            Assert.NotNull(model.Results);

            IFiniteElementNode node2 = model.Model.FindNodeNearTo(point2);

            Assert.False(model.Model.IsConstrained(node2, DegreeOfFreedom.X));
            Assert.False(model.Model.IsConstrained(node2, DegreeOfFreedom.Y));
            Assert.False(model.Model.IsConstrained(node2, DegreeOfFreedom.Z));

            DisplacementVector displacement = model.Results.GetDisplacement(node2);

            Assert.NotNull(displacement);
            Assert.AreNotEqual(0.0, displacement.X);
            Assert.AreEqual(0.0, displacement.Y, 0.001);
        }
        public void DoesModelSolve()
        {
            beam1.ToSharpElement(model);
            beam2.ToSharpElement(model);
            beam3.ToSharpElement(model);


            nodeSupport1.ToSharpSupport(model);
            nodeSupport2.ToSharpSupport(model);


            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[0], DegreeOfFreedom.X));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[0], DegreeOfFreedom.Y));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[0], DegreeOfFreedom.Z));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[0], DegreeOfFreedom.XX));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[0], DegreeOfFreedom.YY));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[0], DegreeOfFreedom.ZZ));


            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[3], DegreeOfFreedom.X));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[3], DegreeOfFreedom.Y));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[3], DegreeOfFreedom.Z));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[3], DegreeOfFreedom.XX));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[3], DegreeOfFreedom.YY));
            Assert.IsTrue(model.Model.IsConstrained(model.Nodes[3], DegreeOfFreedom.ZZ));

            nodalLoad1.ToSharpLoad(model);

            Assert.AreEqual(3, model.Model.ElementCount);

            model.Solve();


            Assert.NotNull(model.Results);

            Assert.False(model.Model.IsConstrained(model.Nodes[1], DegreeOfFreedom.X));
            Assert.False(model.Model.IsConstrained(model.Nodes[1], DegreeOfFreedom.Y));
            Assert.False(model.Model.IsConstrained(model.Nodes[1], DegreeOfFreedom.Z));


            DisplacementVector displacement = model.Results.GetDisplacement(model.Nodes[1]);

            Assert.NotNull(displacement);
            Assert.AreNotEqual(0.0, displacement.X);
            Assert.AreEqual(0.0, displacement.Y, 0.001);
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // Declare a variable for the input
            GH_Model model = null;

            // Use the DA object to retrieve the data inside the first input parameter.
            // If the retieval fails (for example if there is no data) we need to abort.
            if (!DA.GetData(0, ref model))
            {
                return;
            }


            model.Solve();


            DA.SetData(0, model);
        }