コード例 #1
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));
        }