protected override SpatialOperator GetSpatialOperator(SolverConfiguration SolverConf, int SpatialComponent, int SpatialDirection) { VariableDensitySIMPLEControl varDensConf = SolverConf.Control as VariableDensitySIMPLEControl; //To be used with OnlyBoundaryEdges: false //return (new CoupledLaxFriedrichsVelocity(SpatialComponent, SolverConf.SpatialDimension, SolverConf.EoS, SolverConf.BcMap)).Operator(); //To be used with OnlyBoundaryEdges: true return((new LinearizedConvection(SolverConf.SpatialDimension, SolverConf.BcMap, SpatialComponent, varDensConf.EoS)).Operator(2)); }
protected override SpatialOperator GetSpatialOperator(SolverConfiguration SolverConf, int SpatialComponent, int SpatialDirection) { VariableDensitySIMPLEControl varDensConf = SolverConf.Control as VariableDensitySIMPLEControl; //return (new Viscosity(SolverConf.PenaltyViscMomentum, SolverConf.reynolds, SolverConf.BcMap, SpatialComponent, SolverConf.ConfigVariableDensity.EoS)).Operator(); return((new swipViscosity_Term1_variante(SolverConf.PenaltyViscMomentum, SpatialComponent, SolverConf.SpatialDimension, SolverConf.BcMap, ViscosityOption.VariableViscosityDimensionless, reynolds: varDensConf.Reynolds, EoS: varDensConf.EoS)).Operator(2)); }
protected override SpatialOperator GetSpatialOperator(SolverConfiguration SolverConf, int SpatialComponent, int SpatialDirection) { VariableDensitySIMPLEControl varDensConf = SolverConf.Control as VariableDensitySIMPLEControl; return((new swipViscosity_Term3(SolverConf.PenaltyViscMomentum, SpatialDirection, SolverConf.SpatialDimension, SolverConf.BcMap, ViscosityOption.VariableViscosityDimensionless, ViscositySolverMode.Segregated, reynolds: SolverConf.Control.Reynolds, EoS: varDensConf.EoS)).Operator(2)); }
/// <summary> /// Solve flow field equations, i.e. /// Predictor for velocity and /// Corrector for pressure correction. /// </summary> /// <param name="SIMPLEStatus"></param> /// <param name="dt"></param> /// <param name="ResLogger"></param> protected void SolveFlowFieldEquations(ref SIMPLEStepStatus SIMPLEStatus, double dt, ResidualLogger ResLogger) { // Update flow field SIMPLE operators (first!) and matrix assemblies (second!) // =========================================================================== UpdateApproximations = (!MatrixAssembliesFlowField.PredictorApprox[0].IsConstant && ((SIMPLEStatus.SIMPLEStepNo - 1) % SolverConf.Control.PredictorApproximationUpdateCycle == 0)) ? true : false; for (int i = 0; i < SolverConf.SpatialDimension; i++) { OperatorsFlowField.Convection[i].Update(); OperatorsFlowField.Visc[i].Update(); OperatorsFlowField.Swip2[i].Update(); if (SolverConf.Control.PhysicsMode == PhysicsMode.LowMach) { OperatorsFlowField.Swip3[i].Update(); OperatorsFlowField.DivergenceConti[i].Update(); } for (int j = 0; j < SolverConf.SpatialDimension; j++) { MatrixAssembliesFlowField.ViscSplit[i, j].Update(); } MatrixAssembliesFlowField.Predictor[i].Update(); } if (UpdateApproximations) { for (int i = 0; i < SolverConf.SpatialDimension; i++) { MatrixAssembliesFlowField.PredictorApprox[i].Update(); MatrixAssembliesFlowField.PredictorApproxInv[i].Update(); } if (SolverConf.Control.PhysicsMode == PhysicsMode.Multiphase) { MatrixAssembliesFlowField.Corrector.Update(); } } if (SolverConf.Control.PhysicsMode == PhysicsMode.LowMach) { // For Low-Mach flows the corrector is never constant // due to the density in the divergence operator. MatrixAssembliesFlowField.Corrector.Update(); } // Predictor // ========= for (int comp = 0; comp < SolverConf.SpatialDimension; comp++) { SIMPLESolver Predictor; VariableDensitySIMPLEControl varDensConf = SolverConf.Control as VariableDensitySIMPLEControl; Predictor = new VariableDensitySolverPredictor( SolverConf, SolverConf.Control.PredictorSolverFactory(), WorkingSetMatrices.Rho.Matrix, MatrixAssembliesFlowField.Predictor[comp], MatrixAssembliesFlowField.PredictorApprox[comp], OperatorsFlowField.PressureGradient, WorkingSet.Pressure, MatrixAssembliesFlowField.ViscSplit, OperatorsFlowField.BuoyantForce, WorkingSet.Velocity, this.GetScalarField(), varDensConf.EoS, BDF); Predictor.Solve(WorkingSet.Velocity_Intrmed[comp].CoordinateVector, dt, comp); Predictor.Dispose(); } // Corrector // ========= if ((SIMPLEStatus.SIMPLEStepNoTotal == 1) || UpdateApproximations) { if (Corrector != null) { Corrector.Dispose(); } Corrector = this.GetCorrectorSolver(); } Corrector.Solve(WorkingSet.Pressure_Correction.CoordinateVector, dt); // Update flow field variables // =========================== SIMPLEStepUtils.UpdateFlowFieldVariables(dt, SolverConf, OperatorsFlowField.PressureGradient, WorkingSet, BDF, MatrixAssembliesFlowField.PredictorApproxInv); if (WorkingSet.DivAfter != null) { WorkingSet.DivAfter.Clear(); SolverUtils.CalculateMassDefect_Divergence(OperatorsFlowField.DivergenceConti, WorkingSet.Velocity.Current, WorkingSet.DivAfter); } // Calculate residuals flow field // ============================== ResLogger.ComputeL2Norm(WorkingSet.Pressure_Correction, "p'"); ResLogger.ComputeL2Norm(WorkingSet.VelRes); }
/// <summary> /// Ctor /// </summary> /// <param name="VelocityMapping"></param> /// <param name="VelocityVectorMapping"></param> /// <param name="PressureMapping"></param> /// <param name="SolverConf"></param> /// <param name="Velocity0"></param> /// <param name="Velocity0Mean"></param> /// <param name="Phi0"></param> /// <param name="Phi0Mean"></param> /// <param name="eta"> /// Dynamic viscosity for viscous (Laplace) operator. /// </param> public OperatorFactoryFlowFieldVariableDensity(UnsetteledCoordinateMapping VelocityMapping, UnsetteledCoordinateMapping VelocityVectorMapping, UnsetteledCoordinateMapping PressureMapping, SolverConfiguration SolverConf, VectorField <SinglePhaseField> Velocity0, VectorField <SinglePhaseField> Velocity0Mean, SinglePhaseField Phi0, SinglePhaseField Phi0Mean, SinglePhaseField eta, SinglePhaseField[] MassFractionsCurrent = null, SinglePhaseField[] MassFractionsMean = null) { this.Convection = new SIMPLEOperator[SolverConf.SpatialDimension]; this.Visc = new SIMPLEOperator[SolverConf.SpatialDimension]; this.Swip2 = new SIMPLEOperator[SolverConf.SpatialDimension]; this.Swip3 = new SIMPLEOperator[SolverConf.SpatialDimension]; this.PressureGradient = new SIMPLEOperator[SolverConf.SpatialDimension]; this.DivergenceConti = new SIMPLEOperator[SolverConf.SpatialDimension]; for (int d = 0; d < SolverConf.SpatialDimension; d++) { switch (SolverConf.Control.PhysicsMode) { case PhysicsMode.Incompressible: throw new ApplicationException("Wrong OperatorFactory"); case PhysicsMode.LowMach: case PhysicsMode.Multiphase: this.Convection[d] = new MomentumConvectionVariableDensityOperator(VelocityMapping, Velocity0, Velocity0Mean, Phi0, Phi0Mean, SolverConf, d); break; default: throw new NotImplementedException("PhysicsMode not implemented"); } this.Visc[d] = new MomentumViscousVariableDensityOperator(VelocityMapping, Phi0, SolverConf, d); this.Swip2[d] = new MomentumSwip2(VelocityMapping, VelocityVectorMapping, Phi0, SolverConf, d); switch (SolverConf.Control.PhysicsMode) { case PhysicsMode.LowMach: this.Swip3[d] = new MomentumSwip3(VelocityMapping, VelocityVectorMapping, Phi0, SolverConf, d); this.DivergenceConti[d] = GetDivergenceContiOperator(PressureMapping, VelocityMapping, Phi0, SolverConf, d); break; case PhysicsMode.Multiphase: // Divergence of velocity is zero for smooth interface multiphase flows this.Swip3[d] = null; this.DivergenceConti[d] = GetDivergenceContiOperator(PressureMapping, VelocityMapping, Phi0, SolverConf, d); break; default: throw new ApplicationException("PhysicsMode is not compatible with OperatorFactory."); } this.PressureGradient[d] = new MomentumPressureGradientOperator(VelocityMapping, PressureMapping, SolverConf, d); } VariableDensitySIMPLEControl varDensConf = SolverConf.Control as VariableDensitySIMPLEControl; if (varDensConf.Froude.HasValue) { this.BuoyantForce = new SpatialOperator.Evaluator[SolverConf.SpatialDimension]; for (int d = 0; d < SolverConf.SpatialDimension; d++) { SpatialOperator BuoyancyOperator = (new Buoyancy(varDensConf.GravityDirection, d, varDensConf.Froude.Value, varDensConf.EoS)).Operator(); this.BuoyantForce[d] = BuoyancyOperator.GetEvaluator(Phi0.Mapping, VelocityMapping); } } //this.PressureStabilization = new DivergencePressureStabilization(ctx, PressureMapping, SolverConf); }