protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (mikity.NumericalMethodHelper.FriedChiken.isInitialized) { double p = 0; if (!DA.GetData(0, ref p)) { return; } nG.Density = p; } else { double p = 0; if (!DA.GetData(0, ref p)) { return; } nG = new mikity.NumericalMethodHelper.materials.formfindGravity(); m_gvt = new GH_gravity(); m_gvt.Value = nG; nG.Density = p; } DA.SetData(0, m_gvt); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (mikity.NumericalMethodHelper.FriedChiken.isInitialized) { } else { zG = new mikity.NumericalMethodHelper.materials.zeroGravity(); m_gvt = new GH_gravity(); m_gvt.Value = zG; } DA.SetData(0, m_gvt); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { Rhino.Geometry.Curve c = null; if (!DA.GetData(0, ref c)) { return; } if (c.IsPolyline()) { Rhino.Geometry.Polyline pl = null; if (c.TryGetPolyline(out pl)) { int nNewNodes = pl.Count(); int nElements = nNewNodes - 1; newNodes.Clear(); newNodes.AddRange(pl); GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(1, ref mat)) { return; } if (!DA.GetData(2, ref gvt)) { return; } mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]); } eM = new generalSpring(); pS = new GH_particleSystem(particles); for (int i = 0; i < nElements; i++) { mikity.NumericalMethodHelper.elements.isoparametricElement e = new NumericalMethodHelper.elements.isoparametricElement(i, i + 1); eM.addElement(e); } eM.setMaterial(mat.Value, gvt.Value); pS.Value.addObject(eM); lGeometry = new Rhino.Geometry.Polyline(); lGeometry2 = new Rhino.Geometry.Polyline(); for (int i = 0; i < pS.Value.__N; i++) { lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]); } this.DVPW = GetDVPW(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); this.BKGT = GetBKGT(lGeometry); DA.SetData(0, pS); DA.SetDataList(1, newNodes); } } else { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted"); return; } } }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { GH_Point[] pointList = new GH_Point[2]; List <GH_Point> tmpPointList = new List <GH_Point>(); int[] nEdgeNodes = new int[_dim]; eM = new generalSpring(); DA.GetData(0, ref pointList[0]); DA.GetData(1, ref pointList[1]); DA.GetData(2, ref nEdgeNodes[0]); GH_material mat = null; if (!DA.GetData(3, ref mat)) { return; } GH_gravity gvt = null; if (!DA.GetData(4, ref gvt)) { return; } for (int i = 0; i < _dim; i++) { if (nEdgeNodes[i] < 2) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2"); return; } } //点群生成 double[,] wt = mikity.MathUtil.bicubic(_dim, nEdgeNodes); int nNewNodes = wt.GetLength(0); mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new particle(0, 0, 0); for (int j = 0; j < _nNodes; j++) { particles[i][0] += pointList[j].Value.X * wt[i, j]; particles[i][1] += pointList[j].Value.Y * wt[i, j]; particles[i][2] += pointList[j].Value.Z * wt[i, j]; } } el = MathUtil.isoparametricElements(nEdgeNodes); int nElements = el.Length; pS = new GH_particleSystem(particles); for (int i = 0; i < nElements; i++) { eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i])); } eM.setMaterial(mat.Value, gvt.Value); pS.Value.addObject(eM); lGeometry = new Rhino.Geometry.Polyline(); lGeometry2 = new Rhino.Geometry.Polyline(); for (int i = 0; i < pS.Value.__N; i++) { lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]); } this.DVPW = GetDVPW(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); } DA.SetData(0, pS); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { GH_Point[] pointList = new GH_Point[4]; List <GH_Point> tmpPointList = new List <GH_Point>(); int[] nEdgeNodes = new int[_dim]; eM = new generalSpring(); DA.GetData(0, ref pointList[0]); DA.GetData(1, ref pointList[1]); DA.GetData(2, ref pointList[2]); DA.GetData(3, ref pointList[3]); DA.GetData(4, ref nEdgeNodes[0]); DA.GetData(5, ref nEdgeNodes[1]); GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(6, ref mat)) { return; } if (!DA.GetData(7, ref gvt)) { return; } for (int i = 0; i < _dim; i++) { if (nEdgeNodes[i] < 2) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2"); return; } } //点群生成 double[,] wt = mikity.MathUtil.bicubic(_dim, nEdgeNodes); int nNewNodes = wt.GetLength(0); mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new particle(0, 0, 0); for (int j = 0; j < _nNodes; j++) { particles[i][0] += pointList[j].Value.X * wt[i, j]; particles[i][1] += pointList[j].Value.Y * wt[i, j]; particles[i][2] += pointList[j].Value.Z * wt[i, j]; } } el = MathUtil.isoparametricElements(nEdgeNodes); int nElements = el.Length; pS = new GH_particleSystem(particles); bool isJoin = true; if (isJoin) { pS.simplify(el); } for (int i = 0; i < nElements; i++) { if (_subdv == subdivide.quad) { eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i])); } if (_subdv == subdivide.triA) { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][3] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][3], el[i][2] })); } if (_subdv == subdivide.triB) { int S = i % (nEdgeNodes[0] - 1); int T = (i - S) / (nEdgeNodes[0] - 1); if (T % 2 == 1) { S++; } if (S % 2 == 0) { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][3] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][3], el[i][2] })); } else { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][2] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][2], el[i][1], el[i][3] })); } } if (_subdv == subdivide.triC) { int S = i % (nEdgeNodes[0] - 1); if (S % 2 == 0) { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][3] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][3], el[i][2] })); } else { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][2] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][2], el[i][1], el[i][3] })); } } } if (_subdv == subdivide.quad) { nElements *= 1; } else { nElements *= 2; } eM.setMaterial(mat.Value, gvt.Value); pS.Value.addObject(eM); lGeometry = new Rhino.Geometry.Mesh(); lGeometry2 = new Rhino.Geometry.Mesh(); lGeometry.Vertices.Clear(); lGeometry.Faces.Clear(); lGeometry2.Faces.Clear(); for (int i = 0; i < pS.Value.__N; i++) { lGeometry.Vertices.Add(particles[i][0], particles[i][1], particles[i][2]); } for (int i = 0; i < nElements; i++) { if (_subdv == subdivide.quad) { lGeometry.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[3], eM.elemList[i].el[2]); } else { lGeometry.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[2]); } } for (int i = 0; i < nElements; i++) { if (_subdv == subdivide.quad) { lGeometry2.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[3], eM.elemList[i].el[2]); } else { lGeometry2.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[2]); } } this.DVPW = GetDVPW(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); } DA.SetData(0, pS); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { List <GH_Point> pointList1 = new List <GH_Point>(); List <GH_Point> pointList2 = new List <GH_Point>(); List <GH_Point> tmpPointList = new List <GH_Point>(); eM = new generalSpring(); if (!DA.GetDataList(0, pointList1)) { return; } if (!DA.GetDataList(1, pointList2)) { return; } if (pointList1.Count != pointList2.Count) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "The first and second lists must have the same elements"); return; } tmpPointList.AddRange(pointList1); tmpPointList.AddRange(pointList2); nNewNodes = tmpPointList.Count(); nElements = pointList1.Count(); GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(2, ref mat)) { return; } if (!DA.GetData(3, ref gvt)) { return; } //点群生成 mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new particle(tmpPointList[i].Value.X, tmpPointList[i].Value.Y, tmpPointList[i].Value.Z); } pS = new GH_particleSystem(particles); for (int i = 0; i < nElements; i++) { eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + nElements)); } eM.setMaterial(mat.Value, gvt.Value); pS.Value.addObject(eM); lGeometry.Clear(); lGeometry2.Clear(); for (int i = 0; i < nElements; i++) { lGeometry.Add(new Rhino.Geometry.Line(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2], pS.Value.particles[i + nElements, 0], pS.Value.particles[i + nElements, 1], pS.Value.particles[i + nElements, 2])); } } this.DVPW = GetDVPW(lGeometry); this.BKGT = GetBKGT(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); DA.SetData(0, pS); }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { Rhino.Geometry.Mesh m = null; if (!DA.GetData(0, ref m)) { return; } lGeometry = m.DuplicateMesh(); lGeometry2 = m.DuplicateMesh(); newNodes.Clear(); newNodes.AddRange(m.Vertices.ToPoint3dArray()); int nNewNodes = newNodes.Count; el = new List <int[]>(); for (int i = 0; i < m.Faces.Count; i++) { if (m.Faces[i].IsQuad) { int[] f = new int[4] { m.Faces[i].A, m.Faces[i].B, m.Faces[i].D, m.Faces[i].C }; el.Add(f); } if (m.Faces[i].IsTriangle) { int[] f = new int[3] { m.Faces[i].A, m.Faces[i].B, m.Faces[i].C }; el.Add(f); } } bool isJoin = false; mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]); } eM = new generalSpring(); pS = new GH_particleSystem(particles); if (!DA.GetData(3, ref isJoin)) { return; } if (isJoin) { pS.simplify(el); } lGeometry.Faces.Clear(); lGeometry2.Faces.Clear(); for (int i = 0; i < el.Count; i++) { if (el[i].Length == 4) { mikity.NumericalMethodHelper.elements.isoparametricElement e = new NumericalMethodHelper.elements.isoparametricElement(el[i]); eM.addElement(e); lGeometry.Faces.AddFace(e.el[0], e.el[1], e.el[3], e.el[2]); lGeometry2.Faces.AddFace(e.el[0], e.el[1], e.el[3], e.el[2]); } else if (el[i].Length == 3) { mikity.NumericalMethodHelper.elements.simplexElement e = new NumericalMethodHelper.elements.simplexElement(el[i]); eM.addElement(e); lGeometry.Faces.AddFace(e.el[0], e.el[1], e.el[2]); lGeometry2.Faces.AddFace(e.el[0], e.el[1], e.el[2]); } } pS.Value.addObject(eM); this.DVPW = GetDVPW(lGeometry); this.BKGT = GetBKGT(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); DA.SetData(0, pS); DA.SetDataList(1, newNodes); GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(1, ref mat)) { return; } if (!DA.GetData(2, ref gvt)) { return; } eM.setMaterial(mat.Value, gvt.Value); } }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { Rhino.Geometry.Surface s = null; if (!DA.GetData(0, ref s)) { return; } Rhino.Geometry.Interval uDomain = s.Domain(0); Rhino.Geometry.Interval vDomain = s.Domain(1); int[] nEdgeNodes = new int[_dim]; DA.GetData(1, ref nEdgeNodes[0]); DA.GetData(2, ref nEdgeNodes[1]); for (int i = 0; i < _dim; i++) { if (nEdgeNodes[i] < 2) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2"); return; } } Rhino.Geometry.Mesh m = new Rhino.Geometry.Mesh(); //メッシュノード構築 newNodes.Clear(); for (int i = 0; i < nEdgeNodes[1]; i++) { for (int j = 0; j < nEdgeNodes[0]; j++) { newNodes.Add(s.PointAt(uDomain.T0 + (uDomain.T1 - uDomain.T0) / (nEdgeNodes[0] - 1) * j, vDomain.T0 + (vDomain.T1 - vDomain.T0) / (nEdgeNodes[1] - 1) * i)); } } m.Vertices.AddVertices(newNodes); int nNewNodes = newNodes.Count; GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(3, ref mat)) { return; } if (!DA.GetData(4, ref gvt)) { return; } el = MathUtil.isoparametricElements(nEdgeNodes); int nElements = el.Length; //メッシュ構築 for (int i = 0; i < nElements; i++) { m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); } mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]); } eM = new generalSpring(); pS = new GH_particleSystem(particles); for (int i = 0; i < nElements; i++) { if (_subdv == subdivide.quad) { eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i])); } if (_subdv == subdivide.triA) { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][3] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][3], el[i][2] })); } if (_subdv == subdivide.triB) { int S = i % (nEdgeNodes[0] - 1); int T = (i - S) / (nEdgeNodes[0] - 1); if (T % 2 == 1) { S++; } if (S % 2 == 0) { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][3] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][3], el[i][2] })); } else { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][2] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][2], el[i][1], el[i][3] })); } } if (_subdv == subdivide.triC) { int S = i % (nEdgeNodes[0] - 1); if (S % 2 == 0) { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][3] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][3], el[i][2] })); } else { eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][0], el[i][1], el[i][2] })); eM.addElement(new mikity.NumericalMethodHelper.elements.simplexElement(new int[3] { el[i][2], el[i][1], el[i][3] })); } } } if (_subdv == subdivide.quad) { nElements *= 1; } else { nElements *= 2; } lGeometry = new Rhino.Geometry.Mesh(); lGeometry2 = new Rhino.Geometry.Mesh(); lGeometry.Vertices.Clear(); lGeometry.Faces.Clear(); lGeometry2.Faces.Clear(); for (int i = 0; i < pS.Value.__N; i++) { lGeometry.Vertices.Add(particles[i][0], particles[i][1], particles[i][2]); } for (int i = 0; i < nElements; i++) { if (_subdv == subdivide.quad) { lGeometry.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[3], eM.elemList[i].el[2]); } else { lGeometry.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[2]); } } for (int i = 0; i < nElements; i++) { if (_subdv == subdivide.quad) { lGeometry2.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[3], eM.elemList[i].el[2]); } else { lGeometry2.Faces.AddFace(eM.elemList[i].el[0], eM.elemList[i].el[1], eM.elemList[i].el[2]); } } eM.setMaterial(mat.Value, gvt.Value); pS.Value.addObject(eM); this.DVPW = GetDVPW(lGeometry); this.BKGT = GetBKGT(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); DA.SetData(0, pS); DA.SetDataList(1, newNodes); } }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { Rhino.Geometry.Curve c = null; if (!DA.GetData(0, ref c)) { return; } Rhino.Geometry.Interval uDomain = c.Domain; int[] nEdgeNodes = new int[_dim]; DA.GetData(1, ref nEdgeNodes[0]); for (int i = 0; i < _dim; i++) { if (nEdgeNodes[i] < 2) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2"); return; } } lGeometry.Clear(); //メッシュノード構築 newNodes.Clear(); for (int j = 0; j < nEdgeNodes[0]; j++) { newNodes.Add(c.PointAt(uDomain.T0 + (uDomain.T1 - uDomain.T0) / (nEdgeNodes[0] - 1) * j)); } int nNewNodes = newNodes.Count; GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(2, ref mat)) { return; } if (!DA.GetData(3, ref gvt)) { return; } el = MathUtil.isoparametricElements(nEdgeNodes); int nElements = el.Length; mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]); } eM = new generalSpring(); pS = new GH_particleSystem(particles); for (int i = 0; i < el.Length; i++) { mikity.NumericalMethodHelper.elements.isoparametricElement e = new NumericalMethodHelper.elements.isoparametricElement(el[i]); eM.addElement(e); } eM.setMaterial(mat.Value, gvt.Value); for (int i = 0; i < pS.Value.__N; i++) { lGeometry.Add(particles[i][0], particles[i][1], particles[i][2]); } this.DVPW = GetDVPW(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); pS.Value.addObject(eM); DA.SetData(0, pS); DA.SetDataList(1, newNodes); } }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { Rhino.Geometry.Mesh m = null; if (!DA.GetData(0, ref m)) { return; } lGeometry.Clear(); lGeometry2.Clear(); var ms = mikity.GeometryProcessing.MeshStructure.CreateFrom(m); var edges = ms.edges(); var boundary = new Rhino.Geometry.Polyline(); newNodes.Clear(); newNodes.AddRange(m.Vertices.ToPoint3dArray()); int nNewNodes = newNodes.Count; el = new List <int[]>(); foreach (var e in edges) { if (!e.isNaked) { el.Add(new int[2] { e.P.N, e.next.P.N }); } } var s = ms.boundaryStart.hf_begin; do { var P = m.Vertices[s.P.N]; boundary.Add(new Rhino.Geometry.Point3d(P.X, P.Y, P.Z)); s = s.next.P.hf_begin; } while (s.P != ms.boundaryStart); boundary.Add(new Rhino.Geometry.Point3d(boundary[0])); var boundary2 = new Rhino.Geometry.PolylineCurve(boundary); bool isJoin = false; mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new mikity.NumericalMethodHelper.particle(newNodes[i][0], newNodes[i][1], newNodes[i][2]); } eM = new generalSpring(); pS = new GH_particleSystem(particles); if (!DA.GetData(3, ref isJoin)) { return; } if (isJoin) { pS.simplify(el); } foreach (var e in el) { var ee = new mikity.NumericalMethodHelper.elements.simplexElement(e); eM.addElement(ee); lGeometry.Add(new Rhino.Geometry.Line(pS.Value.particles[e[0], 0], pS.Value.particles[e[0], 1], pS.Value.particles[e[0], 2], pS.Value.particles[e[1], 0], pS.Value.particles[e[1], 1], pS.Value.particles[e[1], 2])); } pS.Value.addObject(eM); this.DVPW = GetDVPW(lGeometry); this.BKGT = GetBKGT(lGeometry); pS.DVPW = GetDVPW(lGeometry2); pS.UPGR = GetUPGR(lGeometry2); pS.BKGT = GetBKGT(lGeometry2); DA.SetData(0, pS); DA.SetDataList(1, newNodes); DA.SetData(2, boundary); GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(1, ref mat)) { return; } if (!DA.GetData(2, ref gvt)) { return; } eM.setMaterial(mat.Value, gvt.Value); } }
protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA) { if (!FriedChiken.isInitialized) { GH_Point[] pointList = new GH_Point[8]; List <GH_Point> tmpPointList = new List <GH_Point>(); eM = new generalSpring(); DA.GetData(0, ref pointList[0]); DA.GetData(1, ref pointList[1]); DA.GetData(2, ref pointList[2]); DA.GetData(3, ref pointList[3]); DA.GetData(4, ref pointList[4]); DA.GetData(5, ref pointList[5]); DA.GetData(6, ref pointList[6]); DA.GetData(7, ref pointList[7]); DA.GetData(8, ref nEdgeNodes[0]); DA.GetData(9, ref nEdgeNodes[1]); DA.GetData(10, ref nEdgeNodes[2]); GH_material mat = null; GH_gravity gvt = null; if (!DA.GetData(11, ref mat)) { return; } if (!DA.GetData(12, ref gvt)) { return; } for (int i = 0; i < _dim; i++) { if (nEdgeNodes[i] < 2) { AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Integers must be greater than or equal to 2"); return; } } //点群生成 double[,] wt = mikity.MathUtil.bicubic(_dim, nEdgeNodes); int nNewNodes = wt.GetLength(0); mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes]; for (int i = 0; i < nNewNodes; i++) { particles[i] = new particle(0, 0, 0); for (int j = 0; j < _nNodes; j++) { particles[i][0] += pointList[j].Value.X * wt[i, j]; particles[i][1] += pointList[j].Value.Y * wt[i, j]; particles[i][2] += pointList[j].Value.Z * wt[i, j]; } } el = MathUtil.isoparametricElements(nEdgeNodes); int nElements = el.Length; pS = new GH_particleSystem(particles); for (int i = 0; i < nElements; i++) { eM.addElement(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i])); } eM.setMaterial(mat.Value, gvt.Value); pS.Value.addObject(eM); lGeometry.Clear(); lGeometry2.Clear(); for (int k = 0; k < nEdgeNodes[2]; k++) { for (int j = 0; j < nEdgeNodes[1]; j++) { Rhino.Geometry.Polyline p = new Rhino.Geometry.Polyline(); lGeometry.Add(p); for (int i = 0; i < nEdgeNodes[0]; i++) { p.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } } for (int i = 0; i < nEdgeNodes[0]; i++) { for (int k = 0; k < nEdgeNodes[2]; k++) { Rhino.Geometry.Polyline p = new Rhino.Geometry.Polyline(); lGeometry.Add(p); for (int j = 0; j < nEdgeNodes[1]; j++) { p.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } } for (int i = 0; i < nEdgeNodes[0]; i++) { for (int j = 0; j < nEdgeNodes[1]; j++) { Rhino.Geometry.Polyline p = new Rhino.Geometry.Polyline(); lGeometry.Add(p); for (int k = 0; k < nEdgeNodes[2]; k++) { p.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } } for (int i = 0; i < nEdgeNodes[0] * nEdgeNodes[1] + nEdgeNodes[1] * nEdgeNodes[2] + nEdgeNodes[2] * nEdgeNodes[0]; i++) { lGeometry2.Add(new Rhino.Geometry.Polyline()); } lBoundary.Clear(); lBoundary2.Clear(); /////////////////////////////////////////////////////////////// Rhino.Geometry.Mesh m = new Rhino.Geometry.Mesh(); Rhino.Geometry.Mesh m2 = new Rhino.Geometry.Mesh(); lBoundary.Add(m); lBoundary2.Add(m2); for (int k = 0; k < nEdgeNodes[2]; k++) { for (int j = 0; j < nEdgeNodes[1]; j++) { int i = 0; m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } el = MathUtil.isoparametricElements(new int[2] { nEdgeNodes[1], nEdgeNodes[2] }); for (int i = 0; i < el.Length; i++) { m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); } m = new Rhino.Geometry.Mesh(); m2 = new Rhino.Geometry.Mesh(); lBoundary.Add(m); lBoundary2.Add(m2); for (int k = 0; k < nEdgeNodes[2]; k++) { for (int j = 0; j < nEdgeNodes[1]; j++) { int i = nEdgeNodes[0] - 1; m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } el = MathUtil.isoparametricElements(new int[2] { nEdgeNodes[1], nEdgeNodes[2] }); for (int i = 0; i < el.Length; i++) { m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); } /////////////////////////////////////////////////////////////// m = new Rhino.Geometry.Mesh(); m2 = new Rhino.Geometry.Mesh(); lBoundary.Add(m); lBoundary2.Add(m2); for (int j = 0; j < nEdgeNodes[1]; j++) { for (int i = 0; i < nEdgeNodes[0]; i++) { int k = 0; m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } el = MathUtil.isoparametricElements(new int[2] { nEdgeNodes[0], nEdgeNodes[1] }); for (int i = 0; i < el.Length; i++) { m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); } m = new Rhino.Geometry.Mesh(); m2 = new Rhino.Geometry.Mesh(); lBoundary.Add(m); lBoundary2.Add(m2); for (int j = 0; j < nEdgeNodes[1]; j++) { for (int i = 0; i < nEdgeNodes[0]; i++) { int k = nEdgeNodes[2] - 1; m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } el = MathUtil.isoparametricElements(new int[2] { nEdgeNodes[0], nEdgeNodes[1] }); for (int i = 0; i < el.Length; i++) { m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); } /////////////////////////////////////////////////////////////// m = new Rhino.Geometry.Mesh(); m2 = new Rhino.Geometry.Mesh(); lBoundary.Add(m); lBoundary2.Add(m2); for (int i = 0; i < nEdgeNodes[0]; i++) { for (int k = 0; k < nEdgeNodes[2]; k++) { int j = 0; m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } el = MathUtil.isoparametricElements(new int[2] { nEdgeNodes[2], nEdgeNodes[0] }); for (int i = 0; i < el.Length; i++) { m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); } m = new Rhino.Geometry.Mesh(); m2 = new Rhino.Geometry.Mesh(); lBoundary.Add(m); lBoundary2.Add(m2); for (int i = 0; i < nEdgeNodes[0]; i++) { for (int k = 0; k < nEdgeNodes[2]; k++) { int j = nEdgeNodes[1] - 1; m.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); m2.Vertices.Add(particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][0], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][1], particles[i + j * nEdgeNodes[0] + k * nEdgeNodes[0] * nEdgeNodes[1]][2]); } } el = MathUtil.isoparametricElements(new int[2] { nEdgeNodes[2], nEdgeNodes[0] }); for (int i = 0; i < el.Length; i++) { m.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); m2.Faces.AddFace(el[i][0], el[i][1], el[i][3], el[i][2]); } this.DVPW = GetDVPW(lGeometry, lBoundary); pS.DVPW = GetDVPW(lGeometry2, lBoundary2); pS.UPGR = GetUPGR(lGeometry2, lBoundary2); } DA.SetData(0, pS); }
public void setMaterial(GH_material mat, GH_gravity gvt) { this.Value.setMaterial(mat.Value, gvt.Value); }