コード例 #1
0
ファイル: DataProcess.cs プロジェクト: Siubaak/IGA2D
        public Instance CreateInstance(string Input)
        {
            string[] Blocks = Input.Split('#');
            //Modeling Parameters
            //Order of NURBS
            int pX = Convert.ToInt32(Blocks[1].Split('\r')[1].Split('=')[1]);
            int pY = Convert.ToInt32(Blocks[1].Split('\r')[2].Split('=')[1]);
            //Knot Vector
            List <double> KnotVectorX = new List <double>(Array.ConvertAll(Blocks[2].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            List <double> KnotVectorY = new List <double>(Array.ConvertAll(Blocks[2].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            //Weights
            List <double> WeightsX = new List <double>(Array.ConvertAll(Blocks[3].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            List <double> WeightsY = new List <double>(Array.ConvertAll(Blocks[3].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i)));

            //Nurbs
            NurbsX = new NurbsShapeFunction(KnotVectorX, WeightsX, pX);
            NurbsY = new NurbsShapeFunction(KnotVectorY, WeightsY, pY);
            //Contorl Point
            string[]            Ps  = Blocks[4].Split('(');
            List <List <Node> > CPs = new List <List <Node> >();

            for (int k = 1; k != Ps.Count(); k += NurbsY.Count)
            {
                List <Node> CPj = new List <Node>();
                for (int j = 0; j != NurbsY.Count; ++j)
                {
                    CPj.Add(new Node(k + j - 1, (k - 1) / NurbsY.Count, j, Convert.ToDouble(Ps[k + j].Split(')')[0].Split(',')[0]), Convert.ToDouble(Ps[k + j].Split(')')[0].Split(',')[1])));
                }
                CPs.Add(CPj);
            }
            //Analysis Parameters
            //Material
            string[] MatPara = Blocks[5].Split('\r');
            Material Mat     = new Material(0, Convert.ToDouble(MatPara[1].Split('=')[1]), Convert.ToDouble(MatPara[2].Split('=')[1]), Convert.ToDouble(MatPara[3].Split('=')[1]));
            double   t       = Convert.ToDouble(MatPara[4].Split('=')[1]);

            //Load
            string[]    LoadPara = Blocks[6].Split('\r');
            List <Load> Loads    = new List <Load>();

            for (int k = 1; k != LoadPara.Count() - 2; ++k)
            {
                Loads.Add(new Load(k - 1, CPs[Convert.ToInt32(LoadPara[k].Split(',')[0].Split('\n')[1]) / NurbsY.Count][Convert.ToInt32(LoadPara[k].Split(',')[0].Split('\n')[1]) % NurbsY.Count], LoadPara[k].Split(',')[1], Convert.ToDouble(LoadPara[k].Split(',')[2])));
            }
            //Restriant
            string[]         ResPara    = Blocks[7].Split('\r');
            List <Restraint> Restraints = new List <Restraint>();

            for (int k = 1; k != ResPara.Count() - 2; ++k)
            {
                Restraints.Add(new Restraint(k - 1, CPs[Convert.ToInt32(ResPara[k].Split(',')[0].Split('\n')[1]) / NurbsY.Count][Convert.ToInt32(ResPara[k].Split(',')[0].Split('\n')[1]) % NurbsY.Count], ResPara[k].Split(',')[1]));
            }
            //Create Instance
            return(new Instance(CPs, NurbsX, NurbsY, Mat, t, Loads, Restraints));
        }
コード例 #2
0
ファイル: Analysis.cs プロジェクト: Siubaak/IGA2D
 public IGAElement(int tmpn, List <Node> tmpNodes, Material tmpMat, double tmpt, NurbsShapeFunction tmpNurbsX, NurbsShapeFunction tmpNurbsY)
 {
     n      = tmpn;
     Nodes  = tmpNodes;
     Mat    = tmpMat;
     NurbsX = tmpNurbsX;
     NurbsY = tmpNurbsY;
     t      = tmpt;
     D      = Mat.E / (1 - Mat.v * Mat.v) * Matrix <double> .Build.DenseOfArray(new double[, ] {
         { 1.0, Mat.v, 0.0 },
         { Mat.v, 1.0, 0.0 },
         { 0.0, 0.0, (1 - Mat.v) / 2 }
     });
 }
コード例 #3
0
ファイル: Analysis.cs プロジェクト: Siubaak/IGA2D
        public Instance(List <List <Node> > tmpNodes, NurbsShapeFunction NurbsX, NurbsShapeFunction NurbsY, Material Mat, double t, List <Load> Loads, List <Restraint> Restraints)
        {
            Nodes        = tmpNodes;
            Eles         = new List <IGAElement>();
            m_Loads      = Loads;
            m_Restraints = Restraints;
            //Create IGAElement
            List <double>            ParaSpaceX = (new HashSet <double>(NurbsX.KnotVector)).ToList();
            List <double>            ParaSpaceY = (new HashSet <double>(NurbsY.KnotVector)).ToList();
            Dictionary <double, int> mi         = new Dictionary <double, int>();
            Dictionary <double, int> mj         = new Dictionary <double, int>();

            foreach (double value in NurbsX.KnotVector)
            {
                if (mi.ContainsKey(value))
                {
                    mi[value] += 1;
                }
                else
                {
                    mi.Add(value, 1);
                }
            }
            foreach (double value in NurbsY.KnotVector)
            {
                if (mj.ContainsKey(value))
                {
                    mj[value] += 1;
                }
                else
                {
                    mj.Add(value, 1);
                }
            }
            for (int i = 0; i != ParaSpaceX.Count - 1; ++i)
            {
                for (int j = 0; j != ParaSpaceY.Count - 1; ++j)
                {
                    List <Node> tmpEleNodes = new List <Node>();
                    int         rEnd        = 0;
                    int         sEnd        = 0;
                    for (int h = 0; h != i + 1; ++h)
                    {
                        rEnd += mi[ParaSpaceX[h]];
                    }
                    for (int h = 0; h != j + 1; ++h)
                    {
                        sEnd += mj[ParaSpaceY[h]];
                    }
                    int rBegin = rEnd - (NurbsX.Order + 1);
                    int sBegin = sEnd - (NurbsY.Order + 1);
                    for (int r = rBegin; r != rEnd; ++r)
                    {
                        for (int s = sBegin; s != sEnd; ++s)
                        {
                            tmpEleNodes.Add(tmpNodes[r][s]);
                        }
                    }
                    Eles.Add(new IGAElement(i * (ParaSpaceY.Count - 1) + j, tmpEleNodes, Mat, t, NurbsX, NurbsY));
                }
            }
        }
コード例 #4
0
ファイル: Form2.cs プロジェクト: Siubaak/IGA2D
        private void button1_Click(object sender, EventArgs e)
        {
            BasicForm.Input = textBox1.Text;
            string[] Blocks = BasicForm.Input.Split('#');
            //Order of NURBS
            int pX = Convert.ToInt32(Blocks[1].Split('\r')[1].Split('=')[1]);
            int pY = Convert.ToInt32(Blocks[1].Split('\r')[2].Split('=')[1]);
            //Knot Vector
            List <double>    KnotVectorX = new List <double>(Array.ConvertAll(Blocks[2].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            List <double>    KnotVectorY = new List <double>(Array.ConvertAll(Blocks[2].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            HashSet <double> NodeX       = new HashSet <double>(KnotVectorX);
            HashSet <double> NodeY       = new HashSet <double>(KnotVectorY);
            //Weights
            List <double> WeightsX = new List <double>(Array.ConvertAll(Blocks[3].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            List <double> WeightsY = new List <double>(Array.ConvertAll(Blocks[3].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            //Contorl Point
            List <double> CPx = new List <double>(Array.ConvertAll(Blocks[4].Split('\r')[1].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            List <double> CPy = new List <double>(Array.ConvertAll(Blocks[4].Split('\r')[2].Split('=')[1].Split(','), i => Convert.ToDouble(i)));
            //Nurbs
            NurbsShapeFunction NurbsX = new NurbsShapeFunction(KnotVectorX, WeightsX);
            NurbsShapeFunction NurbsY = new NurbsShapeFunction(KnotVectorY, WeightsY);


            List <double> DrawPx = new List <double> {
            };
            List <double> DrawPy = new List <double> {
            };

            foreach (double x in NodeX)
            {
                for (double y = KnotVectorY[0]; y < KnotVectorY.Last(); y += KnotVectorY.Last() / 50)
                {
                    double tmpx = 0, tmpy = 0;
                    int    k = 0;
                    for (int j = 0; j != WeightsY.Count; ++j)
                    {
                        for (int i = 0; i != WeightsX.Count; ++i)
                        {
                            double NurbsR = NurbsX.R(0, pX, i, x) * NurbsY.R(0, pY, j, y);
                            tmpx += NurbsR * CPx[k];
                            tmpy += NurbsR * CPy[k];
                            ++k;
                        }
                    }
                    DrawPx.Add(tmpx);
                    DrawPy.Add(tmpy);
                }
            }

            /*
             * for (double x = KnotVectorX.Min(); x < KnotVectorX.Max(); x += KnotVectorX.Max() / 500)
             *  for (double y = KnotVectorY.Min(); y < KnotVectorY.Max(); y += KnotVectorY.Max() / 50)
             *  {
             *      double tmpx = 0, tmpy = 0;
             *      int k = 0;
             *      for (int j = 0; j != WeightsY.Count; ++j)
             *          for (int i = 0; i != WeightsX.Count; ++i)
             *          {
             *              double NurbsR = NurbsX.R(0, pX, i, x) * NurbsY.R(0, pY, j, y);
             *              tmpx += NurbsR * CPx[k];
             *              tmpy += NurbsR * CPy[k];
             ++k;
             *          }
             *      DrawPx.Add(tmpx);
             *      DrawPy.Add(tmpy);
             *  }
             */
            List <List <double> > DrawP = new List <List <double> > {
                DrawPx, DrawPy
            };

            BasicForm.bmp[1] = new Bitmap(551, 551);
            Graphics g = Graphics.FromImage(BasicForm.bmp[1]);

            this.Close();
        }