Beispiel #1
0
        public static SpeckleObject ToSpeckle(this GSA0DLoad dummyObject)
        {
            var newLines = ToSpeckleBase <GSA0DLoad>();

            var loads = new List <GSA0DLoad>();

            var nodes = Initialiser.GSASenderObjects[typeof(GSANode)].Cast <GSANode>().ToList();


            foreach (var p in newLines.Values)
            {
                var loadSubList = new List <GSA0DLoad>();

                // Placeholder load object to get list of nodes and load values
                // Need to transform to axis so one load definition may be transformed to many
                var initLoad = new GSA0DLoad()
                {
                    GWACommand = p
                };
                initLoad.ParseGWACommand(nodes);

                // Raise node flag to make sure it gets sent
                foreach (var n in nodes.Where(n => initLoad.Value.NodeRefs.Contains(n.Value.ApplicationId)))
                {
                    n.ForceSend = true;
                }

                // Create load for each node applied
                foreach (string nRef in initLoad.Value.NodeRefs)
                {
                    var load = new GSA0DLoad
                    {
                        GWACommand    = initLoad.GWACommand,
                        SubGWACommand = new List <string>(initLoad.SubGWACommand)
                    };
                    load.Value.Name        = initLoad.Value.Name;
                    load.Value.LoadCaseRef = initLoad.Value.LoadCaseRef;

                    // Transform load to defined axis
                    var            node      = nodes.Where(n => (n.Value.ApplicationId == nRef)).First();
                    string         gwaRecord = null;
                    StructuralAxis loadAxis  = HelperClass.Parse0DAxis(initLoad.Axis, Initialiser.Interface, out gwaRecord, node.Value.Value.ToArray());
                    load.Value.Loading = initLoad.Value.Loading;
                    load.Value.Loading.TransformOntoAxis(loadAxis);

                    // If the loading already exists, add node ref to list
                    var match = loadSubList.Count() > 0 ? loadSubList.Where(l => (l.Value.Loading.Value as List <double>).SequenceEqual(load.Value.Loading.Value as List <double>)).First() : null;
                    if (match != null)
                    {
                        match.Value.NodeRefs.Add(nRef);
                        if (gwaRecord != null)
                        {
                            match.SubGWACommand.Add(gwaRecord);
                        }
                    }
                    else
                    {
                        load.Value.NodeRefs = new List <string>()
                        {
                            nRef
                        };
                        if (gwaRecord != null)
                        {
                            load.SubGWACommand.Add(gwaRecord);
                        }
                        loadSubList.Add(load);
                    }
                }

                loads.AddRange(loadSubList);
            }

            Initialiser.GSASenderObjects[typeof(GSA0DLoad)].AddRange(loads);

            return((loads.Count() > 0) ? new SpeckleObject() : new SpeckleNull());
        }
Beispiel #2
0
        public void ParseGWACommand()
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new Structural2DLoadPanel();

            var pieces = this.GWACommand.ListSplit("\t");

            var counter = 1; // Skip identifier

            obj.Name          = pieces[counter++].Trim(new char[] { '"' });
            obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId);

            HelperClass.GetGridPlaneRef(Convert.ToInt32(pieces[counter++]), out int gridPlaneRefRet, out string gridSurfaceRec);
            HelperClass.GetGridPlaneData(gridPlaneRefRet, out int gridPlaneAxis, out double gridPlaneElevation, out string gridPlaneRec);

            this.SubGWACommand.Add(gridSurfaceRec);
            this.SubGWACommand.Add(gridPlaneRec);

            string gwaRec = null;
            var    axis   = HelperClass.Parse0DAxis(gridPlaneAxis, Initialiser.Interface, out gwaRec);

            if (gwaRec != null)
            {
                this.SubGWACommand.Add(gwaRec);
            }
            double elevation = gridPlaneElevation;

            var polylineDescription = "";

            switch (pieces[counter++])
            {
            case "PLANE":
                // TODO: Do not handle for now
                return;

            case "POLYREF":
                var    polylineRef = pieces[counter++];
                string newRec      = null;
                HelperClass.GetPolylineDesc(Convert.ToInt32(polylineRef), out polylineDescription, out newRec);
                this.SubGWACommand.Add(newRec);
                break;

            case "POLYGON":
                polylineDescription = pieces[counter++];
                break;
            }
            var polyVals = HelperClass.ParsePolylineDesc(polylineDescription);

            for (var i = 2; i < polyVals.Length; i += 3)
            {
                polyVals[i] = elevation;
            }

            obj.Value  = HelperClass.MapPointsLocal2Global(polyVals, axis).ToList();
            obj.Closed = true;

            var loadCaseIndex = Convert.ToInt32(pieces[counter++]);

            if (loadCaseIndex > 0)
            {
                obj.LoadCaseRef = HelperClass.GetApplicationId(typeof(GSALoadCase).GetGSAKeyword(), loadCaseIndex);
            }

            var            loadAxisId   = 0;
            var            loadAxisData = pieces[counter++];
            StructuralAxis loadAxis;

            if (loadAxisData == "LOCAL")
            {
                loadAxis = axis;
            }
            else
            {
                loadAxisId = loadAxisData == "GLOBAL" ? 0 : Convert.ToInt32(loadAxisData);
                loadAxis   = HelperClass.Parse0DAxis(loadAxisId, Initialiser.Interface, out gwaRec);
                if (gwaRec != null)
                {
                    this.SubGWACommand.Add(gwaRec);
                }
            }
            var projected = pieces[counter++] == "YES";
            var direction = pieces[counter++];
            var value     = Convert.ToDouble(pieces[counter++]);

            obj.Loading = new StructuralVectorThree(new double[3]);
            switch (direction.ToUpper())
            {
            case "X":
                obj.Loading.Value[0] = value;
                break;

            case "Y":
                obj.Loading.Value[1] = value;
                break;

            case "Z":
                obj.Loading.Value[2] = value;
                break;

            default:
                // TODO: Error case maybe?
                break;
            }
            obj.Loading.TransformOntoAxis(loadAxis);

            if (projected)
            {
                var scale = (obj.Loading.Value[0] * axis.Normal.Value[0] +
                             obj.Loading.Value[1] * axis.Normal.Value[1] +
                             obj.Loading.Value[2] * axis.Normal.Value[2]) /
                            (axis.Normal.Value[0] * axis.Normal.Value[0] +
                             axis.Normal.Value[1] * axis.Normal.Value[1] +
                             axis.Normal.Value[2] * axis.Normal.Value[2]);

                obj.Loading = new StructuralVectorThree(axis.Normal.Value[0], axis.Normal.Value[1], axis.Normal.Value[2]);
                obj.Loading.Scale(scale);
            }

            this.Value = obj;
        }
