/***************************************************/ public void SetLoad(AreaUniformlyDistributedLoad areaUniformLoad, bool replace) { string axis; int shift; GetDirectionData(areaUniformLoad, out axis, out shift); int ret = 0; string caseName = GetAdapterId <string>(areaUniformLoad.Loadcase); foreach (IAreaElement area in areaUniformLoad.Objects.Elements) { bool tempReplace = replace; for (int direction = 1; direction <= 3; direction++) { double val = direction == 1 ? areaUniformLoad.Pressure.X : areaUniformLoad.Axis == LoadAxis.Global ? direction == 2 ? areaUniformLoad.Pressure.Y : (shift == 6 ? -areaUniformLoad.Pressure.Z : areaUniformLoad.Pressure.Z) : direction == 2 ? -areaUniformLoad.Pressure.Y : areaUniformLoad.Pressure.Z; //note: etabs acts different then stated in API documentstion if (val != 0) { ret = m_model.AreaObj.SetLoadUniform(GetAdapterId <string>(area), caseName, val, direction + shift, tempReplace, axis); tempReplace = false; } } } }
/***************************************************/ private List <ILoad> ReadAreaLoad(List <Loadcase> loadcases) { List <ILoad> bhLoads = new List <ILoad>(); Dictionary <string, Panel> bhomPanels = ReadPanel().ToDictionary(x => GetAdapterId <string>(x)); string[] names = null; string[] loadcase = null; string[] CSys = null; int[] dir = null; int nameCount = 0; double[] f = null; if (m_model.AreaObj.GetLoadUniform("All", ref nameCount, ref names, ref loadcase, ref CSys, ref dir, ref f, eItemType.Group) != 0) { return(bhLoads); } for (int i = 0; i < nameCount; i++) { Loadcase bhLoadcase = loadcases.FirstOrDefault(x => x.Name == loadcase[i]); if (bhLoadcase == null) { continue; } BHoMGroup <IAreaElement> panelObjects = new BHoMGroup <IAreaElement>() { Elements = { bhomPanels[names[i]] } }; Vector pressure = Direction(dir[i], f[i]); if (CSys[i] == "Local") { double temp = -pressure.Y; pressure.Y = pressure.Z; pressure.Z = temp; } AreaUniformlyDistributedLoad bhAreaUniLoad = new AreaUniformlyDistributedLoad() { Pressure = pressure, Loadcase = bhLoadcase, Objects = panelObjects }; SetDirection(bhAreaUniLoad, dir[i], CSys[i]); bhLoads.Add(bhAreaUniLoad); } return(bhLoads); }
/***************************************************/ private IFLoadingGlobalDistributed CreateGlobalDistributedLoadSurface(AreaUniformlyDistributedLoad distributedLoad, object[] lusasSurfaces) { IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(distributedLoad.Loadcase.AdapterId <int>(typeof(LusasId))); IFLoadingGlobalDistributed lusasGlobalDistributed = CreateGlobalDistributed(distributedLoad.Name, "Area", assignedLoadcase, distributedLoad.Pressure, null, lusasSurfaces); int adapterIdName = lusasGlobalDistributed.getID(); distributedLoad.SetAdapterId(typeof(LusasId), adapterIdName); return(lusasGlobalDistributed); }
/***************************************************/ public static List <ICurve> Visualize(this AreaUniformlyDistributedLoad areaUDL, double scaleFactor = 1.0, bool displayForces = true, bool displayMoments = true, bool asResultants = true, bool edgeDisplay = true, bool gridDisplay = false) { if (!displayForces) { return(new List <ICurve>()); } List <ICurve> arrows = new List <ICurve>(); Vector globalForceVec = areaUDL.Pressure * scaleFactor; foreach (IAreaElement element in areaUDL.Objects.Elements) { Vector forceVec; Cartesian system = null; IEnumerable <ICurve> edges = element.IEdges(); if (areaUDL.Axis == LoadAxis.Global) { if (areaUDL.Projected) { Vector normal = element.INormal().Normalise(); double scale = Math.Abs(normal.DotProduct(globalForceVec.Normalise())); forceVec = globalForceVec * scale; } else { forceVec = globalForceVec; } } else { Vector normal = element.INormal(); Vector x = edges.First().IStartDir(); Vector y = normal.CrossProduct(x); system = new Cartesian(new Point(), x, y, normal); forceVec = globalForceVec; } if (edgeDisplay) { arrows.AddRange(ConnectedArrows(edges, forceVec, asResultants, system, 1, true)); } if (gridDisplay) { arrows.AddRange(MultipleArrows(element.IPointGrid(), forceVec, asResultants, system, 1, true)); } } return(arrows); }
private List <ILoad> ReadAreaUniformlyDistributedLoads(List <string> ids = null) { /***************************************************/ /**** Private Methods ****/ /***************************************************/ List <ILoad> areaUniformlyDistributedLoads = new List <ILoad>(); object[] lusasGlobalDistributedLoads = d_LusasData.getAttributes("Global Distributed Load"); object[] lusasLocalDistributedLoads = d_LusasData.getAttributes("Distributed Load"); object[] lusasDistributedLoads = lusasGlobalDistributedLoads.Concat( lusasLocalDistributedLoads).ToArray(); if (!(lusasDistributedLoads.Count() == 0)) { List <Panel> panelsList = ReadPanels(); Dictionary <string, Panel> panels = panelsList.ToDictionary( x => x.AdapterId <string>(typeof(LusasId))); List <IFLoadcase> allLoadcases = new List <IFLoadcase>(); for (int i = 0; i < lusasDistributedLoads.Count(); i++) { IFLoading lusasDistributedLoad = (IFLoading)lusasDistributedLoads[i]; if (lusasDistributedLoad.getValue("type") == "Area" || lusasDistributedLoad.getValue("type") == "all") { IEnumerable <IGrouping <string, IFAssignment> > groupedByLoadcases = GetLoadAssignments(lusasDistributedLoad); foreach (IEnumerable <IFAssignment> groupedAssignment in groupedByLoadcases) { AreaUniformlyDistributedLoad areaUniformlyDistributedLoad = Adapters.Lusas.Convert.ToAreaUniformlyDistributed( lusasDistributedLoad, groupedAssignment, panels); List <string> analysisName = new List <string> { lusasDistributedLoad.getAttributeType() }; areaUniformlyDistributedLoad.Tags = new HashSet <string>(analysisName); areaUniformlyDistributedLoads.Add(areaUniformlyDistributedLoad); } } } } return(areaUniformlyDistributedLoads); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static AreaUniformlyDistributedLoad ToAreaUniformlyDistributed( IFLoading lusasDistributed, IEnumerable <IFAssignment> lusasAssignments, Dictionary <string, Panel> panels) { IFLoadcase assignedLoadcase = (IFLoadcase)lusasAssignments.First().getAssignmentLoadset(); Loadcase loadcase = ToLoadcase(assignedLoadcase); IEnumerable <IAreaElement> assignedPanels = GetSurfaceAssignments( lusasAssignments, panels); Vector pressureVector = new Vector { X = lusasDistributed.getValue("WX"), Y = lusasDistributed.getValue("WY"), Z = lusasDistributed.getValue("WZ") }; AreaUniformlyDistributedLoad areaUniformlyDistributedLoad = null; if (lusasDistributed.getAttributeType() == "Global Distributed Load") { areaUniformlyDistributedLoad = Engine.Structure.Create.AreaUniformlyDistributedLoad( loadcase, pressureVector, assignedPanels, LoadAxis.Global, true, GetName(lusasDistributed)); } else if (lusasDistributed.getAttributeType() == "Distributed Load") { areaUniformlyDistributedLoad = Engine.Structure.Create.AreaUniformlyDistributedLoad( loadcase, pressureVector, assignedPanels, LoadAxis.Local, true, GetName(lusasDistributed)); } int adapterNameId = lusasDistributed.getID(); areaUniformlyDistributedLoad.SetAdapterId(typeof(LusasId), adapterNameId); return(areaUniformlyDistributedLoad); }
public static void SetLoad(cSapModel model, AreaUniformlyDistributedLoad areaUniformLoad, bool replace) { int ret = 0; string csiCaseName = CaseNameToCSI(areaUniformLoad.Loadcase); foreach (IAreaElement area in areaUniformLoad.Objects.Elements) { for (int direction = 1; direction <= 3; direction++) { double val = direction == 1 ? areaUniformLoad.Pressure.X : direction == 2 ? areaUniformLoad.Pressure.Y : areaUniformLoad.Pressure.Z; if (val != 0) { //NOTE: Replace=false has been set to allow setting x,y,z-load directions !!! this should be user controled and allowed as default ret = model.AreaObj.SetLoadUniform(area.CustomData[AdapterId].ToString(), csiCaseName, val, direction + 3, replace); } } } }
/***************************************************/ private bool CreateLoad(ContourLoad bhLoad) { double[] loadVals = bhLoad.Force.ToDoubleArray(); List <Opening> openingsList = new List <Opening>(); Panel loadPanel = Engine.Structure.Create.Panel(bhLoad.Contour as ICurve, openingsList); CreateObject(loadPanel); List <Panel> panelsToLoad = new List <Panel>(); panelsToLoad.Add(loadPanel); AreaUniformlyDistributedLoad contourLoadArea = Engine.Structure.Create.AreaUniformlyDistributedLoad(bhLoad.Loadcase, loadVals.ToVector(), panelsToLoad, bhLoad.Axis, bhLoad.Projected, bhLoad.Name); CreateLoad(contourLoadArea); SetAdapterId(bhLoad, null); return(true); }
public static LoadType LoadType(this AreaUniformlyDistributedLoad load) { return(oM.Structure.Loads.LoadType.AreaUniformLoad); }
public static List <ICurve> Visualize(this AreaUniformlyDistributedLoad areaUDL, double scaleFactor = 1.0, bool displayForces = true, bool displayMoments = true, bool asResultants = true, bool edgeDisplay = true, bool gridDisplay = false) { if (areaUDL.IsNull()) { return(null); } if (!displayForces) { return(new List <ICurve>()); } List <ICurve> arrows = new List <ICurve>(); Vector globalForceVec = areaUDL.Pressure * scaleFactor; foreach (IAreaElement element in areaUDL.Objects.Elements) { Vector forceVec; List <List <ICurve> > allEdges = edgeDisplay ? ISubElementBoundaries(element) : new List <List <ICurve> >(); List <Basis> allOrientations = IAllLocalOrientations(element); List <List <Point> > subElementGrids = gridDisplay ? ISubElementPointGrids(element) : new List <List <Point> >(); for (int i = 0; i < allOrientations.Count; i++) { IEnumerable <ICurve> edges = edgeDisplay ? allEdges[i] : null; List <Point> pts = gridDisplay ? subElementGrids[i] : null; Basis orientation = allOrientations[i]; if (areaUDL.Axis == LoadAxis.Global) { if (areaUDL.Projected) { Vector normal = orientation.Z; double scale = Math.Abs(normal.DotProduct(globalForceVec.Normalise())); forceVec = globalForceVec * scale; } else { forceVec = globalForceVec; } orientation = Basis.XY; } else { forceVec = globalForceVec; } if (edgeDisplay) { arrows.AddRange(ConnectedArrows(edges, forceVec, asResultants, orientation, 1, true)); } if (gridDisplay) { arrows.AddRange(MultipleArrows(pts, forceVec, asResultants, orientation, 1, true)); } } } return(arrows); }
/***************************************************/ /**** Private methods ****/ /***************************************************/ private bool CreateObject(AreaUniformlyDistributedLoad areaUDL) { int uID = 1; int err = 0; int loadCaseId = GetAdapterId <int>(areaUDL.Loadcase); double[] pressures = new double[3]; pressures[0] = areaUDL.Pressure.X; pressures[1] = areaUDL.Pressure.Y; pressures[2] = areaUDL.Pressure.Z; double[] normalPressures = new double[2]; normalPressures[0] = areaUDL.Pressure.Z; // -z surface of the plate. double[] shearPressures = new double[2]; shearPressures[0] = areaUDL.Pressure.X; shearPressures[1] = areaUDL.Pressure.Y; int project = areaUDL.Projected ? St7.ppProjResultant : St7.ppNone; if (areaUDL.Axis == LoadAxis.Local) { foreach (IAreaElement areaElement in areaUDL.Objects.Elements) { if (areaElement is Panel) { int elementId = GetAdapterId <int>(areaElement); if (areaUDL.Pressure.Z != 0) { err = St7.St7SetPlateNormalPressure2(uID, elementId, loadCaseId, normalPressures); if (!St7ErrorCustom(err, "Couldn't set normal pressure for a loadcase " + loadCaseId + " plate " + elementId)) { return(false); } } if (areaUDL.Pressure.X != 0 || areaUDL.Pressure.Y != 0) { err = St7.St7SetPlateShear2(uID, elementId, loadCaseId, shearPressures); if (!St7ErrorCustom(err, "Couldn't set shear pressure for a loadcase " + loadCaseId + " plate " + elementId)) { return(false); } } } else if (areaElement is FEMesh) { foreach (FEMeshFace feFace in (areaElement as FEMesh).Faces) { int elementId = GetAdapterId <int>(feFace); if (areaUDL.Pressure.Z != 0) { err = St7.St7SetPlateNormalPressure2(uID, elementId, loadCaseId, normalPressures); if (!St7ErrorCustom(err, "Couldn't set normal pressure for a loadcase " + loadCaseId + " plate " + elementId)) { return(false); } } if (areaUDL.Pressure.X != 0 || areaUDL.Pressure.Y != 0) { err = St7.St7SetPlateShear2(uID, elementId, loadCaseId, shearPressures); if (!St7ErrorCustom(err, "Couldn't set shear pressure for a loadcase " + loadCaseId + " plate " + elementId)) { return(false); } } } } } } if (areaUDL.Axis == LoadAxis.Global && areaUDL.Pressure.Length() > 0) { foreach (IAreaElement areaElement in areaUDL.Objects.Elements) { if (areaElement is Panel) { int elementId = GetAdapterId <int>(areaElement); err = St7.St7SetPlateGlobalPressure3S(uID, elementId, St7.psPlateZPlus, project, loadCaseId, pressures); if (!St7ErrorCustom(err, "Couldn't set global pressure for a loadcase " + loadCaseId + " plate " + elementId)) { return(false); } } else if (areaElement is FEMesh) { foreach (FEMeshFace feFace in (areaElement as FEMesh).Faces) { int elementId = GetAdapterId <int>(feFace); err = St7.St7SetPlateGlobalPressure3S(uID, elementId, St7.psPlateZPlus, project, loadCaseId, pressures); if (!St7ErrorCustom(err, "Couldn't set global pressure for a loadcase " + loadCaseId + " plate " + elementId)) { return(false); } } } } } return(true); }
/***************************************************/ private bool CreateLoad(AreaUniformlyDistributedLoad bhLoad) { List <IAreaElement> panels = bhLoad.Objects.Elements.ToList(); string loadPat = GetAdapterId <string>(bhLoad.Loadcase); double[] vals = bhLoad.Pressure.ToDoubleArray(); int[] dirs = null; switch (bhLoad.Axis) { case LoadAxis.Global: if (bhLoad.Projected) { dirs = new int[] { 7, 8, 9 }; } else { dirs = new int[] { 4, 5, 6 }; } break; case LoadAxis.Local: dirs = new int[] { 1, 2, 3 }; break; } bool replace = SAPPushConfig.ReplaceLoads; string cSys = bhLoad.Axis.ToCSI(); eItemType type = eItemType.Objects; foreach (Panel panel in panels) { string name = GetAdapterId <string>(panel); string propName = ""; m_model.AreaObj.GetProperty(name, ref propName); if (propName == "None") { bool replaceNow = replace; for (int i = 0; i < dirs.Count(); i++) { if (vals[i] != 0) { if (m_model.AreaObj.SetLoadUniformToFrame(name, loadPat, vals[i], dirs[i], 2, replaceNow, cSys, type) != 0) { Engine.Base.Compute.RecordWarning($"Could not assign an area load in direction {dirs[i]}"); } replaceNow = false; } } } else { bool replaceNow = replace; for (int i = 0; i < dirs.Count(); i++) { if (vals[i] != 0) { if (m_model.AreaObj.SetLoadUniform(name, loadPat, vals[i], dirs[i], replaceNow, cSys, type) != 0) { Engine.Base.Compute.RecordWarning($"Could not assign an area load in direction {dirs[i]}"); } replaceNow = false; } } } } SetAdapterId(bhLoad, null); return(true); }