Esempio n. 1
0
        /// <summary>
        /// init routine for the specialized Fourier level-set
        /// </summary>
        private void InitFourier()
        {
            if (this.Control.FourierLevSetControl == null)
            {
                throw new ArgumentNullException("LevelSetEvolution needs and instance of FourierLevSetControl!");
            }

            Fourier_LevSet = FourierLevelSetFactory.Build(this.Control.FourierLevSetControl);
            if (this.Control.EnforceLevelSetConservation)
            {
                throw new NotSupportedException("mass conservation correction currently not supported");
            }
            Fourier_LevSet.ProjectToDGLevelSet(this.DGLevSet.Current, this.LsTrk);

            if (base.MPIRank == 0 && this.CurrentSessionInfo.ID != Guid.Empty)
            {
                // restart information for Fourier LS
                Log_FourierLS = base.DatabaseDriver.FsDriver.GetNewLog("Log_FourierLS", this.CurrentSessionInfo.ID);
                Guid vecSamplP_id = this.DatabaseDriver.SaveVector <double>(Fourier_LevSet.getRestartInfo());
                Log_FourierLS.WriteLine(vecSamplP_id);
                Log_FourierLS.Flush();

                //if(this.Control.FourierLevSetControl.WriteFLSdata)
                //    Fourier_LevSet.setUpLogFiles(base.DatabaseDriver, this.CurrentSessionInfo, TimestepNo, PhysTime);
            }
            //create specialized fourier timestepper
            Fourier_Timestepper = FourierLevelSetFactory.Build_Timestepper(this.Control.FourierLevSetControl, Fourier_LevSet.GetFLSproperty(),
                                                                           Fourier_LevSet.ComputeChangerate, Fourier_LevSet.EvolveFourierLS);
        }
