/***************************************************/ private List <MeshResult> ReadMeshDisplacement(List <string> panelIds, MeshResultSmoothingType smoothing) { int resultCount = 0; string[] obj = null; string[] elm = null; string[] loadCase = null; string[] stepType = null; double[] stepNum = null; double[] ux = null; double[] uy = null; double[] uz = null; double[] rx = null; double[] ry = null; double[] rz = null; List <MeshResult> results = new List <MeshResult>(); for (int i = 0; i < panelIds.Count; i++) { List <MeshDisplacement> displacements = new List <MeshDisplacement>(); HashSet <string> ptNbs = new HashSet <string>(); int nbELem = 0; string[] elemNames = new string[0]; m_model.AreaObj.GetElm(panelIds[i], ref nbELem, ref elemNames); for (int j = 0; j < nbELem; j++) { //Get out the name of the points for each face int nbPts = 0; string[] ptsNames = new string[0]; m_model.AreaElm.GetPoints(elemNames[j], ref nbPts, ref ptsNames); foreach (string ptId in ptsNames) { ptNbs.Add(ptId); } } foreach (string ptId in ptNbs) { int ret = m_model.Results.JointDispl(ptId, eItemTypeElm.Element, ref resultCount, ref obj, ref elm, ref loadCase, ref stepType, ref stepNum, ref ux, ref uy, ref uz, ref rx, ref ry, ref rz); for (int j = 0; j < resultCount; j++) { int mode; double timeStep; GetStepAndMode(stepType[j], stepNum[j], out timeStep, out mode); MeshDisplacement disp = new MeshDisplacement(panelIds[i], ptId, "", loadCase[j], mode, timeStep, MeshResultLayer.Middle, 0, MeshResultSmoothingType.Global, Basis.XY, ux[j], uy[j], uz[j], rx[j], ry[j], rz[j]); displacements.Add(disp); } } results.AddRange(GroupMeshResults(displacements)); } return(results); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private IEnumerable <IResult> ExtractMeshDisplacement(List <int> ids, List <int> loadcaseIds) { List <MeshDisplacement> meshDisplacements = new List <MeshDisplacement>(); IFView view = m_LusasApplication.getCurrentView(); IFResultsContext resultsContext = m_LusasApplication.newResultsContext(view); string entity = "Displacement"; string location = "Feature extreme"; foreach (int loadcaseId in loadcaseIds) { IFLoadset loadset = d_LusasData.getLoadset(loadcaseId); if (!loadset.needsAssociatedValues()) { resultsContext.setActiveLoadset(loadset); } IFUnitSet unitSet = d_LusasData.getModelUnits(); double lengthSIConversion = 1 / unitSet.getLengthFactor(); List <string> components = new List <string>() { "DX", "DY", "DZ", "THX", "THY", "THZ" }; d_LusasData.startUsingScriptedResults(); Dictionary <string, IFResultsComponentSet> resultsSets = GetResultsSets(entity, components, location, resultsContext); foreach (int meshId in ids) { Dictionary <string, double> featureResults = GetFeatureResults(components, resultsSets, unitSet, meshId, "S", 6); double uX = 0; double uY = 0; double uZ = 0; double rX = 0; double rY = 0; double rZ = 0; featureResults.TryGetValue("DX", out uX); featureResults.TryGetValue("DY", out uY); featureResults.TryGetValue("DZ", out uZ); featureResults.TryGetValue("THX", out rX); featureResults.TryGetValue("THY", out rY); featureResults.TryGetValue("THZ", out rZ); int mode = -1; MeshDisplacement meshDisplacement = new MeshDisplacement ( meshId, 0, 0, loadcaseId, mode, 0, MeshResultLayer.Middle, 0.5, MeshResultSmoothingType.ByPanel, null, uX * lengthSIConversion, uY * lengthSIConversion, uZ * lengthSIConversion, rX, rY, rZ ); meshDisplacements.Add(meshDisplacement); } d_LusasData.stopUsingScriptedResults(); d_LusasData.flushScriptedResults(); } return(meshDisplacements); }
/***************************************************/ private static Mesh DeformedMesh(FEMesh feMesh, IEnumerable <MeshDisplacement> disps, string adapterId, double scaleFactor) { Mesh mesh = new Mesh(); foreach (Node node in feMesh.Nodes) { MeshDisplacement disp = disps.FirstOrDefault(x => x.NodeId.ToString() == node.CustomData[adapterId].ToString()); if (disp == null) { Reflection.Compute.RecordError("Could not find displacement for node with adapter Id: " + node.CustomData[adapterId].ToString() + ", from mesh with Id: " + feMesh.CustomData[adapterId].ToString()); return(new Mesh()); } Vector dispVector = disp.CoordinateSystem.X * disp.UXX * scaleFactor + disp.CoordinateSystem.Y * disp.UYY * scaleFactor + disp.CoordinateSystem.Z * disp.UZZ * scaleFactor; mesh.Vertices.Add(node.Position() + dispVector); } foreach (FEMeshFace feFace in feMesh.MeshFaces) { if (feFace.NodeListIndices.Count < 3) { Reflection.Compute.RecordError("Insuffiecient node indices"); continue; } if (feFace.NodeListIndices.Count > 4) { Reflection.Compute.RecordError("To high number of node indices. Can only handle triangular and quads"); continue; } Face face = new Face(); face.A = feFace.NodeListIndices[0]; face.B = feFace.NodeListIndices[1]; face.C = feFace.NodeListIndices[2]; if (feFace.NodeListIndices.Count == 4) { face.D = feFace.NodeListIndices[3]; } mesh.Faces.Add(face); } return(mesh); }