Example #1
0
        /// <summary>
        /// Quadrature rule on cell boundaries
        /// </summary>
        public IQuadRuleFactory <CellBoundaryQuadRule> GetCellFaceFactory(int levSetIndex, RefElement Kref, JumpTypes jumpType)
        {
            int D = this.m_LevelSetDatas[0].GridDat.SpatialDimension;

            if (D == 2)
            {
                if (jumpType != JumpTypes.Heaviside && jumpType != JumpTypes.OneMinusHeaviside)
                {
                    throw new NotSupportedException();
                }
                Debug.Assert(CellFaceVolume_in3D == null);

                if (LineAndPoint_in2D == null)
                {
                    LineAndPoint_in2D = new LineAndPointQuadratureFactory[this.m_LevelSetDatas.Length];
                }

                if (LineAndPoint_in2D[levSetIndex] == null)
                {
                    LineAndPoint_in2D[levSetIndex] = new LineAndPointQuadratureFactory(Kref, this.m_LevelSetDatas[levSetIndex], true);
                }

                return(LineAndPoint_in2D[levSetIndex].GetLineFactory(jumpType == JumpTypes.Heaviside ? true : false));
            }
            else if (D == 3)
            {
                Debug.Assert(LineAndPoint_in2D == null);

                if (jumpType != JumpTypes.Heaviside)
                {
                    throw new NotSupportedException();
                }

                if (CellFaceVolume_in3D == null)
                {
                    CellFaceVolume_in3D = new LevelSetEdgeVolumeQuadRuleFactory[this.m_LevelSetDatas.Length];
                }

                var rootFindingAlgorithm = new LineSegment.SafeGuardedNewtonMethod(1e-14);
                CellFaceVolume_in3D[levSetIndex] = new LevelSetEdgeVolumeQuadRuleFactory(
                    this.m_LevelSetDatas[levSetIndex], rootFindingAlgorithm, JumpTypes.Heaviside);



                return(CellFaceVolume_in3D[levSetIndex]);
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Example #2
0
        /// <summary>
        /// Returns a rule for the edges of surface-elements (elements on the zero-level-set surface,
        /// i.e. on \f$  K \cap \mathfrak{I}\f$ .
        /// (point integrals in 2D, Line integrals in 3D)
        /// </summary>
        /// <returns>
        /// the returned factory produces <see cref="CellBoundaryQuadRule"/>'s
        /// </returns>
        IQuadRuleFactory <CellBoundaryQuadRule> _GetSurfaceElement_BoundaryRuleFactory(int levSetIndex, RefElement KrefVol)
        {
            int D = this.m_LevelSetDatas[0].GridDat.SpatialDimension;

            if (D == 2)
            {
                if (LineAndPoint_in2D == null)
                {
                    LineAndPoint_in2D = new LineAndPointQuadratureFactory[this.m_LevelSetDatas.Length];
                }

                if (LineAndPoint_in2D[levSetIndex] == null)
                {
                    LineAndPoint_in2D[levSetIndex] = new LineAndPointQuadratureFactory(
                        KrefVol,
                        this.m_LevelSetDatas[levSetIndex],
                        CutCellQuadratureType == MomentFittingVariants.OneStepGaussAndStokes);
                }

                return(LineAndPoint_in2D[levSetIndex].GetPointFactory());
            }
            else
            {
                //throw new NotImplementedException("3d is not implemented yet");
                Debug.Assert(LineAndPoint_in2D == null);

                if (CellFaceSurface_in3D == null)
                {
                    CellFaceSurface_in3D = new LevelSetEdgeSurfaceQuadRuleFactory[this.m_LevelSetDatas.Length];
                }

                var rootFindingAlgorithm  = new LineSegment.SafeGuardedNewtonMethod(1e-14);
                var CoFaceQuadRuleFactory = new CutLineOnEdgeQuadRuleFactory(
                    this.m_LevelSetDatas[levSetIndex],
                    rootFindingAlgorithm,
                    JumpTypes.Heaviside);
                CellFaceSurface_in3D[levSetIndex] = new LevelSetEdgeSurfaceQuadRuleFactory(
                    this.m_LevelSetDatas[levSetIndex],
                    CoFaceQuadRuleFactory,
                    JumpTypes.Heaviside);
                //new LevelSetEdgeVolumeQuadRuleFactory(
                //    lsTrk, levSetIndex, rootFindingAlgorithm, JumpTypes.Heaviside);

                return(CellFaceSurface_in3D[levSetIndex]);
            }
        }
Example #3
0
        private Tuple <double, int, int> PerformConfiguration(
            Modes mode,
            int order,
            int division = 0,
            StreamWriter volumeNodesLog  = null,
            StreamWriter surfaceNodesLog = null,
            int leafDivisions            = -1,
            int vanishingMoment          = -1,
            int continuousDerivative     = -1,
            double width = double.NaN,
            double hBase = double.NaN,
            LineSegment.IRootFindingAlgorithm rootFindingAlgorithm = null,
            int logVolumeNodes_selectedCell = -1)
        {
            SubGrid cutCellGrid = levelSetTracker.Regions.GetCutCellSubGrid();

            IQuadRuleFactory <QuadRule> volumeFactory = null;
            IQuadRuleFactory <QuadRule> edgeFactory   = null;

            switch (mode)
            {
            case Modes.Standard:     //
            {
                volumeFactory = new StandardQuadRuleFactory(Grid.RefElements[0]);
                edgeFactory   = new StandardQuadRuleFactory(
                    Grid.RefElements[0].FaceRefElement);
                break;
            }

            case Modes.BruteForce:     //
            {
                volumeFactory = (IQuadRuleFactory <QuadRule>) new CutCellQuadRuleFactory(
                    new BruteForceSubdivisionStrategy(
                        Grid.RefElements[0], division),
                    order);
                edgeFactory = new CutCellQuadRuleFactory(
                    new BruteForceSubdivisionStrategy(
                        Grid.RefElements[0].FaceRefElement, division),
                    order);
                break;
            }

            case Modes.Adaptive:     //
            {
                volumeFactory = (IQuadRuleFactory <QuadRule>) new CutCellQuadRuleFactory(
                    new AdaptiveSubdivisionStrategy(
                        Grid.RefElements[0], levelSetTracker.DataHistories[0].Current, division),
                    leafDivisions);
                edgeFactory = new CutCellQuadRuleFactory(
                    new AdaptiveSubdivisionStrategy(
                        Grid.RefElements[0].FaceRefElement, levelSetTracker.DataHistories[0].Current, division),
                    leafDivisions);
                break;
            }

            case Modes.Regularized:     //
            {
                volumeFactory = new RegularizedQuadRuleFactory(
                    new StandardQuadRuleFactory(Grid.RefElements[0]),
                    levelSetTracker,
                    testCase.GetPolynomial(vanishingMoment, continuousDerivative),
                    0.5 * width * hBase);
                edgeFactory = null;
                break;
            }

            case Modes.HMFClassic:     //
            {
                IQuadRuleFactory <CellBoundaryQuadRule> volumeRuleFactoryEdge;
                if (Grid.SpatialDimension == 2)
                {
                    LineAndPointQuadratureFactory bndrule = new LineAndPointQuadratureFactory(
                        this.Grid.RefElements[0],
                        levelSetTracker.DataHistories[0].Current,
                        true,
                        rootFindingAlgorithm);

                    volumeRuleFactoryEdge = bndrule.GetLineFactory();

                    //volumeRuleFactoryEdge = new CutLineQuadRuleFactory(
                    //    levelSetTracker,
                    //    Grid.RefElements[0],
                    //    rootFindingAlgorithm: rootFindingAlgorithm);
                }
                else
                {
                    volumeRuleFactoryEdge = new LevelSetEdgeVolumeQuadRuleFactory(
                        levelSetTracker.DataHistories[0].Current,
                        rootFindingAlgorithm,
                        JumpTypes.Heaviside);
                }

                LevelSetSurfaceQuadRuleFactory surfaceFactory =
                    new LevelSetSurfaceQuadRuleFactory(
                        levelSetTracker.DataHistories[0].Current, volumeRuleFactoryEdge);


                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = surfaceFactory;
                }
                else
                {
                    volumeFactory = new LevelSetVolumeQuadRuleFactory(
                        levelSetTracker.DataHistories[0].Current,
                        volumeRuleFactoryEdge,
                        surfaceFactory,
                        JumpTypes.Heaviside);
                }
                edgeFactory = null;
                break;
            }

            case Modes.HMFOneStepGauss:     //
            {
                if (Grid.SpatialDimension != 2)
                {
                    throw new NotImplementedException();
                }

                LineAndPointQuadratureFactory bndrule = new LineAndPointQuadratureFactory(
                    this.Grid.RefElements[0],
                    levelSetTracker.DataHistories[0].Current,
                    true,
                    rootFindingAlgorithm);

                LevelSetComboRuleFactory2 Factory = new LevelSetComboRuleFactory2(
                    levelSetTracker.DataHistories[0].Current,
                    bndrule.GetLineFactory(),
                    null,
                    _SurfaceNodesOnZeroLevset: false,
                    _UseAlsoStokes: false,
                    _DoCheck: false);

                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = Factory.GetSurfaceFactory();
                }
                else
                {
                    volumeFactory = Factory.GetVolumeFactory();
                }
                edgeFactory = null;

                break;
            }

            case Modes.HMFOneStepGaussAndStokes:     //
            {
                if (Grid.SpatialDimension != 2)
                {
                    throw new NotImplementedException();
                }

                LineAndPointQuadratureFactory bndrule = new LineAndPointQuadratureFactory(
                    this.Grid.RefElements[0],
                    levelSetTracker.DataHistories[0].Current,
                    true,
                    rootFindingAlgorithm);

                LevelSetComboRuleFactory2 Factory = new LevelSetComboRuleFactory2(
                    levelSetTracker.DataHistories[0].Current,
                    bndrule.GetLineFactory(), bndrule.GetPointFactory(),
                    _SurfaceNodesOnZeroLevset: false,
                    _UseAlsoStokes: true,
                    _DoCheck: false);

                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = Factory.GetSurfaceFactory();
                }
                else
                {
                    volumeFactory = Factory.GetVolumeFactory();
                }
                edgeFactory = null;

                break;
            }

            case Modes.SayeGaussRules:     //
            {
                SayeGaussComboRuleFactory FactoryFactory = SayeFactories.SayeGaussRule_Combo(
                    levelSetTracker.DataHistories[0].Current,
                    rootFindingAlgorithm
                    );

                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = FactoryFactory.GetSurfaceFactory();
                }
                else
                {
                    volumeFactory = FactoryFactory.GetVolumeFactory();
                }

                edgeFactory = null;
                break;
            }

            case Modes.EquivalentPolynomials:     //
            {
                var lineAndPointFactory = new LineAndPointQuadratureFactory(
                    Grid.RefElements[0],
                    levelSetTracker.DataHistories[0].Current,
                    true,
                    rootFindingAlgorithm);
                if (testCase is ISurfaceTestCase)
                {
                    volumeFactory = new LinearReconstructionQuadRuleFactory(
                        levelSetTracker, lineAndPointFactory);
                }
                else
                {
                    volumeFactory = new EquivalentPolynomialQuadRuleFactory(
                        new StandardQuadRuleFactory(Grid.RefElements[0]),
                        levelSetTracker,
                        lineAndPointFactory);
                }

                edgeFactory = null;
                break;
            }
            }

            if (volumeNodesLog != null)
            {
                WriteVolumeNodes(volumeNodesLog, volumeFactory, order, cutCellGrid, testCase, logVolumeNodes_selectedCell);
            }

            if (surfaceNodesLog != null)
            {
                WriteSurfaceNodes(surfaceNodesLog, edgeFactory, order, cutCellGrid);
            }

            Stopwatch timer      = new Stopwatch();
            Stopwatch localTimer = new Stopwatch();
            double    result     = double.NaN;

            timer.Start();
            if (testCase is IVolumeTestCase ||
                mode == Modes.Regularized ||
                mode == Modes.HMFClassic ||
                mode == Modes.HMFOneStepGauss ||
                mode == Modes.HMFOneStepGaussAndStokes ||
                mode == Modes.EquivalentPolynomials ||
                mode == Modes.SayeGaussRules)
            {
                result = PerformVolumeQuadrature(
                    mode, volumeFactory, cutCellGrid, order, localTimer);
            }
            else
            {
                result = PerformSurfaceQuadrature(
                    mode, volumeFactory, edgeFactory, cutCellGrid, order, localTimer);
            }
            timer.Stop();

            return(new Tuple <double, int, int>(
                       result,
                       (int)timer.ElapsedMilliseconds,
                       (int)localTimer.ElapsedMilliseconds));
        }
Example #4
0
 public LinearReconstructionQuadRuleFactory(LevelSetTracker tracker, LineAndPointQuadratureFactory lineAndPointFactory)
 {
     this.tracker     = tracker;
     this.rootFactory = lineAndPointFactory.GetPointFactory();
 }
Example #5
0
 public EquivalentPolynomialQuadRuleFactory(IQuadRuleFactory <QuadRule> baseFactory, LevelSetTracker tracker, LineAndPointQuadratureFactory lineAndPointFactory)
 {
     this.baseFactory = baseFactory;
     this.tracker     = tracker;
     this.rootFactory = lineAndPointFactory.GetPointFactory();
 }