Пример #1
0
        /// <summary>
        /// Convert a Nucleus Linear Element to a Rhino Extrusion, if possible
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static RC.Extrusion ConvertToExtrusion(LinearElement element)
        {
            Curve           perimeter = element?.Family?.Profile?.Perimeter;
            CurveCollection voids     = element?.Family?.Profile?.Voids;

            if (perimeter != null && element.Geometry != null)
            {
                RC.Curve profile = Convert(perimeter);
                var      cSystem = element.Geometry.LocalCoordinateSystem(0, element.Orientation);
                if (element.Geometry is Line)
                {
                    //If a line, create an extrusion:
                    RC.Extrusion ext = new RC.Extrusion();
                    ext.SetPathAndUp(
                        Convert(element.Geometry.EndPoint), Convert(element.Geometry.StartPoint),
                        ConvertVector(cSystem.Z));
                    ext.SetOuterProfile(profile, true);
                    if (voids != null)
                    {
                        var voidCrvs = Convert(voids);
                        foreach (var rCrv in voidCrvs)
                        {
                            ext.AddInnerProfile(rCrv);
                        }
                    }
                    //RC.Surface surface = RC.Extrusion.CreateExtrusion(profile, new RC.Vector3d(Convert(element.End.Position - element.Start.Position)));
                    return(ext);
                }
            }
            return(null);
        }
Пример #2
0
        /// <summary>
        /// Convert a LinearElement to a Rhino Brep
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static RC.Brep ConvertToBrep(LinearElement element)
        {
            if (element.Geometry is Line)
            {
                return(ConvertToExtrusion(element)?.ToBrep());
            }
            else
            {
                Curve           perimeter = element?.Family?.Profile?.Perimeter;
                CurveCollection voids     = element?.Family?.Profile?.Voids;
                if (perimeter != null && element.Geometry != null)
                {
                    //TODO: Deal with voids!

                    RC.Curve profile = Convert(perimeter);
                    var      cSystem = element.Geometry.LocalCoordinateSystem(0, element.Orientation);

                    RC.Plane startPlane = Convert(cSystem.YZPlane());
                    profile.Transform(RC.Transform.PlaneToPlane(RC.Plane.WorldXY, startPlane));
                    RC.Brep[] breps = RC.Brep.CreateFromSweep(Convert(element.Geometry), profile, false, 0.001); //TODO: Change tolerance
                    if (breps.Length > 0)
                    {
                        return(breps[0]);
                    }
                }
            }
            return(null);
        }
Пример #3
0
        /// <summary>
        /// Constructor for a StructAnalysis1DElement section preview
        /// </summary>
        /// <param name="element"></param>
        public RhinoMeshAvatar(LinearElement element)
        {
            RhinoMeshBuilder rmb = new RhinoMeshBuilder();

            rmb.AddSectionPreview(element);
            RenderMesh = rmb.Mesh;
            RenderMesh.Normals.ComputeNormals();
        }
Пример #4
0
        /// <summary>
        /// Creates an iterator starting at
        /// a component and vertex in a linear <see cref="Geometry" />.
        /// </summary>
        /// <param name="linear">The linear geometry to iterate over.</param>
        /// <param name="componentIndex">The component to start at.</param>
        /// <param name="vertexIndex">The vertex to start at.</param>
        public LinearIterator(IGeometry linear, int componentIndex, int vertexIndex)
        {
            startComponentIndex = componentIndex;
            startVertexIndex    = vertexIndex;

            this.linear = linear;
            Reset();

            current = new LinearElement(this);
        }
Пример #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="dispose"></param>
        protected void Dispose(bool dispose)
        {
            if (dispose)
            {
                // Dispose unmanaged resources
            }

            // Dispose managed resources
            current     = null;
            currentLine = null;
        }
