コード例 #1
0
ファイル: Program.cs プロジェクト: ast-ivanov/Mke
        static void kuslau3(ISlaeService slae, int node1, int node2, Edge edge)
        {
            var r1 = r[node1 % r.Length];
            var z1 = z[node1 / r.Length];
            var r2 = r[node2 % r.Length];
            var z2 = z[node2 / r.Length];

            var ubeta1 = Ubeta(r1, z1, edge);
            var ubeta2 = Ubeta(r2, z2, edge);

            if (edge == Edge.Right || edge == Edge.Left)
            {
                var Mz = Program.Mz(z1, z2);
                slae.GetElementOfA(node1, node1) += beta * r1 * Mz[0, 0];
                slae.GetElementOfA(node1, node2) += beta * r1 * Mz[0, 1];
                slae.GetElementOfA(node2, node1) += beta * r1 * Mz[1, 0];
                slae.GetElementOfA(node2, node2) += beta * r1 * Mz[1, 1];

                slae.b[node1] += beta * (Mz[0, 0] * r1 * ubeta1 + Mz[0, 1] * r1 * ubeta2);
                slae.b[node2] += beta * (Mz[1, 0] * r1 * ubeta1 + Mz[1, 1] * r1 * ubeta2);
            }
            else
            {
                var Mr = Program.Mr(r1, r2);
                slae.GetElementOfA(node1, node1) += beta * Mr[0, 0];
                slae.GetElementOfA(node1, node2) += beta * Mr[0, 1];
                slae.GetElementOfA(node2, node1) += beta * Mr[1, 0];
                slae.GetElementOfA(node2, node2) += beta * Mr[1, 1];

                slae.b[node1] += beta * (Mr[0, 0] * ubeta1 + Mr[0, 1] * ubeta2);
                slae.b[node2] += beta * (Mr[1, 0] * ubeta1 + Mr[1, 1] * ubeta2);
            }
        }
