/// <summary> /// Hack to initalize ThermodynamicPressure - called by NSE_SIMPLE.VariableSet.Initialize() /// </summary> /// <param name="ThermodynamicPressure"></param> public void Initialize(ScalarFieldHistory <SinglePhaseField> ThermodynamicPressure) { if (!IsInitialized) { this.ThermodynamicPressure = ThermodynamicPressure; } else { throw new ApplicationException("Initialize() can be called only once."); } }
/// <summary> /// [Multiphase] Summand for previous time steps in level-set equation. /// </summary> /// <param name="dt"></param> /// <param name="BDFOrder"></param> /// <param name="Scalar"></param> /// <param name="RhsSummand">Accumulator for the result.</param> public void ComputeRhsSummand(double dt, int BDFOrder, ScalarFieldHistory <SinglePhaseField> Scalar, SinglePhaseField RhsSummand) { for (int alpha = 1; alpha <= BDFOrder; alpha++) { RhsSummand.Acc(beta[BDFOrder - 1][alpha], Scalar[1 - alpha]); } RhsSummand.Scale(1.0 / (gamma[BDFOrder - 1] * dt)); }
protected override void CreateFields() { using (new FuncTrace()) { base.CreateFields(); int D = this.GridData.SpatialDimension; this.DGLevSet = new ScalarFieldHistory <SinglePhaseField>( new SinglePhaseField(new Basis(this.GridData, this.Control.FieldOptions["Phi"].Degree), "PhiDG")); if (this.Control.FieldOptions["PhiDG"].Degree >= 0 && this.Control.FieldOptions["PhiDG"].Degree != this.DGLevSet.Current.Basis.Degree) { throw new ApplicationException("Specification of polynomial degree for 'PhiDG' is not supportet, since it is induced by polynomial degree of 'Phi'."); } // ============================== // Initialize ContinuityProjection // if needed, if not , Option: None // ============================== this.LevSet = ContinuityProjection.CreateField( DGLevelSet: this.DGLevSet.Current, gridData: (GridData)GridData, Option: Control.LSContiProjectionMethod ); this.LsTrk = new LevelSetTracker((GridData)this.GridData, base.Control.CutCellQuadratureType, base.Control.LS_TrackerWidth, new string[] { "A", "B" }, this.LevSet); base.RegisterField(this.LevSet); this.LevSetGradient = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(this.LevSet.Basis, "dPhi_dx[" + d + "]"))); base.RegisterField(this.LevSetGradient); base.RegisterField(this.DGLevSet.Current); this.DGLevSetGradient = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(this.DGLevSet.Current.Basis, "dPhiDG_dx[" + d + "]"))); base.RegisterField(this.DGLevSetGradient); if (this.Control.CheckJumpConditions) { Basis basis = new Basis(this.GridData, 0); //Basis basis = new Basis(this.GridData, this.Control.FieldOptions[VariableNames.VelocityX].Degree); this.MassBalanceAtInterface = new SinglePhaseField(basis, "MassBalanceAtInterface"); base.RegisterField(this.MassBalanceAtInterface); //basis = new Basis(this.GridData, this.Control.FieldOptions[VariableNames.Pressure].Degree + this.Control.FieldOptions["Phi"].Degree); this.MomentumBalanceAtInterface = new VectorField <SinglePhaseField>(D.ForLoop(d => new SinglePhaseField(basis, d + "-MomentumBalanceAtInterface"))); base.RegisterField(this.MomentumBalanceAtInterface); //basis = new Basis(this.GridData, this.Control.FieldOptions[VariableNames.Pressure].Degree + this.Control.FieldOptions[VariableNames.VelocityX].Degree + this.Control.FieldOptions["Phi"].Degree); this.EnergyBalanceAtInterface = new SinglePhaseField(basis, "EnergyBalanceAtInterface"); base.RegisterField(this.EnergyBalanceAtInterface); } } }
/// <summary> /// [LowMach] Summand of all time steps for scalar variables, which are constant in space. /// Used for time derivative of thermodynamic pressure in Low-Mach flows. /// </summary> /// <param name="dt"></param> /// <param name="BDFOrder"></param> /// <param name="Scalar"></param> /// <returns> /// Summand of all time steps of <paramref name="Scalar"/>. /// </returns> //public double ComputeSummandScalarHistory(double dt, int BDFOrder, ScalarFieldHistory<SinglePhaseField> Scalar) { // double Summand = 0.0; // for (int alpha = 0; alpha <= BDFOrder; alpha++) // Summand += beta[BDFOrder - 1][alpha] * Scalar[1 - alpha].GetMeanValue(0); // Summand *= 1.0 / (gamma[BDFOrder - 1] * dt); // return Summand; //} /// <summary> /// [LowMach] Summand of all time steps for density. /// Used for time derivative of density in Corrector for Low-Mach flows. /// </summary> /// <param name="dt"></param> /// <param name="BDFOrder"></param> /// <param name="Temperature"></param> /// <param name="EoS"></param> /// <param name="RhsSummand"></param> public void ComputeDensitySummand(double dt, int BDFOrder, ScalarFieldHistory <SinglePhaseField> Temperature, MaterialLaw EoS, SinglePhaseField RhsSummand) { for (int alpha = 0; alpha <= BDFOrder; alpha++) { RhsSummand.ProjectFunction(beta[BDFOrder - 1][alpha], (X, U, cell) => EoS.GetDensity(U[0]), null, Temperature[1 - alpha]); } RhsSummand.Scale(1.0 / (gamma[BDFOrder - 1] * dt)); }
/// <summary> /// [LowMach] Summand for previous time steps in momentum equation. /// </summary> /// <param name="dt"></param> /// <param name="BDFOrder"></param> /// <param name="Scalar"></param> /// <param name="Velocity"></param> /// <param name="SpatialComponent">Velocity component.</param> /// <param name="EoS"></param> /// <param name="RhsSummand">Accumulator for the result.</param> public void ComputeRhsSummand(double dt, int BDFOrder, ScalarFieldHistory <SinglePhaseField> Scalar, VectorFieldHistory <SinglePhaseField> Velocity, int SpatialComponent, MaterialLaw EoS, SinglePhaseField RhsSummand) { for (int alpha = 1; alpha <= BDFOrder; alpha++) { RhsSummand.ProjectFunction(beta[BDFOrder - 1][alpha], (X, U, cell) => EoS.GetDensity(U[0]) * U[1], null, Scalar[1 - alpha], Velocity[1 - alpha][SpatialComponent]); } RhsSummand.Scale(1.0 / (gamma[BDFOrder - 1] * dt)); }
/// <summary> /// Ctor. /// </summary> /// <param name="solverConf"></param> /// <param name="sparseSolver"></param> /// <param name="MatAsmblyScalar"></param> /// <param name="MatAsmblyScalarApprox"></param> /// <param name="Scalar"></param> /// <param name="BDF"></param> public MultiphaseSolverLevelSet(SolverConfiguration solverConf, ISparseSolver sparseSolver, SIMPLEMatrixAssembly MatAsmblyScalar, SIMPLEMatrixAssembly MatAsmblyScalarApprox, ScalarFieldHistory <SinglePhaseField> Scalar, BDFScheme BDF) : base(solverConf, sparseSolver) { m_MatAsmblyLevelSet = MatAsmblyScalar; m_MatAsmblyLevelSetApprox = MatAsmblyScalarApprox; m_LevelSet = Scalar; m_solverConf = solverConf; m_multiphaseControl = solverConf.Control as MultiphaseSIMPLEControl; m_RelaxFactor = (1.0 - m_multiphaseControl.RelaxationFactorLevelSet) / m_multiphaseControl.RelaxationFactorLevelSet; m_ModeRelaxLevelSet = m_multiphaseControl.LevelSetRelaxationType; m_BDF = BDF; }
/// <summary> /// Ctor. /// </summary> /// <param name="solverConf"></param> /// <param name="_sparseSolver"></param> /// <param name="MatAsmblyCorrector"></param> /// <param name="VelocityDivergence"></param> /// <param name="Velocity_Intrmed"></param> /// <param name="DivB4"></param> /// <param name="BDF"></param> /// <param name="Temperature"></param> /// <param name="EoS"></param> public LowMachSolverCorrector(SolverConfiguration solverConf, ISparseSolver _sparseSolver, SIMPLEMatrixAssembly MatAsmblyCorrector, SIMPLEOperator[] VelocityDivergence, VectorField <SinglePhaseField> Velocity_Intrmed, SinglePhaseField DivB4, BDFScheme BDF, ScalarFieldHistory <SinglePhaseField> Temperature, MaterialLaw EoS, double[] RHSManuDivKontiOperatorAffine = null) : base(solverConf, _sparseSolver) { this.MatAsmblyCorrector = MatAsmblyCorrector; this.VelocityDivergence = VelocityDivergence; this.Velocity_Intrmed = Velocity_Intrmed; this.DivB4 = DivB4; this.BDF = BDF; this.Temperature = Temperature; this.EoS = EoS; this.RHSManuDivKontiOperatorAffine = RHSManuDivKontiOperatorAffine; }
public LevelSetMover(DGField[] _Velocity, VectorFieldHistory <SinglePhaseField> FilteredVelocity, LevelSetTracker _LsTrk, XVelocityProjection.CutCellVelocityProjectiontype _CutCellVelocityProjectiontype, ScalarFieldHistory <SinglePhaseField> _DGLevSet, IncompressibleBoundaryCondMap BcMap) { this.Velocity = _Velocity; this.LsTrk = _LsTrk; this.DGLevSet = _DGLevSet; this.FilteredVelocity = FilteredVelocity; VelocityFilter = new XVelocityProjection(_LsTrk, Velocity, FilteredVelocity.Current); VelocityFilter.Config.CutCellVelocityProjectiontype = _CutCellVelocityProjectiontype; //Advection = new ImplicitNonconservativeAdvection(DGLevSet.Current, FilteredVelocity.Current, BcMap); //Advection = new ImplicitNonconservativeAdvection(DGLevSet.Current, FilteredVelocity.Current, BcMap, AssumeDivergenceFreeVelocity: true); Advection = new ExplicitNonconservativeAdvection(DGLevSet.Current, FilteredVelocity, BcMap, AssumeDivergenceFreeVelocity: true); }
/// <summary> /// Ctor. /// </summary> /// <param name="solverConfig"></param> /// <param name="_sparseSolver"></param> /// <param name="DensityMatrix"></param> /// <param name="MatAsmblyTemperature"></param> /// <param name="MatAsmblyTemperatureApprox"></param> /// <param name="Temperature"></param> /// <param name="BDF"></param> /// <param name="EoS"></param> /// <param name="ThermodynamicPressure"></param> public LowMachSolverTemperature(SolverConfiguration solverConfig, ISparseSolver _sparseSolver, BlockDiagonalMatrix DensityMatrix, SIMPLEMatrixAssembly MatAsmblyTemperature, SIMPLEMatrixAssembly MatAsmblyTemperatureApprox, ScalarFieldHistory <SinglePhaseField> Temperature, BDFScheme BDF, MaterialLaw EoS, ScalarFieldHistory <SinglePhaseField> ThermodynamicPressure) : base(solverConfig, _sparseSolver) { this.DensityMatrix = DensityMatrix; this.MatAsmblyTemperature = MatAsmblyTemperature; this.MatAsmblyTemperatureApprox = MatAsmblyTemperatureApprox; LowMachSIMPLEControl lowMachControl = solverConfig.Control as LowMachSIMPLEControl; this.ModeRelaxTemperature = lowMachControl.RelaxationModeTemperature; this.RelaxFactor = (1.0 - lowMachControl.RelexationFactorTemperature) / lowMachControl.RelexationFactorTemperature; this.Temperature = Temperature; this.BDF = BDF; this.EoS = EoS; this.gamma = lowMachControl.Gamma; this.ThermodynamicPressure = ThermodynamicPressure; }
/// <summary> /// Ctor. /// </summary> /// <param name="solverConf"></param> /// <param name="_sparseSolver"></param> /// <param name="DensityMatrix"></param> /// <param name="MatAsmblyPredictor"></param> /// <param name="MatAsmblyPredictorApprox"></param> /// <param name="PressureGradient"></param> /// <param name="Pressure"></param> /// <param name="MatAsmblyViscSplit"></param> /// <param name="BuoyantForce"></param> /// <param name="Velocity"></param> /// <param name="Scalar"></param> /// <param name="EoS"></param> /// <param name="BDF"></param> public VariableDensitySolverPredictor(SolverConfiguration solverConf, ISparseSolver _sparseSolver, BlockDiagonalMatrix DensityMatrix, SIMPLEMatrixAssembly MatAsmblyPredictor, SIMPLEMatrixAssembly MatAsmblyPredictorApprox, SIMPLEOperator[] PressureGradient, SinglePhaseField Pressure, SIMPLEMatrixAssembly[,] MatAsmblyViscSplit, IEvaluatorNonLin[] BuoyantForce, VectorFieldHistory <SinglePhaseField> Velocity, ScalarFieldHistory <SinglePhaseField> Scalar, MaterialLaw EoS, BDFScheme BDF) : base(solverConf, _sparseSolver) { m_DensityMatrix = DensityMatrix; m_MatAsmblyPredictor = MatAsmblyPredictor; m_MatAsmblyPredictorApprox = MatAsmblyPredictorApprox; m_PressureGradient = PressureGradient; m_Pressure = Pressure; m_MatAsmblyViscSplit = MatAsmblyViscSplit; m_BuoyantForceEvaluator = BuoyantForce; m_Velocity = Velocity; m_Scalar = Scalar; m_EoS = EoS; m_RelaxFactor = (1.0 - base.m_solverConf.Control.RelexationFactorVelocity) / base.m_solverConf.Control.RelexationFactorVelocity; m_BDF = BDF; }
/// <summary> /// Update scalar field variables after solving scalar equation. /// </summary> /// <param name="SolverConf"></param> /// <param name="ModeRelaxScalar"></param> /// <param name="relax_scalar"></param> /// <param name="Scalar"></param> /// <param name="ScalarRes"></param> /// <param name="ScalarMean"></param> /// <param name="Rho"></param> /// <param name="Eta"></param> /// <param name="RhoMatrix"></param> /// <param name="EoS"></param> /// <param name="ThermodynamicPressure">Null for multiphase flows.</param> public static void UpdateScalarFieldVariables(SIMPLEControl SolverConf, RelaxationTypes ModeRelaxScalar, double relax_scalar, ScalarFieldHistory <SinglePhaseField> Scalar, SinglePhaseField ScalarRes, SinglePhaseField ScalarMean, SinglePhaseField Rho, SinglePhaseField Eta, QuadratureMatrix RhoMatrix, MaterialLaw EoS, SinglePhaseField ThermodynamicPressure, bool UpdateRhoVisc = true) { using (new FuncTrace()) { // Explicit Under-Relaxation of scalar variable // ============================================ if (ModeRelaxScalar == RelaxationTypes.Explicit) { // phi = alpha * phi_new + (1-alpha) * phi_old Scalar.Current.Scale(relax_scalar); Scalar.Current.Acc((1.0 - relax_scalar), ScalarRes); } // Scalar residual // =============== ScalarRes.Scale(-1.0); ScalarRes.Acc(1.0, Scalar.Current); // ScalarMean // ========== ScalarMean.Clear(); ScalarMean.AccLaidBack(1.0, Scalar.Current); // Thermodynamic pressure - only for Low-Mach number flows // ======================================================= switch (SolverConf.PhysicsMode) { case PhysicsMode.LowMach: LowMachSIMPLEControl lowMachConf = SolverConf as LowMachSIMPLEControl; if (lowMachConf.ThermodynamicPressureMode == ThermodynamicPressureMode.MassDetermined) { ThermodynamicPressure.Clear(); ThermodynamicPressure.AccConstant(((MaterialLawLowMach)EoS).GetMassDeterminedThermodynamicPressure(lowMachConf.InitialMass.Value, Scalar.Current)); } break; case PhysicsMode.Multiphase: break; default: throw new ApplicationException(); } if (UpdateRhoVisc) { // Density // ======= Rho.Clear(); Rho.ProjectFunction(1.0, EoS.GetDensity, null, Scalar.Current); RhoMatrix.Update(); // Viscosity // ========= Eta.Clear(); Eta.ProjectFunction(1.0, EoS.GetViscosity, null, Scalar.Current); } } }