Пример #6
0
        /// <summary>
        /// Calculate the deformed centreline geometry of a linear element
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public Curve DeformedGeometry(LinearElement element, ResultsCase rCase)
        {
            var    sNode = element.StartNode;
            var    eNode = element.EndNode;
            Vector sDef  = this[sNode, rCase]?.GetMaxDisplacementVector() ?? Vector.Zero;
            Vector eDef  = this[eNode, rCase]?.GetMaxDisplacementVector() ?? Vector.Zero;

            // TODO: Add in offsets + rotation
            // TODO: Add in element deflection
            return(new Line(sNode.Position + sDef, sNode.Position + eDef));
        }
 public override bool Execute(ExecutionInfo exInfo = null)
 {
     if (Line.Length > 0)
     {
         Element             = new LinearElement(Line);
         Element.Family      = Section;
         Element.Orientation = Orientation;
         MeshBuilder builder = new MeshBuilder();
         builder.AddSectionPreview(Element);
         Mesh = builder.Mesh;
         return(true);
     }
     return(false);
 }
Пример #8
0
        protected BeamAnalysisBase(LinearElement element, double udl)
        {
            Span = element.Geometry.Length;
            UDL  = udl;
            Material material = element.Family?.GetPrimaryMaterial();

            if (material != null && material is IsoMaterial)
            {
                E = ((IsoMaterial)material).E;
            }
            if (element.Family != null)
            {
                I = element.Family.EquivalentIxx();
            }
        }
Пример #9
0
 /// <summary>
 /// Get the maximum and minimum result interval for the specified case, linear element, type and position
 /// along the element.
 /// </summary>
 /// <param name="rCase"></param>
 /// <param name="element"></param>
 /// <param name="type"></param>
 /// <param name="position"></param>
 /// <returns></returns>
 public Interval this[ResultsCase rCase, LinearElement element, LinearElementResultTypes type, double position]
 {
     get
     {
         var graph = this[rCase, element, type];
         if (graph != null)
         {
             return(graph.ValueAt(position));
         }
         else
         {
             return(Interval.Unset);
         }
     }
 }
Пример #10
0
        public override bool Execute(ExecutionInfo exInfo = null)
        {
            Elements = new ElementCollection();

            if (Geometry != null)
            {
                // Convert each geometry item:
                foreach (VertexGeometry shape in Geometry)
                {
                    if (shape is Curve) // Convert to linear element
                    {
                        LinearElement element = Model.Create.LinearElement((Curve)shape, exInfo);
                        if (FamiliesFromLayers && shape.Attributes != null && !string.IsNullOrWhiteSpace(shape.Attributes.LayerName))
                        {
                            string        layerName = shape.Attributes.LayerName;
                            SectionFamily sF        = Model.Families.Sections.FindByName(layerName);
                            if (sF == null)
                            {
                                sF = Model.Create.SectionFamily(layerName, exInfo);
                            }
                            element.Family = sF;
                        }
                        Elements.Add(element);
                    }
                    else if (shape is Surface) //Reminder: Meshes are also surfaces!
                    {
                        PanelElement element = Model.Create.PanelElement((Surface)shape, exInfo);
                        if (FamiliesFromLayers && shape.Attributes != null && !string.IsNullOrWhiteSpace(shape.Attributes.LayerName))
                        {
                            string        layerName = shape.Attributes.LayerName;
                            BuildUpFamily fF        = Model.Families.PanelFamilies.FindByName(layerName);
                            if (fF == null)
                            {
                                fF = Model.Create.BuildUpFamily(layerName, exInfo);
                            }
                            element.Family = fF;
                        }
                        Elements.Add(element);
                    }
                }
                Elements.GenerateNodes(new NodeGenerationParameters());
                return(true);
            }
            return(false);
        }
