void IInnerEdgeSource_V.InternalEdge_V(ref EdgeFormParams inp, MultidimensionalArray Koeff_V)
        {
            int j0       = inp.e0;
            int Len      = inp.Len;
            int N        = inp.Nodes.GetLength(1); // nodes per cell
            int D        = inp.Nodes.GetLength(2); // spatial dim.
            int NoOfVars = this.ArgumentOrdering.Count;

            // check dimension of input array
            Koeff_V.CheckLengths(Len, N, 2);


            // create temp mem:
            int NP = (this.ParameterOrdering != null) ? this.ParameterOrdering.Count : 0;

            double[]     ParamsPos = new double[NP];
            double[]     ParamsNeg = new double[NP];
            CommonParams cp;

            cp.Normal         = new Vector(D);
            cp.X              = new Vector(D);
            cp.Parameters_IN  = ParamsNeg;
            cp.Parameters_OUT = ParamsPos;
            cp.time           = inp.time;
            cp.iEdge          = -123456;
            cp.GridDat        = null;

            // temp mem.
            double[] uA = new double[NoOfVars];
            double[] uB = new double[NoOfVars];
            double[,] Grad_uA = new double[NoOfVars, D];
            double[,] Grad_uB = new double[NoOfVars, D];
            double vA = 0;
            double vB = 0;

            double[] Grad_vA = new double[D];
            double[] Grad_vB = new double[D];

            for (int j = 0; j < Len; j++)   // loop over items...
            {
                int iSpcNeg = 0;
                int iSpcPos = 1;
                cp.jCellIn  = j + inp.e0;
                cp.jCellOut = cp.jCellIn;

                for (int n = 0; n < N; n++)   // loop over nodes...
                {
                    cp.Normal.SetFrom(inp.Normals, j, n);
                    cp.X.SetFrom(inp.Nodes, j, n);
                    for (int i = 0; i < NP; i++)
                    {
                        ParamsPos[i] = inp.ParameterVars_OUT[i][j, n];
                        ParamsNeg[i] = inp.ParameterVars_IN[i][j, n];
                    }

                    Koeff_V[j, n, iSpcNeg] = GetSourceCoeff(ref vA, ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                    Koeff_V[j, n, iSpcPos] = GetSourceCoeff(ref vB, ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                }
            }
        }
예제 #2
0
        void ILinearLevelSetComponent_V.LevelSetForm_V(LevSetIntParams inp, MultidimensionalArray Koeff_V)
        {
            int             j0       = inp.i0;
            int             Len      = inp.Len;
            int             N        = inp.X.GetLength(1); // nodes per cell
            int             D        = inp.X.GetLength(2); // spatial dim.
            int             NoOfVars = this.ArgumentOrdering.Count;
            LevelSetTracker lsTrk    = m_LsTrk;

            // check dimension of input array
            Koeff_V.CheckLengths(Len, N, 2);


            // create temp mem:
            double[] node   = new double[D];
            double[] normal = new double[D];
            int      NP     = (this.ParameterOrdering != null) ? this.ParameterOrdering.Count : 0;

            double[]       ParamsPos = new double[NP];
            double[]       ParamsNeg = new double[NP];
            CommonParamsLs cp        = default(CommonParamsLs);

            cp.n         = normal;
            cp.x         = node;
            cp.ParamsNeg = ParamsNeg;
            cp.ParamsPos = ParamsPos;
            cp.time      = inp.time;


            // temp mem.
            double[] uA = new double[NoOfVars];
            double[] uB = new double[NoOfVars];
            double[,] Grad_uA = new double[NoOfVars, D];
            double[,] Grad_uB = new double[NoOfVars, D];
            double vA = 0;
            double vB = 0;

            double[] Grad_vA = new double[D];
            double[] Grad_vB = new double[D];
            var      h_min   = this.m_LsTrk.GridDat.Cells.h_min;


            //LevelSetSignCode pos;
            //LevelSetSignCode neg;
            //GetSignCode(out neg, out pos);
            SpeciesId posSpc = this.PositiveSpecies;
            SpeciesId negSpc = this.NegativeSpecies;

            var Reg = lsTrk.Regions;

            for (int j = 0; j < Len; j++)   // loop over items...
            {
                ReducedRegionCode rrc;
                int NoOf = Reg.GetNoOfSpecies(j + inp.i0, out rrc);
                Debug.Assert(NoOf == 2);
                //int iSpcPos = lsTrk.GetSpeciesIndex(rrc, pos);
                //int iSpcNeg = lsTrk.GetSpeciesIndex(rrc, neg);
                int iSpcPos = lsTrk.GetSpeciesIndex(rrc, posSpc);
                int iSpcNeg = lsTrk.GetSpeciesIndex(rrc, negSpc);
                cp.jCell = j + inp.i0;
                if (inp.PosCellLengthScale != null)
                {
                    cp.PosCellLengthScale = inp.PosCellLengthScale[cp.jCell];
                }
                else
                {
                    cp.PosCellLengthScale = double.NaN;
                }
                if (inp.NegCellLengthScale != null)
                {
                    cp.NegCellLengthScale = inp.NegCellLengthScale[cp.jCell];
                }
                else
                {
                    cp.NegCellLengthScale = double.NaN;
                }

                for (int n = 0; n < N; n++)   // loop over nodes...
                {
                    inp.Normal.CopyTo(normal, j, n, -1);
                    inp.X.CopyTo(node, j, n, -1);
                    for (int i = 0; i < NP; i++)
                    {
                        ParamsPos[i] = inp.ParamsPos[i][j, n];
                        ParamsNeg[i] = inp.ParamsNeg[i][j, n];
                    }

                    Koeff_V[j, n, iSpcNeg] = GetSourceCoeff(ref vA, ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                    Koeff_V[j, n, iSpcPos] = GetSourceCoeff(ref vB, ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                }
            }
        }
        void IInnerEdgeform_GradUxGradV.InternalEdge_GradUxGradV(ref EdgeFormParams inp, MultidimensionalArray Koeff_NablaUxNablaV)
        {
            //void ILevelSetForm_GradUxGradV.LevelSetForm_GradUxGradV(LevSetIntParams inp, MultidimensionalArray Koeff_NablaUxNablaV) {
            int j0       = inp.e0;
            int Len      = inp.Len;
            int N        = inp.Nodes.GetLength(1); // nodes per cell
            int D        = inp.Nodes.GetLength(2); // spatial dim.
            int NoOfVars = this.ArgumentOrdering.Count;

            // check dimension of input array
            Koeff_NablaUxNablaV.CheckLengths(Len, N, 2, 2, NoOfVars, D, D);


            // create temp mem:
            int NP = (this.ParameterOrdering != null) ? this.ParameterOrdering.Count : 0;

            double[]     ParamsPos = new double[NP];
            double[]     ParamsNeg = new double[NP];
            CommonParams cp;

            cp.Normal         = new Vector(D);
            cp.X              = new Vector(D);
            cp.Parameters_IN  = ParamsNeg;
            cp.Parameters_OUT = ParamsPos;
            cp.time           = inp.time;
            cp.iEdge          = -123456;
            cp.GridDat        = null;

            // temp mem.
            double[] uA = new double[NoOfVars];
            double[] uB = new double[NoOfVars];
            double[,] Grad_uA = new double[NoOfVars, D];
            double[,] Grad_uB = new double[NoOfVars, D];
            double vA = 0;
            double vB = 0;

            double[] Grad_vA = new double[D];
            double[] Grad_vB = new double[D];


            for (int c = 0; c < NoOfVars; c++)  // loop over variables...
            {
                for (int j = 0; j < Len; j++)   // loop over items...

                {
                    int iSpcNeg = 0;
                    int iSpcPos = 1;

                    cp.jCellIn  = j + inp.e0;
                    cp.jCellOut = cp.jCellIn;

                    for (int n = 0; n < N; n++)   // loop over nodes...
                    {
                        cp.Normal.SetFrom(inp.Normals, j, n);
                        cp.X.SetFrom(inp.Nodes, j, n);

                        for (int i = 0; i < NP; i++)
                        {
                            ParamsPos[i] = inp.ParameterVars_OUT[i][j, n];
                            ParamsNeg[i] = inp.ParameterVars_IN[i][j, n];
                        }

                        for (int d1 = 0; d1 < D; d1++)
                        {
                            for (int d2 = 0; d2 < D; d2++)
                            {
                                Koeff_NablaUxNablaV[j, n, iSpcNeg, iSpcNeg, c, d1, d2] = GetCoeff(ref Grad_uA[c, d1], ref Grad_vA[d2], ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                                Koeff_NablaUxNablaV[j, n, iSpcPos, iSpcNeg, c, d1, d2] = GetCoeff(ref Grad_uA[c, d1], ref Grad_vB[d2], ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                                Koeff_NablaUxNablaV[j, n, iSpcNeg, iSpcPos, c, d1, d2] = GetCoeff(ref Grad_uB[c, d1], ref Grad_vA[d2], ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                                Koeff_NablaUxNablaV[j, n, iSpcPos, iSpcPos, c, d1, d2] = GetCoeff(ref Grad_uB[c, d1], ref Grad_vB[d2], ref cp, uA, uB, Grad_uA, Grad_uB, ref vA, ref vB, Grad_vA, Grad_vB);
                            }
                        }
                    }
                }
            }
        }