/// <summary>
        /// Gets the internal stress at defined location.
        /// tensor is in local coordinate system.
        /// </summary>
        /// <param name="isoLocation">The location for the stress probe in iso coordinates. Order: x,y,z. Maximum bending stress at the shell thickness (z=1.0). Must be withing 0 and 1.</param>
        /// <param name="combination">The load combination.</param>
        /// <param name="probeLocation">The probe location for the stress.</param>
        /// <returns>Stress tensor of flat shell, in local coordination system</returns>
        /// <remarks>
        /// for more info about local coordinate of flat shell see page [72 of 166] (page 81 of pdf) of "Development of Membrane, Plate and Flat Shell Elements in Java" thesis by Kaushalkumar Kansara freely available on the web
        /// </remarks>
        public FlatShellStressTensor GetInternalStress(double[] isoLocation, LoadCombination combination, SectionPoints probeLocation)
        {
            if (isoLocation[2] < 0 || isoLocation[2] > 1.0)
            {
                throw new Exception("z must be between 0 and 1. 0 is the centre of the plate and 1 is on the plate surface. Use the section points to get the top/bottom.")
                      {
                      };
            }
            var helpers = GetHelpers();

            var buf = new FlatShellStressTensor();

            for (var i = 0; i < helpers.Count(); i++)
            {
                if (helpers[i] is Q4MembraneHelper)
                {
                    buf.MembraneTensor = ((Q4MembraneHelper)helpers[i]).GetLocalInternalStress(this, combination, isoLocation).MembraneTensor;
                }
                else if (helpers[i] is DkqHelper)
                {
                    buf.BendingTensor = ((DkqHelper)helpers[i]).GetBendingInternalStress(this, combination, isoLocation).BendingTensor;
                }
            }
            buf.UpdateTotalStress(_section.GetThicknessAt(new double[] { isoLocation[0], isoLocation[1] }) * isoLocation[2], probeLocation);
            return(buf);
        }
Beispiel #2
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private IFBasicCombination CreateLoadCombination(LoadCombination loadCombination)
        {
            IFBasicCombination lusasLoadcombination;

            List <double> loadFactors = new List <double>();
            List <int>    loadcases   = new List <int>();

            if (d_LusasData.existsLoadset(loadCombination.Name))
            {
                lusasLoadcombination = (IFBasicCombination)d_LusasData.getLoadset(loadCombination.Name);
            }
            else
            {
                if (loadCombination.Number == 0)
                {
                    lusasLoadcombination = d_LusasData.createCombinationBasic(loadCombination.Name);
                    Compute.RecordWarning($"LoadCombination {loadCombination.Name} ID will be autogenerated by Lusas.");
                }
                else
                {
                    lusasLoadcombination = d_LusasData.createCombinationBasic(loadCombination.Name, "", loadCombination.Number);
                }
                foreach (Tuple <double, ICase> factoredLoad in loadCombination.LoadCases)
                {
                    double    factor        = factoredLoad.Item1;
                    IFLoadset lusasLoadcase = d_LusasData.getLoadset(factoredLoad.Item2.AdapterId <int>(typeof(LusasId)));
                    lusasLoadcombination.addEntry(factor, lusasLoadcase);
                }
            }

            return(lusasLoadcombination);
        }
        /// <summary>
        /// Sets the named sets database tables 2 selections.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="table">The table.</param>
        private static void setNAMED_SETS_DATABASE_TABLES_2_SELECTIONS(Model model, List <Dictionary <string, string> > table)
        {
            foreach (Dictionary <string, string> tableRow in table)
            {
                TableSet tableSet = model.OutputSettings.FillItem(tableRow["DBNamedSet"]);
                switch (tableRow["SelectType"])
                {
                case "Table":
                    tableSet.TableNames.Add(tableRow["Selection"]);
                    break;

                case "LoadPattern":
                    LoadPattern loadPattern = model.Loading.Patterns.FillItem(tableRow["Selection"]);
                    tableSet.LoadPatterns.Add(loadPattern);
                    break;

                case "LoadCase":
                    LoadCase loadCase = model.Loading.Cases.FillItem(tableRow["Selection"]);
                    tableSet.LoadCases.Add(loadCase);
                    break;

                case "Combo":
                    LoadCombination loadCombo = model.Loading.Combinations.FillItem(tableRow["Selection"]);
                    tableSet.LoadCombinations.Add(loadCombo);
                    break;
                }
            }
        }
        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // get data
            string          name = null, type = "ultimate_ordinary";
            List <LoadCase> loadCases = new List <LoadCase>();
            List <double>   gammas    = new List <double>();

            if (!DA.GetData(0, ref name))
            {
                return;
            }
            if (!DA.GetData(1, ref type))
            {
                // pass
            }
            if (!DA.GetDataList(2, loadCases))
            {
                return;
            }
            if (!DA.GetDataList(3, gammas))
            {
                return;
            }
            if (name == null || type == null || loadCases == null || gammas == null)
            {
                return;
            }

            var             _type = FemDesign.GenericClasses.EnumParser.Parse <LoadCombType>(type);
            LoadCombination obj   = new LoadCombination(name, _type, loadCases, gammas);

            DA.SetData(0, obj);
        }
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static LoadCombination ToLoadCombination(
            this IFBasicCombination lusasLoadCombination,
            Dictionary <string, Loadcase> loadcases)
        {
            object[] loadcaseIDs     = lusasLoadCombination.getLoadcaseIDs();
            object[] loadcaseFactors = lusasLoadCombination.getFactors();

            List <Tuple <double, ICase> > factoredLoadcases = new List <Tuple <double, ICase> >();
            Loadcase loadcase = null;

            for (int i = 0; i < loadcaseIDs.Count(); i++)
            {
                int    loadcaseID     = (int)loadcaseIDs[i];
                double loadcaseFactor = (double)loadcaseFactors[i];
                loadcases.TryGetValue(loadcaseID.ToString(), out loadcase);
                Tuple <double, ICase> factoredLoadcase = new Tuple <double, ICase>(loadcaseFactor, loadcase);
                factoredLoadcases.Add(factoredLoadcase);
            }

            LoadCombination loadCombination = new LoadCombination
            {
                Name      = GetName(lusasLoadCombination),
                Number    = lusasLoadCombination.getID(),
                LoadCases = factoredLoadcases
            };

            int adapterNameId = lusasLoadCombination.getID();

            loadCombination.SetAdapterId(typeof(LusasId), adapterNameId);

            return(loadCombination);
        }
