public UniversalElement(Element elementGlobal, InputData globalData)
        {
            Weight[0] = 1;
            Weight[1] = 1;
            Point[0]  = -1 / Math.Sqrt(3);
            Point[1]  = 1 / Math.Sqrt(3);

            List <double> _Set_Ksi_Eta = new List <double>();
            double        Ksi = 0, Eta = 0;

            //Obliczenia
            for (int i = 0; i < 4; i++)
            {
                _Set_Ksi_Eta = Set_Ksi_Eta(i);
                Ksi          = _Set_Ksi_Eta[0];
                Eta          = _Set_Ksi_Eta[1];

                //PUNKT CAŁKOWANIA
                PC Pc = new PC();
                Pc.Id     = i;
                Pc.dXdKsi = 0;
                Pc.dXdEta = 0;
                Pc.dYdKsi = 0;
                Pc.dYdEta = 0;

                Pc.Matrix_N      = Matrix_N(Ksi, Eta);
                Pc.Matrix_dNdKsi = Matrix_dNdKsi(Eta);
                Pc.Matrix_dNdEta = Matrix_dNdEta(Ksi);

                //JAKOBIANY PRZEKSZTAŁCENIA
                for (int j = 0; j < 4; j++)
                {
                    Pc.dXdKsi += ((Pc.Matrix_dNdKsi[j]) * elementGlobal.ID[j].x);
                    Pc.dXdEta += ((Pc.Matrix_dNdEta[j]) * elementGlobal.ID[j].x);
                    Pc.dYdKsi += ((Pc.Matrix_dNdKsi[j]) * elementGlobal.ID[j].y);
                    Pc.dYdEta += ((Pc.Matrix_dNdEta[j]) * elementGlobal.ID[j].y);
                }


                //J
                Pc.Matrix_J            = new List <List <double> >();
                Pc.Matrix_J_Transposed = new List <List <double> >();
                Pc.Inverse_Matrix_J    = new List <List <double> >();
                for (int j = 0; j < 2; j++)
                {
                    Pc.Matrix_J.Add(new List <double>());
                    Pc.Matrix_J_Transposed.Add(new List <double>());
                    Pc.Inverse_Matrix_J.Add(new List <double>());
                }
                Pc.Matrix_J[0].Add(Pc.dXdKsi);
                Pc.Matrix_J[0].Add(Pc.dYdKsi);
                Pc.Matrix_J[1].Add(Pc.dXdEta);
                Pc.Matrix_J[1].Add(Pc.dYdEta);

                //J Trans
                Pc.Matrix_J_Transposed[0].Add(Pc.Matrix_J[1][1]);
                Pc.Matrix_J_Transposed[0].Add(-Pc.Matrix_J[0][1]);
                Pc.Matrix_J_Transposed[1].Add(-Pc.Matrix_J[1][0]);
                Pc.Matrix_J_Transposed[1].Add(Pc.Matrix_J[0][0]);

                //Det[J]
                Pc.DetJ = (Pc.Matrix_J[0][0] * Pc.Matrix_J[1][1]) - (Pc.Matrix_J[0][1] * Pc.Matrix_J[1][0]);

                //Inverse J
                for (int j = 0; j < 2; j++)
                {
                    Pc.Inverse_Matrix_J[j].Add(Pc.Matrix_J_Transposed[j][0] / Pc.DetJ);
                    Pc.Inverse_Matrix_J[j].Add(Pc.Matrix_J_Transposed[j][1] / Pc.DetJ);
                }

                //dN/dX dN/dY
                Pc.dNdX = new List <double>();
                Pc.dNdY = new List <double>();
                for (int j = 0; j < 4; j++)
                {
                    Pc.dNdX.Add((Pc.Inverse_Matrix_J[0][0] * Pc.Matrix_dNdKsi[j]) +
                                (Pc.Inverse_Matrix_J[0][1] * Pc.Matrix_dNdEta[j]));
                    Pc.dNdY.Add((Pc.Inverse_Matrix_J[1][0] * Pc.Matrix_dNdKsi[j]) +
                                (Pc.Inverse_Matrix_J[1][1] * Pc.Matrix_dNdEta[j]));
                }

                //{dN/dX)(dN/dX} Transp. {dN/dY)(dN/dY} Transp. {N}{N} Transp.
                Pc.dNdX_dNdX_Transposed_Matrix = Matrix_Matrix_Transposed_optionalParam(Pc.dNdX, 1.0);
                Pc.dNdY_dNdY_Transposed_Matrix = Matrix_Matrix_Transposed_optionalParam(Pc.dNdY, 1.0);
                Pc.N_N_Transparent             = Matrix_Matrix_Transposed_optionalParam(Pc.Matrix_N, 1.0);

                //Local H Matrix Local C Matrix
                Pc.Local_H_Matrix    = new List <List <double> >();
                Pc.Local_H_BC_Matrix = new List <List <double> >();
                Pc.Local_C_Matrix    = new List <List <double> >();
                for (int j = 0; j < 4; j++)
                {
                    Pc.Local_H_Matrix.Add(new List <double>());
                    Pc.Local_H_BC_Matrix.Add(new List <double>());
                    Pc.Local_C_Matrix.Add(new List <double>());

                    for (int k = 0; k < 4; k++)
                    {
                        Pc.Local_H_Matrix[j].Add(globalData.K * (((Pc.dNdX_dNdX_Transposed_Matrix[j][k]) +
                                                                  (Pc.dNdY_dNdY_Transposed_Matrix[j][k])) * Pc.DetJ));
                        Pc.Local_C_Matrix[j].Add(globalData.c * globalData.ro *
                                                 Pc.N_N_Transparent[j][k] * Pc.DetJ);
                    }
                }

                PcList.Add(Pc);
                Lateral_Surface_List.Add(_Set_Lateral_Surface(i, globalData));
            }

            //Macierz H Matrix C Vector P
            Matrix_H           = new List <List <double> >();
            Matrix_H_plus_H_bc = new List <List <double> >();
            Matrix_C           = new List <List <double> >();
            P_Vector           = new List <double>();
            double H_Matrix_Index = 0;
            double C_Matrix_Index = 0;

            for (int i = 0; i < 4; i++)
            {
                Matrix_H.Add(new List <double>());
                Matrix_H_plus_H_bc.Add(new List <double>());
                Matrix_C.Add(new List <double>());
                P_Vector.Add(0f);
                for (int j = 0; j < 4; j++)
                {
                    for (int k = 0; k < 4; k++)
                    {
                        H_Matrix_Index += PcList[k].Local_H_Matrix[i][j];
                        C_Matrix_Index += PcList[k].Local_C_Matrix[i][j];
                    }
                    Matrix_H[i].Add(H_Matrix_Index);
                    Matrix_H_plus_H_bc[i].Add(H_Matrix_Index);
                    Matrix_C[i].Add(C_Matrix_Index);
                    H_Matrix_Index = 0;
                    C_Matrix_Index = 0;
                }
            }

            Matrix_Hbc         = Matrix_H_Bc(elementGlobal, Lateral_Surface_List);
            P_Vector           = Vector_P(elementGlobal, Lateral_Surface_List);
            Matrix_H_plus_H_bc = ArraySumary(Matrix_H_plus_H_bc, Matrix_Hbc);

            // Przypisanie do elementu
            elementGlobal.Matrix_H           = Matrix_H;
            elementGlobal.Matrix_Hbc         = Matrix_Hbc;
            elementGlobal.Matrix_H_plus_H_bc = Matrix_H_plus_H_bc;
            elementGlobal.Matrix_C           = Matrix_C;
            elementGlobal.P_Vector           = P_Vector;
        }
        public Lateral_Surface _Set_Lateral_Surface(int i, InputData globalData)
        {
            Lateral_Surface lateral_surface = new Lateral_Surface();

            lateral_surface.pcBCs = new List <PcBC>();
            double surface_length = 0;

            //Punkty całkowania na pow. bocznych
            if (i == 0)
            {
                surface_length = globalData.W / (globalData.nW - 1);
                PcBC pcBC = new PcBC();
                pcBC.Ksi                = Point[0];
                pcBC.Eta                = -1;
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
                pcBC.Ksi                = Point[1];
                pcBC.Eta                = -1;
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
            }
            else if (i == 1)
            {
                surface_length = globalData.H / (globalData.nH - 1);
                PcBC pcBC = new PcBC();
                pcBC.Ksi                = 1;
                pcBC.Eta                = Point[0];
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
                pcBC.Ksi                = 1;
                pcBC.Eta                = Point[1];
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
            }
            else if (i == 2)
            {
                surface_length = globalData.W / (globalData.nW - 1);
                PcBC pcBC = new PcBC();
                pcBC.Ksi                = Point[1];
                pcBC.Eta                = 1;
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
                pcBC.Ksi                = Point[0];
                pcBC.Eta                = 1;
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
            }
            else if (i == 3)
            {
                surface_length = globalData.H / (globalData.nH - 1);
                PcBC pcBC = new PcBC();
                pcBC.Ksi                = -1;
                pcBC.Eta                = Point[1];
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
                pcBC.Ksi                = -1;
                pcBC.Eta                = Point[0];
                pcBC.Matrix_N_BC        = Matrix_N(pcBC.Ksi, pcBC.Eta);
                pcBC.Matrix_N_Transp_BC = Matrix_Matrix_Transposed_optionalParam(pcBC.Matrix_N_BC, globalData.alfa);
                lateral_surface.pcBCs.Add(pcBC);
            }
            double DetJ = surface_length / 2;

            lateral_surface.sum       = new List <List <double> >();
            lateral_surface.VectorSum = new List <double>();
            for (int j = 0; j < 4; j++)
            {
                // Vector P
                lateral_surface.sum.Add(new List <double>());
                lateral_surface.VectorSum.Add((lateral_surface.pcBCs[0].Matrix_N_BC[j] +
                                               lateral_surface.pcBCs[1].Matrix_N_BC[j]) * DetJ * globalData.alfa * globalData.ambient_temp);
                for (int k = 0; k < 4; k++)
                {
                    lateral_surface.sum[j].Add((lateral_surface.pcBCs[0].Matrix_N_Transp_BC[j][k] +
                                                lateral_surface.pcBCs[1].Matrix_N_Transp_BC[j][k]) * DetJ);
                }
            }
            return(lateral_surface);
        }