Exemple #1
0
        private double GetSourceCoeff(ref double d2, ref CommonParamsLs inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, ref double vA, ref double vB, double[] Grad_vA, double[] Grad_vB)
        {
            Debug.Assert(this.OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB) == 0.0);

            d2 = 1;                                                                                                  // set test function
            double a1 = this.OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB); // probe for the source part

            Debug.Assert((this.LevelSetTerms & (TermActivationFlags.GradV | TermActivationFlags.V)) != 0 || a1 == 0);
            d2 = 0; // reset
            return(a1);
        }
Exemple #2
0
        ///// <summary>
        ///// override this method to implement the bilinear form on the edge.
        ///// </summary>
        //public abstract double EdgeForm(ref Linear2ndDerivativeCouplingFlux.CommonParams inp,
        //    double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB,
        //    double vA, double vB, double[] Grad_vA, double[] Grad_vB);


        private double GetCoeff(ref double d1, ref double d2, ref CommonParamsLs inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, ref double vA, ref double vB, double[] Grad_vA, double[] Grad_vB)
        {
            //if(this.OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB) != 0.0) {
            //    double funky = this.OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB);
            //    Console.WriteLine(funky);
            //}
            Debug.Assert(this.OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB) == 0.0);

            d2 = 1;                                                                                                  // set test function
            double a1 = this.OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB); // probe for the source/affine part

            Debug.Assert((this.LevelSetTerms & (TermActivationFlags.GradV | TermActivationFlags.V)) != 0 || a1 == 0);
            d1 = 1;                                                                                                 // set trial function
            double a = this.OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB); // probe for the bilinear+affine part

            d1 = 0;                                                                                                 // reset
            d2 = 0;                                                                                                 // reset
            return(a - a1);
        }
Exemple #3
0
 public double LevelSetForm(ref CommonParamsLs inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB)
 {
     throw new NotSupportedException("Should not be called.");
 }
Exemple #4
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);
                }
            }
        }
Exemple #5
0
 double ILevelSetForm.LevelSetForm(ref CommonParamsLs inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB)
 {
     return(OrgComponent.LevelSetForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB));
 }