/***************************************************/ private IFLoadingGlobalDistributed CreateGlobalDistributed(string lusasName, string type, IFLoadcase assignedLoadcase, Vector force, Vector moment, object[] lusasGeometry) { IFLoadingGlobalDistributed lusasGlobalDistributed; if (d_LusasData.existsAttribute("Loading", lusasName)) { lusasGlobalDistributed = (IFLoadingGlobalDistributed)d_LusasData.getAttribute("Loading", lusasName); } else { lusasGlobalDistributed = d_LusasData.createLoadingGlobalDistributed(lusasName); if (type == "Length") { lusasGlobalDistributed.setGlobalDistributed(type, force.X, force.Y, force.Z, moment.X, moment.Y, moment.Z); } else if (type == "Area") { lusasGlobalDistributed.setGlobalDistributed(type, force.X, force.Y, force.Z); } } IFAssignment lusasAssignment = m_LusasApplication.assignment(); lusasAssignment.setLoadset(assignedLoadcase); lusasGlobalDistributed.assignTo(lusasGeometry, lusasAssignment); return(lusasGlobalDistributed); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFLoadingBody CreateGravityLoad(GravityLoad gravityLoad, IFGeometry[] lusasGeometry) { IFLoadingBody lusasGravityLoad; IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(gravityLoad.Loadcase.AdapterId <int>(typeof(LusasId))); if (d_LusasData.existsAttribute("Loading", gravityLoad.Name)) { lusasGravityLoad = (IFLoadingBody)d_LusasData.getAttributes("Loading", gravityLoad.Name); } else { lusasGravityLoad = d_LusasData.createLoadingBody(gravityLoad.Name); lusasGravityLoad.setBody(gravityLoad.GravityDirection.X, gravityLoad.GravityDirection.Y, gravityLoad.GravityDirection.Z); } IFAssignment lusasAssignment = m_LusasApplication.assignment(); lusasAssignment.setLoadset(assignedLoadcase); lusasGravityLoad.assignTo(lusasGeometry, lusasAssignment); int adapterIdName = lusasGravityLoad.getID(); gravityLoad.SetAdapterId(typeof(LusasId), adapterIdName); return(lusasGravityLoad); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFLoadingConcentrated CreateConcentratedLoad(PointLoad pointLoad, object[] lusasPoints) { IFLoadingConcentrated lusasPointLoad; IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(pointLoad.Loadcase.AdapterId <int>(typeof(LusasId))); if (d_LusasData.existsAttribute("Loading", pointLoad.Name)) { lusasPointLoad = (IFLoadingConcentrated)d_LusasData.getAttribute("Loading", pointLoad.Name); } else { lusasPointLoad = d_LusasData.createLoadingConcentrated(pointLoad.Name); lusasPointLoad.setConcentrated( pointLoad.Force.X, pointLoad.Force.Y, pointLoad.Force.Z, pointLoad.Moment.X, pointLoad.Moment.Y, pointLoad.Moment.Z); } IFAssignment lusasAssignment = m_LusasApplication.assignment(); lusasAssignment.setLoadset(assignedLoadcase); lusasPointLoad.assignTo(lusasPoints, lusasAssignment); int adapterIdName = lusasPointLoad.getID(); pointLoad.SetAdapterId(typeof(LusasId), adapterIdName); return(lusasPointLoad); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFSurface CreateSurface(Panel panel) { List <IFLine> edges = new List <IFLine>(); foreach (Edge edge in panel.ExternalEdges) { string edgeId = GetAdapterId <string>(edge); if (string.IsNullOrEmpty(edgeId)) { Engine.Base.Compute.RecordError("Could not find the ids for at least one Edge, Panel not created."); return(null); } else { edges.Add(d_LusasData.getLineByNumber(edgeId)); } } IFSurface lusasSurface = d_LusasData.createSurfaceBy(edges.ToArray()); if (lusasSurface != null) { int adapterIdName = lusasSurface.getID(); panel.SetAdapterId(typeof(LusasId), adapterIdName); if (!(panel.Tags.Count == 0)) { AssignObjectSet(lusasSurface, panel.Tags); } if (CheckPropertyWarning(panel, p => p.Property) && !Engine.Adapters.Lusas.Query.InvalidSurfaceProperty(panel.Property)) { IFAttribute lusasGeometricSurface = d_LusasData.getAttribute("Surface Geometric", panel.Property.AdapterId <int>(typeof(LusasId))); lusasGeometricSurface.assignTo(lusasSurface); if (CheckPropertyWarning(panel, p => p.Property.Material)) { IFAttribute lusasMaterial = d_LusasData.getAttribute("Material", panel.Property.Material.AdapterId <int>(typeof(LusasId))); lusasMaterial.assignTo(lusasSurface); } } if (panel.Fragments.Contains(typeof(MeshSettings2D))) { IFAssignment meshAssignment = m_LusasApplication.newAssignment(); meshAssignment.setAllDefaults(); MeshSettings2D meshSettings2D = panel.FindFragment <MeshSettings2D>(); IFMeshAttr mesh = d_LusasData.getMesh(meshSettings2D.Name); mesh.assignTo(lusasSurface, meshAssignment); } } return(lusasSurface); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFPrescribedDisplacementLoad CreatePrescribedDisplacement(PointDisplacement pointDisplacement, object[] lusasPoints) { IFPrescribedDisplacementLoad lusasPrescribedDisplacement; IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(pointDisplacement.Loadcase.AdapterId <int>(typeof(LusasId))); if (d_LusasData.existsAttribute("Loading", pointDisplacement.Name)) { lusasPrescribedDisplacement = (IFPrescribedDisplacementLoad)d_LusasData.getAttribute("Loading", pointDisplacement.Name); } else { List <string> valueNames = new List <string> { "u", "v", "w", "thx", "thy", "thz" }; List <string> boolCheck = new List <string> { "haveDispX", "haveDispY", "haveDispZ", "haveRotX", "haveRotY", "haveRotZ" }; List <double> displacements = new List <double> { pointDisplacement.Translation.X, pointDisplacement.Translation.Y, pointDisplacement.Translation.Z, pointDisplacement.Rotation.X, pointDisplacement.Rotation.Y, pointDisplacement.Rotation.Z }; lusasPrescribedDisplacement = d_LusasData.createPrescribedDisplacementLoad( pointDisplacement.Name, "Total"); for (int i = 0; i < valueNames.Count(); i++) { if (!(displacements[i] == 0)) { lusasPrescribedDisplacement.setValue(boolCheck[i], true); lusasPrescribedDisplacement.setValue(valueNames[i], displacements[i]); } else { lusasPrescribedDisplacement.setValue(boolCheck[i], false); } } } IFAssignment lusasAssignment = m_LusasApplication.assignment(); lusasAssignment.setLoadset(assignedLoadcase); lusasPrescribedDisplacement.assignTo(lusasPoints, lusasAssignment); int adapterIdName = lusasPrescribedDisplacement.getID(); pointDisplacement.SetAdapterId(typeof(LusasId), adapterIdName); return(lusasPrescribedDisplacement); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static IEnumerable <IGrouping <string, IFAssignment> > GetLoadAssignments(IFLoading lusasForce) { object[] assignmentObjects = lusasForce.getAssignments(); List <IFAssignment> assignments = new List <IFAssignment>(); for (int j = 0; j < assignmentObjects.Count(); j++) { IFAssignment assignment = (IFAssignment)assignmentObjects[j]; assignments.Add(assignment); } IEnumerable <IGrouping <string, IFAssignment> > groupedByLoadcases = assignments.GroupBy(m => m.getAssignmentLoadset().getName()); return(groupedByLoadcases); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static List <string> GetAttributeAssignments(IFGeometry lusasGeometry, string attributeType) { object[] lusasAssignments = lusasGeometry.getAssignments(attributeType); List <string> attributeNames = new List <string>(); int n = lusasAssignments.Count(); for (int i = 0; i < n; i++) { IFAssignment lusasAssignment = lusasGeometry.getAssignments(attributeType)[i]; IFAttribute lusasAttribute = lusasAssignment.getAttribute(); string attributeName = GetName(lusasAttribute); attributeNames.Add(attributeName); } return(attributeNames); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static void AssignmentWarning(IFAssignment lusasAssignment) { if (lusasAssignment.getDatabaseObject() is IFPoint) { Engine.Base.Compute.RecordWarning( lusasAssignment.GetType().ToString() + " does not support assignment to points, these have not been pulled"); } else if (lusasAssignment.getDatabaseObject() is IFLine) { Engine.Base.Compute.RecordWarning( lusasAssignment.GetType().ToString() + " does not support assignment to lines, these have not been pulled"); } else if (lusasAssignment.getDatabaseObject() is IFSurface) { Engine.Base.Compute.RecordWarning( lusasAssignment.GetType().ToString() + " does not support assignment to surfaces, these have not been pulled"); } }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private void DeletePointAssignments(object[] lusasAttributes) { for (int i = 0; i < lusasAttributes.Count(); i++) { IFAttribute lusasAttribute = (IFAttribute)lusasAttributes[i]; object[] lusasAssignments = lusasAttribute.getAssignments(); for (int j = 0; j < lusasAssignments.Count(); j++) { IFAssignment lusasAssignment = (IFAssignment)lusasAssignments[j]; IFGeometry lusasGeometry = (IFGeometry)lusasAssignment.getDatabaseObject(); if (lusasGeometry is IFPoint) { Engine.Base.Compute.RecordWarning(lusasAttribute.getName() + " has been deleted because it was assigned to a point"); d_LusasData.Delete(lusasAttribute); break; } } } }
/***************************************************/ private IFLoadingLocalDistributed CreateLocalDistributed(string lusasName, string type, IFLoadcase assignedLoadcase, Vector force, object[] lusasGeometry) { IFLoadingLocalDistributed lusasLocalDistributed; if (d_LusasData.existsAttribute("Loading", lusasName)) { lusasLocalDistributed = (IFLoadingLocalDistributed)d_LusasData.getAttribute("Loading", lusasName); } else { lusasLocalDistributed = d_LusasData.createLoadingLocalDistributed(lusasName); lusasLocalDistributed.setLocalDistributed(force.X, force.Y, force.Z, type); } IFAssignment lusasAssignment = m_LusasApplication.assignment(); lusasAssignment.setLoadset(assignedLoadcase); lusasLocalDistributed.assignTo(lusasGeometry, lusasAssignment); return(lusasLocalDistributed); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ public static Tuple <bool, double, BarRelease, BarFEAType> GetMeshProperties(IFLine lusasLine) { bool meshAssigned = true; double betaAngle = 0; BarRelease barRelease = null; BarFEAType barType = BarFEAType.Flexural; object[] meshAssignments = lusasLine.getAssignments("Mesh"); if (meshAssignments.Length > 0) { foreach (object assignment in meshAssignments) { IFAssignment lusasAssignment = (IFAssignment)assignment; IFAttribute lusasMesh = lusasAssignment.getAttribute(); IFMeshLine lusasLineMesh = (IFMeshLine)lusasMesh; betaAngle = lusasAssignment.getBetaAngle(); barRelease = GetBarRelease(lusasLineMesh); object[] barMeshName = lusasLineMesh.getElementNames(); foreach (object type in barMeshName) { barType = GetFEAType(type); } } } else { meshAssigned = false; } Tuple <bool, double, BarRelease, BarFEAType> lineMeshProperties = new Tuple <bool, double, BarRelease, BarFEAType>(meshAssigned, betaAngle, barRelease, barType); return(lineMeshProperties); }
private IFLoadingTemperature CreateTemperatureLoad(string name, double temperatureChange, object[] lusasGeometry, IFLoadcase assignedLoadcase) { IFLoadingTemperature lusasTemperatureLoad; if (d_LusasData.existsAttribute("Loading", name)) { lusasTemperatureLoad = (IFLoadingTemperature)d_LusasData.getAttributes("Loading", name); } else { lusasTemperatureLoad = d_LusasData.createLoadingTemperature(name); lusasTemperatureLoad.setValue("T0", 0); lusasTemperatureLoad.setValue("T", temperatureChange); } IFAssignment lusasAssignment = m_LusasApplication.assignment(); lusasAssignment.setLoadset(assignedLoadcase); lusasTemperatureLoad.assignTo(lusasGeometry, lusasAssignment); return(lusasTemperatureLoad); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFLoadingBeamPoint CreateBarPointLoad(BarPointLoad barPointLoad, object[] lusasLines) { IFLoadingBeamPoint lusasBarPointLoad; IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(barPointLoad.Loadcase.AdapterId <int>(typeof(LusasId))); if (d_LusasData.existsAttribute("Loading", barPointLoad.Name)) { lusasBarPointLoad = (IFLoadingBeamPoint)d_LusasData.getAttribute("Loading", barPointLoad.Name); } else { lusasBarPointLoad = d_LusasData.createLoadingBeamPoint(barPointLoad.Name); if (barPointLoad.Axis.ToString() == "Global") { lusasBarPointLoad.setBeamPoint("parametric", "global", "beam"); } else { lusasBarPointLoad.setBeamPoint("parametric", "local", "beam"); } lusasBarPointLoad.addRow( barPointLoad.DistanceFromA, barPointLoad.Force.X, barPointLoad.Force.Y, barPointLoad.Force.Z, barPointLoad.Moment.X, barPointLoad.Moment.Y, barPointLoad.Moment.Z); } IFAssignment lusasAssignment = m_LusasApplication.assignment(); lusasAssignment.setLoadset(assignedLoadcase); lusasBarPointLoad.assignTo(lusasLines, lusasAssignment); int adapterIdName = lusasBarPointLoad.getID(); barPointLoad.SetAdapterId(typeof(LusasId), adapterIdName); return(lusasBarPointLoad); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFLine CreateLine(Bar bar) { if (!CheckPropertyError(bar, b => b.StartNode, true) || !CheckPropertyError(bar, b => b.EndNode, true) || !CheckPropertyError(bar, b => b.StartNode.Position, true) || !CheckPropertyError(bar, b => b.EndNode.Position, true)) { return(null); } if ( bar.FEAType == BarFEAType.CompressionOnly || bar.FEAType == BarFEAType.TensionOnly) { Engine.Base.Compute.RecordError("Lusas does not support " + bar.FEAType.ToString() + " Bars"); return(null); } string startNodeId = GetAdapterId <string>(bar.StartNode); string endNodeId = GetAdapterId <string>(bar.EndNode); if (string.IsNullOrEmpty(startNodeId) || string.IsNullOrEmpty(endNodeId)) { Engine.Base.Compute.RecordError("Could not find the ids for at least one end node for at least one Bar. Bar not created."); return(null); } IFPoint startPoint = d_LusasData.getPointByNumber(bar.StartNode.AdapterId <int>(typeof(LusasId))); IFPoint endPoint = d_LusasData.getPointByNumber(bar.EndNode.AdapterId <int>(typeof(LusasId))); IFLine lusasLine = d_LusasData.createLineByPoints(startPoint, endPoint); int adapterIdName = lusasLine.getID(); bar.SetAdapterId(typeof(LusasId), adapterIdName); if (bar.Tags.Count != 0) { AssignObjectSet(lusasLine, bar.Tags); } if (CheckPropertyWarning(bar, b => b.SectionProperty) && !Engine.Adapters.Lusas.Query.InvalidSectionProperty(bar.SectionProperty)) { if (!Engine.Adapters.Lusas.Query.InvalidSectionProfile(bar.SectionProperty)) { //Needed in case the SectionProfile is null and was not created if (d_LusasData.existsAttribute("Line Geometric", bar.SectionProperty.AdapterId <int>(typeof(LusasId)))) { IFAttribute lusasGeometricLine = d_LusasData.getAttribute("Line Geometric", bar.SectionProperty.AdapterId <int>(typeof(LusasId))); lusasGeometricLine.assignTo(lusasLine); } if (CheckPropertyWarning(bar, b => b.SectionProperty.Material)) { if (bar.SectionProperty.Material is IOrthotropic) { Engine.Base.Compute.RecordWarning($"Orthotropic Material {bar.SectionProperty.Material.DescriptionOrName()} cannot be assigned to Bar {bar.AdapterId<int>(typeof(LusasId))}, " + $"orthotropic materials can only be applied to 2D and 3D elements in Lusas."); } else if (bar.SectionProperty.Material is IIsotropic) { if (d_LusasData.existsAttribute("Material", bar.SectionProperty.Material.AdapterId <int>(typeof(LusasId)))) { IFAttribute lusasMaterial = d_LusasData.getAttribute("Material", bar.SectionProperty.Material.AdapterId <int>(typeof(LusasId))); lusasMaterial.assignTo(lusasLine); } } } } } if (bar.Support != null) { IFAttribute lusasSupport = d_LusasData.getAttribute("Support", System.Convert.ToInt32(bar.Support.AdapterId <int>(typeof(LusasId)))); lusasSupport.assignTo(lusasLine); IFLocalCoord barLocalAxis = CreateLocalCoordinate(lusasLine); barLocalAxis.assignTo(lusasLine); } if (bar.Fragments.Contains(typeof(MeshSettings1D))) { IFAssignment meshAssignment = m_LusasApplication.newAssignment(); meshAssignment.setAllDefaults(); if (bar.OrientationAngle != 0 && bar.FEAType == BarFEAType.Axial) { Engine.Base.Compute.RecordWarning( "Orientation angle not supported in Lusas for " + bar.FEAType + " element types, this information will be lost when pushed to Lusas"); } meshAssignment.setBetaAngle(bar.OrientationAngle); MeshSettings1D meshSettings1D = bar.FindFragment <MeshSettings1D>(); IFMeshAttr mesh = d_LusasData.getMesh( meshSettings1D.Name + "\\" + bar.FEAType.ToString() + "|" + CreateReleaseString(bar.Release)); mesh.assignTo(lusasLine, meshAssignment); } if (bar.Offset != null) { Engine.Base.Compute.RecordWarning("Offsets are currently unsupported."); } return(lusasLine); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private List <IFLoadingBeamDistributed> CreateBarDistributedLoad( BarVaryingDistributedLoad barDistributedLoad, object[] lusasLines) { List <IFLoadingBeamDistributed> lusasBarDistributedLoads = new List <IFLoadingBeamDistributed>(); IFAssignment lusasAssignment = m_LusasApplication.assignment(); IFLoadcase assignedLoadcase = (IFLoadcase)d_LusasData.getLoadset(barDistributedLoad.Loadcase.AdapterId <int>(typeof(LusasId))); Engine.Base.Compute.RecordWarning( barDistributedLoad.GetType().ToString() + " uses parametric distances in the Lusas_Toolkit" ); List <double> valuesAtA = new List <double> { barDistributedLoad.ForceAtStart.X, barDistributedLoad.ForceAtStart.Y, barDistributedLoad.ForceAtStart.Z, barDistributedLoad.MomentAtStart.X, barDistributedLoad.MomentAtStart.Y, barDistributedLoad.MomentAtStart.Z }; List <double> valuesAtB = new List <double> { barDistributedLoad.ForceAtEnd.X, barDistributedLoad.ForceAtEnd.Y, barDistributedLoad.ForceAtEnd.Z, barDistributedLoad.MomentAtEnd.X, barDistributedLoad.MomentAtEnd.Y, barDistributedLoad.MomentAtEnd.Z }; List <string> keys = new List <string>() { "FX", "FY", "FZ", "MX", "MY", "MZ" }; List <int> ids = new List <int>(); string positioning = barDistributedLoad.RelativePositions ? "parametric" : "actual"; string axis; if (barDistributedLoad.Projected) { axis = "projected"; if (barDistributedLoad.RelativePositions) { Engine.Base.Compute.RecordError("Projected loads with parametric distances are not supported in Lusas."); return(null); } } else { axis = barDistributedLoad.Axis == LoadAxis.Global ? "global" : "local"; } for (int i = 0; i < valuesAtA.Count(); i++) { double valueAtA = valuesAtA[i]; double valueAtB = valuesAtB[i]; if ((valueAtA != 0) || (valueAtB != 0)) { IFLoadingBeamDistributed lusasBarDistributedLoad; if (d_LusasData.existsAttribute("Loading", barDistributedLoad.Name + keys[i])) { lusasBarDistributedLoad = (IFLoadingBeamDistributed)d_LusasData.getAttribute("Loading", barDistributedLoad.Name + keys[i]); lusasBarDistributedLoads.Add(lusasBarDistributedLoad); } else { lusasBarDistributedLoad = d_LusasData.createLoadingBeamDistributed(barDistributedLoad.Name + keys[i]); lusasBarDistributedLoad.setBeamDistributed(positioning, axis, "beam"); switch (keys[i]) { case "FX": lusasBarDistributedLoad.addRow( barDistributedLoad.StartPosition, valueAtA, 0, 0, 0, 0, 0, barDistributedLoad.EndPosition, valueAtB, 0, 0, 0, 0, 0); lusasBarDistributedLoads.Add(lusasBarDistributedLoad); lusasAssignment.setLoadset(assignedLoadcase); lusasBarDistributedLoad.assignTo(lusasLines, lusasAssignment); break; case "FY": lusasBarDistributedLoad.addRow( barDistributedLoad.StartPosition, 0, valueAtA, 0, 0, 0, 0, barDistributedLoad.EndPosition, 0, valueAtB, 0, 0, 0, 0); lusasBarDistributedLoads.Add(lusasBarDistributedLoad); lusasAssignment.setLoadset(assignedLoadcase); lusasBarDistributedLoad.assignTo(lusasLines, lusasAssignment); break; case "FZ": lusasBarDistributedLoad.addRow( barDistributedLoad.StartPosition, 0, 0, valueAtA, 0, 0, 0, barDistributedLoad.EndPosition, 0, 0, valueAtB, 0, 0, 0); lusasBarDistributedLoads.Add(lusasBarDistributedLoad); lusasAssignment.setLoadset(assignedLoadcase); lusasBarDistributedLoad.assignTo(lusasLines, lusasAssignment); break; case "MX": lusasBarDistributedLoad.addRow( barDistributedLoad.StartPosition, 0, 0, 0, valueAtA, 0, 0, barDistributedLoad.EndPosition, 0, 0, 0, valueAtB, 0, 0); lusasBarDistributedLoads.Add(lusasBarDistributedLoad); lusasAssignment.setLoadset(assignedLoadcase); if (barDistributedLoad.Projected || barDistributedLoad.Axis == LoadAxis.Global) { Engine.Base.Compute.RecordWarning("Lusas does not support internal distributed moments in the global axis or as projected loads."); } lusasBarDistributedLoad.assignTo(lusasLines, lusasAssignment); break; case "MY": lusasBarDistributedLoad.addRow( barDistributedLoad.StartPosition, 0, 0, 0, 0, valueAtA, 0, barDistributedLoad.EndPosition, 0, 0, 0, 0, valueAtB, 0); lusasBarDistributedLoads.Add(lusasBarDistributedLoad); lusasAssignment.setLoadset(assignedLoadcase); lusasBarDistributedLoad.assignTo(lusasLines, lusasAssignment); break; case "MZ": lusasBarDistributedLoad.addRow( barDistributedLoad.StartPosition, 0, 0, 0, 0, 0, valueAtA, barDistributedLoad.EndPosition, 0, 0, 0, 0, 0, valueAtB); lusasBarDistributedLoads.Add(lusasBarDistributedLoad); lusasAssignment.setLoadset(assignedLoadcase); lusasBarDistributedLoad.assignTo(lusasLines, lusasAssignment); break; } lusasBarDistributedLoads.Add(lusasBarDistributedLoad); ids.Add(lusasBarDistributedLoad.getID()); } } } barDistributedLoad.SetAdapterId(typeof(LusasId), ids); return(lusasBarDistributedLoads); }