Exemplo n.º 1
0
        private void CalcAB(IvyFEM.Linear.DoubleSparseMatrix A, double[] B)
        {
            uint         quantityId = 0;
            IList <uint> feIds      = World.GetTriangleFEIds(quantityId);

            foreach (uint feId in feIds)
            {
                TriangleFE triFE       = World.GetTriangleFE(quantityId, feId);
                uint       elemNodeCnt = triFE.NodeCount;
                int[]      nodes       = new int[elemNodeCnt];
                for (int iNode = 0; iNode < elemNodeCnt; iNode++)
                {
                    int coId   = triFE.NodeCoordIds[iNode];
                    int nodeId = World.Coord2Node(quantityId, coId);
                    nodes[iNode] = nodeId;
                }

                Material ma0 = World.GetMaterial(triFE.MaterialId);
                System.Diagnostics.Debug.Assert(ma0 is PoissonMaterial);
                var    ma = ma0 as PoissonMaterial;
                double k  = ma.Alpha;
                double f  = ma.F;

                double[,] sNN       = triFE.CalcSNN();
                double[, ][,] sNuNv = triFE.CalcSNuNv();
                double[,] sNxNx     = sNuNv[0, 0];
                double[,] sNyNx     = sNuNv[1, 0];
                double[,] sNxNy     = sNuNv[0, 1];
                double[,] sNyNy     = sNuNv[1, 1];
                double[] sN = triFE.CalcSN();
                for (int row = 0; row < elemNodeCnt; row++)
                {
                    int rowNodeId = nodes[row];
                    if (rowNodeId == -1)
                    {
                        continue;
                    }
                    for (int col = 0; col < elemNodeCnt; col++)
                    {
                        int colNodeId = nodes[col];
                        if (colNodeId == -1)
                        {
                            continue;
                        }
                        double a = k * (sNxNx[row, col] + sNyNy[row, col]);

                        A[rowNodeId, colNodeId] += a;
                    }
                }
                for (int row = 0; row < elemNodeCnt; row++)
                {
                    int rowNodeId = nodes[row];
                    if (rowNodeId == -1)
                    {
                        continue;
                    }
                    B[rowNodeId] += f * sN[row];
                }
            }
        }
Exemplo n.º 2
0
        private void CalcAB(double k0,
                            IvyFEM.Linear.ComplexSparseMatrix A, System.Numerics.Complex[] B)
        {
            IList <uint> feIds = World.GetTriangleFEIds(QuantityId);

            foreach (uint feId in feIds)
            {
                TriangleFE triFE       = World.GetTriangleFE(QuantityId, feId);
                uint       elemNodeCnt = triFE.NodeCount;
                int[]      nodes       = new int[elemNodeCnt];
                for (int iNode = 0; iNode < elemNodeCnt; iNode++)
                {
                    int coId   = triFE.NodeCoordIds[iNode];
                    int nodeId = World.Coord2Node(QuantityId, coId);
                    nodes[iNode] = nodeId;
                }

                Material ma0 = World.GetMaterial(triFE.MaterialId);
                System.Diagnostics.Debug.Assert(ma0 is DielectricMaterial);
                var ma = ma0 as DielectricMaterial;

                double[,] sNN       = triFE.CalcSNN();
                double[, ][,] sNuNv = triFE.CalcSNuNv();
                double[,] sNxNx     = sNuNv[0, 0];
                double[,] sNyNx     = sNuNv[1, 0];
                double[,] sNxNy     = sNuNv[0, 1];
                double[,] sNyNy     = sNuNv[1, 1];
                for (int row = 0; row < elemNodeCnt; row++)
                {
                    int rowNodeId = nodes[row];
                    if (rowNodeId == -1)
                    {
                        continue;
                    }
                    for (int col = 0; col < elemNodeCnt; col++)
                    {
                        int colNodeId = nodes[col];
                        if (colNodeId == -1)
                        {
                            continue;
                        }
                        double a = (1.0 / ma.Muxx) * sNyNy[row, col] + (1.0 / ma.Muyy) * sNxNx[row, col] -
                                   (k0 * k0 * ma.Epzz) * sNN[row, col];

                        A[rowNodeId, colNodeId] += (System.Numerics.Complex)a;
                    }
                }
            }
        }
