コード例 #1
0
        /***************************************************/
        /**** Private method - Extraction methods       ****/
        /***************************************************/


        private List <BarForce> ReadBarForce(List <string> barIds, int divisions)
        {
            List <BarForce> barForces = new List <BarForce>();

            int resultCount = 0;

            string[] loadcaseNames = null;
            string[] objects       = null;
            string[] elm           = null;
            double[] objStation    = null;
            double[] elmStation    = null;
            double[] stepNum       = null;
            string[] stepType      = null;

            double[] p  = null;
            double[] v2 = null;
            double[] v3 = null;
            double[] t  = null;
            double[] m2 = null;
            double[] m3 = null;

            int    type    = 2; //Use minimum nb of division points
            double segSize = 0;
            bool   op1     = false;
            bool   op2     = false;

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

            for (int i = 0; i < barIds.Count; i++)
            {
                //Get element length
                double length = GetBarLength(barIds[i], points);

                int divs = divisions;

                m_model.FrameObj.SetOutputStations(barIds[i], type, 0, divs);
                m_model.FrameObj.GetOutputStations(barIds[i], ref type, ref segSize, ref divs, ref op1, ref op2);

                int ret = m_model.Results.FrameForce(barIds[i], eItemTypeElm.ObjectElm, ref resultCount, ref objects, ref objStation, ref elm, ref elmStation,
                                                     ref loadcaseNames, ref stepType, ref stepNum, ref p, ref v2, ref v3, ref t, ref m2, ref m3);
                if (ret == 0)
                {
                    for (int j = 0; j < resultCount; j++)
                    {
                        int    mode;
                        double timeStep;
                        GetStepAndMode(stepType[j], stepNum[j], out timeStep, out mode);

                        BarForce bf = new BarForce(barIds[i], loadcaseNames[j], mode, timeStep, objStation[j] / length, divs, p[j], v3[j], v2[j], t[j], -m3[j], m2[j]);
                        barForces.Add(bf);
                    }
                }
            }

            return(barForces);
        }
コード例 #2
0
ファイル: IsNull.cs プロジェクト: BHoM/BHoM_Engine
        public static bool IsNull(this BarForce barForce, [CallerMemberName] string methodName = "Method", string msg = "")
        {
            if (barForce == null)
            {
                ErrorMessage(methodName, "BarForce", msg);
                return(true);
            }

            return(false);
        }
コード例 #3
0
        /***************************************************/

        private List <BarForce> ReadBarForce(List <string> barIds, int divisions = 0)
        {
            List <BarForce> barForces = new List <BarForce>();

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

            int resultCount = 0;

            string[] loadcaseNames = null;
            string[] objects       = null;
            string[] elm           = null;
            double[] objStation    = null;
            double[] elmStation    = null;
            double[] stepNum       = null;
            string[] stepType      = null;

            double[] p  = null;
            double[] v2 = null;
            double[] v3 = null;
            double[] t  = null;
            double[] m2 = null;
            double[] m3 = null;

            Dictionary <string, Point> points = ReadNodes().ToDictionary(x => GetAdapterId <string>(x), y => y.Position);

            for (int i = 0; i < barIds.Count; i++)
            {
                //Get element length
                double length = GetBarLength(barIds[i], points);

                if (m_model.Results.FrameForce(barIds[i],
                                               eItemTypeElm.ObjectElm,
                                               ref resultCount,
                                               ref objects,
                                               ref objStation,
                                               ref elm,
                                               ref elmStation,
                                               ref loadcaseNames,
                                               ref stepType,
                                               ref stepNum,
                                               ref p,
                                               ref v2,
                                               ref v3,
                                               ref t,
                                               ref m2,
                                               ref m3) != 0)
                {
                    Engine.Base.Compute.RecordError($"Could not extract results for an output station in bar {barIds}.");
                }
                else
                {
                    divisions = objStation.ToHashSet().Count(); //Get unique values of objStation, which is equal to the divisions set by SAP.

                    for (int j = 0; j < resultCount; j++)
                    {
                        BarForce bf = new BarForce(barIds[i], loadcaseNames[j], -1, stepNum[j], objStation[j] / length, divisions, p[j], v3[j], v2[j], t[j], -m3[j], m2[j]);
                        barForces.Add(bf);
                    }
                }
            }

            return(barForces);
        }
コード例 #4
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);
        }
