예제 #1
0
        protected virtual void AddThirdBoundary(IMatrix A, double[] b, ThirdBoundaryEdge edge)
        {
            double[,] M = info.BoundaryBasis.MassMatrix;

            Func <double, double, double, double> ubetatime = edge.UBeta;
            Func <double, double, double>         ubeta     = (double x, double y) => ubetatime(x, y, 0);
            double beta = edge.Beta;

            Point p1 = info.Mesh.Points[edge[0]];
            Point p2 = info.Mesh.Points[edge[edge.NodeCount - 1]];

            double x0 = p1.X;
            double y0 = p1.Y;
            double x1 = p2.X;
            double y1 = p2.Y;

            double h = Point.Distance(p1, p2);

            for (int i = 0; i < info.BoundaryBasis.Size; i++)
            {
                b[edge[i]] += beta * h * Quadratures.NewtonCotes(0.0, 1.0, (double ksi) => ubeta(x0 + ksi * (x1 - x0), y0 + ksi * (y1 - y0)) * boundaryPsi[i](ksi));
            }

            for (int i = 0; i < info.BoundaryBasis.Size; i++)
            {
                for (int j = 0; j < info.BoundaryBasis.Size; j++)
                {
                    A.Add(edge[i], edge[j], beta * h * M[i, j]);
                }
            }
        }
예제 #2
0
        protected virtual void BuildLocalMatrix(FiniteElement e)
        {
            Point a = points[e[0]];
            Point b = points[e[1]];
            Point c = points[e[2]];

            double D = Math.Abs(Utilities.Det(a, b, c));

            for (int i = 0; i < info.Basis.Size; i++)
            {
                for (int j = 0; j < info.Basis.Size; j++)
                {
                    double G = Quadratures.TriangleGauss18(GetGrad(i, j, a, b, c));
                    double M = Quadratures.TriangleGauss18((double ksi, double etta) => psi[i](ksi, etta) * psi[j](ksi, etta));
                    local[i, j] = (e.Material.Lambda * G + e.Material.RoCp * M) * D;
                }
            }
        }
예제 #3
0
        protected virtual void AddSecondBoundary(IMatrix A, double[] b, SecondBoundaryEdge edge)
        {
            Func <double, double, double, double> thetatime = edge.Theta;
            Func <double, double, double>         theta     = (double x, double y) => thetatime(x, y, 0);

            Point p1 = info.Mesh.Points[edge[0]];
            Point p2 = info.Mesh.Points[edge[edge.NodeCount - 1]];

            double x0 = p1.X;
            double y0 = p1.Y;
            double x1 = p2.X;
            double y1 = p2.Y;

            double h = Point.Distance(p1, p2);

            for (int i = 0; i < info.BoundaryBasis.Size; i++)
            {
                b[edge[i]] += h * Quadratures.NewtonCotes(0.0, 1.0, (double ksi) => theta(x0 + ksi * (x1 - x0), y0 + ksi * (y1 - y0)) * boundaryPsi[i](ksi));
            }
        }
예제 #4
0
        protected virtual void BuildLocalB(FiniteElement e)
        {
            // TODO: implement this method

            Point a = points[e[0]];
            Point b = points[e[1]];
            Point c = points[e[2]];

            double D = Math.Abs(Utilities.Det(a, b, c));

            for (int i = 0; i < info.Basis.Size; i++)
            {
                localb[i] = Quadratures.TriangleGauss18((double ksi, double etta) =>
                {
                    double x = a.X * ksi + b.X * etta + c.X * (1 - ksi - etta);
                    double y = a.Y * ksi + b.Y * etta + c.Y * (1 - ksi - etta);

                    return(e.Material.F(x, y, 0) * psi[i](ksi, etta));
                });
                localb[i] *= D;
            }
        }