Example #1
0
        /***************************************************/
        /**** Private method - Extraction methods       ****/
        /***************************************************/

        private List <BarDisplacement> ReadBarDisplacements(List <string> barIds = null,
                                                            int divisions        = 0)
        {
            List <BarDisplacement> displacements = new List <BarDisplacement>();

            if (divisions != 0)
            {
                Engine.Base.Compute.RecordWarning("Displacements will only be extracted at SAP2000 calculation nodes." +
                                                  "'Divisions' parameter will not be considered in result extraction");
            }

            int resultCount = 0;

            string[] Obj      = null;
            string[] Elm      = null;
            string[] LoadCase = null;
            string[] StepType = null;
            double[] StepNum  = null;

            double[] ux = null;
            double[] uy = null;
            double[] uz = null;
            double[] rx = null;
            double[] ry = null;
            double[] rz = null;


            for (int i = 0; i < barIds.Count; i++)
            {
                Dictionary <string, double> nodes = new Dictionary <string, double>();
                string[] intElems = null;
                double[] di       = null;
                double[] dj       = null;
                int      div      = 0;

                if (m_model.FrameObj.GetElm(barIds[i], ref div, ref intElems, ref di, ref dj) != 0)
                {
                    Engine.Base.Compute.RecordWarning($"Could not get output stations for bar {barIds[i]}.");
                }
                else
                {
                    divisions = div + 1;

                    string p1Id = "";
                    string p2Id = "";

                    //get first point
                    int successtwo = m_model.LineElm.GetPoints(intElems[0], ref p1Id, ref p2Id);
                    nodes[p1Id] = di[0];

                    //get the rest of the points
                    for (int j = 0; j < div; j++)
                    {
                        m_model.LineElm.GetPoints(intElems[j], ref p1Id, ref p2Id);

                        nodes[p2Id] = dj[j];
                    }

                    foreach (var point in nodes)
                    {
                        if (m_model.Results.JointDispl(point.Key,
                                                       eItemTypeElm.Element,
                                                       ref resultCount,
                                                       ref Obj,
                                                       ref Elm,
                                                       ref LoadCase,
                                                       ref StepType,
                                                       ref StepNum,
                                                       ref ux,
                                                       ref uy,
                                                       ref uz,
                                                       ref rx,
                                                       ref ry,
                                                       ref rz) != 0)
                        {
                            Engine.Base.Compute.RecordWarning($"Could not extract results for an output station in bar {barIds[i]}.");
                        }
                        else
                        {
                            for (int j = 0; j < resultCount; j++)
                            {
                                BarDisplacement disp = new BarDisplacement(barIds[i], LoadCase[j], -1, StepNum[j], point.Value, divisions, ux[j], uy[j], uz[j], rx[j], ry[j], rz[j]);
                                displacements.Add(disp);
                            }
                        }
                    }
                }
            }

            return(displacements);
        }
Example #2
0
        /***************************************************/

        private List <BarDisplacement> ReadBarDisplacements(List <string> barIds, int divisions)
        {
            List <BarDisplacement> displacements = new List <BarDisplacement>();

            Engine.Base.Compute.RecordWarning("Displacements will only be extracted at ETABS calculation nodes. 'Divisions' parameter will not be considered in result extraction");

            int resultCount = 0;

            string[] obj      = null;
            string[] elm      = null;
            string[] loadCase = null;
            string[] stepType = null;
            double[] stepNum  = null;

            double[] ux = null;
            double[] uy = null;
            double[] uz = null;
            double[] rx = null;
            double[] ry = null;
            double[] rz = null;

            Dictionary <string, Point> points = new Dictionary <string, Point>();

            for (int i = 0; i < barIds.Count; i++)
            {
                int      divs    = divisions;
                string[] intElem = null;
                double[] di      = null;
                double[] dj      = null;

                m_model.FrameObj.GetElm(barIds[i], ref divs, ref intElem, ref di, ref dj);

                Dictionary <string, double> nodeWithPos = new Dictionary <string, double>();

                for (int j = 0; j < divs; j++)
                {
                    string p1Id = "";
                    string p2Id = "";
                    m_model.LineElm.GetPoints(intElem[j], ref p1Id, ref p2Id);

                    nodeWithPos[p1Id] = di[j];
                    nodeWithPos[p2Id] = dj[j];
                }


                foreach (var nodePos in nodeWithPos)
                {
                    int ret = m_model.Results.JointDispl(nodePos.Key, eItemTypeElm.Element, ref resultCount, ref obj, ref elm, ref loadCase, ref stepType, ref stepNum, ref ux, ref uy, ref uz, ref rx, ref ry, ref rz);

                    if (ret == 0)
                    {
                        for (int j = 0; j < resultCount; j++)
                        {
                            int    mode;
                            double timeStep;
                            GetStepAndMode(stepType[j], stepNum[j], out timeStep, out mode);

                            BarDisplacement disp = new BarDisplacement(barIds[i], loadCase[j], mode, timeStep, nodePos.Value, divs + 1, ux[j], uy[j], uz[j], rx[j], ry[j], rz[j]);
                            displacements.Add(disp);
                        }
                    }
                }
            }

            return(displacements);
        }