Beispiel #6
0
        public static void SetLoadCombination(cSapModel model, LoadCombination loadCombination)
        {
            //string combinationName = loadCombination.CustomData[AdapterId].ToString();
            string combinationName = CaseNameToCSI(loadCombination);

            model.RespCombo.Add(combinationName, 0);//0=case, 1=combo

            foreach (var factorCase in loadCombination.LoadCases)
            {
                double     factor    = factorCase.Item1;
                Type       lcType    = factorCase.Item2.GetType();
                string     lcName    = CaseNameToCSI(factorCase.Item2);// factorCase.Item2.Name;// Number.ToString();
                eCNameType cTypeName = eCNameType.LoadCase;

                if (lcType == typeof(Loadcase))
                {
                    cTypeName = eCNameType.LoadCase;
                }
                else if (lcType == typeof(LoadCombination))
                {
                    cTypeName = eCNameType.LoadCombo;
                }

                model.RespCombo.SetCaseList(combinationName, ref cTypeName, lcName, factor);
            }
        }
Beispiel #7
0
        public static LoadCombination GetLoadCombination(cSapModel model, Dictionary <string, ICase> caseDict, string id)
        {
            LoadCombination combination = new LoadCombination();
            int             number;

            string[] nameNum = id.Split(new[] { ":::" }, StringSplitOptions.None);
            int.TryParse(nameNum[1], out number);
            combination.Number = number;
            combination.Name   = nameNum[0];

            string[] caseNames = null;
            double[] factors   = null;
            int      caseNum   = 0;

            eCNameType[] nameTypes = null;//<--TODO: maybe need to check if 1? (1=loadcombo)

            model.RespCombo.GetCaseList(id, ref caseNum, ref nameTypes, ref caseNames, ref factors);
            if (caseNames != null)
            {
                ICase currentCase;

                for (int i = 0; i < caseNames.Count(); i++)
                {
                    if (caseDict.TryGetValue(caseNames[i], out currentCase))
                    {
                        combination.LoadCases.Add(new Tuple <double, ICase>(factors[i], currentCase));
                    }
                }
            }
            return(combination);
        }
        /***************************************************/
        /**** Private methods                           ****/
        /***************************************************/
        private bool CreateObject(LoadCombination bhLoadCombo)
        {
            int err;
            int uID            = 1;
            int loadCaseType   = St7.ltLoadCase;
            int freedomCaseNum = 1;
            int loadComboId    = GetAdapterId <int>(bhLoadCombo);

            List <Loadcase> allLoadCases = ReadLoadcase();
            var             comparer     = new BHoMObjectNameOrToStringComparer();

            err = St7.St7AddLSACombination(uID, bhLoadCombo.Name);
            if (err != St7.ERR7_NoError)
            {
                err = St7.St7SetLSACombinationName(uID, loadComboId, bhLoadCombo.Name);
                if (!St7ErrorCustom(err, "Could not create or update a load combination number " + loadComboId))
                {
                    return(false);
                }
            }
            foreach (Tuple <double, ICase> tuple in bhLoadCombo.LoadCases)
            {
                Loadcase ldcas    = allLoadCases.Where(x => x.Number == (tuple.Item2 as Loadcase).Number).FirstOrDefault();
                int      lCaseNum = ldcas.Number;
                // int lCaseNum = GetAdapterId<int>(ldcas);
                err = St7.St7SetLSACombinationFactor(uID, loadCaseType, loadComboId, lCaseNum, freedomCaseNum, tuple.Item1);
                if (!St7ErrorCustom(err, "Could not set load case " + lCaseNum + " factor for a load combo " + loadComboId))
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #9
0
        /***************************************************/

        public static LoadCombination ToBHoMObject(IModel ramModel, ILoadCombination ramLoadCombination)
        {
            LoadCombination loadCombination = new LoadCombination();

            loadCombination.Name   = ramLoadCombination.strDisplayString;
            loadCombination.Number = ramLoadCombination.lLabelNo;

            ILoadCombinationTerms iLoadCombinationTerms = ramLoadCombination.GetLoadCombinationTerms();

            for (int i = 0; i < iLoadCombinationTerms.GetCount(); i++)
            {
                //Get LoadCombination Cases and Factors
                ILoadCombinationTerm iLoadCombinationTerm = iLoadCombinationTerms.GetAt(i);
                int        caseID     = iLoadCombinationTerm.lLoadCaseID;
                ILoadCases iLoadCases = ramModel.GetLoadCases(EAnalysisResultType.RAMFrameResultType);
                ILoadCase  iLoadCase  = iLoadCases.Get(caseID);

                //Convert Loadcase from RAM to BHoM
                Loadcase bhomLoadcase = ToBHoMObject(iLoadCase);
                //Add dict for load factor and loadcase
                loadCombination.LoadCases.Add(new Tuple <double, ICase>(iLoadCombinationTerm.dFactor, bhomLoadcase));
            }

            return(loadCombination);
        }
Beispiel #10
0
        String m_usage; // Indicate usage column of LoadCombination DataGridView control

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Default constructor of LoadCombinationMap
        /// </summary>
        /// <param name="combination">the reference of LoadCombination</param>
        public LoadCombinationMap(LoadCombination combination)
        {
            m_name = combination.Name;
            m_type = combination.CombinationType;
            m_state = combination.CombinationState;

            // Generate the formula property.
            StringBuilder formulaString = new StringBuilder();
            for (int i = 0; i < combination.NumberOfComponents; i++)
            {
                formulaString.Append(combination.get_Factor(i));
                formulaString.Append("*");
                formulaString.Append(combination.get_CombinationCaseName(i));

                // Add plus sign between each case.
                if (i < combination.NumberOfComponents - 1)
                {
                    formulaString.Append(" + ");
                }
            }
            m_formula = formulaString.ToString();

            // Generate the usage property.
            StringBuilder usageString = new StringBuilder();
            for (int i = 0; i < combination.NumberOfUsages; i++)
            {
                usageString.Append(combination.get_UsageName(i));
                // Add semicolon between each usage.
                if (i < combination.NumberOfUsages - 1)
                {
                    usageString.Append(";");
                }
            }
            m_usage = usageString.ToString();
        }
Beispiel #11
0
        /***************************************************/

        private bool CreateObject(LoadCombination loadCombination)
        {
            if (m_model.RespCombo.Add(loadCombination.Name, 0) == 0) //0=case, 1=combo
            {
                foreach (var factorCase in loadCombination.LoadCases)
                {
                    double     factor    = factorCase.Item1;
                    Type       lcType    = factorCase.Item2.GetType();
                    string     lcName    = factorCase.Item2.Name;// factorCase.Item2.Name;// Number.ToString();
                    eCNameType cTypeName = eCNameType.LoadCase;

                    if (lcType == typeof(Loadcase))
                    {
                        cTypeName = eCNameType.LoadCase;
                    }
                    else if (lcType == typeof(LoadCombination))
                    {
                        cTypeName = eCNameType.LoadCombo;
                    }

                    m_model.RespCombo.SetCaseList(loadCombination.Name, ref cTypeName, lcName, factor);
                }
                SetAdapterId(loadCombination, loadCombination.Name);
            }
            else
            {
                CreateElementError(loadCombination.GetType().ToString(), loadCombination.Name);
            }

            return(true);
        }
 public LoadCombinationsDialog(Canguro.Model.Model model, LoadCombination combo)
 {
     this.currentCombo = combo;
     this.model        = model;
     InitializeComponent();
     wizardControl.HideTabs = true;
     oneCombo = (combo != null);
 }
Beispiel #13
0
        /***************************************************/

        private bool CreateObject(LoadCombination loadcombination)
        {
            bool success = true;

            Helper.SetLoadCombination(m_model, loadcombination);

            return(success);
        }
        public Displacement GetInternalDisplacementAt(double xi, LoadCombination combination)
        {
            var buf = new Displacement();

            foreach (var pair in combination)
            {
                buf += pair.Value * GetInternalDisplacementAt(xi, pair.Key);
            }

            return(buf);
        }
        /// <summary>
        /// Gets the exact internal force at <see cref="xi" /> position.
        /// </summary>
        /// <param name="xi">The iso coordinate of desired point (start = -1, mid = 0, end = 1).</param>
        /// <param name="combination">The Load Combination.</param>
        /// <returns></returns>
        /// <remarks>
        /// Will calculate the internal forces of member regarding the <see cref="combination" />
        /// </remarks>
        public Force GetExactInternalForceAt(double xi, LoadCombination combination)
        {
            var buf = Force.Zero;

            foreach (var lc in combination.Keys)
            {
                buf += combination[lc] * this.GetExactInternalForceAt(xi, lc);
            }

            return(buf);
        }
 private void backButton_Click(object sender, EventArgs e)
 {
     if (oneCombo)
     {
         DialogResult = DialogResult.Cancel;
     }
     else
     {
         currentCombo = null;
         wizardControl.SelectTab(0);
     }
 }
Beispiel #17
0
        private void editComboLinkLabel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            LoadCombination combo = (allCombosListBox.SelectedItem != null) ? (LoadCombination)allCombosListBox.SelectedItem :
                                    (selectedCombosListBox.SelectedItem != null) ? (LoadCombination)selectedCombosListBox.SelectedItem : null;

            if (combo != null)
            {
                Canguro.Commands.Forms.LoadCombinationsDialog dlg = new Canguro.Commands.Forms.LoadCombinationsDialog(services.Model, combo);
                dlg.ShowDialog(this);
                updateDesignCombosPage();
            }
        }
Beispiel #18
0
        private void store(OleDbConnection cn, LoadCombination obj, Canguro.Model.Model model)
        {
            List <AbstractCaseFactor> list = obj.Cases;

            string sql       = "";
            string steel     = CodeYN(model.SteelDesignOptions.DesignCombinations.Contains(obj));
            string concrete  = CodeYN(model.ConcreteDesignOptions.DesignCombinations.Contains(obj));
            string alum      = CodeYN(model.AluminumDesignOptions.DesignCombinations.Contains(obj));
            string cold      = CodeYN(model.ColdFormedDesignOptions.DesignCombinations.Contains(obj));
            string comboType = GetComboType(obj.Type);

            foreach (AbstractCaseFactor f in list)
            {
                AbstractCase aCase = f.Case as AbstractCase;
                sql = "";
                if (aCase != null) // && aCase.IsActive)
                {
                    if (aCase is LoadCombination)
                    {
                        sql = "INSERT INTO [Combination Definitions] " +
                              "(ComboName,ComboType,CaseType,CaseName,ScaleFactor,SteelDesign,ConcDesign,AlumDesign,ColdDesign) VALUES " +
                              "(\"" + obj.Name + "\",\"\",\"Combo\",\"" + aCase.Name + "\"," + f.Factor + "," + steel + "," + concrete + "," + alum + "," + cold + ");";
                    }
                    else if (aCase is AnalysisCase)
                    {
                        AnalysisCaseProps props = ((AnalysisCase)aCase).Properties;
                        if (props is StaticCaseProps)
                        {
                            // StaticCaseProps sprops = (StaticCaseProps)props;
                            sql = "INSERT INTO [Combination Definitions] " +
                                  "(ComboName,ComboType,CaseType,CaseName,ScaleFactor,SteelDesign,ConcDesign,AlumDesign,ColdDesign) VALUES " +
                                  "(\"" + obj.Name + "\",\"" + comboType + "\",\"Linear Static\",\"" + aCase.Name + "\"," + f.Factor + "," + steel + "," + concrete + "," + alum + "," + cold + ");";
                        }
                        else if (props is ResponseSpectrumCaseProps)
                        {
                            sql = "INSERT INTO [Combination Definitions] " +
                                  "(ComboName,ComboType,CaseType,CaseName,ScaleFactor,SteelDesign,ConcDesign,AlumDesign,ColdDesign) VALUES " +
                                  "(\"" + obj.Name + "\",\"" + comboType + "\",\"Response Spectrum\",\"" + aCase.Name + "\"," + f.Factor + "," + steel + "," + concrete + "," + alum + "," + cold + ");";
                        }
                        //steel = concrete = alum = cold = "\"\"";
                    }
                    if (sql.Length > 0)
                    {
                        new OleDbCommand(sql, cn).ExecuteNonQuery();
                    }
                }
            }

            // Insert record in RESULTS Named Set
            sql = " INSERT INTO [Named Sets - Database Tables 2 - Selections] " +
                  "(DBNamedSet, SelectType, [Selection]) VALUES (\"RESULTS\", \"Combo\", \"" + obj.Name + "\");";
            new OleDbCommand(sql, cn).ExecuteNonQuery();
        }
 /// <summary>
 /// Sets a load combination selected for output flag.
 /// </summary>
 /// <param name="loadCombination">An existing load combination.</param>
 public void SetComboSelectedForOutput(LoadCombination loadCombination)
 {
     if (loadCombination.IsSelectedForAnalysis)
     {
         if (!CombosSelectedForOutput.Contains(loadCombination))
         {
             CombosSelectedForOutput.Add(loadCombination);
         }
     }
     else
     {
         CombosSelectedForOutput.Remove(loadCombination);
     }
 }
Beispiel #20
0
 public RFLoadCombo(LoadCombination load)
 {
     Comment         = load.Comment;
     ID              = load.ID;
     IsValid         = load.IsValid;
     No              = load.Loading.No;
     Tag             = load.Tag;
     ToSolve         = load.ToSolve;
     Description     = load.Description;
     Definition      = load.Definition;
     DesignSituation = load.DesignSituation;
     ToModify        = false;
     ToDelete        = false;
 }
        /// <summary>
        /// Gets the internal force at defined location.
        /// tensor is in local coordinate system.
        /// </summary>
        /// <param name="localX">The X in local coordinate system (see remarks).</param>
        /// <param name="localY">The Y in local coordinate system (see remarks).</param>
        /// <param name="combination">The load combination.</param>
        /// <returns>Stress tensor of flat shell, in local coordination system</returns>
        /// <remarks>
        /// for more info about local coordinate of flat shell see page [72 of 166] (page 81 of pdf) of "Development of Membrane, Plate and Flat Shell Elements in Java" thesis by Kaushalkumar Kansara freely available on the web
        /// </remarks>
        public FlatShellStressTensor GetInternalForce(double localX, double localY, LoadCombination combination)
        {
            var buf = new FlatShellStressTensor();

            if ((this._behaviour & FlatShellBehaviour.ThinPlate) != 0)
            {
                buf.MembraneTensor = GetMembraneInternalForce(combination);
            }

            if ((this._behaviour & FlatShellBehaviour.Membrane) != 0)
            {
                buf.BendingTensor = GetBendingInternalForce(localX, localY, combination);
            }

            return(buf);
        }
Beispiel #22
0
        /// <summary>
        /// Builds an adjacencyList of dependant abstract cases, so that each entry has its dependant cases in its list
        /// </summary>
        /// <returns>The adjacency list</returns>
        public Dictionary <AbstractCase, LinkedList <AbstractCase> > BuildAnalysisCaseAdjacency()
        {
            Dictionary <AbstractCase, LinkedList <AbstractCase> > adjancencyList = new Dictionary <AbstractCase, LinkedList <AbstractCase> >();

            AnalysisCase    aCase = null;
            LoadCombination combo = null;

            foreach (AbstractCase ac in abstractCases)
            {
                if ((aCase = ac as AnalysisCase) != null)
                {
                    if (aCase.Properties.DependsOn == null)
                    {
                        if (!adjancencyList.ContainsKey(aCase))
                        {
                            adjancencyList.Add(aCase, new LinkedList <AbstractCase>());
                        }
                    }
                    else if (adjancencyList.ContainsKey(aCase.Properties.DependsOn))
                    {
                        adjancencyList[aCase.Properties.DependsOn].AddLast(aCase);
                    }
                    else
                    {
                        adjancencyList.Add(aCase.Properties.DependsOn, new LinkedList <AbstractCase>());
                        adjancencyList[aCase.Properties.DependsOn].AddLast(aCase);
                    }
                }
                else if ((combo = ac as LoadCombination) != null)
                {
                    foreach (AbstractCaseFactor acf in combo.Cases)
                    {
                        if (adjancencyList.ContainsKey(acf.Case))
                        {
                            adjancencyList[acf.Case].AddLast(combo);
                        }
                        else
                        {
                            adjancencyList.Add(acf.Case, new LinkedList <AbstractCase>());
                            adjancencyList[acf.Case].AddLast(combo);
                        }
                    }
                }
            }

            return(adjancencyList);
        }
Beispiel #23
0
        /***************************************************/

        private List <LoadCombination> ReadLoadCombination(List <string> ids = null)
        {
            List <LoadCombination> combinations = new List <LoadCombination>();

            Dictionary <string, Loadcase> bhomCases = ReadLoadcase().ToDictionary(x => GetAdapterId <string>(x));

            int nameCount = 0;

            string[] nameArr = null;
            m_model.RespCombo.GetNameList(ref nameCount, ref nameArr);

            ids = FilterIds(ids, nameArr);

            foreach (string id in ids)
            {
                LoadCombination bhomCombo = new LoadCombination();

                double[]     factors   = null;
                int          caseCount = 0;
                eCNameType[] caseTypes = null;
                string[]     caseNames = null;

                if (m_model.RespCombo.GetCaseList(id, ref caseCount, ref caseTypes, ref caseNames, ref factors) != 0)
                {
                    ReadElementError("Load Combo", id);
                }
                else
                {
                    bhomCombo.Name = id;

                    if (caseCount > 0)
                    {
                        List <ICase> comboCases = new List <ICase>();
                        for (int j = 0; j < caseCount; j++)
                        {
                            comboCases.Add(bhomCases[caseNames[j]]);
                            bhomCombo.LoadCases.Add(new Tuple <double, ICase>(factors[j], comboCases[j]));
                        }
                    }

                    SetAdapterId(bhomCombo, id);
                    combinations.Add(bhomCombo);
                }
            }

            return(combinations);
        }
Beispiel #24
0
        /***************************************************/

        private List <LoadCombination> ReadLoadCombination(List <string> ids = null)
        {
            List <LoadCombination> combinations = new List <LoadCombination>();

            //get all load cases before combinations
            Dictionary <string, Loadcase> bhomCases = ReadLoadcase().ToDictionary(x => x.Name.ToString());

            int nameCount = 0;

            string[] nameArr = { };
            m_model.RespCombo.GetNameList(ref nameCount, ref nameArr);

            ids = FilterIds(ids, nameArr);

            foreach (string id in ids)
            {
                LoadCombination combination = new LoadCombination();

                string[]     caseNames = null;
                double[]     factors   = null;
                int          caseNum   = 0;
                eCNameType[] nameTypes = null;//<--TODO: maybe need to check if 1? (1=loadcombo)

                if (m_model.RespCombo.GetCaseList(id, ref caseNum, ref nameTypes, ref caseNames, ref factors) == 0)
                {
                    combination.Name = id;

                    if (caseNames != null)
                    {
                        Loadcase currentCase;

                        for (int i = 0; i < caseNames.Count(); i++)
                        {
                            if (bhomCases.TryGetValue(caseNames[i], out currentCase))
                            {
                                combination.LoadCases.Add(new Tuple <double, ICase>(factors[i], currentCase));
                            }
                        }
                    }

                    SetAdapterId(combination, id);
                    combinations.Add(combination);
                }
            }

            return(combinations);
        }
Beispiel #25
0
        /// <summary>
        /// Find out all Load Combination and Usage in the existing document.
        /// As specification require, prepare some Load Combination Usages if they are not in document
        /// </summary>
        public void PrepareData()
        {
            // Find out all  Load Combination and Usage in the existing document.
            IList <Element> elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadCombination)).ToElements();

            foreach (Element elem in elements)
            {
                LoadCombination combination = elem as LoadCombination;
                if (null != combination)
                {
                    // Add the Load Combination name.
                    m_dataBuffer.LoadCombinationNames.Add(combination.Name);

                    // Create LoadCombinationMap object.
                    LoadCombinationMap combinationMap = new LoadCombinationMap(combination);

                    // Add the LoadCombinationMap object to the array list.
                    m_dataBuffer.LoadCombinationMap.Add(combinationMap);
                }
            }

            elements = (new FilteredElementCollector(m_document)).OfClass(typeof(LoadUsage)).ToElements();
            foreach (Element elem in elements)
            {
                // Add Load Combination Usage information
                LoadUsage usage = elem as LoadUsage;
                if (null != usage)
                {
                    // Add the Load Usage name
                    m_dataBuffer.LoadUsageNames.Add(usage.Name);

                    // Add the Load Usage object to a LoadUsageArray
                    m_dataBuffer.LoadUsages.Add(usage);

                    // Add the Load Usage information to UsageMap.
                    UsageMap usageMap = new UsageMap(m_dataBuffer, usage.Name);
                    m_dataBuffer.UsageMap.Add(usageMap);
                }
            }

            // As specification require, some Load Combination Usages if they are not in document
            String[] initUsageArray = { "Gravity", "Lateral", "Steel", "Composite", "Concrete" };
            foreach (String s in initUsageArray)
            {
                NewLoadUsage(s);
            }
        }
