Example #1
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!DA.GetData(1, ref v))
            {
                return;
            }

            if (!FriedChiken.isInitialized)
            {
                Rhino.Geometry.Mesh m = null;
                if (!DA.GetData(0, ref m))
                {
                    return;
                }
                newNodes.Clear();
                newNodes.AddRange(m.Vertices.ToPoint3dArray());
                int nNewNodes = newNodes.Count;
                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]);
                }

                pS = new GH_particleSystem(particles);
                node[] lNodes = new node[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                nF = new nodalForce(v.X, v.Y, v.Z);
                for (int i = 0; i < nNewNodes; i++)
                {
                    nF.addNode(lNodes[i]);
                }
                pS.Value.addObject(nF);
                lGeometry = new Rhino.Geometry.Point3d[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]);
                }
            }
            else
            {
                nF.forceX = v.X;
                nF.forceY = v.Y;
                nF.forceZ = v.Z;
            }

            DA.SetData(0, pS);
        }
Example #2
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;

            DA.GetData(2, ref v);
            if (!FriedChiken.isInitialized)
            {
                GH_Point[] pointList = new GH_Point[2];
                DA.GetData(0, ref pointList[0]);
                DA.GetData(1, ref pointList[1]);
                cV = new constrainVolumeObject(v);
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[_nNodes];
                for (int i = 0; i < _nNodes; i++)
                {
                    particles[i] = new particle(pointList[i].Value.X, pointList[i].Value.Y, pointList[i].Value.Z);
                }
                pS = new GH_particleSystem(particles);
                cV.addElement(new isoparametricElement(0, 1));
                pS.Value.addObject(cV);
                lGeometry.Clear();
                lGeometry2.Clear();
                lGeometry.Add(particles[0][0], particles[0][1], particles[0][2]);
                lGeometry.Add(particles[1][0], particles[1][1], particles[1][2]);
                lGeometry2.Add(particles[0][0], particles[0][1], particles[0][2]);
                lGeometry2.Add(particles[1][0], particles[1][1], particles[1][2]);

                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
            }
            else
            {
                if (cV != null)
                {
                    if (v > 0)
                    {
                        cV.refVolume = v;
                    }
                }
            }

            DA.SetData(0, pS);
        }
Example #3
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!DA.GetData(11, ref v))
            {
                return;
            }
            if (!FriedChiken.isInitialized)
            {
                GH_Point[]      pointList    = new GH_Point[8];
                List <GH_Point> tmpPointList = new List <GH_Point>();

                int[] nEdgeNodes = new int[_dim];

                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]);
                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];
                pS = new GH_particleSystem(particles);
                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];
                    }
                }
                node[] lNodes = new node[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                nF = new nodalForce(v.X, v.Y, v.Z);
                for (int i = 0; i < nNewNodes; i++)
                {
                    nF.addNode(lNodes[i]);
                }
                pS.Value.addObject(nF);
                lGeometry = new Rhino.Geometry.Point3d[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]);
                }
            }
            else
            {
                nF.forceX = v.X;
                nF.forceY = v.Y;
                nF.forceZ = v.Z;
            }
            DA.SetData(0, pS);
        }
        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);
        }