Пример #11
0
 public override bool Execute(ExecutionInfo exInfo = null)
 {
     if (Line.Length > 0)
     {
         Element             = Model.Create.LinearElement(Line, exInfo);
         Element.Family      = Section;
         Element.Orientation = Orientation;
         Element.GenerateNodes(new NodeGenerationParameters());
         if (!StartReleases.AllFalse)
         {
             Element.Start.Releases = StartReleases;
         }
         if (!EndReleases.AllFalse)
         {
             Element.End.Releases = EndReleases;
         }
         return(true);
     }
     return(false);
 }
        public void GetKMatrixLinearElementTest()
        {
            //  ElasticCoefficient = E / (1 - v^2)
            double elasticCoefficient = 2.31E+06;

            Node node1 = new Node(0.0, 0.0);
            Node node2 = new Node(1.0, 0.0);

            LinearElement element1 = new LinearElement(node1, node2);

            double[][] dMatrix = MatrixOperations.MatrixCreate(1, 1);
            dMatrix[0][0] = elasticCoefficient;

            element1.SetDMatrix(dMatrix);

            #region Kglobal

            FiniteElementMethodModel model = new FiniteElementMethodModel();

            model.Nodes.Add(node1);
            model.Nodes.Add(node2);
            model.Elements.Add(element1);

            var kGlobal = model.BuildGlobalKMatrix();

            Console.Write(kGlobal.DisplayMatrixToString());

            //  Setting displacements
            double[][] uMatrix = MatrixOperations.MatrixCreate(2, 1);

            uMatrix[0][0] = 0.0;
            uMatrix[1][0] = 0.001;

            //  todo improve matrix inverse and determinant
            double[][] fMatrix = kGlobal.MatrixProduct(uMatrix);

            //  With those strains, this is equivalent to a force of 2310 N applying on the free side
            Assert.AreEqual(-2310, fMatrix[0][0]);
            Assert.AreEqual(2310, fMatrix[1][0]);
            #endregion
        }
Пример #13
0
        public override bool Execute(ExecutionInfo exInfo = null)
        {
            Beams = new LinearElementCollection();
            VertexCollection   verts = new VertexCollection(SupportPoints);
            MeshFaceCollection faces = Mesh.DelaunayTriangulationXY(verts);

            if (Perimeter != null)
            {
                faces.CullOutsideXY(Perimeter);
            }
            faces.Quadrangulate();
            IList <MeshEdge> edges = faces.ExtractUniqueEdges();

            foreach (MeshEdge mE in edges)
            {
                LinearElement lEl = Model.Create.LinearElement(mE.ToLine(), exInfo);
                lEl.Family = BeamSection;
                Beams.Add(lEl);
            }
            PanelBoundaries = faces.ExtractFaceBoundaries();
            return(true);
        }
Пример #14
0
 /// <summary>
 /// Get the stored results (if any) for the specified linear
 /// element and case.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="rCase"></param>
 /// <returns></returns>
 public CaseLinearElementResults this[LinearElement element, ResultsCase rCase]
 {
     get { return(this[element]?[rCase]); }
 }
