public static UniversalElement[] CreateUniversalElements()
 {
     UniversalElement[] universalElements = new UniversalElement[4];
     universalElements[0] = new UniversalElement(-1 / Math.Sqrt(3), -1 / Math.Sqrt(3), 1, 1);
     universalElements[1] = new UniversalElement(1 / Math.Sqrt(3), -1 / Math.Sqrt(3), 1, 1);
     universalElements[2] = new UniversalElement(1 / Math.Sqrt(3), 1 / Math.Sqrt(3), 1, 1);
     universalElements[3] = new UniversalElement(-1 / Math.Sqrt(3), 1 / Math.Sqrt(3), 1, 1);
     return(universalElements);
 }
Beispiel #2
0
        private void buildMeshButton_Click(object sender, EventArgs e)
        {
            double initTemp     = double.Parse(initTempBox.Text.Replace('.', ','));
            double symTime      = double.Parse(symTimeBox.Text.Replace('.', ','));
            double symStepTime  = double.Parse(symStepTimeBox.Text.Replace('.', ','));
            double ambientTemp  = double.Parse(ambientTempBox.Text.Replace('.', ','));
            double alpha        = double.Parse(alphaBox.Text.Replace('.', ','));
            double H            = double.Parse(hBox.Text.Replace('.', ','));
            double B            = double.Parse(bBox.Text.Replace('.', ','));
            int    nH           = int.Parse(nHBox.Text);
            int    nB           = int.Parse(nBBox.Text);
            double specHeat     = double.Parse(specHeatBox.Text.Replace('.', ','));
            double conductivity = double.Parse(conductivityBox.Text.Replace('.', ','));
            double density      = double.Parse(densityBox.Text.Replace('.', ','));

            this.globalData = new GlobalData(initTemp, symTime, symStepTime, ambientTemp, alpha, H, B, nH, nB, specHeat, conductivity, density);
            grid            = new Grid(globalData);
            UniversalElement[] universalElements = UniversalElement.CreateUniversalElements();
            int nodeNumber = globalData.GetNumberOfNodes();

            c = new double[nodeNumber, nodeNumber];
            h = new double[nodeNumber, nodeNumber];
            p = new double[nodeNumber];


            foreach (Element element in grid.GetElements())
            {
                int elementNodeNumber = element.GetNodes().Length;
                double[,] elementH = new double[elementNodeNumber, elementNodeNumber];
                double[,] elementC = new double[elementNodeNumber, elementNodeNumber];
                double[] elementP;
                foreach (UniversalElement universalElement in universalElements)
                {
                    Jacobian jacobian = new Jacobian(element, universalElement);
                    elementH = MatrixOperations.addition(elementH, element.GetPointMatrixH(jacobian, globalData.GetConductivity()));
                    elementC = MatrixOperations.addition(elementC, element.GetPointMatrixC(universalElement, jacobian.GetDetJ(), globalData.GetSpecificHeat(), globalData.GetDensity()));
                }
                elementH = MatrixOperations.addition(elementH, element.GetMatrixHbc(globalData.GetAlfa()));
                elementP = element.getVectorP(globalData.GetAlfa(), globalData.GetAmbientTemp());
                Node[] nodes = element.GetNodes();
                for (int i = 0; i < nodes.Length; i++)
                {
                    for (int j = 0; j < nodes.Length; j++)
                    {
                        c[nodes[i].GetId() - 1, nodes[j].GetId() - 1] += elementC[i, j];
                        h[nodes[i].GetId() - 1, nodes[j].GetId() - 1] += elementH[i, j];
                    }
                    p[nodes[i].GetId() - 1] += elementP[i];
                }
            }
        }
 public Jacobian(Element element, UniversalElement universalElement)
 {
     double[,] tab = new double[2, 2];
     for (int i = 0; i < element.GetNodes().Length; i++)
     {
         tab[0, 0] += universalElement.GetdKsi(i) * element.GetNode(i).GetX();
         tab[0, 1] += universalElement.GetdKsi(i) * element.GetNode(i).GetY();
         tab[1, 0] += universalElement.GetdEta(i) * element.GetNode(i).GetX();
         tab[1, 1] += universalElement.GetdEta(i) * element.GetNode(i).GetY();
     }
     det             = MatrixOperations.determinant(tab);
     inverseJacobian = MatrixOperations.inverse(tab);
     dNdx            = new double[4];
     dNdy            = new double[4];
     for (int i = 0; i < 4; i++)
     {
         dNdx[i] = GetInverseJacobian()[0, 0] * universalElement.GetdKsi(i) - GetInverseJacobian()[0, 1] * universalElement.GetdEta(i);
         dNdy[i] = -GetInverseJacobian()[1, 0] * universalElement.GetdKsi(i) + GetInverseJacobian()[1, 1] * universalElement.GetdEta(i);
     }
 }
Beispiel #4
0
 public double[,] GetPointMatrixC(UniversalElement universalElement, double det, double specificHeat, double density)
 {
     double[] shapeFunctions = universalElement.GetShapeFun();
     return(MatrixOperations.multiply(shapeFunctions, MatrixOperations.transpose(shapeFunctions), det * specificHeat * density));
 }