Example #5
0
        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)
            {
                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);
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;

            DA.GetData(2, ref v);
            if (!FriedChiken.isInitialized)
            {
                GH_Point[]      pointList    = new GH_Point[2];
                List <GH_Point> tmpPointList = new List <GH_Point>();
                GH_Curve        c            = new GH_Curve();
                int[]           nEdgeNodes   = new int[_dim];
                DA.GetData(0, ref c);
                DA.GetData(1, ref nEdgeNodes[0]);
                //cV = new constrainVolumeObject(v);
                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;
                    }
                }
                //点群生成
                int nNewNodes = nEdgeNodes[0];
                nElements = nNewNodes - 1;
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    Rhino.Geometry.Point3d p = c.Value.PointAt(c.Value.Domain.T0 + (c.Value.Domain.T1 - c.Value.Domain.T0) / nElements * i);
                    particles[i] = new particle(p.X, p.Y, p.Z);
                }
                pS = new GH_particleSystem(particles);
                List <mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List <mikity.NumericalMethodHelper.elements.isoparametricElement>();
                for (int i = 0; i < nElements; i++)
                {
                    e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + 1));
                }
                lCV.Clear();
                for (int i = 0; i < e.Count; i++)
                {
                    lCV.Add(new constrainVolumeObject(v / nElements));
                    lCV[i].addElement(e[i]);
                    pS.Value.addObject(lCV[i]);
                }

                lGeometry.Clear();
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry.Add(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2]);
                }
                this.DVPW = GetDVPW(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
            }
            else
            {
                if (lCV != null && v > 0)
                {
                    for (int i = 0; i < lCV.Count; i++)
                    {
                        lCV[i].refVolume = v / nElements;
                    }
                }
            }

            DA.SetData(0, pS);
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;

            DA.GetData(1, ref v);
            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))
                    {
                        nNewNodes = pl.Count();
                        nElements = nNewNodes - 1;
                        newNodes.Clear();
                        newNodes.AddRange(pl);


                        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]);
                        }
                        List <mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List <mikity.NumericalMethodHelper.elements.isoparametricElement>();
                        for (int i = 0; i < nElements; i++)
                        {
                            e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + 1));
                        }
                        lCV.Clear();
                        pS = new GH_particleSystem(particles);
                        for (int i = 0; i < e.Count; i++)
                        {
                            lCV.Add(new constrainVolumeObject(v / nElements));
                            lCV[i].addElement(e[i]);
                            pS.Value.addObject(lCV[i]);
                        }

                        lGeometry.Clear();
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            lGeometry.Add(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2]);
                        }
                        this.DVPW = GetDVPW(lGeometry);
                        pS.DVPW   = GetDVPW(lGeometry2);
                        pS.UPGR   = GetUPGR(lGeometry2);
                        pS.BKGT   = GetBKGT(lGeometry2);
                        this.BKGT = GetBKGT(lGeometry);
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }
            }
            else
            {
                if (lCV != null && v > 0)
                {
                    for (int i = 0; i < lCV.Count; i++)
                    {
                        lCV[i].refVolume = v / nElements;
                    }
                }
            }
            DA.SetData(0, pS);
            DA.SetDataList(1, newNodes);
        }
        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];
                DA.GetData(0, ref pointList[0]);
                DA.GetData(1, ref pointList[1]);
                DA.GetData(2, ref nEdgeNodes[0]);
                bool x = true, y = true, z = true;
                if (!DA.GetData(3, ref x))
                {
                    return;
                }
                if (!DA.GetData(4, ref y))
                {
                    return;
                }
                if (!DA.GetData(5, ref z))
                {
                    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];
                    }
                }
                pS = new GH_particleSystem(particles);
                node[] lNodes = new node[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                fixedNodes fN = new fixedNodes(x, y, z);

                for (int i = 0; i < nNewNodes; i++)
                {
                    fN.addNode(lNodes[i]);
                }
                pS.Value.addObject(fN);
                lGeometry = new Rhino.Geometry.Point3d[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]);
                }
            }
            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)
        {
            double v = -1.0;

            DA.GetData(2, ref v);
            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>();
                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();
                lCV.Clear();
                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++)
                {
                    lCV.Add(new constrainVolumeObject(v));
                    lCV[i].addElement(new isoparametricElement(i, i + nElements));
                }
                pS.Value.addObjects(lCV.ToArray());
                lGeometry.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]));
                }
            }
            else
            {
                if (lCV != null)
                {
                    if (v > 0)
                    {
                        for (int i = 0; i < nElements; i++)
                        {
                            lCV[i].refVolume = v;
                        }
                    }
                }
            }
            this.DVPW = GetDVPW(lGeometry);
            this.BKGT = GetBKGT(lGeometry);
            pS.DVPW   = GetDVPW(lGeometry2);
            pS.UPGR   = GetUPGR(lGeometry2);
            pS.BKGT   = GetBKGT(lGeometry2);
            DA.SetData(0, pS);
        }