Пример #15
0
 /// <summary>
 /// Remove an element record
 /// </summary>
 /// <param name="element"></param>
 public void Remove(LinearElement element)
 {
     Remove(BarCategory, element.GUID);
 }
        public void GetKMatrixLinearNElementTest()
        {
            //  ElasticCoefficient = E / (1 - v^2)
            double elasticCoefficient = 2.31E+06;

            Node node1 = new Node(0.0, 0.0);
            Node node2 = new Node(0.25, 0.0);
            Node node3 = new Node(0.5, 0.0);
            Node node4 = new Node(0.75, 0.0);
            Node node5 = new Node(1.0, 0.0);

            LinearElement element1 = new LinearElement(node1, node2);
            LinearElement element2 = new LinearElement(node2, node3);
            LinearElement element3 = new LinearElement(node3, node4);
            LinearElement element4 = new LinearElement(node4, node5);

            double[][] dMatrix = MatrixOperations.MatrixCreate(1, 1);
            dMatrix[0][0] = elasticCoefficient;

            element1.SetDMatrix(dMatrix);
            element2.SetDMatrix(dMatrix);
            element3.SetDMatrix(dMatrix);
            element4.SetDMatrix(dMatrix);

            #region Kglobal

            FiniteElementMethodModel model = new FiniteElementMethodModel();

            model.Nodes.Add(node1);
            model.Nodes.Add(node2);
            model.Nodes.Add(node3);
            model.Nodes.Add(node4);
            model.Nodes.Add(node5);
            model.Elements.Add(element1);
            model.Elements.Add(element2);
            model.Elements.Add(element3);
            model.Elements.Add(element4);

            var kGlobal = model.BuildGlobalKMatrix();

            Console.Write(kGlobal.DisplayMatrixToString());

            //  Setting displacements
            double[][] uMatrix = MatrixOperations.MatrixCreate(5, 1);

            uMatrix[0][0] = 0.0;
            uMatrix[1][0] = 0.00025;
            uMatrix[2][0] = 0.0005;
            uMatrix[3][0] = 0.00075;
            uMatrix[4][0] = 0.001;

            //  todo improve matrix inverse and determinant
            double[][] fMatrix = kGlobal.MatrixProduct(uMatrix);

            //  With those strains, this is equivalent to a force of 2310 N applying on the free side
            Assert.AreEqual(-2310, fMatrix[0][0]);
            Assert.AreEqual(0, fMatrix[1][0]);
            Assert.AreEqual(0, fMatrix[2][0]);
            Assert.AreEqual(0, fMatrix[3][0]);
            Assert.AreEqual(2310, fMatrix[4][0]);

            //  Let's get the submatrix and get its inverse to solve the problem automatically and compare its results

            double[][] subKMatrix = MatrixOperations.MatrixCreate(4, 4);
            double[][] subFMatrix = MatrixOperations.MatrixCreate(4, 1);
            int        i2         = 0;

            for (int i1 = 1; i1 < kGlobal.Length; i1++)
            {
                int j2 = 0;
                for (int j1 = 1; j1 < kGlobal[0].Length; j1++)
                {
                    subKMatrix[i2][j2] = kGlobal[i1][j1];

                    j2++;
                }

                subFMatrix[i2] = fMatrix[i1];
                i2++;
            }

            double[][] subKInverse = subKMatrix.MatrixInverse();
            double[][] newUMatrix  = subKInverse.MatrixProduct(subFMatrix);

            Assert.IsTrue(Math.Abs(uMatrix[1][0] - newUMatrix[0][0]) < 0.001);
            Assert.IsTrue(Math.Abs(uMatrix[2][0] - newUMatrix[1][0]) < 0.001);
            Assert.IsTrue(Math.Abs(uMatrix[3][0] - newUMatrix[2][0]) < 0.001);
            Assert.IsTrue(Math.Abs(uMatrix[4][0] - newUMatrix[3][0]) < 0.001);
            #endregion
        }
Пример #17
0
 public Spring(LinearElement element)
 {
     Element = element;
     Reset();
 }
Пример #18
0
 /// <summary>
 /// Get or set the results table for the specified linear element
 /// </summary>
 /// <param name="element"></param>
 /// <returns></returns>
 public LinearElementResults this[LinearElement element]
 {
     get { return(this[element.GUID] as LinearElementResults); }
     set { this[element.GUID] = value; }
 }
