示例#1
0
文件: Analysis.cs 项目: Siubaak/IGA2D
        public void Calculate()
        {
            int Dim = 2 * Nodes.Count * Nodes[0].Count;

            m_GlobalK = Matrix <double> .Build.Dense(Dim, Dim, 0);

            Force = Vector <double> .Build.Dense(Dim, 0);

            Disp = Vector <double> .Build.Dense(Dim, 0);

            //Global Stiffness Matrix
            foreach (IGAElement Ele in Eles)
            {
                Matrix <double> LocalK = Ele.K();
                for (int i = 0; i != Ele.Nodes.Count; ++i)
                {
                    for (int j = 0; j != Ele.Nodes.Count; ++j)
                    {
                        m_GlobalK[Ele.Nodes[i].n * 2, Ele.Nodes[j].n * 2]         += LocalK[i * 2, j * 2];
                        m_GlobalK[Ele.Nodes[i].n * 2, Ele.Nodes[j].n * 2 + 1]     += LocalK[i * 2, j * 2 + 1];
                        m_GlobalK[Ele.Nodes[i].n * 2 + 1, Ele.Nodes[j].n * 2]     += LocalK[i * 2 + 1, j * 2];
                        m_GlobalK[Ele.Nodes[i].n * 2 + 1, Ele.Nodes[j].n * 2 + 1] += LocalK[i * 2 + 1, j * 2 + 1];
                    }
                }
            }
            //Force Vector
            foreach (Load load in m_Loads)
            {
                Force = load.Assembly(Force);
            }
            //Processing
            m_Force_Pro = Vector <double> .Build.DenseOfVector(Force);

            m_GlobalK_Pro = Matrix <double> .Build.DenseOfMatrix(m_GlobalK);

            foreach (Restraint res in m_Restraints)
            {
                m_Force_Pro   = res.ForceProcessing(m_Force_Pro);
                m_GlobalK_Pro = res.KProcessing(m_GlobalK_Pro);
            }
            //Calculate
            Disp = m_GlobalK_Pro.QR().Solve(m_Force_Pro);
            Vector <double> tmpForce = m_GlobalK * Disp;

            Reaction = tmpForce - Force;
        }