Example #12
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            newNodes.Clear();
            if (!DA.GetData(1, ref v))
            {
                return;
            }
            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.AddRange(pl);

                        //メッシュ構築

                        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]);
                        }
                        pS = new GH_particleSystem(particles);
                        node[] lNodes = new node[nNewNodes];
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            lNodes[i] = new node(i);
                            lNodes[i].copyFrom(pS.Value.particles);
                        }
                        nF = new nodalForce(v.X, v.Y, v.Z);
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            nF.addNode(lNodes[i]);
                        }
                        pS.Value.addObject(nF);
                        lGeometry.Clear();
                        for (int i = 0; i < nNewNodes; i++)
                        {
                            lGeometry.Add(new Rhino.Geometry.Point3d(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);
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }
            }
            else
            {
                nF.forceX = v.X;
                nF.forceY = v.Y;
                nF.forceZ = v.Z;
            }
            DA.SetData(0, pS);
        }
Example #13
0
        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);
        }
Example #14
0
        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);
            }
        }
Example #17
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!DA.GetData(2, ref v))
            {
                return;
            }
            if (!FriedChiken.isInitialized)
            {
                GH_Point[]      pointList    = new GH_Point[2];
                List <GH_Point> tmpPointList = new List <GH_Point>();
                GH_Curve        c            = new GH_Curve();
                int[]           nEdgeNodes   = new int[_dim];
                DA.GetData(0, ref c);
                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;
                    }
                }
                //点群生成
                int nNewNodes = nEdgeNodes[0];
                nElements = nNewNodes - 1;
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    Rhino.Geometry.Point3d p = c.Value.PointAt(c.Value.Domain.T0 + (c.Value.Domain.T1 - c.Value.Domain.T0) / nElements * i);
                    particles[i] = new particle(p.X, p.Y, p.Z);
                }

                pS = new GH_particleSystem(particles);
                node[] lNodes = new node[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                nF = new nodalForce(v.X, v.Y, v.Z);
                for (int i = 0; i < nNewNodes; i++)
                {
                    nF.addNode(lNodes[i]);
                }
                pS.Value.addObject(nF);
                lGeometry.Clear();
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry.Add(new Rhino.Geometry.Point3d(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);
            }
            else
            {
                nF.forceX = v.X;
                nF.forceY = v.Y;
                nF.forceZ = v.Z;
            }

            DA.SetData(0, pS);
        }
        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>();
                GH_Curve        c            = new GH_Curve();
                int[]           nEdgeNodes   = new int[_dim];
                DA.GetData(0, ref c);
                DA.GetData(1, ref nEdgeNodes[0]);
                bool x = true, y = true, z = true;
                if (!DA.GetData(2, ref x))
                {
                    return;
                }
                if (!DA.GetData(3, ref y))
                {
                    return;
                }
                if (!DA.GetData(4, ref z))
                {
                    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;
                    }
                }
                //点群生成
                int nNewNodes = nEdgeNodes[0];
                nElements = nNewNodes - 1;
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    Rhino.Geometry.Point3d p = c.Value.PointAt(c.Value.Domain.T0 + (c.Value.Domain.T1 - c.Value.Domain.T0) / nElements * i);
                    particles[i] = new particle(p.X, p.Y, p.Z);
                }
                pS = new GH_particleSystem(particles);
                node[] lNodes = new node[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                fixedNodes fN = new fixedNodes(x, y, z);

                for (int i = 0; i < nNewNodes; i++)
                {
                    fN.addNode(lNodes[i]);
                }
                pS.Value.addObject(fN);
                lGeometry = new Rhino.Geometry.Point3d[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]);
                }
            }

            DA.SetData(0, pS);
        }
Example #19
0
        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;
                }
            }
        }
