예제 #1
0
파일: Panel.cs 프로젝트: PawelBee/Guanaco
        /***************************************************/

        // Convert panel information to CCX format.
        public override List <string> ToCCX()
        {
            string panelType;

            switch (this._feType)
            {
            case Element2D.Element2DType.Shell:
                panelType = "*SHELL";
                break;

            case Element2D.Element2DType.Membrane:
                panelType = "*MEMBRANE";
                break;

            default:
                throw new Exception(String.Format("{0} is not supported in the current implementation of Guanaco.", this._feType));
            }
            List <string> CCXFormat = new List <string> {
                "*ORIENTATION,NAME=ORPANEL" + this.CCXId()
            };

            CCXFormat.Add(GuanacoUtil.RhinoVectorToString(this._lcs.XAxis) + "," + GuanacoUtil.RhinoVectorToString(this._lcs.YAxis));
            CCXFormat.Add("*ELSET,ELSET=PANEL" + this.CCXId());
            CCXFormat.AddRange(GuanacoUtil.IntsToCCX(this._elements.Select(e => e.Id.AsInteger), true));
            CCXFormat.Add(panelType + " SECTION,MATERIAL=" + this._material.Name + ",ELSET=PANEL" + this.CCXId() + ",ORIENTATION=ORPANEL" + this.CCXId());
            CCXFormat.Add(this._thickness.ToString(GuanacoUtil.Invariant));
            return(CCXFormat);
        }
예제 #2
0
파일: Bar.cs 프로젝트: PawelBee/Guanaco
        /***************************************************/

        // Convert bar information to CCX format.
        public override List <string> ToCCX()
        {
            Plane orLCS = new Plane(this._lcs);

            orLCS.Rotate(this._rotation, orLCS.ZAxis);

            List <string> CCXFormat = new List <string> {
                "*ORIENTATION,NAME=ORBAR" + this.CCXId()
            };

            CCXFormat.Add(GuanacoUtil.RhinoVectorToString(orLCS.XAxis) + "," + GuanacoUtil.RhinoVectorToString(orLCS.YAxis));
            CCXFormat.Add("*ELSET,ELSET=BAR" + this.CCXId());
            CCXFormat.AddRange(GuanacoUtil.IntsToCCX(this._elements.Select(e => e.Id.AsInteger), true));
            string[] profileInfo = this._profile.ToCCXFormat();
            string   barInfo     = profileInfo[0] + ",MATERIAL=" + this._material.Name + ",ELSET=BAR" + this.CCXId() + ",ORIENTATION=ORBAR" + this.CCXId() + ",";

            if (this._offset.X != 0)
            {
                barInfo += "OFFSET1=" + (this._offset.X / this._profile.GetHeight()).ToString(GuanacoUtil.Invariant) + ",";
            }
            if (this._offset.Y != 0)
            {
                barInfo += "OFFSET2=" + (this._offset.Y / this._profile.GetWidth()).ToString(GuanacoUtil.Invariant) + ",";
            }
            barInfo += profileInfo[1];

            CCXFormat.Add(barInfo);
            CCXFormat.Add(profileInfo[2]);
            CCXFormat.Add(GuanacoUtil.RhinoVectorToString(orLCS.XAxis));

            return(CCXFormat);
        }
예제 #3
0
        /***************************************************/

        // Convert list of integers to CCX format.
        public static List <string> IntsToCCX(IEnumerable <int> ints, bool toCCXIds = false)
        {
            List <int> data = new List <int>(ints);

            if (toCCXIds)
            {
                for (int i = 0; i < data.Count; i++)
                {
                    data[i]++;
                }
            }

            List <string> CCXFormat = new List <string>();

            foreach (List <int> chnk in GuanacoUtil.Chunks(data, 16))
            {
                CCXFormat.Add(string.Join(",", chnk) + ",");
            }

            if (CCXFormat.Count != 0)
            {
                CCXFormat[CCXFormat.Count - 1] = CCXFormat.Last().TrimEnd(',');
            }

            return(CCXFormat);
        }
예제 #4
0
        /***************************************************/

        // Apply infill load to the adjoining elements.
        private void ApplyLoad(InfillLoad load)
        {
            foreach (Element e in this._mesh.Elements)
            {
                // Check if the element is 2D.
                Element2D el = e as Element2D;
                if (el == null)
                {
                    continue;
                }

                Point3d  elC = el.GetCentroid();
                Vector3d elN = el.GetNormal();
                foreach (Infill i in load.Infills)
                {
                    // Check if the element is adjoining to the infill (if all its vertices lie within tolerance).
                    bool broken = false;
                    foreach (Point3d v in el.GetVertices())
                    {
                        if (v.DistanceTo(i.Volume.ClosestPoint(v)) > this._tolerance)
                        {
                            broken = true;
                            break;
                        }
                    }

                    // If the element is adjoining to the infill, apply the load based on location of the element and load function of the infill.
                    if (!broken)
                    {
                        // Flip normal of the element if it points outside the infill.
                        Point3d cpt = Point3d.Add(elC, elN * this._tolerance);
                        if (!i.Volume.IsPointInside(cpt, Rhino.RhinoMath.SqrtEpsilon, true))
                        {
                            el.FlipNormal();
                        }

                        // Check if the element is not surrounded by the infill from both sides - if it is then do nothing (no hydrostatic pressure).
                        else
                        {
                            cpt = Point3d.Add(elC, -elN * this._tolerance);
                            if (i.Volume.IsPointInside(cpt, Rhino.RhinoMath.SqrtEpsilon, true))
                            {
                                continue;
                            }
                        }

                        // Apply the load based on location of the element and load function of the infill.
                        string g = load.InfillDensity.ToString(GuanacoUtil.Invariant);
                        string x = (i.MaxZ - elC.Z).ToString(GuanacoUtil.Invariant);
                        string z = (i.MaxZ - i.MinZ).ToString(GuanacoUtil.Invariant);
                        string f = load.LoadFunction.Replace("g", g).Replace("x", x).Replace("z", z);
                        double p = GuanacoUtil.Evaluate(f);
                        el.AddPressure(-p);
                    }
                }
            }
        }
예제 #5
0
파일: Support.cs 프로젝트: PawelBee/Guanaco
        /***************************************************/

        // Convert support information to CCX format.
        public List <string> ToCCX()
        {
            List <string> CCXFormat = new List <string>();

            CCXFormat.Add("*NSET,NSET=Support_" + this._name);

            CCXFormat.AddRange(GuanacoUtil.IntsToCCX(this._nodes.Select(n => n.Id.AsInteger).ToList(), true));

            CCXFormat.Add("*BOUNDARY");

            foreach (int dof in this._supportType.DOFs)
            {
                CCXFormat.Add("Support_" + this._name + ", " + dof.ToString(GuanacoUtil.Invariant));
            }

            return(CCXFormat);
        }
예제 #6
0
        /***************************************************/

        // Convert element information to CCX format.
        public override List <string> ToCCX()
        {
            List <string> ss = new List <string>();
            string        s  = this.CCXId() + ",";

            foreach (List <int> chnk in GuanacoUtil.Chunks(this._nodes.Select(n => n.Id.AsInteger).ToList(), 15))
            {
                foreach (int n in chnk)
                {
                    s += ((n + 1).ToString() + ",");
                }
                ss.Add(s);
                s = string.Empty;
            }

            ss[ss.Count - 1] = ss.Last().TrimEnd(',');
            return(ss);
        }