示例#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
        /// <summary>
        /// [VariableDensity] Ctor.
        /// </summary>
        /// <param name="SolverConf"></param>
        /// <param name="Src"></param>
        /// <param name="BDF"></param>
        /// <param name="Rho"></param>
        /// <param name="MaxUseMatrix"></param>
        public MatrixAssemblyApprox(SolverConfiguration SolverConf, int NoOfCells, SIMPLEMatrixAssembly Src, BDFScheme BDF, BlockDiagonalMatrix Rho, int MaxUseMatrix = 1)
            : base(SolverConf.Control.PredictorApproximationIsConstant, false, MaxUsePerIterMatrix: MaxUseMatrix)
        {
            m_SolverConf = SolverConf;
            m_Src        = Src;
            m_BDF        = BDF;
            m_NoOfCells  = NoOfCells;

            if (Rho != null)
            {
                // VariableDensity
                m_Rho = Rho;
                if (m_Src.i0 != m_Rho.RowPartitioning.i0)
                {
                    throw new NotImplementedException("Different row partitions, which should be equal.");
                }
            }
            else
            {
                // Incompressible
                m_Rho = new BlockDiagonalMatrix(m_Src.LocalLength, 1);
                m_Rho.AccEyeSp();
            }

            base.Initialize();
        }
示例#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>
        /// Ctor.
        /// </summary>
        /// <param name="IPOperator"></param>
        /// <param name="PressureStabilization"></param>
        /// <param name="SolverConf"></param>
        /// <param name="BDF"></param>
        public MatrixAssemblyCorrectorIP1(SIMPLEOperator IPOperator, SIMPLEOperator PressureStabilization, SolverConfiguration SolverConf, BDFScheme BDF)
            : base((SolverConf.Control.Algorithm == SolutionAlgorithms.Steady_SIMPLE), false)
        {
            m_IPOperator = IPOperator;

            m_PressureStabilization = PressureStabilization;
            m_SolverConf            = SolverConf;
            m_BDF = BDF;

            base.Initialize();
        }
示例#5
0
        /// <summary>
        /// Ctor.
        /// </summary>
        public MatrixFactoryTemperature(OperatorFactoryTemperature TemperatureOperators, int LocalNoOfCells, BlockDiagonalMatrix Rho,
                                        SolverConfiguration solverConf, BDFScheme BDF)
        {
            Temperature = new MatrixAssemblyTemperature(TemperatureOperators.TemperatureConvection, TemperatureOperators.HeatConduction);

            LowMachSIMPLEControl lowMachControl = solverConf.Control as LowMachSIMPLEControl;

            if (lowMachControl.RelaxationModeTemperature == RelaxationTypes.Implicit)
            {
                TemperatureApprox = new MatrixAssemblyApprox(
                    solverConf, LocalNoOfCells, Temperature, BDF, Rho, 2 * lowMachControl.PredictorApproximationUpdateCycle);
            }
        }
示例#6
0
        /// <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;
        }
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="solverConf"></param>
        /// <param name="_sparseSolver"></param>
        /// <param name="MatAsmblyPredictor"></param>
        /// <param name="MatAsmblyPredictorApprox"></param>
        /// <param name="PressureGradient"></param>
        /// <param name="BDF"></param>
        /// <param name="Velocity"></param>
        /// <param name="Pressure"></param>
        public SolverPredictor(SolverConfiguration solverConf, ISparseSolver _sparseSolver,
                               SIMPLEMatrixAssembly[] MatAsmblyPredictor, SIMPLEMatrixAssembly MatAsmblyPredictorApprox, SIMPLEOperator[] PressureGradient, BDFScheme BDF,
                               VectorFieldHistory <SinglePhaseField> Velocity, SinglePhaseField Pressure)
            : base(solverConf, _sparseSolver)
        {
            m_SolverConf = solverConf;

            m_MatAsmblyPredictor       = MatAsmblyPredictor;
            m_MatAsmblyPredictorApprox = MatAsmblyPredictorApprox;
            m_PressureGradient         = PressureGradient;

            m_BDF = BDF;

            m_Velocity = Velocity;
            m_Pressure = Pressure;

            m_RelaxFactor = (1.0 - base.m_solverConf.Control.RelexationFactorVelocity) / base.m_solverConf.Control.RelexationFactorVelocity;
        }
        /// <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;
        }
示例#10
0
        /// <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;
        }