Beispiel #3
0
        public void ParseGWACommand()
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new StructuralNode();

            var pieces = this.GWACommand.ListSplit("\t");

            var counter = 1; // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);
            obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId);
            obj.Name          = pieces[counter++].Trim(new char[] { '"' });
            counter++; // Color
            obj.Value = new List <double>
            {
                Convert.ToDouble(pieces[counter++]),
                Convert.ToDouble(pieces[counter++]),
                Convert.ToDouble(pieces[counter++])
            };

            //counter += 3; // TODO: Skip unknown fields in NODE.3

            while (counter < pieces.Length)
            {
                var s = pieces[counter++];

                switch (s)
                {
                case "NO_GRID":
                case "NO_REST":
                case "NO_MESH":
                case "NO_STIFF":
                    continue;

                case "GRID":
                    counter++; // Grid place
                    counter++; // Datum
                    counter++; // Grid line A
                    counter++; // Grid line B
                    break;

                case "REST":
                    obj.Restraint = new StructuralVectorBoolSix(new bool[6]);
                    for (var i = 0; i < 6; i++)
                    {
                        obj.Restraint.Value[i] = pieces[counter++] == "0" ? false : true;
                    }
                    this.ForceSend = true;
                    break;

                case "STIFF":
                    obj.Stiffness = new StructuralVectorSix(new double[6]);
                    for (var i = 0; i < 6; i++)
                    {
                        obj.Stiffness.Value[i] = Convert.ToDouble(pieces[counter++]);
                    }
                    this.ForceSend = true;
                    break;

                case "MESH":
                    obj.GSALocalMeshSize = pieces[counter++].ToDouble();
                    counter++; // Edge length
                    counter++; // Radius
                    counter++; // Tie to mesh
                    counter++; // Column rigidity
                    counter++; // Column prop
                    counter++; // Column node
                    counter++; // Column angle
                    counter++; // Column factor
                    counter++; // Column slab factor
                    break;

                default: // Axis
                    string gwaRec = null;
                    obj.Axis = HelperClass.Parse0DAxis(Convert.ToInt32(s), Initialiser.Interface, out gwaRec, obj.Value.ToArray());
                    if (gwaRec != null)
                    {
                        this.SubGWACommand.Add(gwaRec);
                    }
                    break;
                }
            }

            this.Value = obj;
        }
