示例#1
0
        /// <summary>
        /// Reinitializes <paramref name="Phi"/> on <paramref name="reinitField"/> using the <paramref name="Accepted"/> cells as start value.
        /// </summary>
        /// <param name="Phi">Level Set</param>
        /// <param name="Accepted">Given Field</param>
        /// <param name="NegativeField">Field, on which the level set function is negative</param>
        /// <param name="reinitField">Field , on which the level set function should be initialized</param>
        public void FirstOrderReinit(SinglePhaseField Phi, CellMask Accepted, CellMask NegativeField, CellMask reinitField)
        {
            //Idea: Add options : FirstOrder, Elliptic, Geometric, Iterative. That is, include the existing Local Solvers.
            CellMask ReinitField;

            if (reinitField == null)
            {
                ReinitField = CellMask.GetFullMask(Phi.GridDat);
            }
            else
            {
                ReinitField = reinitField;
            }
            //Build Local Solver that solves the Eikonal in each cell.
            FastMarching.ILocalSolver localSolver = new FastMarching.LocalMarcher.LocalMarcher_2DStructured(Phi.Basis);

            //Build Global Solver that marches through all cells
            FastMarching.GlobalMarcher.CellMarcher fastMarcher = new FastMarching.GlobalMarcher.CellMarcher(Phi.Basis, localSolver);

            //Solve
            fastMarcher.Reinit(Phi, Accepted, ReinitField);

            //Invert Negative Domain that is part of ReinitField
            Phi.Scale(-1, NegativeField.Intersect(ReinitField).Except(Accepted));
        }
示例#2
0
文件: Particle.cs 项目: leyel/BoSSS
        /// <summary>
        /// get cut cells describing the boundary of this particle
        /// </summary>
        /// <param name="LsTrk"></param>
        /// <returns></returns>
        public CellMask cutCells_P(LevelSetTracker LsTrk)
        {
            // tolerance is very important
            var radiusTolerance = radius_P + LsTrk.GridDat.Cells.h_minGlobal;// +2.0*Math.Sqrt(2*LsTrk.GridDat.Cells.h_minGlobal.Pow2());

            CellMask cellCollection;
            CellMask cells = null;
            double   alpha = -(currentAng_P[0]);

            switch (m_shape)
            {
            case ParticleShape.spherical:
                cells = CellMask.GetCellMask(LsTrk.GridDat, X => (-(X[0] - currentPos_P[0][0]).Pow2() + -(X[1] - currentPos_P[0][1]).Pow2() + radiusTolerance.Pow2()) > 0);
                break;

            case ParticleShape.elliptic:
                double a = 3.0;
                double b = 1.0;
                cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow2()) / length_P.Pow2()) + -(((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow2() / thickness_P.Pow2()) + radiusTolerance.Pow2() > 0);

                break;

            case ParticleShape.hippopede:
                a     = 4.0 * radiusTolerance.Pow2();
                b     = 1.0 * radiusTolerance.Pow2();
                cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(2) + ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow(2)).Pow2() - a * ((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow2() - b * ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow2()) > 0);
                break;

            case ParticleShape.bean:
                a     = 4.0 * radiusTolerance.Pow2();
                b     = 1.0 * radiusTolerance.Pow2();
                cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(2) + ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow(2)).Pow2() - a * ((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(3) - b * ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow2()) > 0);
                break;

            case ParticleShape.squircle:
                cells = CellMask.GetCellMask(LsTrk.GridDat, X => - ((((X[0] - currentPos_P[0][0]) * Math.Cos(alpha) - (X[1] - currentPos_P[0][1]) * Math.Sin(alpha)).Pow(4) + ((X[0] - currentPos_P[0][0]) * Math.Sin(alpha) + (X[1] - currentPos_P[0][1]) * Math.Cos(alpha)).Pow(4)) - radiusTolerance.Pow(4)) > 0);
                break;


            default:
                throw new NotImplementedException("Shape is not implemented yet");
            }


            CellMask allCutCells = LsTrk.Regions.GetCutCellMask();

            cellCollection = cells.Intersect(allCutCells);
            return(cellCollection);
        }
示例#3
0
        /// <summary>
        /// get cut cells describing the boundary of this particle
        /// </summary>
        /// <param name="LsTrk"></param>
        /// <returns></returns>
        public CellMask CutCells_P(LevelSetTracker LsTrk)
        {
            BitArray CellArray = new BitArray(LsTrk.GridDat.Cells.NoOfLocalUpdatedCells);
            MultidimensionalArray CellCenters = LsTrk.GridDat.Cells.CellCenter;
            var h_min = LsTrk.Regions.GetCutCellSubGrid().h_minSubGrd;

            for (int i = 0; i < CellArray.Length; i++)
            {
                CellArray[i] = Contains(new Vector(CellCenters[i, 0], CellCenters[i, 1]), 2 * h_min);
            }
            CellMask CutCells = new CellMask(LsTrk.GridDat, CellArray, MaskType.Logical);

            CutCells = CutCells.Intersect(LsTrk.Regions.GetCutCellMask());
            return(CutCells);
        }
示例#4
0
        /// <summary>
        /// get cut cells describing the boundary of this particle
        /// </summary>
        /// <param name="LsTrk"></param>
        /// <returns></returns>
        public CellMask CutCells_P(LevelSetTracker LsTrk)
        {
            BitArray CellArray = new BitArray(LsTrk.GridDat.Cells.NoOfLocalUpdatedCells);
            MultidimensionalArray CellCenters = LsTrk.GridDat.Cells.CellCenter;
            double h_min = LsTrk.GridDat.Cells.h_minGlobal;
            double h_max = LsTrk.GridDat.Cells.h_maxGlobal;

            for (int i = 0; i < CellArray.Length; i++)
            {
                CellArray[i] = Contains(new double[] { CellCenters[i, 0], CellCenters[i, 1] }, h_min, h_max, false);
            }
            CellMask CutCells = new CellMask(LsTrk.GridDat, CellArray, MaskType.Logical);

            CutCells = CutCells.Intersect(LsTrk.Regions.GetCutCellMask());
            return(CutCells);
        }