Exemplo n.º 3
0
        protected void CalcLinearElasticElementAB(
            uint feId, IvyFEM.Linear.DoubleSparseMatrix A, double[] B)
        {
            uint quantityId = 0;
            int  nodeCnt    = (int)World.GetNodeCount(quantityId);

            System.Diagnostics.Debug.Assert(World.GetDof(quantityId) == 2);
            int dof = 2;

            double dt    = TimeStep;
            double beta  = NewmarkBeta;
            double gamma = NewmarkGamma;
            var    FV    = World.GetFieldValue(ValueId);

            TriangleFE triFE = World.GetTriangleFE(quantityId, feId);
            Material   ma0   = World.GetMaterial(triFE.MaterialId);

            if (!(ma0 is LinearElasticMaterial))
            {
                return;
            }

            int[] coIds       = triFE.NodeCoordIds;
            uint  elemNodeCnt = triFE.NodeCount;

            int[] nodes = new int[elemNodeCnt];
            for (int iNode = 0; iNode < elemNodeCnt; iNode++)
            {
                int coId   = coIds[iNode];
                int nodeId = World.Coord2Node(quantityId, coId);
                nodes[iNode] = nodeId;
            }

            var    ma     = ma0 as LinearElasticMaterial;
            double lambda = ma.LameLambda;
            double mu     = ma.LameMu;
            double rho    = ma.MassDensity;

            double[] g = { ma.GravityX, ma.GravityY };

            double[] sN = triFE.CalcSN();
            double[,] sNN       = triFE.CalcSNN();
            double[, ][,] sNuNv = triFE.CalcSNuNv();
            double[,] sNxNx     = sNuNv[0, 0];
            double[,] sNyNx     = sNuNv[1, 0];
            double[,] sNxNy     = sNuNv[0, 1];
            double[,] sNyNy     = sNuNv[1, 1];

            for (int row = 0; row < elemNodeCnt; row++)
            {
                int rowNodeId = nodes[row];
                if (rowNodeId == -1)
                {
                    continue;
                }

                for (int col = 0; col < elemNodeCnt; col++)
                {
                    int colNodeId = nodes[col];
                    if (colNodeId == -1)
                    {
                        continue;
                    }

                    int      colCoId = coIds[col];
                    double[] u       = FV.GetDoubleValue(colCoId, FieldDerivativeType.Value);
                    double[] vel     = FV.GetDoubleValue(colCoId, FieldDerivativeType.Velocity);
                    double[] acc     = FV.GetDoubleValue(colCoId, FieldDerivativeType.Acceleration);

                    double[,] k = new double[dof, dof];
                    double[,] m = new double[dof, dof];
                    k[0, 0]     = (lambda + mu) * sNxNx[row, col] + mu * (sNxNx[row, col] + sNyNy[row, col]);
                    k[1, 0]     = lambda * sNyNx[row, col] + mu * sNxNy[row, col];
                    k[0, 1]     = lambda * sNxNy[row, col] + mu * sNyNx[row, col];
                    k[1, 1]     = (lambda + mu) * sNyNy[row, col] + mu * (sNxNx[row, col] + sNyNy[row, col]);

                    m[0, 0] = rho * sNN[row, col];
                    m[1, 0] = 0.0;
                    m[0, 1] = 0.0;
                    m[1, 1] = rho * sNN[row, col];

                    for (int rowDof = 0; rowDof < dof; rowDof++)
                    {
                        for (int colDof = 0; colDof < dof; colDof++)
                        {
                            A[rowNodeId * dof + rowDof, colNodeId *dof + colDof] +=
                                (1.0 / (beta * dt * dt)) * m[rowDof, colDof] +
                                k[rowDof, colDof];

                            B[rowNodeId * dof + rowDof] +=
                                m[rowDof, colDof] * (
                                    (1.0 / (beta * dt * dt)) * u[colDof] +
                                    (1.0 / (beta * dt)) * vel[colDof] +
                                    (1.0 / (2.0 * beta) - 1.0) * acc[colDof]);
                        }
                    }
                }
            }

            for (int row = 0; row < elemNodeCnt; row++)
            {
                int rowNodeId = nodes[row];
                if (rowNodeId == -1)
                {
                    continue;
                }
                for (int rowDof = 0; rowDof < dof; rowDof++)
                {
                    B[rowNodeId * dof + rowDof] += rho * g[rowDof] * sN[row];
                }
            }
        }