Beispiel #4
0
        public void ParseGWACommand(List <GSANode> nodes)
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var obj = new StructuralNodalInfluenceEffect();

            var pieces = this.GWACommand.ListSplit("\t");

            var counter = 1; // Skip identifier

            obj.Name           = pieces[counter++].Trim(new char[] { '"' });
            obj.GSAEffectGroup = Convert.ToInt32(pieces[counter++]);

            var targetNodeRef = pieces[counter++];

            GSANode targetNode;

            if (nodes != null)
            {
                targetNode = nodes.Where(n => targetNodeRef == n.GSAId.ToString()).FirstOrDefault();

                obj.NodeRef = targetNode.Value.ApplicationId;

                this.SubGWACommand.Add(targetNode.GWACommand);

                targetNode.ForceSend = true;
            }
            else
            {
                return;
            }

            obj.Factor = Convert.ToDouble(pieces[counter++]);
            var effectType = pieces[counter++];

            switch (effectType)
            {
            case "DISP":
                obj.EffectType = StructuralInfluenceEffectType.Displacement;
                break;

            case "FORCE":
                obj.EffectType = StructuralInfluenceEffectType.Force;
                break;

            default:
                return;
            }

            var axis = pieces[counter++];

            if (axis == "GLOBAL")
            {
                obj.Axis = HelperClass.Parse0DAxis(0, Initialiser.Interface, out var temp);
            }
            else if (axis == "LOCAL")
            {
                obj.Axis = targetNode.Value.Axis;
            }
            else
            {
                obj.Axis = HelperClass.Parse0DAxis(Convert.ToInt32(axis), Initialiser.Interface, out string rec, targetNode.Value.Value.ToArray());
                if (rec != null)
                {
                    this.SubGWACommand.Add(rec);
                }
            }

            var dir = pieces[counter++];

            obj.Directions = new StructuralVectorBoolSix(new bool[6]);
            switch (dir.ToLower())
            {
            case "x":
                obj.Directions.Value[0] = true;
                break;

            case "y":
                obj.Directions.Value[1] = true;
                break;

            case "z":
                obj.Directions.Value[2] = true;
                break;

            case "xx":
                obj.Directions.Value[3] = true;
                break;

            case "yy":
                obj.Directions.Value[4] = true;
                break;

            case "zz":
                obj.Directions.Value[5] = true;
                break;
            }

            this.Value = obj;
        }
Beispiel #5
0
        public void ParseGWACommand()
        {
            if (this.GWACommand == null)
            {
                return;
            }

            var pieces = this.GWACommand.ListSplit("\t");

            var obj = new StructuralSpringProperty();

            var counter = 1; // Skip identifier

            this.GSAId        = Convert.ToInt32(pieces[counter++]);
            obj.ApplicationId = HelperClass.GetApplicationId(this.GetGSAKeyword(), this.GSAId);
            obj.Name          = pieces[counter++].Trim(new char[] { '"' });
            counter++; //Skip colour
            var gsaAxis = pieces[counter++];

            if (gsaAxis == "GLOBAL")
            {
                obj.Axis = HelperClass.Parse0DAxis(0, Initialiser.Interface, out var gwaRec);
            }
            else if (gsaAxis == "VERTICAL")
            {
                obj.Axis = HelperClass.Parse0DAxis(-14, Initialiser.Interface, out var gwaRec);
            }
            else
            {
                obj.Axis = HelperClass.Parse0DAxis(Convert.ToInt32(gsaAxis), Initialiser.Interface, out var gwaRec);
                this.SubGWACommand.Add(gwaRec);
            }

            var springPropertyType = pieces[counter++];

            var stiffnesses  = new double[6];
            var dampingRatio = 0d;

            switch (springPropertyType.ToLower())
            {
            case "axial":
                obj.SpringType = StructuralSpringPropertyType.Axial;
                double.TryParse(pieces[counter++], out stiffnesses[0]);
                break;

            case "compression":
                obj.SpringType = StructuralSpringPropertyType.Compression;
                double.TryParse(pieces[counter++], out stiffnesses[0]);
                break;

            case "tension":
                obj.SpringType = StructuralSpringPropertyType.Tension;
                double.TryParse(pieces[counter++], out stiffnesses[0]);
                break;

            case "gap":
                obj.SpringType = StructuralSpringPropertyType.Gap;
                double.TryParse(pieces[counter++], out stiffnesses[0]);
                break;

            case "friction":
                obj.SpringType = StructuralSpringPropertyType.Friction;
                double.TryParse(pieces[counter++], out stiffnesses[0]);
                double.TryParse(pieces[counter++], out stiffnesses[1]);
                double.TryParse(pieces[counter++], out stiffnesses[2]);
                counter++; //Coefficient of friction, not supported yet
                break;

            case "torsional":
                // TODO: As of build 48 of GSA, the torsional stiffness is not extracted in GWA records
                //return;
                obj.SpringType = StructuralSpringPropertyType.Torsional;
                double.TryParse(pieces[counter++], out stiffnesses[3]);
                break;

            case "lockup":
                obj.SpringType = StructuralSpringPropertyType.Lockup;
                double.TryParse(pieces[counter++], out stiffnesses[0]);
                break;

            case "general":
                obj.SpringType = StructuralSpringPropertyType.General;
                counter--;
                for (var i = 0; i < 6; i++)
                {
                    double.TryParse(pieces[counter += 2], out stiffnesses[i]);
                }
                counter++;
                double.TryParse(pieces[counter], out dampingRatio);
                break;

            default:
                return;
            }
            ;

            obj.Stiffness = new StructuralVectorSix(stiffnesses);

            double.TryParse(pieces[counter++], out dampingRatio);
            //Found some extremely small floating point issues so rounding to (arbitrarily-chosen) 4 digits
            obj.DampingRatio = Math.Round(dampingRatio, 4);

            this.Value = obj;
        }