Example #20
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;

            DA.GetData(3, ref v);
            if (!FriedChiken.isInitialized)
            {
                GH_Point[]      pointList    = new GH_Point[2];
                List <GH_Point> tmpPointList = new List <GH_Point>();

                int[] nEdgeNodes = new int[_dim];
                DA.GetData(0, ref pointList[0]);
                DA.GetData(1, ref pointList[1]);
                DA.GetData(2, ref nEdgeNodes[0]);
                cV = new constrainVolumeObject(v);
                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);
                List <mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List <mikity.NumericalMethodHelper.elements.isoparametricElement>();
                for (int i = 0; i < nElements; i++)
                {
                    e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(el[i]));
                }
                for (int i = 0; i < e.Count; i++)
                {
                    cV.addElement(e[i]);
                }
                pS.Value.addObject(cV);
                lGeometry.Clear();
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry.Add(pS.Value.particles[i, 0], pS.Value.particles[i, 1], pS.Value.particles[i, 2]);
                }
                this.DVPW = GetDVPW(lGeometry);
                this.BKGT = GetBKGT(lGeometry);
                pS.DVPW   = GetDVPW(lGeometry2);
                pS.UPGR   = GetUPGR(lGeometry2);
                pS.BKGT   = GetBKGT(lGeometry2);
            }
            else
            {
                if (cV != null)
                {
                    if (v > 0)
                    {
                        cV.refVolume = v;
                    }
                }
            }
            DA.SetData(0, pS);
        }
Example #21
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!FriedChiken.isInitialized)
            {
                List <GH_Point> pointList = new List <GH_Point>();
                DA.GetDataList(0, pointList);
                bool x = true, y = true, z = true;
                if (!DA.GetData(1, ref x))
                {
                    return;
                }
                if (!DA.GetData(2, ref y))
                {
                    return;
                }
                if (!DA.GetData(3, ref z))
                {
                    return;
                }
                bool isGroup = true;
                if (!DA.GetData(4, ref isGroup))
                {
                    return;
                }
                _nNodes = pointList.Count;
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[_nNodes];
                for (int i = 0; i < _nNodes; i++)
                {
                    particles[i] = new particle(pointList[i].Value.X, pointList[i].Value.Y, pointList[i].Value.Z);
                }
                pS = new GH_particleSystem(particles);
                node[] lNodes = new node[_nNodes];
                for (int i = 0; i < _nNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                if (isGroup)
                {
                    fixedNodes fN = new fixedNodes(x, y, z);

                    for (int i = 0; i < _nNodes; i++)
                    {
                        fN.addNode(lNodes[i]);
                    }
                    pS.Value.addObject(fN);
                }
                else
                {
                    for (int i = 0; i < _nNodes; i++)
                    {
                        fixedNodes fN = new fixedNodes(x, y, z);
                        fN.addNode(lNodes[i]);
                        pS.Value.addObject(fN);
                    }
                }
                lGeometry  = new Rhino.Geometry.Point3d[_nNodes];
                lGeometry2 = new Rhino.Geometry.Point3d[_nNodes];
                for (int i = 0; i < _nNodes; i++)
                {
                    lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][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);
        }
Example #22
0
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            if (!DA.GetData(3, ref v))
            {
                return;
            }
            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;
                    }
                }
                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));
                    }
                }
                int nNewNodes = newNodes.Count;

                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]);
                }
                pS = new GH_particleSystem(particles);

                node[] lNodes = new node[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                nF = new nodalForce(v.X, v.Y, v.Z);
                for (int i = 0; i < nNewNodes; i++)
                {
                    nF.addNode(lNodes[i]);
                }
                pS.Value.addObject(nF);
                lGeometry = new Rhino.Geometry.Point3d[nNewNodes];
                for (int i = 0; i < nNewNodes; i++)
                {
                    lGeometry[i] = new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][2]);
                }
            }
            else
            {
                nF.forceX = v.X;
                nF.forceY = v.Y;
                nF.forceZ = v.Z;
            }

            DA.SetData(0, pS);
        }
        protected override void SolveInstance(Grasshopper.Kernel.IGH_DataAccess DA)
        {
            double v = -1.0;
            DA.GetData(1, ref v);
            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))
                    {
                        nNewNodes = pl.Count();
                        nElements = nNewNodes - 1;
                        newNodes.Clear();
                        newNodes.AddRange(pl);
                        lGeometry.Clear();
                        for (int i = 0; i < nElements; i++)
                        {
                            lGeometry.Add(new Rhino.Geometry.Line(newNodes[i], newNodes[i + 1]));
                        }


                        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]);
                        }
                        List<mikity.NumericalMethodHelper.elements.isoparametricElement> e = new List<mikity.NumericalMethodHelper.elements.isoparametricElement>();
                        for (int i = 0; i < nElements; i++)
                        {
                            e.Add(new mikity.NumericalMethodHelper.elements.isoparametricElement(i, i + 1));
                        }
                        lCV.Clear();
                        pS = new GH_particleSystem(particles);
                        for (int i = 0; i < e.Count; i++)
                        {
                            lCV.Add(new constrainVolumeObject(v / nElements));
                            lCV[i].addElement(e[i]);
                            pS.Value.addObject(lCV[i]);
                        }

                        lGeometry.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 + 1, 0], pS.Value.particles[i + 1, 1], pS.Value.particles[i + 1, 2]));
                        }
                    }
                }
                else
                {
                    AddRuntimeMessage(Grasshopper.Kernel.GH_RuntimeMessageLevel.Error, "Only polyline is accepted");
                    return;
                }

            }
            else
            {
                if (lCV != null && v > 0)
                {
                    for (int i = 0; i < lCV.Count; i++)
                    {
                        lCV[i].refVolume = v / nElements;
                    }
                }
            }
            DA.SetData(0, pS);
            DA.SetDataList(1, newNodes);
        }
