Exemplo n.º 1
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private List <Loadcase> ReadLoadcases(List <string> ids = null)
        {
            List <Loadcase> loadcaseList = new List <Loadcase>();
            int             loadId;
            Loadcase        loadcase;
            string          lcName;

            if (ids == null)
            {
                List <rf.LoadCase> rfLoadcases = model.GetLoads().GetLoadCases().ToList();

                foreach (rf.LoadCase rfLoadcase in rfLoadcases)
                {
                    loadId   = rfLoadcase.Loading.No;
                    lcName   = rfLoadcase.Description;//.ID
                    loadcase = new Loadcase {
                        Name = lcName, Number = loadId, Nature = GetLoadNature(rfLoadcase.ActionCategory)
                    };
                    loadcaseList.Add(loadcase);

                    //string rfLoadcaseId = rfLoadcase.ID.Trim(new char[] { '#', ' ' });//some loadcases can have the id: "" !!
                    //if(int.TryParse(rfLoadcaseId, out loadId))
                    //{
                    //    lcName = rfLoadcase.Description;//.ID
                    //    loadcase = BH.Engine.Structure.Create.Loadcase(lcName, loadId, GetLoadNature(rfLoadcase.ActionCategory));
                    //    loadcaseList.Add(loadcase);
                    //}
                    //else
                    //    Engine.Base.Compute.RecordWarning("loadcase id: " + rfLoadcase.ID + " could not be converted to int");
                }
            }
            else
            {
                foreach (string id in ids)
                {
                    if (int.TryParse(id, out loadId))
                    {
                        rf.LoadCase rfLoadcase = model.GetLoads().GetLoadCase(loadId, rf.ItemAt.AtNo).GetData();
                        lcName   = rfLoadcase.Description;//.ID
                        loadcase = new Loadcase {
                            Name = lcName, Number = loadId, Nature = GetLoadNature(rfLoadcase.ActionCategory)
                        };
                        loadcaseList.Add(loadcase);
                    }
                    else
                    {
                        Engine.Base.Compute.RecordWarning("loadcase id: " + id + " could not be converted to int");
                    }
                }
            }

            return(loadcaseList);
        }
Exemplo n.º 2
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private bool CreateCollection(IEnumerable <Loadcase> loadcases)
        {
            if (loadcases.Count() > 0)
            {
                string loadcaseId = "";

                List <Loadcase> loadcaseList = loadcases.ToList();
                rf.LoadCase[]   rfLoadcases  = new rf.LoadCase[loadcaseList.Count()];

                //*****move this to adapter *****
                //modelData.FinishModification();

                rf.ILoads loads = model.GetLoads();
                loads.PrepareModification();
                //*******************************

                if (loadcaseList.Count == 1)
                {
                    loadcaseId     = GetAdapterId <string>(loadcaseList[0]);
                    rfLoadcases[0] = loadcaseList[0].ToRFEM(loadcaseId);
                    loads.SetLoadCase(rfLoadcases[0]);
                }
                else
                {
                    for (int i = 0; i < loadcaseList.Count(); i++)
                    {
                        loadcaseId = GetAdapterId <string>(loadcaseList[i]);

                        rfLoadcases[i] = loadcaseList[i].ToRFEM(loadcaseId);
                        loads.SetLoadCase(rfLoadcases[i]);
                    }
                    loads.SetLoadCases(rfLoadcases);
                }

                loads.FinishModification();      // <---- move to adapter
                modelData.PrepareModification(); //<--- hack to avoid app lock issue
            }

            return(true);
        }
Exemplo n.º 3
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static rf.LoadCase ToRFEM(this Loadcase loadcase, string loadcaseId)
        {
            rf.LoadCase rfLoadcase = new rf.LoadCase();
            int         lcNo       = loadcase.Number;

            if (loadcase.Number == 0)
            {
                int.TryParse(loadcaseId, out lcNo);
            }

            rfLoadcase.Loading.No     = lcNo;
            rfLoadcase.Description    = loadcase.Name;
            rfLoadcase.ActionCategory = GetLoadCategory(loadcase.Nature);
            rfLoadcase.ToSolve        = true;

            //// unsure about these ***********
            //rfLoadcase.ToSolve = true;
            //rfLoadcase.Loading.Type = rf.LoadingType.LoadCaseType;
            //// ******************************

            return(rfLoadcase);
        }
Exemplo n.º 4
0
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/

        private List <ILoad> ReadLoads(List <string> ids = null)
        {
            List <ILoad> loadList = new List <ILoad>();


            if (ids == null)
            {
                List <rf.LoadCase> rfLoadcases = model.GetLoads().GetLoadCases().ToList();
                rf.ILoads          l           = model.GetLoads();
                int lcCount = l.GetLoadCaseCount();

                Dictionary <int, Loadcase> bhLoadcaseDict = new Dictionary <int, Loadcase>();
                bhLoadcaseDict = ReadLoadcases().Distinct().ToDictionary(x => x.Number, x => x);

                Dictionary <string, Bar> bhBarDict = new Dictionary <string, Bar>();
                bool barsRead = false;

                for (int i = 0; i < lcCount; i++)
                {
                    rf.LoadCase rfLoadcase = l.GetLoadCase(i, rf.ItemAt.AtIndex).GetData();
                    Loadcase    bhLoadcase;

                    bhLoadcase = bhLoadcaseDict[rfLoadcase.Loading.No];


                    rf.MemberLoad[] rfMemberLoads = l.GetLoadCase(i, rf.ItemAt.AtIndex).GetMemberLoads();
                    if (rfMemberLoads.Length > 0)
                    {
                        if (!barsRead)
                        {
                            bhBarDict = ReadBars().ToDictionary(x => GetAdapterId(x).ToString(), x => x);
                            barsRead  = true;
                        }


                        foreach (rf.MemberLoad rfLoad in rfMemberLoads)
                        {
                            List <string>           barIds   = BH.Engine.Adapters.RFEM.Compute.GetIdListFromString(rfLoad.ObjectList);
                            oM.Base.BHoMGroup <Bar> barGroup = new oM.Base.BHoMGroup <Bar>();
                            barGroup.Elements.AddRange(barIds.Where(k => bhBarDict.ContainsKey(k)).Select(k => bhBarDict[k]));


                            if (rfLoad.Distribution == rf.LoadDistributionType.UniformType)
                            {
                                BarUniformlyDistributedLoad barUniformLoad = rfLoad.FromRFEM(bhLoadcase, barGroup);
                                loadList.Add(barUniformLoad);
                            }
                            else if (rfLoad.Distribution == rf.LoadDistributionType.ConcentratedType)
                            {
                                BarPointLoad barPointLoad = new BarPointLoad();
                                //...
                            }
                            else
                            {
                                Engine.Base.Compute.RecordWarning("Load distribution of type: " + rfLoad.Distribution.ToString() + " is not supported!");
                            }
                        }
                    }
                }
            }
            else
            {
                foreach (string id in ids)
                {
                    //loadList.Add();
                }
            }

            return(loadList);
        }