public static List <IGeometry> DeformedShape(List <Bar> bars, List <BarDisplacement> barDisplacements, Type adapterIdType, object loadcase, double scaleFactor = 1.0, bool drawSections = false) { if (adapterIdType == null) { Reflection.Compute.RecordError("The provided adapter id type is null."); return(new List <IGeometry>()); } if (!typeof(IAdapterId).IsAssignableFrom(adapterIdType)) { Reflection.Compute.RecordError($"The `{adapterIdType.Name}` is not a valid `{typeof(IAdapterId).Name}`."); return(new List <IGeometry>()); } barDisplacements = barDisplacements.SelectCase(loadcase); List <IGeometry> geom = new List <IGeometry>(); var resGroups = barDisplacements.GroupBy(x => x.ObjectId.ToString()).ToDictionary(x => x.Key); if (drawSections) { Reflection.Compute.RecordWarning("Display of rotations of sections is not yet supported for deformed shape."); } foreach (Bar bar in bars) { IAdapterId idFragment = bar.FindFragment <IAdapterId>(adapterIdType); if (idFragment == null) { Engine.Reflection.Compute.RecordWarning("Could not find the adapter id for at least one Bar."); continue; } string id = idFragment.Id.ToString(); List <BarDisplacement> deformations; IGrouping <string, BarDisplacement> outVal; if (resGroups.TryGetValue(id, out outVal)) { deformations = outVal.ToList(); } else { continue; } deformations.Sort(); if (drawSections) { geom.AddRange(DeformedShapeSection(bar, deformations, scaleFactor)); } else { geom.Add(DeformedShapeCentreLine(bar, deformations, scaleFactor)); } } return(geom); }
/***************************************************/ /**** Public Methods ****/ /***************************************************/ public static List <ICurve> PlotBarForce(List <Bar> bars, List <BarForce> forces, Type adapterIdType, double scaleFactor = 1.0, object loadCase = null, bool fx = true, bool fy = true, bool fz = true, bool mx = true, bool my = true, bool mz = true) { if (adapterIdType == null) { Reflection.Compute.RecordError("The provided adapter id type is null."); return(new List <ICurve>()); } if (!typeof(IAdapterId).IsAssignableFrom(adapterIdType)) { Reflection.Compute.RecordError($"The `{adapterIdType.Name}` is not a valid `{typeof(IAdapterId).Name}`."); return(new List <ICurve>()); } forces = forces.SelectCase(loadCase); List <ICurve> plots = new List <ICurve>(); foreach (Bar bar in bars) { IAdapterId id = bar.FindFragment <IAdapterId>(adapterIdType); if (id == null) { Engine.Reflection.Compute.RecordWarning("Could not find the adapter id for at least one Bar."); continue; } string barId = id.Id.ToString(); List <BarForce> elementForces = forces.Where(x => x.ObjectId.ToString() == barId).ToList(); elementForces.Sort(); plots.AddRange(PlotBarForce(bar, elementForces, scaleFactor, fx, fy, fz, mx, my, mz)); } return(plots); }
public static List <Mesh> DeformedShape(List <FEMesh> meshes, List <MeshResult> meshDisplacements, Type adapterIdType, object loadcase, double scaleFactor = 1.0) { if (adapterIdType == null) { Reflection.Compute.RecordError("The provided adapter id type is null."); return(new List <Mesh>()); } if (!typeof(IAdapterId).IsAssignableFrom(adapterIdType)) { Reflection.Compute.RecordError($"The `{adapterIdType.Name}` is not a valid `{typeof(IAdapterId).Name}`."); return(new List <Mesh>()); } meshDisplacements = meshDisplacements.SelectCase(loadcase); List <Mesh> defMeshes = new List <Mesh>(); var resGroups = meshDisplacements.GroupBy(x => x.ObjectId.ToString()).ToDictionary(x => x.Key); foreach (FEMesh feMesh in meshes) { IAdapterId idFragment = feMesh.FindFragment <IAdapterId>(adapterIdType); if (idFragment == null) { Engine.Reflection.Compute.RecordWarning("Could not find the adapter id for at least one FEMesh."); continue; } string id = idFragment.Id.ToString(); List <MeshResult> deformations; IGrouping <string, MeshResult> outVal; if (resGroups.TryGetValue(id, out outVal)) { deformations = outVal.ToList(); } else { continue; } MeshResult singleDisp = deformations.Where(x => x.ObjectId.ToString() == id && x.Results.First() is IMeshDisplacement).First(); defMeshes.Add(DeformedMesh(feMesh, singleDisp.Results.Cast <IMeshDisplacement>(), adapterIdType, scaleFactor)); } return(defMeshes); }