public ExtensionVelocityBDFMover(LevelSetTracker LSTrk, SinglePhaseField LevelSet, VectorField <SinglePhaseField> LevelSetGradient, VectorField <DGField> Velocity, EllipticExtVelAlgoControl Control, IncompressibleBoundaryCondMap bcMap, int BDForder, VectorField <SinglePhaseField> VectorExtension, double[] Density = null, bool AssumeDivergenceFreeVelocity = false, SubGrid subGrid = null) { this.GridDat = LSTrk.GridDat; D = GridDat.SpatialDimension; this.LevelSetGradient = LevelSetGradient; this.LSTrk = LSTrk; this.LevelSet = LevelSet; this.Velocity = Velocity; this.OldRHS = LevelSet.CloneAs(); this.AdvectionSpatialOperator = CreateAdvectionSpatialOperator(bcMap); this.subGrid = subGrid; this.nearfield = subGrid != null; Basis NonXVelocityBasis; if (Velocity == null) { throw new ArgumentException("Velocity Field not initialized!"); } // Initialize Extension Velocity Algorithm double PenaltyBase = Control.PenaltyMultiplierInterface * ((double)((LevelSet.Basis.Degree + 1) * (LevelSet.Basis.Degree + D))) / ((double)D); ILevelSetForm InterfaceFlux; //VectorExtension = new VectorField<SinglePhaseField>(D, Velocity[0].Basis, "ExtVel", SinglePhaseField.Factory); if (Velocity[0].GetType() == typeof(SinglePhaseField)) { NonXVelocityBasis = ((SinglePhaseField)Velocity[0]).Basis; InterfaceFlux = new SingleComponentInterfaceForm(PenaltyBase, LSTrk); } else if (Velocity[0].GetType() == typeof(XDGField)) { NonXVelocityBasis = ((XDGField)Velocity[0]).Basis.NonX_Basis; InterfaceFlux = new DensityWeightedExtVel(PenaltyBase, LSTrk, Density); } else { throw new ArgumentException("VelocityField must be either a SinglePhaseField or a XDGField!"); }; //VectorExtension = new VectorField<SinglePhaseField>(D, NonXVelocityBasis, "ExtVel", SinglePhaseField.Factory); this.VectorExtension = VectorExtension; VelocityExtender = new Extender[D]; for (int d = 0; d < D; d++) { VelocityExtender[d] = new Extender(VectorExtension[d], LSTrk, InterfaceFlux, new List <DGField> { Velocity[d] }, LevelSetGradient, Control); VelocityExtender[d].ConstructExtension(new List <DGField> { Velocity[d] }, Control.subGridRestriction); } #if DEBUG VectorExtension.CheckForNanOrInf(); #endif // Initialize Advection Algorithm divU = new SinglePhaseField(NonXVelocityBasis); divU.Identification = "Divergence"; divU.Clear(); divU.Divergence(1.0, VectorExtension); MeanVelocity = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(new Basis(GridDat, 0), VariableNames.Velocity0MeanVector(D)[d]))); MeanVelocity.Clear(); MeanVelocity.AccLaidBack(1.0, VectorExtension); myBDFTimestepper = new BDFTimestepper(AdvectionSpatialOperator, new List <DGField>() { LevelSet }, ArrayTools.Cat(VectorExtension, this.MeanVelocity, this.divU), BDForder, Control.solverFactory, false, subGrid); }
public ScalarExtUpdate(LevelSetTracker LSTrk, SinglePhaseField LevelSet, VectorField <SinglePhaseField> LevelSetGradient, VectorField <SinglePhaseField> Velocity, EllipticExtVelAlgoControl Control, out SinglePhaseField Extension, bool nearfield) { this.LevelSet = LevelSet; this.nearfield = nearfield; int D = LSTrk.GridDat.SpatialDimension; double PenaltyBase = Control.PenaltyMultiplierInterface * ((double)((LevelSet.Basis.Degree + 1) * (LevelSet.Basis.Degree + D))) / ((double)D); ILevelSetComponent InterfaceFlux = new ScalarVelocityInterfaceForm(PenaltyBase, LSTrk); List <DGField> Paramlist = new List <DGField> { }; Paramlist.AddRange(Velocity); Extension = new SinglePhaseField(LevelSet.Basis, "ExtensionVelocity"); this.Extension = Extension; VelocityExtender = new Extender(Extension, LSTrk, InterfaceFlux, Paramlist, LevelSetGradient, Control); VelocityExtender.ConstructExtension(nearfield: nearfield); }
public ScalarExtVelAdvection(LevelSetTracker LSTrk, SinglePhaseField LevelSet, VectorField <SinglePhaseField> LevelSetGradient, VectorField <SinglePhaseField> Velocity, EllipticExtVelAlgoControl Control, bool nearfield, out SinglePhaseField Extension) { int D = LSTrk.GridDat.SpatialDimension; double PenaltyBase = Control.PenaltyMultiplierInterface * ((double)((LevelSet.Basis.Degree + 1) * (LevelSet.Basis.Degree + D))) / ((double)D); ILevelSetForm InterfaceFlux = new ScalarVelocityInterfaceForm(PenaltyBase, LSTrk); this.nearfield = nearfield; List <DGField> Paramlist = new List <DGField> { }; Paramlist.AddRange(Velocity); Extension = new SinglePhaseField(Velocity[0].Basis, "ExtensionVelocity"); VelocityExtender = new Extender(Extension, LSTrk, InterfaceFlux, Paramlist, LevelSetGradient, Control); Advection = new ScalarVelocityAdvection(LSTrk, LevelSet, Extension, null, nearfield); }
/// <summary> /// /// </summary> /// <param name="LSTrk"></param> /// <param name="LevelSet"></param> /// <param name="LevelSetGradient"></param> /// <param name="Velocity"></param> /// <param name="Control"></param> /// <param name="bcMap"></param> /// <param name="BDForder">Quick Hack: -1 = CrankNicholson, 0= Explicit, >0: BDF</param> /// <param name="VectorExtension"></param> /// <param name="nearfield"></param> public VectorExtVelAdvection(LevelSetTracker LSTrk, SinglePhaseField LevelSet, VectorField <SinglePhaseField> LevelSetGradient, VectorField <SinglePhaseField> Velocity, EllipticExtVelAlgoControl Control, NSECommon.IncompressibleBoundaryCondMap bcMap, int BDForder, out VectorField <SinglePhaseField> VectorExtension, SubGrid subGrid = null) { D = LSTrk.GridDat.SpatialDimension; this.LevelSetGradient = LevelSetGradient; this.UseImplicitTimeStepping = (BDForder != 0); this.nearfield = subGrid != null; this.Velocity = Velocity; this.LSTrk = LSTrk; this.LevelSet = LevelSet; VectorExtensionHistory = new VectorFieldHistory <SinglePhaseField>(new VectorField <SinglePhaseField>(D, Velocity[0].Basis, "ExtVel", SinglePhaseField.Factory)); VectorExtension = VectorExtensionHistory.Current; this.VectorExtension = VectorExtension; double PenaltyBase = Control.PenaltyMultiplierInterface * ((double)((LevelSet.Basis.Degree + 1) * (LevelSet.Basis.Degree + D))) / ((double)D); ILevelSetForm InterfaceFlux = new SingleComponentInterfaceForm(PenaltyBase, LSTrk); VelocityExtender = new Extender[D]; for (int d = 0; d < D; d++) { VelocityExtender[d] = new Extender(VectorExtension[d], LSTrk, InterfaceFlux, new List <DGField> { Velocity[d] }, LevelSetGradient, Control); VelocityExtender[d].ConstructExtension(new List <DGField> { Velocity[d] }, Control.subGridRestriction); } if (!this.UseImplicitTimeStepping) { VectorExtensionHistory.IncreaseHistoryLength(1); VectorExtensionHistory.Push(); Advection = new ExplicitNonconservativeAdvection(LevelSet, VectorExtensionHistory, bcMap); } else { Advection = new BDFNonconservativeAdvection(LevelSet, VectorExtension, bcMap, BDForder, subGrid, false); } }