/***************************************************/ /**** Private Methods ****/ /***************************************************/ private List <Loadcase> ReadLoadcase(List <string> ids = null) { List <Loadcase> loadCases = new List <Loadcase>(); int nameCount = 0; string[] nameArr = null; m_model.LoadPatterns.GetNameList(ref nameCount, ref nameArr); ids = FilterIds(ids, nameArr); foreach (string id in ids) { Loadcase bhomCase = new Loadcase(); eLoadPatternType patternType = eLoadPatternType.Other; if (m_model.LoadPatterns.GetLoadType(id, ref patternType) == 0) { bhomCase.Name = id; bhomCase.Nature = patternType.ToBHoM(); } else { ReadElementError("Load Pattern", id); } SetAdapterId(bhomCase, id); loadCases.Add(bhomCase); } return(loadCases); }
/***************************************************/ private List <ILoad> ReadPointLoad(List <Loadcase> loadcases) { List <ILoad> bhLoads = new List <ILoad>(); Dictionary <string, Node> bhomNodes = ReadNode().ToDictionary(x => GetAdapterId <string>(x)); string[] names = null; string[] loadcase = null; string[] CSys = null; int[] step = null; int nameCount = 0; double[] fx = null; double[] fy = null; double[] fz = null; double[] mx = null; double[] my = null; double[] mz = null; if (m_model.PointObj.GetLoadForce("All", ref nameCount, ref names, ref loadcase, ref step, ref CSys, ref fx, ref fy, ref fz, ref mx, ref my, ref mz, eItemType.Group) != 0) { return(bhLoads); } for (int i = 0; i < nameCount; i++) { if (CSys[i] != "Global") { Engine.Base.Compute.RecordWarning($"The coordinate system: {CSys[i]} was not read. The PointLoads defined in the coordinate system: {CSys[i]} were set as Global"); } Loadcase bhLoadcase = loadcases.FirstOrDefault(x => x.Name == loadcase[i]); if (bhLoadcase == null) { continue; } PointLoad bhLoad = new PointLoad() { Force = new Vector() { X = fx[i], Y = fy[i], Z = fz[i] }, Moment = new Vector() { X = mx[i], Y = my[i], Z = mz[i] }, Loadcase = bhLoadcase, Objects = new BHoMGroup <Node>() { Elements = { bhomNodes[names[i]] } } }; bhLoads.Add(bhLoad); } return(bhLoads); }
/***************************************************/ public static PointVelocity PointVelocity(Loadcase loadcase, IEnumerable <Node> objects, Vector translation = null, Vector rotation = null, LoadAxis axis = LoadAxis.Global, string name = "") { return(PointVelocity(loadcase, new BHoMGroup <Node>() { Elements = objects.ToList() }, translation, rotation, axis, name)); }
/***************************************************/ /**** 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); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static BarUniformTemperatureLoad ToBarUniformTemperatureLoad( IFLoading lusasTemperatureLoad, IEnumerable <IFAssignment> lusasAssignments, Dictionary <string, Bar> bars) { IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset(); Loadcase loadcase = ToLoadcase(assignedLoadcase); double temperatureChange = lusasTemperatureLoad.getValue("T") - lusasTemperatureLoad.getValue("T0"); IEnumerable <Bar> assignedBars = GetLineAssignments(lusasAssignments, bars); BarUniformTemperatureLoad barUniformTemperatureLoad = Engine.Structure.Create.BarUniformTemperatureLoad( loadcase, temperatureChange, assignedBars, LoadAxis.Local, false, GetName(lusasTemperatureLoad)); int adapterNameId = lusasTemperatureLoad.getID(); barUniformTemperatureLoad.SetAdapterId(typeof(LusasId), adapterNameId); return(barUniformTemperatureLoad); }
/***************************************************/ /**** 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); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static GravityLoad ToGravityLoad(IFLoading lusasGravityLoad, IEnumerable <IFAssignment> lusasAssignments, Dictionary <string, Node> nodes, Dictionary <string, Bar> bars, Dictionary <string, Panel> panels) { IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset(); Loadcase loadcase = ToLoadcase(assignedLoadcase); Vector gravityVector = new Vector { X = lusasGravityLoad.getValue("accX"), Y = lusasGravityLoad.getValue("accY"), Z = lusasGravityLoad.getValue("accZ") }; IEnumerable <BHoMObject> assignedObjects = GetGeometryAssignments( lusasAssignments, nodes, bars, panels); GravityLoad gravityLoad = Engine.Structure.Create.GravityLoad( loadcase, gravityVector, assignedObjects, GetName(lusasGravityLoad)); int adapterNameId = lusasGravityLoad.getID(); gravityLoad.SetAdapterId(typeof(LusasId), adapterNameId); return(gravityLoad); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static AreaUniformTemperatureLoad ToAreaTempratureLoad( IFLoading lusasTemperatureLoad, IEnumerable <IFAssignment> lusasAssignments, Dictionary <string, Panel> panels) { IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset(); Loadcase loadcase = ToLoadcase(assignedLoadcase); double temperatureChange = lusasTemperatureLoad.getValue("T") - lusasTemperatureLoad.getValue("T0"); IEnumerable <IAreaElement> assignedPanels = GetSurfaceAssignments(lusasAssignments, panels); AreaUniformTemperatureLoad AreaUniformTemperatureLoad = BH.Engine.Structure.Create.AreaUniformTemperatureLoad( loadcase, temperatureChange, assignedPanels, LoadAxis.Local, false, GetName(lusasTemperatureLoad)); int adapterNameId = lusasTemperatureLoad.getID(); AreaUniformTemperatureLoad.SetAdapterId(typeof(LusasId), adapterNameId); return(AreaUniformTemperatureLoad); }
/***************************************************/ 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); }
/***************************************************/ public static BarUniformlyDistributedLoad BarUniformlyDistributedLoad(Loadcase loadcase, IEnumerable <Bar> objects, Vector force = null, Vector moment = null, LoadAxis axis = LoadAxis.Global, bool projected = false, string name = "") { return(BarUniformlyDistributedLoad(loadcase, new BHoMGroup <Bar>() { Elements = objects.ToList() }, force, moment, axis, projected, name)); }
/***************************************************/ public static BarTemperatureLoad BarTemperatureLoad(Loadcase loadcase, double temperatureChange, IEnumerable <Bar> objects, LoadAxis axis = LoadAxis.Global, bool projected = false, string name = "") { return(BarTemperatureLoad(loadcase, temperatureChange, new BHoMGroup <Bar>() { Elements = objects.ToList() }, axis, projected, name)); }
/***************************************************/ public static AreaTemperatureLoad AreaTemperatureLoad(Loadcase loadcase, double t, IEnumerable <IAreaElement> objects, LoadAxis axis = LoadAxis.Global, bool projected = false, string name = "") { return(AreaTemperatureLoad(loadcase, t, new BHoMGroup <IAreaElement>() { Elements = objects.ToList() }, axis, projected, name)); }
/***************************************************/ public static GravityLoad GravityLoad(Loadcase loadcase, Vector direction, IEnumerable <IBHoMObject> objects, string name = "") { return(GravityLoad(loadcase, direction, new BHoMGroup <BHoMObject>() { Elements = objects.Cast <BHoMObject>().ToList() }, name)); }
/***************************************************/ public static BarPrestressLoad BarPrestressLoad(Loadcase loadcase, double prestress, IEnumerable <Bar> objects, string name = "") { return(BarPrestressLoad(loadcase, prestress, new BHoMGroup <Bar>() { Elements = objects.ToList() }, name)); }
/***************************************************/ public static AreaUniformalyDistributedLoad AreaUniformalyDistributedLoad(Loadcase loadcase, Vector pressure, IEnumerable <IAreaElement> objects, LoadAxis axis = LoadAxis.Global, bool projected = false, string name = "") { return(AreaUniformalyDistributedLoad(loadcase, pressure, new BHoMGroup <IAreaElement>() { Elements = objects.ToList() }, axis, projected, name)); }
/***************************************************/ public static BarPointLoad BarPointLoad(Loadcase loadcase, double distFromA, IEnumerable <Bar> objects, Vector force = null, Vector moment = null, LoadAxis axis = LoadAxis.Global, string name = "") { return(BarPointLoad(loadcase, new BHoMGroup <Bar>() { Elements = objects.ToList() }, distFromA, force, moment, axis, name)); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFLoadcase CreateLoadcase(Loadcase loadcase) { IFLoadcase lusasLoadcase; if (d_LusasData.existsLoadset(loadcase.Name)) { lusasLoadcase = (IFLoadcase)d_LusasData.getLoadset(loadcase.Name); } else { if (loadcase.Number == 0) { lusasLoadcase = d_LusasData.createLoadcase(loadcase.Name); Compute.RecordWarning($"Loadcase {loadcase.Name} ID will be autogenerated by Lusas."); } else { lusasLoadcase = d_LusasData.createLoadcase(loadcase.Name, "", loadcase.Number); } } int adapterIdName = lusasLoadcase.getID(); loadcase.SetAdapterId(typeof(LusasId), adapterIdName); return(lusasLoadcase); }
/***************************************************/ public static PointForce PointForce(Loadcase loadcase, IEnumerable <Node> objects, Vector force = null, Vector moment = null, LoadAxis axis = LoadAxis.Global, string name = "") { return(PointForce(loadcase, new BHoMGroup <Node>() { Elements = objects.ToList() }, force, moment, axis, name)); }
/***************************************************/ public static BarDistributedMass BarDistributedMass(Loadcase loadcase, IEnumerable <Bar> objects, double distFromA = 0, double massA = 0, double distFromB = 0, double massB = 0, string name = "") { return(BarDistributedMass(loadcase, new BHoMGroup <Bar>() { Elements = objects.ToList() }, distFromA, massA, distFromB, massB, name)); }
/***************************************************/ public static BarVaryingDistributedLoad BarVaryingDistributedLoad(Loadcase loadcase, IEnumerable <Bar> objects, double distFromA = 0, Vector forceA = null, Vector momentA = null, double distFromB = 0, Vector forceB = null, Vector momentB = null, LoadAxis axis = LoadAxis.Global, bool projected = false, string name = "") { return(BarVaryingDistributedLoad(loadcase, new BHoMGroup <Bar>() { Elements = objects.ToList() }, distFromA, forceA, momentA, distFromB, forceB, momentB, axis, projected, name)); }
/***************************************************/ /*** Read Methods ***/ /***************************************************/ private List <Loadcase> ReadLoadcase(List <string> ids = null) { int nameCount = 0; string[] nameArr = { }; List <Loadcase> loadcaseList = new List <Loadcase>(); m_model.LoadPatterns.GetNameList(ref nameCount, ref nameArr); ids = FilterIds(ids, nameArr); foreach (string id in ids) { Loadcase bhLoadcase = new Loadcase(); eLoadPatternType type = eLoadPatternType.Other; if (m_model.LoadPatterns.GetLoadType(id, ref type) == 0) { bhLoadcase.Name = id; bhLoadcase.Nature = LoadPatternTypeToBHoM(type); } SetAdapterId(bhLoadcase, id); loadcaseList.Add(bhLoadcase); } return(loadcaseList); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateObject(Loadcase bhLoadCase) { int err; int loadCaseId = bhLoadCase.Number; int loadCaseCount = 0; int uID = 1; err = St7.St7GetNumLoadCase(uID, ref loadCaseCount); if (loadCaseCount < loadCaseId) { err = St7.St7NewLoadCase(uID, bhLoadCase.Name); if (!St7ErrorCustom(err, "Could not create a load case number " + loadCaseId)) { return(false); } } else // updating { StringBuilder currentLoadCaseName = new StringBuilder(St7.kMaxStrLen); err = St7.St7GetLoadCaseName(uID, loadCaseId, currentLoadCaseName, St7.kMaxStrLen); if (!String.Equals(currentLoadCaseName.ToString(), bhLoadCase.Name, StringComparison.OrdinalIgnoreCase)) { err = St7.St7SetLoadCaseName(uID, loadCaseId, bhLoadCase.Name); if (!St7ErrorCustom(err, "Could not update a load case number " + loadCaseId)) { return(false); } } } err = St7.St7SetLoadCaseType(uID, loadCaseId, St7LoadCaseTypeFromNature(bhLoadCase.Nature)); err = St7.St7EnableLSALoadCase(uID, loadCaseId, 1); return(true); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static PointDisplacement ToPointDisplacement(IFLoading lusasPrescribedDisplacement, IEnumerable <IFAssignment> lusasAssignments, Dictionary <string, Node> nodes) { IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset(); Loadcase loadcase = ToLoadcase(assignedLoadcase); IEnumerable <Node> assignedNodes = GetPointAssignments(lusasAssignments, nodes); Vector translationVector = new Vector { X = lusasPrescribedDisplacement.getValue("U"), Y = lusasPrescribedDisplacement.getValue("V"), Z = lusasPrescribedDisplacement.getValue("W") }; Vector rotationVector = new Vector { X = lusasPrescribedDisplacement.getValue("THX"), Y = lusasPrescribedDisplacement.getValue("THY"), Z = lusasPrescribedDisplacement.getValue("THZ") }; PointDisplacement pointDisplacement = BH.Engine.Structure.Create.PointDisplacement( loadcase, assignedNodes, translationVector, rotationVector, LoadAxis.Global, GetName(lusasPrescribedDisplacement)); int adapterNameId = lusasPrescribedDisplacement.getID(); pointDisplacement.SetAdapterId(typeof(LusasId), adapterNameId); // Needs to be a bit here that determines whether it is global or local - actually this cannot be done as the //attribute is applied to a group, and within the group the axis could local or global return(pointDisplacement); }
public static Loadcase GetLoadcase(cSapModel model, string id) { Loadcase bhLoadcase = new Loadcase(); int number; string name = "NA"; string[] nameNum = id.Split(new [] { ":::" }, StringSplitOptions.None); if (nameNum.Count() > 1) { name = nameNum[0]; int.TryParse(nameNum[1], out number); } else { int.TryParse(id, out number); } bhLoadcase.Name = name; bhLoadcase.Number = number; eLoadPatternType type = eLoadPatternType.Other; model.LoadPatterns.GetLoadType(id, ref type); bhLoadcase.Nature = GetLoadNature(type); return(bhLoadcase); }
public static void SetLoadcase(cSapModel model, Loadcase loadcase) { //string name = loadcase.CustomData[AdapterId].ToString(); string name = CaseNameToCSI(loadcase); eLoadPatternType patternType = GetLoadPatternType(loadcase.Nature); model.LoadPatterns.Add(name, patternType); }
/***************************************************/ private bool CreateObject(Loadcase loadcase) { bool success = true; Helper.SetLoadcase(m_model, loadcase); return(success); }
public static BarDifferentialTemperatureLoad BarDifferentialTemperatureLoad(Loadcase loadcase, List <double> positions, List <double> temperatures, DifferentialTemperatureLoadDirection localLoadDirection, IEnumerable <Bar> objects, string name = "") { if (loadcase.IsNull() || positions.IsNullOrEmpty() || temperatures.IsNullOrEmpty()) { return(null); } //Checks for positions and profiles if (positions.Count != temperatures.Count) { Reflection.Compute.RecordError("Number of positions and temperatures provided are not equal"); return(null); } else if (positions.Exists((double d) => { return(d > 1); }) || positions.Exists((double d) => { return(d < 0); })) { Reflection.Compute.RecordError("Positions must exist between 0 and 1 (inclusive)"); return(null); } // Check that top and bottom positions are included if (!(positions.Contains(0) && positions.Contains(1))) { Reflection.Compute.RecordError("Positions must inlude the bottom (0) and top (1) position."); return(null); } if (positions.Zip(positions.Skip(1), (a, b) => new { a, b }).Any(p => p.a > p.b)) { Reflection.Compute.RecordError("Positions must be sorted in ascending order."); return(null); } //Create ditionary for TaperedProfile Dictionary <Double, Double> temperatureProfile = positions.Zip(temperatures, (z, t) => new { z, t }) .ToDictionary(x => x.z, x => x.t); BHoMGroup <Bar> group = new BHoMGroup <Bar>(); if (objects == null) { group = null; } else { group.Elements = objects.ToList(); } return(new BarDifferentialTemperatureLoad { Loadcase = loadcase, TemperatureProfile = temperatureProfile, LoadDirection = localLoadDirection, Objects = group, Name = name }); }
public static BarDifferentialTemperatureLoad BarDifferentialTemperatureLoad(Loadcase loadcase, double topTemperature, double bottomTemperature, DifferentialTemperatureLoadDirection localLoadDirection, IEnumerable <Bar> objects, string name = "") { return(BarDifferentialTemperatureLoad(loadcase, new List <double>() { 0, 1 }, new List <double>() { topTemperature, bottomTemperature }, localLoadDirection, objects, name)); }
/***************************************************/ public static BarPrestressLoad BarPrestressLoad(Loadcase loadcase, double prestress, BHoMGroup <Bar> group, string name = "") { return(new BarPrestressLoad { Loadcase = loadcase, Prestress = prestress, Objects = group, Name = name }); }
/***************************************************/ public static GravityLoad GravityLoad(Loadcase loadcase, Vector direction, BHoMGroup <BHoMObject> group, string name = "") { return(new GravityLoad { Loadcase = loadcase, GravityDirection = direction, Objects = group, Name = name }); }