コード例 #5
0
        /***************************************************/
        /**** Private  Methods                          ****/
        /***************************************************/

        private IEnumerable <IResult> ExtractBarForce(List <int> ids, List <int> loadcaseIds)
        {
            List <BarForce> barForces = new List <BarForce>();

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

            string entity   = "Force/Moment - Thick 3D Beam";
            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    forceSIConversion  = 1 / unitSet.getForceFactor();
                double    lengthSIConversion = 1 / unitSet.getLengthFactor();

                List <string> components = new List <string>()
                {
                    "Fx", "Fy", "Fz", "Mx", "My", "Mz"
                };
                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 fX = 0; double fY = 0; double fZ = 0; double mX = 0; double mY = 0; double mZ = 0;
                    featureResults.TryGetValue("Fx", out fX); featureResults.TryGetValue("Fy", out fY); featureResults.TryGetValue("Fz", out fZ);
                    featureResults.TryGetValue("Mx", out mX); featureResults.TryGetValue("My", out mY); featureResults.TryGetValue("Mz", out mZ);

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

                    BarForce barForce = new BarForce(
                        barId,
                        Adapters.Lusas.Convert.GetName(loadset.getName()),
                        mode,
                        timeStep,
                        position,
                        divisions,
                        fX * forceSIConversion,
                        fY * forceSIConversion,
                        fZ * forceSIConversion,
                        mX * forceSIConversion * lengthSIConversion,
                        mY * forceSIConversion * lengthSIConversion,
                        mZ * forceSIConversion * lengthSIConversion
                        );
                    barForces.Add(barForce);
                }

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

            return(barForces);
        }
コード例 #6
0
        public static List<BarForce> GetBarForce(cSapModel model, IList ids = null, IList cases = null, int divisions = 5)
        {
            List<string> loadcaseIds = new List<string>();
            List<string> barIds = new List<string>();
            List<BarForce> barForces = new List<BarForce>();

            if (ids == null || ids.Count == 0)
            {
                int bars = 0;
                string[] names = null;
                model.FrameObj.GetNameList(ref bars, ref names);
                barIds = names.ToList();
            }
            else
            {
                for (int i = 0; i < ids.Count; i++)
                {
                    barIds.Add(ids[i].ToString());
                }
            }

            //Get out loadcases, get all for null list
            loadcaseIds = CheckAndGetCases(model, cases);

            int resultCount = 0;
            string[] loadcaseNames = null;
            string[] objects = null;
            string[] elm = null;
            double[] objStation = null;
            double[] elmStation = null;
            double[] stepNum = null;
            string[] stepType = null;

            double[] fx = null;
            double[] fy = null;
            double[] fz = null;
            double[] mx = null;
            double[] my = null;
            double[] mz = null;

            int type = 0;
            double segSize = 0;
            bool op1 = false;
            bool op2 = false;

            model.Results.Setup.DeselectAllCasesAndCombosForOutput();

            for (int loadcase = 0; loadcase < loadcaseIds.Count; loadcase++)
            {
                if (model.Results.Setup.SetCaseSelectedForOutput(loadcaseIds[loadcase]) != 0)
                {
                    model.Results.Setup.SetComboSelectedForOutput(loadcaseIds[loadcase]);
                }
            }

            for (int i = 0; i < barIds.Count; i++)
            {
                model.FrameObj.GetOutputStations(barIds[i], ref type, ref segSize, ref divisions, ref op1, ref op2);
                int ret = model.Results.FrameForce(barIds[i], eItemTypeElm.ObjectElm, ref resultCount, ref objects, ref objStation, ref elm, ref elmStation,
                ref loadcaseNames, ref stepType, ref stepNum, ref fx, ref fy, ref fz, ref mx, ref my, ref mz);
                if (ret == 0)
                {
                    for (int j = 0; j < resultCount; j++)
                    {

                        BarForce bf = new BarForce()
                        {
                            ResultCase = loadcaseNames[j],
                            ObjectId = barIds[i],
                            MX = mx[j],
                            MY = my[j],
                            MZ = mz[j],
                            FX = fx[j],
                            FY = fy[j],
                            FZ = fz[j],
                            Divisions = divisions,
                            Position = objStation[j],
                            TimeStep = stepNum[j]
                        };

                        barForces.Add(bf);
                    }
                }
            }

            return barForces;
        }