Beispiel #26
0
        /***************************************************/

        private bool CreateObject(LoadCombination loadcombination)
        {
            eCNameType nameType = eCNameType.LoadCase;

            int caseNameCount = 0;

            string[] caseNameArr = null;

            m_model.LoadPatterns.GetNameList(ref caseNameCount, ref caseNameArr);

            if (m_model.RespCombo.Add(loadcombination.Name, 0) == 0)
            {
                SetAdapterId(loadcombination, loadcombination.Name);
                foreach (Tuple <double, ICase> comboCase in loadcombination.LoadCases)
                {
                    double factor   = comboCase.Item1;
                    ICase  bhomCase = comboCase.Item2;
                    string caseName = "";

                    if (bhomCase.HasAdapterIdFragment(typeof(SAP2000Id)))
                    {
                        caseName = GetAdapterId <string>(bhomCase);
                    }
                    else if (caseNameArr.Contains(bhomCase.Name))
                    {
                        caseName = bhomCase.Name;
                    }
                    else
                    {
                        Engine.Base.Compute.RecordWarning($"case {bhomCase.Name} has no SAP2000_id, and no case with that name was found in the model. Try pushing the loadcase and using the result of that push to build the combo.");
                    }


                    if (m_model.RespCombo.SetCaseList(loadcombination.Name, ref nameType, caseName, factor) != 0)
                    {
                        Engine.Base.Compute.RecordWarning("Could not add case " + bhomCase.Name + " to combo " + loadcombination.Name);
                    }
                }
            }
            else
            {
                CreateElementError("Load Combination", loadcombination.Name);
            }

            return(true);
        }