示例#11
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="solverConf"></param>
        /// <param name="sparseSolver"></param>
        /// <param name="MatAsmblyCorrector"></param>
        /// <param name="VelocityDivergence"></param>
        /// <param name="BDF"></param>
        /// <param name="Velocity_Intrmed"></param>
        /// <param name="DivB4"></param>
        /// <param name="PressureStabilization">Can be null</param>
        /// <param name="Pressure"></param>
        public SolverCorrector(SolverConfiguration solverConf, ISparseSolver sparseSolver,
                               SIMPLEMatrixAssembly MatAsmblyCorrector, SIMPLEOperator[] VelocityDivergence, BDFScheme BDF,
                               VectorField <SinglePhaseField> Velocity_Intrmed, SinglePhaseField DivB4,
                               SIMPLEOperator PressureStabilization, SinglePhaseField Pressure)
            : base(solverConf, sparseSolver)
        {
            if ((VelocityDivergence.Length != solverConf.SpatialDimension) || (Velocity_Intrmed.Dim != solverConf.SpatialDimension))
            {
                throw new ArgumentException("Mismatch of dimensions!");
            }

            m_SolverConf = solverConf;

            m_MatAsmblyCorrector = MatAsmblyCorrector;
            m_VelocityDivergence = VelocityDivergence;

            m_BDF = BDF;

            m_Velocity_Intrmed = Velocity_Intrmed;
            m_DivB4            = DivB4;

            m_PressureStabilization = PressureStabilization;
            m_Pressure = Pressure;
        }
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="SolverConf"></param>
        /// <param name="IncompressibleOperators"></param>
        /// <param name="PressureMapping"></param>
        /// <param name="Pressure"></param>
        /// <param name="BDF"></param>
        public MatrixFactoryIncompressibleFlows(SolverConfiguration SolverConf, OperatorFactoryFlowFieldIncompressible IncompressibleOperators,
                                                UnsetteledCoordinateMapping PressureMapping, SinglePhaseField Pressure, BDFScheme BDF)
        {
            // Initialize Predictor
            Predictor = new SIMPLEMatrixAssembly[SolverConf.SpatialDimension];
            for (int d = 0; d < SolverConf.SpatialDimension; d++)
            {
                Predictor[d] = new MatrixAssemblyIncompressiblePredictor(IncompressibleOperators.Convection[d], IncompressibleOperators.Visc[d], 2, 1);
            }

            PredictorApprox = new MatrixAssemblyApprox(
                SolverConf, PressureMapping.GridDat.iLogicalCells.NoOfLocalUpdatedCells, Predictor[0], BDF, 1 + (1 + SolverConf.SpatialDimension) * SolverConf.Control.PredictorApproximationUpdateCycle);

            // Initialize Corrector
            PredictorApproxInv = new MatrixAssemblyApproxInv(
                SolverConf.Control, PressureMapping.GridDat.iLogicalCells.NoOfLocalUpdatedCells, PredictorApprox, SolverConf.SpatialDimension + SolverConf.SpatialDimension * SolverConf.Control.PredictorApproximationUpdateCycle);

            switch (SolverConf.Control.PredictorApproximation)
            {
            case PredictorApproximations.Identity:
            case PredictorApproximations.Diagonal:
            case PredictorApproximations.BlockDiagonal:
                Corrector = new MatrixAssemblyIncompressibleCorrector(IncompressibleOperators.VelocityDivergence,
                                                                      PredictorApproxInv,
                                                                      IncompressibleOperators.PressureGradient,
                                                                      SolverConf.Control.PredictorApproximationUpdateCycle,
                                                                      IncompressibleOperators.PressureStabilization);
                break;

            case PredictorApproximations.Identity_IP1:
                Corrector = new MatrixAssemblyCorrectorIP1(IncompressibleOperators.IP1PressureCorrection,
                                                           IncompressibleOperators.PressureStabilization,
                                                           SolverConf,
                                                           BDF);
                break;

            default:
                throw new NotSupportedException("Unknown option for extended property 'Option_Approximation_Predictor'.");
            }
        }
示例#13
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);
            }
        }
示例#14
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="LevelSetOperators"></param>
        /// <param name="multiphaseControl"></param>
        /// <param name="BDF"></param>
        public MatrixFactoryLevelSet(OperatorFactoryLevelSet LevelSetOperators, int LocalNoOfCells, SolverConfiguration solverConf, BDFScheme BDF)
        {
            LevelSet = new MatrixAssemblyLevelSet(LevelSetOperators.LevelSetAdvection);

            MultiphaseSIMPLEControl multiphaseControl = solverConf.Control as MultiphaseSIMPLEControl;

            if (multiphaseControl.LevelSetRelaxationType == RelaxationTypes.Implicit)
            {
                LevelSetApprox = new MatrixAssemblyApprox(
                    solverConf, LocalNoOfCells, LevelSet, BDF, 2 * multiphaseControl.PredictorApproximationUpdateCycle);
            }
        }