Exemplo n.º 4
0
        private void CalcAB(IvyFEM.Linear.DoubleSparseMatrix A, double[] B)
        {
            uint         quantityId = 0;
            double       dt         = TimeStep;
            double       beta       = NewmarkBeta;
            double       gamma      = NewmarkGamma;
            var          FV         = World.GetFieldValue(ValueId);
            IList <uint> feIds      = World.GetTriangleFEIds(quantityId);

            foreach (uint feId in feIds)
            {
                TriangleFE triFE = World.GetTriangleFE(quantityId, feId);
                Material   ma0   = World.GetMaterial(triFE.MaterialId);

                int[] coIds       = triFE.NodeCoordIds;
                uint  elemNodeCnt = triFE.NodeCount;
                int[] nodes       = new int[elemNodeCnt];
                for (int iNode = 0; iNode < elemNodeCnt; iNode++)
                {
                    int coId   = coIds[iNode];
                    int nodeId = World.Coord2Node(quantityId, coId);
                    nodes[iNode] = nodeId;
                }

                System.Diagnostics.Debug.Assert(ma0 is DiffusionMaterial);
                var    ma     = ma0 as DiffusionMaterial;
                double rho    = ma.MassDensity;
                double cap    = ma.Capacity;
                double lambda = ma.DiffusionCoef;
                double f      = ma.F;

                double[] sN = triFE.CalcSN();
                double[,] sNN       = triFE.CalcSNN();
                double[, ][,] sNuNv = triFE.CalcSNuNv();
                double[,] sNxNx     = sNuNv[0, 0];
                double[,] sNyNx     = sNuNv[1, 0];
                double[,] sNxNy     = sNuNv[0, 1];
                double[,] sNyNy     = sNuNv[1, 1];

                for (int row = 0; row < elemNodeCnt; row++)
                {
                    int rowNodeId = nodes[row];
                    if (rowNodeId == -1)
                    {
                        continue;
                    }

                    for (int col = 0; col < elemNodeCnt; col++)
                    {
                        int colNodeId = nodes[col];
                        if (colNodeId == -1)
                        {
                            continue;
                        }

                        int      colCoId = coIds[col];
                        double[] u       = FV.GetDoubleValue(colCoId, FieldDerivativeType.Value);
                        double[] vel     = FV.GetDoubleValue(colCoId, FieldDerivativeType.Velocity);
                        double[] acc     = FV.GetDoubleValue(colCoId, FieldDerivativeType.Acceleration);

                        double k = lambda * (sNxNx[row, col] + sNyNy[row, col]);
                        double m = rho * cap * sNN[row, col];

                        A[rowNodeId, colNodeId] +=
                            k + (gamma / (beta * dt)) * m;
                        B[rowNodeId] +=
                            m * (
                                (gamma / (beta * dt)) * u[0] -
                                (1.0 - gamma / beta) * vel[0] -
                                dt * (1.0 - gamma / (2.0 * beta)) * acc[0]
                                );
                    }
                }

                for (int row = 0; row < elemNodeCnt; row++)
                {
                    int rowNodeId = nodes[row];
                    if (rowNodeId == -1)
                    {
                        continue;
                    }
                    B[rowNodeId] += f * sN[row];
                }
            }
        }