Esempio n. 2
0
        /// <summary>
        /// setUp for the Level set initialization (Level-set algorithm, continuity, conservation)
        /// </summary>
        protected void InitLevelSet()
        {
            using (new FuncTrace()) {
                // check level-set
                if (this.LevSet.L2Norm() == 0)
                {
                    throw new NotSupportedException("Level set is not initialized - norm is 0.0 - ALL cells will be cut, no gradient can be defined!");
                }

                // tracker needs to be updated to get access to the cut-cell mask
                this.LsTrk.UpdateTracker(0.0);

                // ==============================
                // level-set initialization
                // ==============================

                //PlotCurrentState(0.0, new TimestepNumber(new int[] { 0, 0 }), 3);

                #region Initialize Level Set Evolution Algorithm
                switch (this.Control.Option_LevelSetEvolution)
                {
                case LevelSetEvolution.Fourier:
                    InitFourier();
                    break;

                case LevelSetEvolution.None:
                    if (this.Control.AdvancedDiscretizationOptions.SST_isotropicMode == SurfaceStressTensor_IsotropicMode.Curvature_Fourier)
                    {
                        Fourier_LevSet = FourierLevelSetFactory.Build(this.Control.FourierLevSetControl);
                        Fourier_LevSet.ProjectToDGLevelSet(this.DGLevSet.Current, this.LsTrk);
                    }
                    else
                    {
                        goto default;
                    }
                    break;

                case LevelSetEvolution.ExtensionVelocity: {
                    // Create ExtensionVelocity Motion Algorithm
                    this.DGLevSet.Current.Clear();
                    this.DGLevSet.Current.AccLaidBack(1.0, this.LevSet);
                    DGLevSetGradient.Gradient(1.0, DGLevSet.Current);
                    //VectorField<SinglePhaseField> VectorExtVel = ExtensionVelocity.Current;
                    base.RegisterField(ExtensionVelocity.Current);

                    //ReInitPDE = new EllipticReInit(this.LsTrk, this.Control.ReInitControl, DGLevSet.Current);
                    FastMarchReinitSolver = new FastMarchReinit(DGLevSet.Current.Basis);

                    // full initial reinitialization
                    //ReInitPDE.ReInitialize(Restriction: LsTrk.Regions.GetNearFieldSubgrid(1));

                    CellMask Accepted      = LsTrk.Regions.GetNearFieldMask(1);
                    CellMask ActiveField   = Accepted.Complement();
                    CellMask NegativeField = LsTrk.Regions.GetSpeciesMask("A");
                    FastMarchReinitSolver.FirstOrderReinit(DGLevSet.Current, Accepted, NegativeField, ActiveField);

                    //ReInitPDE.ReInitialize();

                    // setup extension velocity mover
                    switch (this.Control.TimeSteppingScheme)
                    {
                    case TimeSteppingScheme.RK_CrankNic:
                    case TimeSteppingScheme.CrankNicolson: {
                        //do not instantiate rksch, use bdf instead
                        bdfOrder = -1;
                        break;
                    }

                    case TimeSteppingScheme.RK_ImplicitEuler:
                    case TimeSteppingScheme.ImplicitEuler: {
                        //do not instantiate rksch, use bdf instead
                        bdfOrder = 1;
                        break;
                    }

                    default: {
                        if (this.Control.TimeSteppingScheme.ToString().StartsWith("BDF"))
                        {
                            //do not instantiate rksch, use bdf instead
                            bdfOrder = Convert.ToInt32(this.Control.TimeSteppingScheme.ToString().Substring(3));
                            break;
                        }
                        else
                        {
                            throw new NotImplementedException();
                        }
                    }
                    }

                    ExtVelMover = new ExtensionVelocityBDFMover(LsTrk, DGLevSet.Current, DGLevSetGradient, new VectorField <DGField>(XDGvelocity.Velocity.ToArray()),
                                                                Control.EllipticExtVelAlgoControl, BcMap, bdfOrder, ExtensionVelocity.Current, new double[2] {
                            Control.PhysicalParameters.rho_A, Control.PhysicalParameters.rho_B
                        });


                    break;
                }

                case LevelSetEvolution.FastMarching:
                case LevelSetEvolution.Prescribed:
                case LevelSetEvolution.ScalarConvection:
                default:
                    // evolution algorithms need a signed-distance level-set:
                    // do some reinit at startup
                    //BoSSS.Solution.LevelSetTools.Advection.NarrowMarchingBand.CutCellReinit(this.LsTrk, this.DGLevSet.Current);
                    // apply only the minimal necessary change
                    this.DGLevSet.Current.Clear();
                    this.DGLevSet.Current.AccLaidBack(1.0, this.LevSet);

                    //FastMarchReinitSolver = new FastMarchReinit(DGLevSet.Current.Basis);

                    break;
                }
                //PlotCurrentState(0.0, new TimestepNumber(new int[] { 0, 1 }), 3);
                #endregion

                // =========================================
                // Enforcing the continuity of the level-set
                // =========================================

                ContinuityEnforcer = new ContinuityProjection(
                    ContBasis: this.LevSet.Basis,
                    DGBasis: this.DGLevSet.Current.Basis,
                    gridData: GridData,
                    Option: Control.LSContiProjectionMethod
                    );

                //var CC = this.LsTrk.Regions.GetCutCellMask4LevSet(0);
                var Near1 = this.LsTrk.Regions.GetNearMask4LevSet(0, 1);
                var Near  = this.LsTrk.Regions.GetNearMask4LevSet(0, this.Control.LS_TrackerWidth);
                var PosFF = this.LsTrk.Regions.GetLevelSetWing(0, +1).VolumeMask;

                if (this.Control.Option_LevelSetEvolution != LevelSetEvolution.ExtensionVelocity)
                {
                    ContinuityEnforcer.SetFarField(this.DGLevSet.Current, Near1, PosFF);
                }

                ContinuityEnforcer.MakeContinuous(this.DGLevSet.Current, this.LevSet, Near, PosFF);

                //PlotCurrentState(0.0, new TimestepNumber(new int[] { 0, 2 }), 3);

                this.LsTrk.UpdateTracker(0.0);
            }
        }