コード例 #1
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="SolverConf"></param>
        /// <param name="WorkingSet"></param>
        /// <param name="WorkingSetMatrices"></param>
        public BaseSIMPLEStepVariableDensity(SolverConfiguration SolverConf, VariableSet WorkingSet, VariableMatrices WorkingSetMatrices)
        {
            this.SolverConf         = SolverConf;
            this.WorkingSet         = WorkingSet;
            this.WorkingSetMatrices = WorkingSetMatrices;

            // Construct BDF scheme for unsteady solver
            if (SolverConf.Control.Algorithm == SolutionAlgorithms.Unsteady_SIMPLE)
            {
                BDF = new BDFScheme();
            }

            // Construct SIMPLEOperators
            UnsetteledCoordinateMapping VelocityMapping = new UnsetteledCoordinateMapping(WorkingSet.VelBasis);
            UnsetteledCoordinateMapping PressureMapping = new UnsetteledCoordinateMapping(WorkingSet.PressureBasis);

            Basis[] VelBasisS = new Basis[SolverConf.SpatialDimension];
            for (int d = 0; d < SolverConf.SpatialDimension; d++)
            {
                VelBasisS[d] = WorkingSet.VelBasis;
            }
            UnsetteledCoordinateMapping VelocityVectorMapping = new UnsetteledCoordinateMapping(VelBasisS);

            OperatorsFlowField = GetOperatorsFlowField(VelocityMapping, VelocityVectorMapping, PressureMapping);

            // Construct matrix assemblies
            MatrixAssembliesFlowField = new MatrixFactoryVariableDensityFlowField(
                SolverConf,
                OperatorsFlowField,
                WorkingSetMatrices.Rho.Matrix,
                BDF,
                VelocityMapping,
                VelocityVectorMapping);
        }
コード例 #2
0
ファイル: SIMPLEStepLowMach.cs プロジェクト: xyuan/BoSSS
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="SolverConf"></param>
        /// <param name="WorkingSet"></param>
        /// <param name="WorkingSetMatrices"></param>
        public SIMPLEStepLowMach(SolverConfiguration SolverConf, VariableSet WorkingSet, VariableMatrices WorkingSetMatrices)
            : base(SolverConf, WorkingSet, WorkingSetMatrices)
        {
            this.LowMachControl = SolverConf.Control as LowMachSIMPLEControl;
            if (this.LowMachControl == null)
            {
                throw new ArgumentException("Invalid config", nameof(SolverConf));
            }

            // Construct SIMPLEOperators
            UnsetteledCoordinateMapping TemperatureMapping = new UnsetteledCoordinateMapping(WorkingSet.TemperatureBasis);
            UnsetteledCoordinateMapping PressureMapping    = new UnsetteledCoordinateMapping(WorkingSet.PressureBasis);

            OperatorsTemperature = new OperatorFactoryTemperature(
                TemperatureMapping,
                PressureMapping,
                base.WorkingSet.Velocity.Current,
                base.WorkingSet.VelocityMean,
                base.WorkingSet.Temperature.Current,
                base.WorkingSet.TemperatureMean,
                SolverConf);

            // Construct matrix assemblies
            MatrixAssembliesTemperature = new MatrixFactoryTemperature(
                OperatorsTemperature, TemperatureMapping.GridDat.iLogicalCells.NoOfLocalUpdatedCells, WorkingSetMatrices.Rho.Matrix, SolverConf, base.BDF);
        }