Beispiel #27
0
        /// <summary>
        /// Gets the internal force at defined location.
        /// tensor is in local coordinate system.
        /// </summary>
        /// <param name="xi">The xi.</param>
        /// <param name="eta">The eta.</param>
        /// <param name="combination">The locad combination.</param>
        /// <returns>Stress tensor of flat shell, in local coordination system</returns>
        /// <remarks>
        /// for more info about local coordinate of flat shell see page [72 of 166] (page 81 of pdf) of "Development of Membrane, Plate and Flat Shell Elements in Java" thesis by Kaushalkumar Kansara freely available on the web
        /// </remarks>
        public FlatShellStressTensor GetInternalForce(double xi, double eta, LoadCombination combination)
        {
            var buf = new FlatShellStressTensor();

            if (_behaviour == FlatShellBehaviour.Membrane || _behaviour == FlatShellBehaviour.ThinShell)
            {
                buf.MembraneTensor = GetMembraneInternalForce(xi, eta, combination);
            }
            ;

            if (_behaviour == FlatShellBehaviour.ThinPlate || _behaviour == FlatShellBehaviour.ThinShell)
            {
                buf.BendingTensor = GetBendingInternalForce(xi, eta, combination);
            }

            return(buf);
        }
Beispiel #28
0
        /***************************************************/

        private List <LoadCombination> ReadLoadCombination(List <string> ids = null)
        {
            //Implement code for reading loadcombinations
            List <LoadCombination> bhomLoadCombinations = new List <LoadCombination>();

            ILoadCombinations ILoadCombinations = m_Model.GetLoadCombinations(COMBO_MATERIAL_TYPE.ANALYSIS_CUSTOM);

            for (int i = 0; i < ILoadCombinations.GetCount(); i++)
            {
                //Get LoadCombinations
                ILoadCombination ILoadCombination    = ILoadCombinations.GetAt(i);
                LoadCombination  bhomLoadCombination = BH.Adapter.RAM.Convert.ToBHoMObject(m_Model, ILoadCombination);
                bhomLoadCombinations.Add(bhomLoadCombination);
            }

            return(bhomLoadCombinations);
        }
