/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static Edge GetEdge(IFSurface lusasSurf, int lineIndex, Dictionary <string, Edge> bars) { Edge edge; IFLine lusasEdge = lusasSurf.getLOFs()[lineIndex]; bars.TryGetValue(lusasEdge.getID().ToString(), out edge); return(edge); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFLocalCoord CreateLocalCoordinate(IFLine lusasLine) { object lineXAxis = null; object lineYAxis = null; object lineZAxis = null; object origin = null; lusasLine.getAxesAtNrmCrds(0, ref origin, ref lineXAxis, ref lineYAxis, ref lineZAxis); double[] localXAxis = Adapters.Lusas.Convert.ToDouble(lineXAxis); double[] localYAxis = Adapters.Lusas.Convert.ToDouble(lineYAxis); double[] localZAxis = Adapters.Lusas.Convert.ToDouble(lineZAxis); IF3dCoords barStart = lusasLine.getStartPositionCoords(); double[] worldXAxis = new double[] { 1, 0, 0 }; double[] worldYAxis = new double[] { 0, 1, 0 }; double[] worldZAxis = new double[] { 0, 0, 1 }; double[] barorigin = new double[] { barStart.getX(), barStart.getY(), barStart.getZ() }; double[] matrixCol0 = new double[] { worldXAxis.Zip(localXAxis, (d1, d2) => d1 * d2).Sum(), worldYAxis.Zip(localXAxis, (d1, d2) => d1 * d2).Sum(), worldZAxis.Zip(localXAxis, (d1, d2) => d1 * d2).Sum(), }; double[] matrixCol1 = new double[] { worldXAxis.Zip(localYAxis, (d1, d2) => d1 * d2).Sum(), worldYAxis.Zip(localYAxis, (d1, d2) => d1 * d2).Sum(), worldZAxis.Zip(localYAxis, (d1, d2) => d1 * d2).Sum(), }; double[] matrixCol2 = new double[] { worldXAxis.Zip(localZAxis, (d1, d2) => d1 * d2).Sum(), worldYAxis.Zip(localZAxis, (d1, d2) => d1 * d2).Sum(), worldZAxis.Zip(localZAxis, (d1, d2) => d1 * d2).Sum(), }; string lusasName = "L" + lusasLine.getID().ToString() + "/ Local Axis"; IFLocalCoord barLocalAxis = d_LusasData.createLocalCartesianAttr( lusasName, barorigin, matrixCol0, matrixCol1, matrixCol2); return(barLocalAxis); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IFLine CreateEdge(Edge edge, IFPoint startPoint, IFPoint endPoint) { IFLine lusasLine = d_LusasData.createLineByPoints(startPoint, endPoint); int adapterIdName = lusasLine.getID(); edge.SetAdapterId(typeof(LusasId), adapterIdName); if (!(edge.Tags.Count == 0)) { AssignObjectSet(lusasLine, edge.Tags); } if (!(edge.Support == null)) { IFAttribute lusasSupport = d_LusasData.getAttribute("Support", edge.Support.AdapterId <int>(typeof(LusasId))); lusasSupport.assignTo(lusasLine); } return(lusasLine); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private static IEnumerable <Bar> GetLineAssignments(IEnumerable <IFAssignment> lusasAssignments, Dictionary <string, Bar> bars) { List <Bar> assignedBars = new List <Bar>(); Bar bar; foreach (IFAssignment lusasAssignment in lusasAssignments) { if (lusasAssignment.getDatabaseObject() is IFLine) { IFLine lusasLine = (IFLine)lusasAssignment.getDatabaseObject(); bars.TryGetValue(lusasLine.getID().ToString(), out bar); assignedBars.Add(bar); } else { AssignmentWarning(lusasAssignment); } } return(assignedBars); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static Edge ToEdge(this IFLine lusasLine, Dictionary <string, Node> nodes, HashSet <string> groupNames) { Node startNode = GetNode(lusasLine, 0, nodes); Node endNode = GetNode(lusasLine, 1, nodes); Point startPoint = startNode.Position; Point endPoint = endNode.Position; HashSet <string> tags = new HashSet <string>(IsMemberOf(lusasLine, groupNames)); Line line = new Line { Start = startPoint, End = endPoint }; Edge edge = new Edge { Curve = line, Tags = tags }; string adapterID = lusasLine.getID().ToString(); edge.SetAdapterId(typeof(LusasId), adapterID); return(edge); }
/***************************************************/ /**** 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); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static Bar ToBar(this IFLine lusasLine, Dictionary <string, Node> nodes, Dictionary <string, Constraint4DOF> supports, HashSet <string> lusasGroups, Dictionary <string, IMaterialFragment> materials, Dictionary <string, ISectionProperty> sections, Dictionary <string, MeshSettings1D> meshes ) { Node startNode = GetNode(lusasLine, 0, nodes); Node endNode = GetNode(lusasLine, 1, nodes); HashSet <string> tags = new HashSet <string>(IsMemberOf(lusasLine, lusasGroups)); List <string> supportAssignments = GetAttributeAssignments(lusasLine, "Support"); Constraint4DOF barConstraint = null; if (!(supportAssignments.Count() == 0)) { supports.TryGetValue(supportAssignments[0], out barConstraint); } Bar bar = new Bar { StartNode = startNode, EndNode = endNode, Tags = tags, Support = barConstraint }; List <string> geometricAssignments = GetAttributeAssignments(lusasLine, "Geometric"); List <string> materialAssignments = GetAttributeAssignments(lusasLine, "Material"); IMaterialFragment lineMaterial; ISectionProperty lineSection; if (!(geometricAssignments.Count() == 0)) { sections.TryGetValue(geometricAssignments[0], out lineSection); if (lineSection != null) { if (!(materialAssignments.Count() == 0)) { materials.TryGetValue(materialAssignments[0], out lineMaterial); if (lineMaterial != null) { lineSection.Material = lineMaterial; } } bar.SectionProperty = lineSection; } } MeshSettings1D lineMesh; List <string> meshSettings = GetAttributeAssignments(lusasLine, "Mesh"); if (!(meshSettings.Count() == 0)) { meshes.TryGetValue(meshSettings[0], out lineMesh); bar.Fragments.Add(lineMesh); } Tuple <bool, double, BarRelease, BarFEAType> barMeshProperties = GetMeshProperties(lusasLine); if (barMeshProperties.Item1) { bar.OrientationAngle = barMeshProperties.Item2; bar.Release = barMeshProperties.Item3; bar.FEAType = barMeshProperties.Item4; } string adapterID = lusasLine.getID().ToString(); bar.SetAdapterId(typeof(LusasId), adapterID); return(bar); }