示例#15
0
 /// <summary>
 /// [Incompressible] Ctor.
 /// </summary>
 public MatrixAssemblyApprox(SolverConfiguration SolverConf, int NoOfCells, SIMPLEMatrixAssembly Src, BDFScheme BDF, int MaxUseMatrix = 1)
     : this(SolverConf, NoOfCells, Src, BDF, null, MaxUseMatrix)
 {
 }
示例#16
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="SolverConf"></param>
        /// <param name="OperatorsFlowField"></param>
        /// <param name="Rho"></param>
        /// <param name="BDF"></param>
        /// <param name="VelocityMapping"></param>
        /// <param name="VelocityVectorMapping"></param>
        public MatrixFactoryVariableDensityFlowField(SolverConfiguration SolverConf, OperatorFactoryFlowFieldVariableDensity OperatorsFlowField,
                                                     BlockDiagonalMatrix Rho, BDFScheme BDF,
                                                     UnsetteledCoordinateMapping VelocityMapping, UnsetteledCoordinateMapping VelocityVectorMapping)
        {
            // Initialize Predictor
            // ====================

            ViscSplit = new SIMPLEMatrixAssembly[SolverConf.SpatialDimension, SolverConf.SpatialDimension];
            for (int i = 0; i < SolverConf.SpatialDimension; i++)
            {
                for (int j = 0; j < SolverConf.SpatialDimension; j++)
                {
                    switch (SolverConf.Control.PhysicsMode)
                    {
                    case PhysicsMode.LowMach:
                        ViscSplit[i, j] = new MatrixAssemblyViscSplit(OperatorsFlowField.Swip2[i], OperatorsFlowField.Swip3[i],
                                                                      j, VelocityMapping, VelocityVectorMapping);
                        break;

                    case PhysicsMode.Multiphase:
                        ViscSplit[i, j] = new MatrixAssemblyViscSplit(OperatorsFlowField.Swip2[i], null,
                                                                      j, VelocityMapping, VelocityVectorMapping);
                        break;

                    case PhysicsMode.Incompressible:
                        throw new ApplicationException("Using wrong matrix factory for incompressible flows");

                    default:
                        throw new NotImplementedException();
                    }
                }
            }

            //SaveMatricesToTextFile(OperatorsFlowField, VelocityMapping, VelocityVectorMapping);

            Predictor          = new SIMPLEMatrixAssembly[SolverConf.SpatialDimension];
            PredictorApprox    = new SIMPLEMatrixAssembly[SolverConf.SpatialDimension];
            PredictorApproxInv = new SIMPLEMatrixAssembly[SolverConf.SpatialDimension];
            for (int comp = 0; comp < SolverConf.SpatialDimension; comp++)
            {
                Predictor[comp]          = new MatrixAssemblyVariableDensityPredictor(comp, OperatorsFlowField.Convection, OperatorsFlowField.Visc, ViscSplit);
                PredictorApprox[comp]    = new MatrixAssemblyApprox(SolverConf, VelocityMapping.GridDat.iLogicalCells.NoOfLocalUpdatedCells, Predictor[comp], BDF, Rho, 1 + 2 * SolverConf.Control.PredictorApproximationUpdateCycle);
                PredictorApproxInv[comp] = new MatrixAssemblyApproxInv(SolverConf.Control, VelocityMapping.GridDat.iLogicalCells.NoOfLocalUpdatedCells, PredictorApprox[comp], 1 + SolverConf.Control.PredictorApproximationUpdateCycle);
            }

            // Initialize Corrector
            // ====================

            switch (SolverConf.Control.PhysicsMode)
            {
            case PhysicsMode.LowMach:
                Corrector = new MatrixAssemblyVariableDensityCorrector(OperatorsFlowField.DivergenceConti, PredictorApproxInv, OperatorsFlowField.PressureGradient);
                break;

            case PhysicsMode.Multiphase:
                Corrector = new MatrixAssemblyVariableDensityCorrector(OperatorsFlowField.DivergenceConti, PredictorApproxInv, OperatorsFlowField.PressureGradient, SolverConf.Control.PredictorApproximationUpdateCycle);
                break;

            case PhysicsMode.Incompressible:
                throw new ApplicationException("Using wrong matrix factory for incompressible flows");

            default:
                throw new NotImplementedException();
            }
        }