Beispiel #29
0
        public StrainTensor GetBendingInternalStrain(double localX, double localY, LoadCombination cmb)
        {
            //step 1 : get transformation matrix
            //step 2 : convert globals points to locals
            //step 3 : convert global displacements to locals
            //step 4 : calculate B matrix
            //step 5 : e=B*U
            //Note : Steps changed...

            var trans = this.GetTransformationMatrix();

            var lp = GetLocalPoints();

            var g2l = new Func <Vector, Vector>(glob => (trans.Transpose() * glob.ToMatrix()).ToVector());
            //var l2g = new Func<Vector, Vector>(local => (trans*local.ToMatrix()).ToPoint());


            var d1g = this.nodes[0].GetNodalDisplacement(cmb);
            var d2g = this.nodes[1].GetNodalDisplacement(cmb);
            var d3g = this.nodes[2].GetNodalDisplacement(cmb);

            //step 3
            var d1l = new Displacement(g2l(d1g.Displacements), g2l(d1g.Rotations));
            var d2l = new Displacement(g2l(d2g.Displacements), g2l(d2g.Rotations));
            var d3l = new Displacement(g2l(d3g.Displacements), g2l(d3g.Rotations));

            var uDkt =
                new Matrix(new[]
                           { d1l.DZ, d1l.RX, d1l.RY, /**/ d2l.DZ, d2l.RX, d2l.RY, /**/ d3l.DZ, d3l.RX, d3l.RY });



            var b = DktElement.GetBMatrix(localX, localY,
                                          lp.Select(i => i.X).ToArray(),
                                          lp.Select(i => i.Y).ToArray());

            var mDkt = b * uDkt;

            var buf = new StrainTensor();

            buf.S11 = mDkt[0, 0];
            buf.S22 = mDkt[1, 0];
            buf.S12 = mDkt[2, 0];

            return(buf);
        }
        private double[] ReadMyDisplacementVector(LoadCombination allCmb)
        {
            var ds = new double[6 * model.Nodes.Count];

            for (var i = 0; i < model.Nodes.Count; i++)
            {
                var d = model.Nodes[i].GetNodalDisplacement(allCmb);

                ds[6 * i + 0] = d.DX;
                ds[6 * i + 1] = d.DY;
                ds[6 * i + 2] = d.DZ;

                ds[6 * i + 3] = d.RX;
                ds[6 * i + 4] = d.RY;
                ds[6 * i + 5] = d.RZ;
            }

            return(ds);
        }