コード例 #3
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="SolverConf"></param>
        /// <param name="WorkingSet"></param>
        public SIMPLEStepIncompressible(SolverConfiguration SolverConf, VariableSet WorkingSet)
        {
            m_SolverConf = SolverConf;
            m_WorkingSet = WorkingSet;

            // Construct BDF scheme for unsteady solver
            if (SolverConf.Control.Algorithm == SolutionAlgorithms.Unsteady_SIMPLE)
            {
                m_BDF = new BDFScheme();
            }

            // Construct all SIMPLEOperators, which are needed for incompressible flows
            UnsetteledCoordinateMapping VelocityMapping = new UnsetteledCoordinateMapping(WorkingSet.VelBasis);
            UnsetteledCoordinateMapping PressureMapping = new UnsetteledCoordinateMapping(WorkingSet.PressureBasis);

            m_IncompressibleOperators = new OperatorFactoryFlowFieldIncompressible(VelocityMapping,
                                                                                   PressureMapping,
                                                                                   SolverConf,
                                                                                   WorkingSet.Velocity.Current,
                                                                                   WorkingSet.VelocityMean);

            // Construct matrix assemblies
            m_IncompressibleMatrixAssemblies = new MatrixFactoryIncompressibleFlows(
                SolverConf, m_IncompressibleOperators, PressureMapping, WorkingSet.Pressure, m_BDF);
        }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        protected override void CreateFields()
        {
            using (new FuncTrace()) {
                // create fields for flow field
                WorkingSet = new VariableSet(base.GridData, Control, base.m_IOFields, base.m_RegisteredFields);

                // create extended fields for variable density solvers
                WorkingSet.CreateExtendedVariables(Control);

                // read settings for SIMPLE-algorithm
                SolverConf = new SolverConfiguration(
                    Control, GridData, WorkingSet, base.MPIRank);

                // Plot analytic solution
                PlotAnalyticSolution(Control.AnalyticVelocityX, WorkingSet.VelBasis, "VelocityX_Ana");
                PlotAnalyticSolution(Control.AnalyticVelocityY, WorkingSet.VelBasis, "VelocityY_Ana");
                if (SolverConf.SpatialDimension == 3)
                {
                    PlotAnalyticSolution(Control.AnalyticVelocityZ, WorkingSet.VelBasis, "VelocityZ_Ana");
                }

                PlotAnalyticSolution(Control.AnalyticPressure, WorkingSet.PressureBasis, "Pressure_Ana");

                switch (Control.PhysicsMode)
                {
                case PhysicsMode.Incompressible:
                    break;

                case PhysicsMode.LowMach:
                    LowMachSIMPLEControl lowMachConf = Control as LowMachSIMPLEControl;
                    PlotAnalyticSolution(lowMachConf.AnalyticTemperature, WorkingSet.TemperatureBasis, "Temperature_Ana");
                    PlotAnalyticSolution(lowMachConf.AnalyticDensity, WorkingSet.TemperatureBasis, "Density_Ana");
                    break;

                case PhysicsMode.Multiphase:
                    MultiphaseSIMPLEControl multiphaseConf = Control as MultiphaseSIMPLEControl;
                    PlotAnalyticSolution(multiphaseConf.AnalyticLevelSet, WorkingSet.LevelSetBasis, "LevelSet_Ana");
                    PlotAnalyticSolution(multiphaseConf.AnalyticDensity, WorkingSet.LevelSetBasis, "Density_Ana");
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
コード例 #5
0
ファイル: SolverConfiguration.cs プロジェクト: xyuan/BoSSS
        public SolverConfiguration(
            SIMPLEControl control, IGridData GridDat, VariableSet workingSet, int MPIRank)
        {
            this.SpatialDimension = GridDat.SpatialDimension;
            this.MPIRank          = MPIRank;
            this.Control          = control;
            this.BcMap            = new IncompressibleBoundaryCondMap(GridDat, Control.BoundaryValues, Control.PhysicsMode);

            CheckSetupPressure(SpatialDimension);
            if (Control.PressureReferencePoint != null)
            {
                UnsetteledCoordinateMapping MappingPressure = new UnsetteledCoordinateMapping(
                    new Basis(GridDat, workingSet.Pressure.Basis.Degree));

                PressureReferencePointIndex = BoSSS.Solution.NSECommon.SolverUtils.GetIndexOfPressureReferencePoint(Control.PressureReferencePoint, MappingPressure, 0);
                if (PressureReferencePointIndex < 0)
                {
                    throw new ApplicationException("Unknown error finding index for pressure reference point.");
                }
            }

            // SIP penalty for viscous part of momentum equation
            this.PenaltyViscMomentum = Control.ViscousPenaltyScaling;

            // SIP penalty for SIP pressure correction
            if ((Control.PredictorApproximation == PredictorApproximations.Identity_IP1))
            {
                this.PenaltyPressureCorrection = Control.PressureCorrectionPenaltyScaling * GetSIPPenaltyBase(workingSet.Pressure.Basis.Degree, GridDat);
            }
            else if (Control.PressureCorrectionPenaltyScaling != 1.0)
            {
                throw new NotSupportedException("Extended property 'penalty_PressureCorrection' is only available for Identity_IP option.");
            }

            if (control.PhysicsMode == PhysicsMode.LowMach)
            {
                LowMachSIMPLEControl lowMachControl = control as LowMachSIMPLEControl;
                this.PenaltyHeatConduction = lowMachControl.PenaltyHeatConductionScaling * GetSIPPenaltyBase(workingSet.Pressure.Basis.Degree, GridDat);
            }

            this.Velocity = workingSet.Velocity;

            dt = control.Endtime / control.NoOfTimesteps;
        }
コード例 #6
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="SolverConf"></param>
        /// <param name="WorkingSet"></param>
        /// <param name="WorkingSetMatrices"></param>
        public SIMPLEStepMultiphase(SolverConfiguration SolverConf, VariableSet WorkingSet, VariableMatrices WorkingSetMatrices)
            : base(SolverConf, WorkingSet, WorkingSetMatrices)
        {
            this.SolverConf        = SolverConf;
            this.MultiphaseControl = SolverConf.Control as MultiphaseSIMPLEControl;
            if (this.MultiphaseControl == null)
            {
                throw new ArgumentException("Invalid configuration", nameof(SolverConf));
            }

            // Construct SIMPLEOperators
            UnsetteledCoordinateMapping LevelSetMapping = new UnsetteledCoordinateMapping(WorkingSet.LevelSetBasis);

            OperatorsLevelSet = new OperatorFactoryLevelSet(LevelSetMapping,
                                                            WorkingSet.Velocity.Current,
                                                            WorkingSet.VelocityMean,
                                                            SolverConf);

            // Construct matrix assemblies
            MatrixAssembliesLevelSet = new MatrixFactoryLevelSet(OperatorsLevelSet, LevelSetMapping.GridDat.iLogicalCells.NoOfLocalUpdatedCells, SolverConf, base.BDF);
        }
コード例 #7
0
        /// <summary>
        /// Update flow field variables after solving Predictor and Corrector.
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="SolverConf"></param>
        /// <param name="PressureGradient"></param>
        /// <param name="WorkingSet"></param>
        /// <param name="BDF"></param>
        /// <param name="PredictorApproxInv"></param>
        public static void UpdateFlowFieldVariables(double dt, SolverConfiguration SolverConf, SIMPLEOperator[] PressureGradient,
                                                    VariableSet WorkingSet, BDFScheme BDF, params SIMPLEMatrixAssembly[] PredictorApproxInv)
        {
            using (var t = new FuncTrace()) {
                // Pressure - explicit under-relaxation
                // ====================================

                WorkingSet.Pressure.Acc(SolverConf.Control.RelaxationFactorPressure, WorkingSet.Pressure_Correction);

                if (!SolverConf.BcMap.DirichletPressureBoundary)
                {
                    if (!double.IsNaN(SolverConf.Control.PressureMeanValue))
                    {
                        // set specified mean value of pressure
                        double NegCalcMeanValuePressure = -1.0 * WorkingSet.Pressure.GetMeanValueTotal(null);
                        WorkingSet.Pressure.AccConstant(NegCalcMeanValuePressure);
                        WorkingSet.Pressure.AccConstant(SolverConf.Control.PressureMeanValue);
                    }
                    if ((SolverConf.Control.PressureReferencePoint != null) && double.IsNaN(SolverConf.Control.PressureMeanValue))
                    {
                        // set pressure to zero at the specified reference point
                        double ShiftPressure = -1.0 * WorkingSet.Pressure.ProbeAt(SolverConf.Control.PressureReferencePoint);
                        WorkingSet.Pressure.AccConstant(ShiftPressure);
                    }
                }

                // Velocity
                // ========

                for (int comp = 0; comp < SolverConf.SpatialDimension; comp++)
                {
                    // Velocity_Correction = - ApproximationPredictorMatrix^(-1) * PressureGradient * pri_Pressure_Correction
                    double[] GradientPressureCorrection = new double[PressureGradient[0].LocalLength];
                    PressureGradient[comp].OperatorMatrix.SpMVpara(1.0, WorkingSet.Pressure_Correction.CoordinateVector,
                                                                   0.0, GradientPressureCorrection);
                    if (PredictorApproxInv.Length > 1)
                    {
                        PredictorApproxInv[comp].AssemblyMatrix.SpMVpara(-1.0, GradientPressureCorrection,
                                                                         0.0, WorkingSet.Velocity_Correction[comp].CoordinateVector);
                    }
                    else
                    {
                        PredictorApproxInv[0].AssemblyMatrix.SpMVpara(-1.0, GradientPressureCorrection,
                                                                      0.0, WorkingSet.Velocity_Correction[comp].CoordinateVector);
                    }

                    for (int i = 0; i < WorkingSet.Velocity_Correction[comp].Mapping.LocalLength; i++)
                    {
                        // VelRes = Vel(n) - Vel(n-1)
                        WorkingSet.VelRes[comp].CoordinateVector[i] =
                            WorkingSet.Velocity_Intrmed[comp].CoordinateVector[i] + WorkingSet.Velocity_Correction[comp].CoordinateVector[i]
                            - WorkingSet.Velocity.Current[comp].CoordinateVector[i];

                        // Vel = Vel^* + Vel'
                        WorkingSet.Velocity.Current[comp].CoordinateVector[i] =
                            WorkingSet.Velocity_Intrmed[comp].CoordinateVector[i] + WorkingSet.Velocity_Correction[comp].CoordinateVector[i];
                    }
                }

                // VelocityMean
                // ============

                WorkingSet.VelocityMean.Clear();
                WorkingSet.VelocityMean.AccLaidBack(1.0, WorkingSet.Velocity.Current);
            }
        }