Example #3
0
        public static List <FEMResult> Results(List <Bar> bars, List <PointLoad> loads, Vector <double> es, Matrix <double> ed)
        {
            int nEL = bars.Count;
            List <FEMResult> outResults = new List <FEMResult>();

            for (int i = 0; i < nEL; i++)
            {
                FEMResult outResult1 = new FEMResult();

                BarDeformation  barDef1    = new BarDeformation();
                BarDisplacement barDisp1   = new BarDisplacement();
                BarForce        barForce1  = new BarForce();
                BarStrain       barStrain1 = new BarStrain();
                BarStress       barStress1 = new BarStress();

                barDisp1.UX         = ed[i, 0];
                barDisp1.UY         = ed[i, 1];
                barDisp1.UZ         = ed[i, 2];
                barDisp1.ObjectId   = bars[i].Name;
                barDisp1.ResultCase = loads[0].Loadcase.Number;
                barDisp1.Position   = 0;
                barDisp1.Divisions  = 2;

                barForce1.FX         = es[i];
                barForce1.ObjectId   = bars[i].Name;
                barForce1.ResultCase = loads[0].Loadcase.Number;
                barForce1.Position   = 0;
                barForce1.Divisions  = 2;

                outResult1.barDisplacement = barDisp1;
                outResult1.barForce        = barForce1;

                FEMResult outResult2 = new FEMResult();

                BarDeformation  barDef2    = new BarDeformation();
                BarDisplacement barDisp2   = new BarDisplacement();
                BarForce        barForce2  = new BarForce();
                BarStrain       barStrain2 = new BarStrain();
                BarStress       barStress2 = new BarStress();

                barDisp2.UX         = ed[i, 3];
                barDisp2.UY         = ed[i, 4];
                barDisp2.UZ         = ed[i, 5];
                barDisp2.ObjectId   = bars[i].Name;
                barDisp2.ResultCase = loads[0].Loadcase.Number;
                barDisp2.Position   = 1;
                barDisp2.Divisions  = 2;

                barForce2.FX         = es[i];
                barForce2.ObjectId   = bars[i].Name;
                barForce2.ResultCase = loads[0].Loadcase.Number;
                barForce2.Position   = 1;
                barForce2.Divisions  = 2;

                outResult2.barDisplacement = barDisp2;
                outResult2.barForce        = barForce2;

                outResults.Add(outResult1);
                outResults.Add(outResult2);
            }
            return(outResults);
        }
Example #4
0
        /***************************************************/

        private IEnumerable <IResult> ExtractBarDisplacement(List <int> ids, List <int> loadcaseIds)
        {
            List <BarDisplacement> barDisplacements = new List <BarDisplacement>();

            IFView           view           = m_LusasApplication.getCurrentView();
            IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view);

            string entity   = "Displacement";
            string location = "Feature extreme";

            foreach (int loadcaseId in loadcaseIds)
            {
                IFLoadset loadset = d_LusasData.getLoadset(loadcaseId);

                if (!loadset.needsAssociatedValues())
                {
                    resultsContext.setActiveLoadset(loadset);
                }

                IFUnitSet unitSet            = d_LusasData.getModelUnits();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "DX", "DY", "DZ", "THX", "THY", "THZ"
                };
                d_LusasData.startUsingScriptedResults();

                Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext);

                foreach (int barId in ids)
                {
                    Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, barId, "L", 6);

                    double uX = 0; double uY = 0; double uZ = 0; double rX = 0; double rY = 0; double rZ = 0;
                    featureResults.TryGetValue("DX", out uX); featureResults.TryGetValue("DY", out uY); featureResults.TryGetValue("DZ", out uZ);
                    featureResults.TryGetValue("THX", out rX); featureResults.TryGetValue("THY", out rY); featureResults.TryGetValue("THZ", out rZ);

                    //TODO: resolve below identifiers extractable through the API
                    int    mode      = -1;
                    double timeStep  = 0;
                    double position  = 0;
                    int    divisions = 0;

                    BarDisplacement barDisplacement = new BarDisplacement(
                        barId,
                        Adapters.Lusas.Convert.GetName(loadset.getName()),
                        mode,
                        timeStep,
                        position,
                        divisions,
                        uX * lengthSIConversion,
                        uY * lengthSIConversion,
                        uZ * lengthSIConversion,
                        rX,
                        rY,
                        rZ
                        );

                    barDisplacements.Add(barDisplacement);
                }

                d_LusasData.stopUsingScriptedResults();
                d_LusasData.flushScriptedResults();
            }

            return(barDisplacements);
        }