Beispiel #31
0
        private List <LoadCombination> ReadLoadCombination(List <string> ids = null)
        {
            // Linear Load Combinations !! Only !!
            // only solver generated combinations
            List <LoadCombination> loadCombinations = new List <LoadCombination>();
            int             err            = 0;
            int             uID            = 1;
            int             freedomCase    = 1;
            int             loadComboCount = 0;
            List <Loadcase> allLoadCases   = ReadLoadcase();

            err = St7.St7GetNumLSACombinations(uID, ref loadComboCount);
            if (!St7ErrorCustom(err, "Could not get loadCombinations"))
            {
                return(loadCombinations);
            }

            for (int ldCombo = 1; ldCombo <= loadComboCount; ldCombo++)
            {
                StringBuilder loadComboName = new StringBuilder(St7.kMaxStrLen);
                err = St7.St7GetLSACombinationName(uID, ldCombo, loadComboName, St7.kMaxStrLen);
                if (!St7ErrorCustom(err, "Could not get a name of load combination " + ldCombo))
                {
                    continue;
                }
                List <double> loadCaseFactors = new List <double>();
                for (int j = 0; j < allLoadCases.Count; j++)
                {
                    int    loadcaseNum = GetAdapterId <int>(allLoadCases[j]);
                    double factor      = 0;
                    err = St7.St7GetLSACombinationFactor(uID, St7.ltLoadCase, ldCombo, loadcaseNum, freedomCase, ref factor);
                    if (!St7ErrorCustom(err, "Could not get a factor for a loadcase " + loadcaseNum + " load combo " + ldCombo))
                    {
                        return(loadCombinations);
                    }
                    loadCaseFactors.Add(factor);
                }
                LoadCombination loadCombination = BH.Engine.Structure.Create.LoadCombination(loadComboName.ToString(), ldCombo, allLoadCases, loadCaseFactors);
                SetAdapterId(loadCombination, ldCombo);
                loadCombinations.Add(loadCombination);
            }
            return(loadCombinations);
        }
        private void Stream( ArrayList data, LoadCombination loadcombo )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( LoadCombination ) ) );

              data.Add( new Snoop.Data.String( "Name", loadcombo.Name ) );
              data.Add( new Snoop.Data.Object( "Combination type", loadcombo.Type ) );
              data.Add( new Snoop.Data.Object( "Combination state", loadcombo.State ) );

              data.Add( new Snoop.Data.CategorySeparator( "Components" ) );
              data.Add( new Snoop.Data.Int( "Number of components", loadcombo.GetComponents().Count ) );

              foreach( var component in loadcombo.GetComponents() )
              {
            LoadCase cs = loadcombo.Document.GetElement( component.LoadCaseOrCombinationId ) as LoadCase;
            if( cs != null )
            {
              data.Add( new Snoop.Data.String( "Combination case name", cs.Name ) );
              data.Add( new Snoop.Data.ElementId( "Combination nature name", cs.NatureId, loadcombo.Document ) );
            }
            data.Add( new Snoop.Data.Double( "Factor", component.Factor ) );
              }

              data.Add( new Snoop.Data.CategorySeparator( "Usages" ) );
              data.Add( new Snoop.Data.Int( "Number of usages", loadcombo.GetUsageIds().Count ) );

              for( int i = 0; i < loadcombo.GetUsageIds().Count; i++ )
              {
            data.Add( new Snoop.Data.String( string.Format( "Usage name [{0:d}]", i ), loadcombo.Document.GetElement( loadcombo.GetUsageIds()[i] ).Name ) );
              }
        }
        private void Stream( ArrayList data, LoadCombination loadcombo )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( LoadCombination ) ) );

              data.Add( new Snoop.Data.String( "Name", loadcombo.Name ) );
              data.Add( new Snoop.Data.String( "Combination type", loadcombo.Type.ToString() ) );
              data.Add( new Snoop.Data.String( "Combination state", loadcombo.State.ToString() ) );

              data.Add( new Snoop.Data.CategorySeparator( "Components" ) );
              data.Add( new Snoop.Data.Int( "Number of components", loadcombo.GetComponents().Count ) );

              for( int i = 0; i < loadcombo.GetComponents().Count; i++ )
              {
            data.Add( new Snoop.Data.String( string.Format( "Combination case name [{0:d}]", i ), loadcombo.Document.GetElement( loadcombo.GetCaseAndCombinationIds()[i] ).Name ) );
            data.Add( new Snoop.Data.String( string.Format( "Combination nature name [{0:d}]", i ), loadcombo.Document.GetElement( loadcombo.GetCaseAndCombinationIds()[i] ).Name ) );
            data.Add( new Snoop.Data.Double( string.Format( "Factor [{0:d}]", i ), loadcombo.GetComponents()[i].Factor ) );
              }

              data.Add( new Snoop.Data.CategorySeparator( "Usages" ) );
              data.Add( new Snoop.Data.Int( "Number of usages", loadcombo.GetUsageIds().Count ) );

              for( int i = 0; i < loadcombo.GetUsageIds().Count; i++ )
              {
            data.Add( new Snoop.Data.String( string.Format( "Usage name [{0:d}]", i ), loadcombo.Document.GetElement( loadcombo.GetUsageIds()[i] ).Name ) );
              }
        }
        private void Stream( ArrayList data, LoadCombination loadcombo )
        {
            data.Add( new Snoop.Data.ClassSeparator( typeof( LoadCombination ) ) );

              data.Add( new Snoop.Data.String( "Name", loadcombo.Name ) );
              data.Add( new Snoop.Data.String( "Combination type", loadcombo.CombinationType ) );
              data.Add( new Snoop.Data.Int( "Combination type index", loadcombo.CombinationTypeIndex ) );
              data.Add( new Snoop.Data.String( "Combination state", loadcombo.CombinationState ) );
              data.Add( new Snoop.Data.Int( "Combination state index", loadcombo.CombinationStateIndex ) );

              data.Add( new Snoop.Data.CategorySeparator( "Components" ) );
              data.Add( new Snoop.Data.Int( "Number of components", loadcombo.NumberOfComponents ) );

              for( int i = 0; i < loadcombo.NumberOfComponents; i++ )
              {
            data.Add( new Snoop.Data.String( string.Format( "Combination case name [{0:d}]", i ), loadcombo.get_CombinationCaseName( i ) ) );
            data.Add( new Snoop.Data.String( string.Format( "Combination nature name [{0:d}]", i ), loadcombo.get_CombinationNatureName( i ) ) );
            data.Add( new Snoop.Data.Double( string.Format( "Factor [{0:d}]", i ), loadcombo.get_Factor( i ) ) );
              }

              data.Add( new Snoop.Data.CategorySeparator( "Usages" ) );
              data.Add( new Snoop.Data.Int( "Number of usages", loadcombo.NumberOfUsages ) );

              for( int i = 0; i < loadcombo.NumberOfUsages; i++ )
              {
            data.Add( new Snoop.Data.String( string.Format( "Usage name [{0:d}]", i ), loadcombo.get_UsageName( i ) ) );
              }
        }