コード例 #2
0
        private void kuslau2(ISlaeService slae, int node1, int node2, EEdge edge)
        {
            var r = SolutionParams.r;
            var z = SolutionParams.z;

            var r1 = r[node1 % r.Length];
            var z1 = z[node1 / r.Length];
            var r2 = r[node2 % r.Length];
            var z2 = z[node2 / r.Length];

            var teta1 = teta(r1, z1, edge);
            var teta2 = teta(r2, z2, edge);

            if (edge == EEdge.Right || edge == EEdge.Left)
            {
                var Mz = GetMz(z1, z2);
                slae.b[node1] += Mz[0, 0] * r1 * teta1 + Mz[0, 1] * r1 * teta2;
                slae.b[node2] += Mz[1, 0] * r1 * teta1 + Mz[1, 1] * r1 * teta2;
            }
            else
            {
                var Mr = GetMr(r1, r2);
                slae.b[node1] += Mr[0, 0] * teta1 + Mr[0, 1] * teta2;
                slae.b[node2] += Mr[1, 0] * teta1 + Mr[1, 1] * teta2;
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: ast-ivanov/Mke
 static void ConsoleOut(ISlaeService slae)
 {
     for (int i = 0; i < r.Length * z.Length; i++)
     {
         Console.Write($"{slae.q[i]:0.########}\t{U(r[i % r.Length], z[i / r.Length]):0.###}");
         Console.WriteLine();
     }
 }
コード例 #4
0
        private void kuslau1(ISlaeService slae, int node)
        {
            var n = SolutionParams.N;

            for (var i = 0; i < n; i++)
            {
                slae.A[node, i] = i == node ? 1 : 0;
                slae.A[i, node] = i == node ? 1 : 0;
            }

            slae.b[node] = 0;
        }
コード例 #5
0
ファイル: Solution.cs プロジェクト: ast-ivanov/Mke
        private void kuslau1(ISlaeService slae, int node)
        {
            var n = SolutionParams.N;

            var(x1, y1, z1) = GetNodeCoordinates(node);

            for (var i = 0; i < n; i++)
            {
                slae.GetElementOfA(node, i) = i == node ? 1 : 0;
            }
            slae.b[node] = U(x1, y1, z1);
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: ast-ivanov/Mke
 static void FileOut(ISlaeService slae)
 {
     using (var file = File.OpenWrite("LOS.txt"))
     {
         using (var sw = new StreamWriter(file))
         {
             for (var i = 0; i < r.Length * z.Length; i++)
             {
                 sw.Write($"{slae.q[i]:0.########}\t{U(r[i % r.Length], z[i / r.Length]):0.###}");
                 sw.WriteLine();
             }
         }
     }
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: ast-ivanov/Mke
        static void kuslau1(ISlaeService slae, int number1, int number2)
        {
            var r1 = r[number1 % r.Length];
            var z1 = z[number1 / r.Length];
            var r2 = r[number2 % r.Length];
            var z2 = z[number2 / r.Length];

            for (int i = 0; i < r.Length * z.Length; i++)
            {
                slae.GetElementOfA(number1, i) = i != number1 ? 0 : 1;
                slae.GetElementOfA(number2, i) = i != number2 ? 0 : 1;
            }
            slae.b[number1] = U(r1, z1);
            slae.b[number2] = U(r2, z2);
        }
コード例 #8
0
        private void CalculateKU(EEdge edge, ISlaeService slae)
        {
            var startNode = GetStartNode(edge);
            var endNode   = GetEndNode(edge);

            bool isFirst;

            switch (edge)
            {
            case EEdge.Bottom:
                isFirst = SolutionParams.BottomFirst;
                break;

            case EEdge.Top:
                isFirst = SolutionParams.TopFirst;
                break;

            case EEdge.Left:
                isFirst = SolutionParams.LeftFirst;
                break;

            case EEdge.Right:
                isFirst = SolutionParams.RightFirst;
                break;

            case EEdge.Front:
                isFirst = SolutionParams.FrontFirst;
                break;

            case EEdge.Back:
                isFirst = SolutionParams.BackFirst;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(edge), edge, null);
            }

            if (!isFirst)
            {
                return;
            }

            for (var i = startNode; i <= endNode; i = GetNextNode(i, edge))
            {
                kuslau1(slae, i);
            }
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: ast-ivanov/Mke
        static void kuslau2(ISlaeService slae, int node1, int node2, Edge edge)
        {
            var r1 = r[node1 % r.Length];
            var z1 = z[node1 / r.Length];
            var r2 = r[node2 % r.Length];
            var z2 = z[node2 / r.Length];

            var teta1 = teta(r1, z1, edge);
            var teta2 = teta(r2, z2, edge);

            if (edge == Edge.Right || edge == Edge.Left)
            {
                var Mz = Program.Mz(z1, z2);
                slae.b[node1] += Mz[0, 0] * r1 * teta1 + Mz[0, 1] * r1 * teta2;
                slae.b[node2] += Mz[1, 0] * r1 * teta1 + Mz[1, 1] * r1 * teta2;
            }
            else
            {
                var Mr = Program.Mr(r1, r2);
                slae.b[node1] += Mr[0, 0] * teta1 + Mr[0, 1] * teta2;
                slae.b[node2] += Mr[1, 0] * teta1 + Mr[1, 1] * teta2;
            }
        }
コード例 #10
0
        private void kuslau3(ISlaeService slae, int node1, int node2, EEdge edge)
        {
            var r = SolutionParams.r;
            var z = SolutionParams.z;

            var r1 = r[node1 % r.Length];
            var z1 = z[node1 / r.Length];
            var r2 = r[node2 % r.Length];
            var z2 = z[node2 / r.Length];

            var ubeta1 = Ubeta(r1, z1, edge);
            var ubeta2 = Ubeta(r2, z2, edge);

            if (edge == EEdge.Right || edge == EEdge.Left)
            {
                var Mz = GetMz(z1, z2);
                slae.GetElementOfA(node1, node1) += SolutionParams.Beta * r1 * Mz[0, 0];
                slae.GetElementOfA(node1, node2) += SolutionParams.Beta * r1 * Mz[0, 1];
                slae.GetElementOfA(node2, node1) += SolutionParams.Beta * r1 * Mz[1, 0];
                slae.GetElementOfA(node2, node2) += SolutionParams.Beta * r1 * Mz[1, 1];

                slae.b[node1] += SolutionParams.Beta * (Mz[0, 0] * r1 * ubeta1 + Mz[0, 1] * r1 * ubeta2);
                slae.b[node2] += SolutionParams.Beta * (Mz[1, 0] * r1 * ubeta1 + Mz[1, 1] * r1 * ubeta2);
            }
            else
            {
                var Mr = GetMr(r1, r2);
                slae.GetElementOfA(node1, node1) += SolutionParams.Beta * Mr[0, 0];
                slae.GetElementOfA(node1, node2) += SolutionParams.Beta * Mr[0, 1];
                slae.GetElementOfA(node2, node1) += SolutionParams.Beta * Mr[1, 0];
                slae.GetElementOfA(node2, node2) += SolutionParams.Beta * Mr[1, 1];

                slae.b[node1] += SolutionParams.Beta * (Mr[0, 0] * ubeta1 + Mr[0, 1] * ubeta2);
                slae.b[node2] += SolutionParams.Beta * (Mr[1, 0] * ubeta1 + Mr[1, 1] * ubeta2);
            }
        }
コード例 #11
0
        private void AddLocal(ISlaeService slae, int number)
        {
            var(x1, y1, z1) = GetNodeCoordinates(number);
            var(x2, y2, z2) = GetOppositeNodeCoordinates(number);

            var Gx = GetLocalG(x1, x2);
            var Gy = GetLocalG(y1, y2);
            var Gz = GetLocalG(z1, z2);

            var Mx = GetLocalM(x1, x2);
            var My = GetLocalM(y1, y2);
            var Mz = GetLocalM(z1, z2);

            #region Формирование матрицы жёсткости и массы

            const int nodesCount = 8;
            var       G          = new double[nodesCount, nodesCount];
            var       M          = new double[nodesCount, nodesCount];

            for (var i = 0; i < nodesCount; i++)
            {
                var iBinaryArray = ToBinaryConverter.ConvertToBinary(i, 3);
                var xi           = iBinaryArray[0];
                var yi           = iBinaryArray[1];
                var zi           = iBinaryArray[2];

                for (var j = i; j < nodesCount; j++)
                {
                    var jBinaryArray = ToBinaryConverter.ConvertToBinary(j, 3);
                    var xj           = jBinaryArray[0];
                    var yj           = jBinaryArray[1];
                    var zj           = jBinaryArray[2];

                    G[i, j] = SolutionParams.Lambda * (Gx[xi, xj] * My[yi, yj] * Mz[zi, zj] +
                                                       Mx[xi, xj] * Gy[yi, yj] * Mz[zi, zj] +
                                                       Mx[xi, xj] * My[yi, yj] * Gz[zi, zj]);

                    M[i, j] = SolutionParams.Gamma * Mx[xi, xj] * My[yi, yj] * Mz[zi, zj];
                }

                for (var j = 0; j < i; j++)
                {
                    G[i, j] = G[j, i];
                    M[i, j] = M[j, i];
                }
            }

            #endregion

            #region Добавление в матрицу А

            var nodesNumbers = GetNodesNumbers(number);
            var n            = nodesNumbers.Length;
            for (var i = 0; i < n; i++)
            {
                var row = nodesNumbers[i];
                for (var j = 0; j < n; j++)
                {
                    var column = nodesNumbers[j];
                    slae.A[row, column] += G[i, j] + M[i, j];
                }
            }

            #endregion

            #region Добавление в вектор правой части

            for (var j = 0; j < n; j++)
            {
                var row = nodesNumbers[j];
                var(x, y, z) = GetNodeCoordinates(row);
                var fValue = f(x, y, z);

                for (var i = 0; i < n; i++)
                {
                    slae.b[nodesNumbers[i]] += M[i, j] * fValue;
                }
            }

            #endregion
        }
コード例 #12
0
ファイル: Program.cs プロジェクト: ast-ivanov/Mke
        static void AddLocal(ISlaeService slae, int number)
        {
            var r1 = r[number % r.Length];
            var z1 = z[number / r.Length];
            var r2 = r[number % r.Length + 1];
            var z2 = z[number / r.Length + 1];
            var hr = r2 - r1;
            var hz = z2 - z1;

            var G = new double[4, 4];
            var M = new double[4, 4];

            double[,] Gr =
            {
                { (r2 + r1) / 2 / hr,  -(r2 + r1) / 2 / hr },
                { -(r2 + r1) / 2 / hr, (r2 + r1) / 2 / hr  }
            };

            var Mr = Program.Mr(r1, r2);

            double[,] Gz =
            {
                {  1 / hz, -1 / hz },
                { -1 / hz,  1 / hz }
            };

            var Mz = Program.Mz(z1, z2);

            #region Матрицы жёсткости и массы

            G[0, 0] = lambda * (Gr[0, 0] * Mz[0, 0] + Mr[0, 0] * Gz[0, 0]);
            G[0, 1] = lambda * (Gr[0, 1] * Mz[0, 0] + Mr[0, 1] * Gz[0, 0]);
            G[0, 2] = lambda * (Gr[0, 0] * Mz[0, 1] + Mr[0, 0] * Gz[0, 1]);
            G[0, 3] = lambda * (Gr[0, 1] * Mz[0, 1] + Mr[0, 1] * Gz[0, 1]);
            G[1, 0] = G[0, 1];
            G[1, 1] = lambda * (Gr[1, 1] * Mz[0, 0] + Mr[1, 1] * Gz[0, 0]);
            G[1, 2] = lambda * (Gr[1, 0] * Mz[0, 1] + Mr[1, 0] * Gz[0, 1]);
            G[1, 3] = lambda * (Gr[1, 1] * Mz[0, 1] + Mr[1, 1] * Gz[0, 1]);
            G[2, 0] = G[0, 2];
            G[2, 1] = G[1, 2];
            G[2, 2] = lambda * (Gr[0, 0] * Mz[1, 1] + Mr[0, 0] * Gz[1, 1]);
            G[2, 3] = lambda * (Gr[0, 1] * Mz[1, 1] + Mr[0, 1] * Gz[1, 1]);
            G[3, 0] = G[0, 3];
            G[3, 1] = G[1, 3];
            G[3, 2] = G[2, 3];
            G[3, 3] = lambda * (Gr[1, 1] * Mz[1, 1] + Mr[1, 1] * Gz[1, 1]);

            M[0, 0] = gamma * Mr[0, 0] * Mz[0, 0];
            M[0, 1] = gamma * Mr[0, 1] * Mz[0, 0];
            M[0, 2] = gamma * Mr[0, 0] * Mz[0, 1];
            M[0, 3] = gamma * Mr[0, 1] * Mz[0, 1];
            M[1, 0] = M[0, 1];
            M[1, 1] = gamma * Mr[1, 1] * Mz[0, 0];
            M[1, 2] = gamma * Mr[1, 0] * Mz[0, 1];
            M[1, 3] = gamma * Mr[1, 1] * Mz[0, 1];
            M[2, 0] = M[0, 2];
            M[2, 1] = M[1, 2];
            M[2, 2] = gamma * Mr[0, 0] * Mz[1, 1];
            M[2, 3] = gamma * Mr[0, 1] * Mz[1, 1];
            M[3, 0] = M[0, 3];
            M[3, 1] = M[1, 3];
            M[3, 2] = M[2, 3];
            M[3, 3] = gamma * Mr[1, 1] * Mz[1, 1];

            #endregion

            #region Добавление в матрицу А

            slae.GetElementOfA(number, number)                               += G[0, 0] + M[0, 0];
            slae.GetElementOfA(number, number + 1)                           += G[0, 1] + M[0, 1];
            slae.GetElementOfA(number, number + r.Length)                    += G[0, 2] + M[0, 2];
            slae.GetElementOfA(number, number + r.Length + 1)                += G[0, 3] + M[0, 3];
            slae.GetElementOfA(number + 1, number)                           += G[1, 0] + M[1, 0];
            slae.GetElementOfA(number + 1, number + 1)                       += G[1, 1] + M[1, 1];
            slae.GetElementOfA(number + 1, number + r.Length)                += G[1, 2] + M[1, 2];
            slae.GetElementOfA(number + 1, number + r.Length + 1)            += G[1, 3] + M[1, 3];
            slae.GetElementOfA(number + r.Length, number)                    += G[2, 0] + M[2, 0];
            slae.GetElementOfA(number + r.Length, number + 1)                += G[2, 1] + M[2, 1];
            slae.GetElementOfA(number + r.Length, number + r.Length)         += G[2, 2] + M[2, 2];
            slae.GetElementOfA(number + r.Length, number + r.Length + 1)     += G[2, 3] + M[2, 3];
            slae.GetElementOfA(number + r.Length + 1, number)                += G[3, 0] + M[3, 0];
            slae.GetElementOfA(number + r.Length + 1, number + 1)            += G[3, 1] + M[3, 1];
            slae.GetElementOfA(number + r.Length + 1, number + r.Length)     += G[3, 2] + M[3, 2];
            slae.GetElementOfA(number + r.Length + 1, number + r.Length + 1) += G[3, 3] + M[3, 3];

            #endregion

            #region Добавление в вектор правой части

            for (var i = 0; i < 2; i++)
            {
                for (var j = 0; j < 2; j++)
                {
                    slae.b[number]                += M[0, 2 * i + j] * f(r[number % r.Length + j], z[number / r.Length + i]);
                    slae.b[number + 1]            += M[1, 2 * i + j] * f(r[number % r.Length + j], z[number / r.Length + i]);
                    slae.b[number + r.Length]     += M[2, 2 * i + j] * f(r[number % r.Length + j], z[number / r.Length + i]);
                    slae.b[number + r.Length + 1] += M[3, 2 * i + j] * f(r[number % r.Length + j], z[number / r.Length + i]);
                }
            }

            #endregion
        }