コード例 #1
0
        public Matrix GetTaylorSystemCoeffs(int i, int j, int surplus_i, int surplus_j)
        {
            NCAMRNode[] stencil =
            {
                nodes[i,             j],
                nodes[i + 1,         j],
                nodes[i,             j + 1],
                nodes[i - 1,         j],
                nodes[i,             j - 1],
                nodes[i + surplus_i, j + surplus_j]
            };
            TaylorSystem t_system = new TaylorSystem(stencil);
            Matrix       Astar    = t_system.TaylorCoefficients;
            double       k        = 20;

            double[] kstuff = { k, k, k *k, k *k, k *k };
            for (int c = 0; c < 5; c++)
            {
                for (int d = 0; d < 5; d++)
                {
                    Astar[d, c] = Astar[d, c] * kstuff[c];
                }
            }
            Matrix K = new Matrix(5);

            K[0, 0] = k;
            K[1, 1] = k;
            K[2, 2] = k * k;
            K[3, 3] = k * k;
            K[4, 4] = k * k;
            return(K * Astar.Inverse);
        }
コード例 #2
0
        public void ApplyMeshMorphGA(double size)
        {
            int surplus_i = 1;
            int surplus_j = 1;

            for (int i = 1; i < x_node_count - 1; i++)
            {
                for (int j = 1; j < y_node_count - 1; j++)
                {
                    NCAMRNode[] stencil =
                    {
                        nodes[i,             j],
                        nodes[i + 1,         j],
                        nodes[i,             j + 1],
                        nodes[i - 1,         j],
                        nodes[i,             j - 1],
                        nodes[i + surplus_i, j + surplus_j]
                    };
                    TaylorSystem t_system = new TaylorSystem(stencil);
                    Matrix       Astar    = t_system.TaylorCoefficients;
                    double       k        = 200;
                    double[]     kstuff   = { k, k, k *k, k *k, k *k };
                    for (int c = 0; c < 5; c++)
                    {
                        for (int d = 0; d < 5; d++)
                        {
                            Astar[d, c] = Astar[d, c] * kstuff[c];
                        }
                    }
                    Matrix K = new Matrix(5);
                    K[0, 0] = k;
                    K[1, 1] = k;
                    K[2, 2] = k * k;
                    K[3, 3] = k * k;
                    K[4, 4] = k * k;
                    Matrix b   = K * Astar.Inverse;
                    Matrix xi  = b * t_system.RHS;
                    double ux  = xi[0];
                    double uxx = xi[2];
                    double uy  = xi[1];
                    double uyy = xi[3];
                    double uxy = xi[4];
                    double _dx = ((uxx * ux) + (uxy * uy));
                    double _dy = ((uyy * uy) + (ux * uxy));
                    //normalize to max of gradient?
                    double step_size = size;

                    Vector3 move = new Vector3(step_size * _dx, step_size * _dy, 0);
                    double  xnew = (this[i, j] + move).X;
                    double  ynew = (this[i, j] + move).Y;
                    while (xnew < bounds.Xmin || xnew > bounds.Xmax || ynew > bounds.Ymax || ynew < bounds.Ymin || move.Norm > 0.2 * (dx + dy))
                    {
                        move = 0.5 * move;
                        xnew = (this[i, j] + move).X;
                        ynew = (this[i, j] + move).Y;
                    }
                    this[i, j] = this[i, j] + move;
                }
            }
        }
コード例 #3
0
        public Matrix EstimateSecondDerivs(int i, int j, SurplusNodeAccessingMode mode)
        {
            int surplus_i = 1;
            int surplus_j = 1;

            switch (mode)
            {
            case SurplusNodeAccessingMode.RANDOM:
            {
                surplus_i = 1 - 2 * R.Next(0, 1);
                surplus_j = 1 - 2 * R.Next(0, 1);
                break;
            }
            }
            NCAMRNode[] stencil =
            {
                nodes[i,             j],
                nodes[i + 1,         j],
                nodes[i,             j + 1],
                nodes[i - 1,         j],
                nodes[i,             j - 1],
                nodes[i + surplus_i, j + surplus_j]
            };
            TaylorSystem t_system = new TaylorSystem(stencil);
            Matrix       Astar    = t_system.TaylorCoefficients;
            double       k        = 9999;

            double[] kstuff = { k, k, k *k, k *k, k *k };
            for (int c = 0; c < 5; c++)
            {
                for (int d = 0; d < 5; d++)
                {
                    Astar[d, c] = Astar[d, c] * kstuff[c];
                }
            }
            Matrix K = new Matrix(5);

            K[0, 0] = k;
            K[1, 1] = k;
            K[2, 2] = k * k;
            K[3, 3] = k * k;
            K[4, 4] = k * k;
            return(K * Astar.Inverse * t_system.RHS);
        }