Example #24
0
        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>();
                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;
                }
                int __n = pointList1.Count;
                int nU  = 0;
                if (!DA.GetData(2, ref nU))
                {
                    return;
                }
                List <GH_Point[]> pointLists = new List <GH_Point[]>();
                for (int i = 0; i < __n; i++)
                {
                    pointLists.Add(new GH_Point[nU]);
                }
                bool x = true, y = true, z = true;
                if (!DA.GetData(3, ref x))
                {
                    return;
                }
                if (!DA.GetData(4, ref y))
                {
                    return;
                }
                if (!DA.GetData(5, ref z))
                {
                    return;
                }
                bool isGroup = true;
                if (!DA.GetData(6, ref isGroup))
                {
                    return;
                }
                //点群生成
                double[,] wt = mikity.MathUtil.bicubic(1, new int[1] {
                    nU
                });
                int nNewNodes = wt.GetLength(0);
                mikity.NumericalMethodHelper.particle[] particles = new mikity.NumericalMethodHelper.particle[nNewNodes * __n];
                for (int j = 0; j < __n; j++)
                {
                    for (int i = 0; i < nNewNodes; i++)
                    {
                        particles[i + j * nNewNodes]     = new particle(0, 0, 0);
                        particles[i + j * nNewNodes][0] += pointList1[j].Value.X * wt[i, 0];
                        particles[i + j * nNewNodes][1] += pointList1[j].Value.Y * wt[i, 0];
                        particles[i + j * nNewNodes][2] += pointList1[j].Value.Z * wt[i, 0];
                        particles[i + j * nNewNodes][0] += pointList2[j].Value.X * wt[i, 1];
                        particles[i + j * nNewNodes][1] += pointList2[j].Value.Y * wt[i, 1];
                        particles[i + j * nNewNodes][2] += pointList2[j].Value.Z * wt[i, 1];
                    }
                }
                pS = new GH_particleSystem(particles);
                node[] lNodes = new node[__n * nNewNodes];
                for (int i = 0; i < __n * nNewNodes; i++)
                {
                    lNodes[i] = new node(i);
                    lNodes[i].copyFrom(pS.Value.particles);
                }
                if (isGroup)
                {
                    fixedNodes fN = new fixedNodes(x, y, z);

                    for (int i = 0; i < __n * nNewNodes; i++)
                    {
                        fN.addNode(lNodes[i]);
                    }
                    pS.Value.addObject(fN);
                }
                else
                {
                    for (int i = 0; i < __n; i++)
                    {
                        fixedNodes fN = new fixedNodes(x, y, z);
                        for (int j = 0; j < nNewNodes; j++)
                        {
                            fN.addNode(lNodes[j + nNewNodes * i]);
                        }
                        pS.Value.addObject(fN);
                    }
                }


                if (isGroup)
                {
                }
                else
                {
                }
                lGeometry.Clear();
                lGeometry2.Clear();
                for (int i = 0; i < __n * nNewNodes; i++)
                {
                    lGeometry.Add(new Rhino.Geometry.Point3d(particles[i][0], particles[i][1], particles[i][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);
        }