Пример #19
0
 private void HandlesAddRhinoObject(object sender, RhinoObjectEventArgs e)
 {
     if (!RhinoOutput.Writing && !_Replacing)
     {
         if (e.TheObject.Attributes.HasUserData)
         {
             string data = e.TheObject.Attributes.GetUserString("SAL_ORIGINAL");
             if (!string.IsNullOrEmpty(data) && data != e.ObjectId.ToString())
             {
                 Guid storedGuid = new Guid(data);
                 if (this.Links.ContainsSecond(storedGuid))
                 {
                     ModelObject mO = LinkedModelObject(storedGuid);
                     //Create copy of object:
                     if (mO is Element)
                     {
                         VertexGeometry geometry = FromRC.Convert(e.TheObject.Geometry);
                         Element        element  = null;
                         if (mO is LinearElement)
                         {
                             LinearElement lElement = ((LinearElement)mO).Duplicate();//Core.Instance.ActiveDocument?.Model?.Create.CopyOf((Element)mO, geometry);
                             bool          split    = false;
                             if (geometry is Curve)
                             {
                                 Curve newCrv = (Curve)geometry;
                                 if (lElement.Geometry != null)
                                 {
                                     Curve oldCrv = lElement.Geometry;
                                     if (newCrv.Length < oldCrv.Length)
                                     {
                                         //TODO: Check end point distance to curve
                                         double maxDist = 0;
                                         foreach (Vertex v in newCrv.Vertices)
                                         {
                                             double dist = oldCrv.DistanceToSquared(v.Position);
                                             if (dist > maxDist)
                                             {
                                                 maxDist = dist;
                                             }
                                         }
                                         if (maxDist < Tolerance.Distance)
                                         {
                                             split = true;
                                         }
                                     }
                                 }
                                 lElement.ReplaceGeometry(newCrv, split);
                             }
                             lElement.GenerateNodes(new NodeGenerationParameters());
                             element = lElement;
                         }
                         if (mO is PanelElement)
                         {
                             PanelElement pElement = ((PanelElement)mO).Duplicate();//Core.Instance.ActiveDocument?.Model?.Create.CopyOf((Element)mO, geometry);
                             if (geometry is Surface)
                             {
                                 pElement.ReplaceGeometry((Surface)geometry);
                             }
                             element = pElement;
                         }
                         RhinoOutput.SetOriginalIDUserString(e.ObjectId);
                         if (element != null)
                         {
                             Links.Set(element.GUID, e.ObjectId);
                             Core.Instance.ActiveDocument.Model.Add(element);
                         }
                     }
                     else if (mO is Node)
                     {
                         if (e.TheObject.Geometry is RC.Point)
                         {
                             Node     node = ((Node)mO).Duplicate();
                             RC.Point pt   = (RC.Point)e.TheObject.Geometry;
                             node.Position = FromRC.Convert(pt).Position;
                             RhinoOutput.SetOriginalIDUserString(e.ObjectId);
                             Links.Set(node.GUID, e.ObjectId);
                             Core.Instance.ActiveDocument.Model.Add(node);
                         }
                     }
                 }
             }
         }
     }
 }
Пример #20
0
 /// <summary>
 /// Add a new Bar entry to this mapping table
 /// </summary>
 /// <param name="element"></param>
 /// <param name="bar"></param>
 public void Add(LinearElement element, IRobotBar bar)
 {
     Add(BarCategory, element.GUID, bar.Number.ToString());
 }
Пример #21
0
 /// <summary>
 /// Get the results table for the specified linear element under the specified case
 /// </summary>
 /// <param name="rCase"></param>
 /// <param name="element"></param>
 /// <returns></returns>
 public LinearElementResults this[ResultsCase rCase, LinearElement element]
 {
     get { return(this[rCase]?[element]); }
 }
Пример #22
0
 /// <summary>
 /// Adds the results for the specified linear element to the store.
 /// </summary>
 /// <param name="element"></param>
 /// <param name="results"></param>
 public void Add(LinearElement element, LinearElementResults results)
 {
     Add(element.GUID, results);
 }
Пример #23
0
 /// <summary>
 /// Get the results interval graph along the specified linear element for the given
 /// case and result type
 /// </summary>
 /// <param name="rCase"></param>
 /// <param name="element"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public LinearIntervalDataSet this[ResultsCase rCase, LinearElement element, LinearElementResultTypes type]
 {
     get { return(this[rCase, element]?[type]); }
 }
Пример #24
0
 /// <summary>
 /// Initialise a beam calculation for the specified element under the specified load
 /// </summary>
 /// <param name="element"></param>
 /// <param name="udl"></param>
 public SimpleBeamAnalysis(LinearElement element, double udl = 0) : base(element, udl)
 {
 }