Exemplo n.º 5
0
        protected void CalcLinearElasticElementAB(
            uint feId, IvyFEM.Linear.DoubleSparseMatrix A, double[] B)
        {
            uint quantityId = 0;
            int  nodeCnt    = (int)World.GetNodeCount(quantityId);

            System.Diagnostics.Debug.Assert(World.GetDof(quantityId) == 2);
            int dof = 2;

            TriangleFE triFE = World.GetTriangleFE(quantityId, feId);
            Material   ma0   = World.GetMaterial(triFE.MaterialId);

            if (!(ma0 is LinearElasticMaterial))
            {
                return;
            }
            int[] coIds       = triFE.NodeCoordIds;
            uint  elemNodeCnt = triFE.NodeCount;

            int[] nodes = new int[elemNodeCnt];
            for (int iNode = 0; iNode < elemNodeCnt; iNode++)
            {
                int coId   = coIds[iNode];
                int nodeId = World.Coord2Node(quantityId, coId);
                nodes[iNode] = nodeId;
            }

            var    ma     = ma0 as LinearElasticMaterial;
            double lambda = ma.LameLambda;
            double mu     = ma.LameMu;
            double rho    = ma.MassDensity;

            double[] g = { ma.GravityX, ma.GravityY };

            double[] sN = triFE.CalcSN();
            double[,] sNN       = triFE.CalcSNN();
            double[, ][,] sNuNv = triFE.CalcSNuNv();
            double[,] sNxNx     = sNuNv[0, 0];
            double[,] sNyNx     = sNuNv[1, 0];
            double[,] sNxNy     = sNuNv[0, 1];
            double[,] sNyNy     = sNuNv[1, 1];

            for (int row = 0; row < elemNodeCnt; row++)
            {
                int rowNodeId = nodes[row];
                if (rowNodeId == -1)
                {
                    continue;
                }
                for (int col = 0; col < elemNodeCnt; col++)
                {
                    int colNodeId = nodes[col];
                    if (colNodeId == -1)
                    {
                        continue;
                    }

                    double[,] k = new double[dof, dof];
                    double[,] m = new double[dof, dof];
                    k[0, 0]     = (lambda + mu) * sNxNx[row, col] + mu * (sNxNx[row, col] + sNyNy[row, col]);
                    k[1, 0]     = lambda * sNyNx[row, col] + mu * sNxNy[row, col];
                    k[0, 1]     = lambda * sNxNy[row, col] + mu * sNyNx[row, col];
                    k[1, 1]     = (lambda + mu) * sNyNy[row, col] + mu * (sNxNx[row, col] + sNyNy[row, col]);

                    for (int rowDof = 0; rowDof < dof; rowDof++)
                    {
                        for (int colDof = 0; colDof < dof; colDof++)
                        {
                            A[rowNodeId * dof + rowDof, colNodeId *dof + colDof] +=
                                k[rowDof, colDof];
                        }
                    }
                }
            }

            for (int row = 0; row < elemNodeCnt; row++)
            {
                int rowNodeId = nodes[row];
                if (rowNodeId == -1)
                {
                    continue;
                }
                for (int rowDof = 0; rowDof < dof; rowDof++)
                {
                    B[rowNodeId * dof + rowDof] += rho * g[rowDof] * sN[row];
                }
            }
        }
Exemplo n.º 6
0
        private void CalcAB(IvyFEM.Linear.ComplexSparseMatrix A, System.Numerics.Complex[] B)
        {
            uint         quantityId = 0;
            IList <uint> feIds      = World.GetTriangleFEIds(quantityId);

            foreach (uint feId in feIds)
            {
                TriangleFE triFE       = World.GetTriangleFE(quantityId, feId);
                uint       elemNodeCnt = triFE.NodeCount;
                int[]      nodes       = new int[elemNodeCnt];
                for (int iNode = 0; iNode < elemNodeCnt; iNode++)
                {
                    int coId   = triFE.NodeCoordIds[iNode];
                    int nodeId = World.Coord2Node(quantityId, coId);
                    nodes[iNode] = nodeId;
                }

                Material ma0 = World.GetMaterial(triFE.MaterialId);
                System.Diagnostics.Debug.Assert(ma0 is HelmholtzMaterial);
                var    ma = ma0 as HelmholtzMaterial;
                double v  = ma.Velocity;
                System.Numerics.Complex f = ma.F;
                double omega = 2.0 * Math.PI * Frequency;
                double k     = omega / v;

                double[,] sNN       = triFE.CalcSNN();
                double[, ][,] sNuNv = triFE.CalcSNuNv();
                double[,] sNxNx     = sNuNv[0, 0];
                double[,] sNyNx     = sNuNv[1, 0];
                double[,] sNxNy     = sNuNv[0, 1];
                double[,] sNyNy     = sNuNv[1, 1];
                double[] sN = triFE.CalcSN();
                for (int row = 0; row < elemNodeCnt; row++)
                {
                    int rowNodeId = nodes[row];
                    if (rowNodeId == -1)
                    {
                        continue;
                    }
                    for (int col = 0; col < elemNodeCnt; col++)
                    {
                        int colNodeId = nodes[col];
                        if (colNodeId == -1)
                        {
                            continue;
                        }
                        double a = sNxNx[row, col] + sNyNy[row, col] - k * k * sNN[row, col];

                        A[rowNodeId, colNodeId] += a;
                    }
                }
                for (int row = 0; row < elemNodeCnt; row++)
                {
                    int rowNodeId = nodes[row];
                    if (rowNodeId == -1)
                    {
                        continue;
                    }
                    System.Numerics.Complex b = f * sN[row];
                    B[rowNodeId] += b;
                }
            }
        }