/// <summary>
        /// Ctor for variable density flows
        /// </summary>
        /// <param name="EoS">The material law</param>
        /// <param name="energy">Set conti: true for the energy equation</param>
        /// <param name="ArgumentOrdering"></param>
        /// <param name="TimeStepSize"></param>
        public MassMatrixComponent(MaterialLaw EoS, String[] ArgumentOrdering, int j, PhysicsMode _physicsMode, int spatDim, int NumberOfReactants)
        {
            this.j                  = j;
            this.EoS                = EoS;
            m_ParameterOrdering     = EoS.ParameterOrdering;
            this.m_SpatialDimension = spatDim;
            this.NumberOfReactants  = NumberOfReactants;

            int SpatDim           = 2;
            int numberOfReactants = 3;

            this.physicsMode = _physicsMode;
            switch (_physicsMode)
            {
            case PhysicsMode.Multiphase:
                m_ArgumentOrdering  = new string[] { VariableNames.LevelSet };
                m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim));
                break;

            case PhysicsMode.LowMach:
                m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature);
                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            case PhysicsMode.MixtureFraction:
                m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.MixtureFraction);

                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            case PhysicsMode.Combustion:
                m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature, VariableNames.MassFractions(numberOfReactants - 1));     // u,v,w,T, Y0,Y1,Y2,Y3  as variables (Y4 is calculated as Y4 = 1- (Y0+Y1+Y2+Y3)
                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #2
0
        /// <summary>
        /// Ctor for low Mach number flows.
        /// </summary>
        /// <param name="Component"></param>
        /// <param name="Bcmap"></param>
        /// <param name="EoS"></param>
        public Divergence_CentralDifferenceJacobian(int Component, IncompressibleBoundaryCondMap Bcmap, int SpatDim, MaterialLaw EoS, int NumberOfSpecies = -1)
            : this(Component, Bcmap, SpatDim)
        {
            this.EoS = EoS;

            switch (Bcmap.PhysMode)
            {
            case PhysicsMode.Incompressible:
            case PhysicsMode.Multiphase:
                throw new ApplicationException("Wrong constructor");

            case PhysicsMode.MixtureFraction:
                m_ArgumentOrdering   = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), new string[] { VariableNames.MixtureFraction });
                m_ParameterOrdering  = null;
                this.NumberOfSpecies = NumberOfSpecies;
                break;

            case PhysicsMode.LowMach:
                m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), new string[] { VariableNames.Temperature });
                break;

            case PhysicsMode.Combustion:
                if (NumberOfSpecies == -1)
                {
                    throw new ArgumentException("NumberOfSpecies must be specified for combustion flows.");
                }
                string[] Parameters = ArrayTools.Cat(new string[] { VariableNames.Temperature }, VariableNames.MassFractions(NumberOfSpecies - 1));
                this.NumberOfSpecies = NumberOfSpecies;
                m_ArgumentOrdering   = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), Parameters);
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #3
0
 /// <summary>
 /// Ctor for incompressible flows.
 /// </summary>
 /// <param name="Component"></param>
 /// <param name="Bcmap"></param>
 public Divergence_CentralDifferenceJacobian(int Component, IncompressibleBoundaryCondMap Bcmap, int SpatDim)
 {
     this.Component     = Component;
     this.Bcmap         = Bcmap;
     this.VelFunction   = Bcmap.bndFunction[VariableNames.Velocity_d(Component)];
     m_SpatialDimension = SpatDim;
     m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim));
 }
        /// <summary>
        /// Ctor for incompressible flows.
        /// </summary>
        /// <param name="SpatDim">
        /// Spatial dimension (either 2 or 3).
        /// </param>
        /// <param name="_bcmap"></param>
        /// <param name="_component"></param>
        /// <param name="UseBoundaryVelocityParameter">
        /// True, if (an offset to) the boundary velocity is supplied in form of parameter variables.
        /// </param>
        public LinearizedConvection(int SpatDim, IncompressibleBoundaryCondMap _bcmap, int _component, bool UseBoundaryVelocityParameter = false)
            : this(SpatDim, _bcmap, _component)
        {
            m_UseBoundaryVelocityParameter = UseBoundaryVelocityParameter;

            m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim));
            if (m_UseBoundaryVelocityParameter)
            {
                m_ParameterOrdering = ArrayTools.Cat(m_ParameterOrdering, VariableNames.BoundaryVelocityVector(SpatDim));
            }
        }
Example #5
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="SpatDim">Spatial dimension (either 2 or 3)</param>
        /// <param name="BcMap"></param>
        /// <param name="EoS">Null for multiphase. Has to be given for Low-Mach and combustion to calculate density.</param>
        /// <param name="Argument">Variable name of the argument (e.g. "Temperature" or "MassFraction0")</param>
        public LinearizedScalarConvection2(int SpatDim, int NumberOfReactants, IncompressibleBoundaryCondMap BcMap, MaterialLaw EoS, string Argument = null)
        {
            this.NumberOfReactants = NumberOfReactants;
            m_SpatialDimension     = SpatDim;
            m_bcmap = BcMap;

            switch (BcMap.PhysMode)
            {
            case PhysicsMode.Multiphase:
                this.Argument       = VariableNames.LevelSet;
                m_ArgumentOrdering  = new string[] { VariableNames.LevelSet };
                m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim));
                break;

            case PhysicsMode.LowMach:
                this.Argument       = VariableNames.Temperature;
                m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim),
                                                     VariableNames.Temperature0, VariableNames.Temperature0Mean);
                m_ArgumentOrdering = new string[] { VariableNames.Temperature };
                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            case PhysicsMode.Combustion:
                this.Argument       = Argument;
                m_ParameterOrdering = ArrayTools.Cat(
                    VariableNames.Velocity0Vector(SpatDim),
                    VariableNames.Velocity0MeanVector(SpatDim),
                    VariableNames.Temperature0,
                    VariableNames.MassFractions0(NumberOfReactants),
                    VariableNames.Temperature0Mean,
                    VariableNames.MassFractionsMean(NumberOfReactants));
                m_ArgumentOrdering = new string[] { Argument };
                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #6
0
        /// <summary>
        /// Ctor for common part of incompressible and low Mach number flows.
        /// </summary>
        public UpwindMomentumConvection(int SpatDim, IncompressibleBoundaryCondMap _bcmap, int _component, double __rho)
        {
            m_SpatialDimension = SpatDim;
            m_bcmap            = _bcmap;
            m_component        = _component;
            m_rho = __rho;

            velFunction = new Func <double[], double, double> [m_bcmap.MaxEdgeTagNo, SpatDim];
            for (int d = 0; d < SpatDim; d++)
            {
                velFunction.SetColumn(m_bcmap.bndFunction[VariableNames.Velocity_d(d)], d);
            }
        }
Example #7
0
        /// <summary>
        /// ctor.
        /// </summary>
        /// <param name="_penaltyBase"></param>
        /// <param name="iComp">
        /// component index
        /// </param>
        /// <param name="D">
        /// spatial dimension.
        /// </param>
        /// <param name="bcmap"></param>
        /// <param name="_ViscosityMode">
        /// see <see cref="ViscosityOption"/>
        /// </param>
        /// <param name="constantViscosityValue">
        /// Constant value for viscosity.
        /// Needs to be given for <see cref="ViscosityOption.ConstantViscosity"/>.
        /// </param>
        /// <param name="reynolds">
        /// Reynolds number for dimensionless formulation.
        /// Needs to be given for <see cref="ViscosityOption.ConstantViscosityDimensionless"/> and <see cref="ViscosityOption.VariableViscosityDimensionless"/>.
        /// </param>
        /// <param name="EoS">
        /// Optional material law for calculating the viscosity
        /// as a function of the level-set.
        /// Only available for <see cref="ViscosityOption.VariableViscosity"/> and <see cref="ViscosityOption.VariableViscosityDimensionless"/>.
        /// </param>
        protected swipViscosityBase(
            double _penaltyBase,
            int iComp, int D, IncompressibleBoundaryCondMap bcmap,
            ViscosityOption _ViscosityMode, double constantViscosityValue = double.NaN, double reynolds = double.NaN, MaterialLaw EoS = null)
        {
            //Func<double, int, int, MultidimensionalArray, double> ComputePenalty = null) {
            this.m_penalty_base = _penaltyBase;
            //this.m_ComputePenalty = ComputePenalty;
            this.m_iComp = iComp;
            this.m_D     = D;
            //this.cj = PenaltyLengthScales;
            velFunction        = D.ForLoop(d => bcmap.bndFunction[VariableNames.Velocity_d(d)]);
            EdgeTag2Type       = bcmap.EdgeTag2Type;
            this.m_PhysicsMode = bcmap.PhysMode;

            this.m_ViscosityMode = _ViscosityMode;
            switch (_ViscosityMode)
            {
            case ViscosityOption.ConstantViscosity:
                if (double.IsNaN(constantViscosityValue))
                {
                    throw new ArgumentException("constantViscosityValue is missing!");
                }
                this.m_constantViscosityValue = constantViscosityValue;
                break;

            case ViscosityOption.ConstantViscosityDimensionless:
                if (double.IsNaN(reynolds))
                {
                    throw new ArgumentException("reynolds number is missing!");
                }
                this.m_reynolds = reynolds;
                break;

            case ViscosityOption.VariableViscosity:
                this.m_EoS = EoS;
                break;

            case ViscosityOption.VariableViscosityDimensionless:
                if (double.IsNaN(reynolds))
                {
                    throw new ArgumentException("reynolds number is missing!");
                }
                this.m_reynolds = reynolds;
                this.m_EoS      = EoS;
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #8
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="SpatDimension"></param>
        /// <param name="EoS"></param>
        /// <param name="bcmap"></param>
        public CoupledLaxFriedrichsScalar(int SpatDimension, MaterialLaw EoS, IncompressibleBoundaryCondMap bcmap)
        {
            this.SpatDimension = SpatDimension;
            this.EoS           = EoS;
            this.bcmap         = bcmap;

            velFunction = new Func <double[], double, double> [GridCommons.FIRST_PERIODIC_BC_TAG, SpatDimension];
            for (int d = 0; d < SpatDimension; d++)
            {
                velFunction.SetColumn(bcmap.bndFunction[VariableNames.Velocity_d(d)], d);
            }

            scalarFunction = bcmap.bndFunction[VariableNames.LevelSet];
        }
        /// <summary>
        /// Ctor for common part of incompressible and low Mach number flows.
        /// </summary>
        /// <param name="SpatDim"></param>
        /// <param name="_bcmap"></param>
        /// <param name="_component"></param>
        private LinearizedConvection(int SpatDim, IncompressibleBoundaryCondMap _bcmap, int _component)
        {
            m_SpatialDimension = SpatDim;
            m_bcmap            = _bcmap;
            m_component        = _component;

            velFunction = new Func <double[], double, double> [GridCommons.FIRST_PERIODIC_BC_TAG, SpatDim];
            for (int d = 0; d < SpatDim; d++)
            {
                velFunction.SetColumn(m_bcmap.bndFunction[VariableNames.Velocity_d(d)], d);
            }

            PhysMode = _bcmap.PhysMode;
        }
        /// <summary>
        /// Ctor for variable density flows,
        /// i.e. low Mach number flows and
        /// multiphase flows with smooth interface.
        /// </summary>
        /// <param name="SpatDim">
        /// Spatial dimension (either 2 or 3).
        /// </param>
        /// <param name="_bcmap"></param>
        /// <param name="_component"></param>
        /// <param name="EoS">
        /// Material law for variable density flows.
        /// </param>
        public LinearizedConvection(int SpatDim, IncompressibleBoundaryCondMap _bcmap, int _component, MaterialLaw EoS, int NumberOfReactants = -1)
            : this(SpatDim, _bcmap, _component)
        {
            //m_VariableDensity = true;
            this.EoS = EoS;
            this.NumberOfReactants = NumberOfReactants;

            switch (_bcmap.PhysMode)
            {
            case PhysicsMode.LowMach:
                scalarFunction      = m_bcmap.bndFunction[VariableNames.Temperature];
                m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim),
                                                     VariableNames.Velocity0MeanVector(SpatDim),
                                                     VariableNames.Temperature0,
                                                     VariableNames.Temperature0Mean);
                break;

            case PhysicsMode.Multiphase:
                scalarFunction      = m_bcmap.bndFunction[VariableNames.LevelSet];
                m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim),
                                                     VariableNames.Velocity0MeanVector(SpatDim),
                                                     VariableNames.Phi0,
                                                     VariableNames.Phi0Mean);
                break;

            case PhysicsMode.Combustion:
                if (NumberOfReactants == -1)
                {
                    throw new ArgumentException("NumberOfReactants needs to be specified!");
                }
                m_ParameterOrdering = ArrayTools.Cat(
                    VariableNames.Velocity0Vector(SpatDim),
                    VariableNames.Velocity0MeanVector(SpatDim),
                    VariableNames.Temperature0,
                    VariableNames.MassFractions0(NumberOfReactants),
                    VariableNames.Temperature0Mean,
                    VariableNames.MassFractionsMean(NumberOfReactants));
                break;

            case PhysicsMode.Viscoelastic:
                throw new ApplicationException("Using of wrong constructor for viscoelastic flows.");

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

            default:
                throw new NotImplementedException();
            }
        }
Example #11
0
        static string[] BndFunctions(IGridData g, PhysicsMode _PhysicsMode)
        {
            int D = g.SpatialDimension;

            string[] ScalarFields;

            switch (_PhysicsMode)
            {
            case PhysicsMode.Incompressible:
                ScalarFields = new string[] { VariableNames.Pressure };
                break;

            case PhysicsMode.LowMach:
                ScalarFields = new string[] { VariableNames.Pressure, VariableNames.Temperature };
                break;

            case PhysicsMode.Multiphase:
                ScalarFields = new string[] { VariableNames.Pressure, VariableNames.LevelSet };
                break;

            case PhysicsMode.Combustion:
                ScalarFields = new string[] { VariableNames.Pressure, VariableNames.Temperature, VariableNames.MassFraction0, VariableNames.MassFraction1, VariableNames.MassFraction2, VariableNames.MassFraction3, VariableNames.MassFraction4 };
                break;

            case PhysicsMode.Helical:
                ScalarFields = new string[] { VariableNames.u, VariableNames.v, VariableNames.w, VariableNames.Pressure };
                return(ScalarFields);

            case PhysicsMode.Viscoelastic:
                ScalarFields = new string[] { VariableNames.Pressure, VariableNames.StressXX, VariableNames.StressXY, VariableNames.StressYY };
                break;

            case PhysicsMode.RANS:
                ScalarFields = new string[] { VariableNames.Pressure, "k", "omega" };     // TODO physics mode for each turbulence model?
                break;

            case PhysicsMode.MixtureFraction:
                ScalarFields = new string[] { VariableNames.Pressure, VariableNames.MixtureFraction };
                break;

            default:
                throw new ArgumentException();
            }

            return(ArrayTools.Cat(VariableNames.VelocityVector(D), ScalarFields));
        }
Example #12
0
        /// <summary>
        /// Ctor
        /// intended for use in the context of RANS turbulence model equations
        /// </summary>
        public LinearizedScalarConvection(int SpatDim, IncompressibleBoundaryCondMap BcMap, string TurbulentVariable, string TurbulentVariable0, string TurbulentVariable0Mean)
        {
            if (BcMap.PhysMode != PhysicsMode.RANS)
            {
                throw new ApplicationException("This Constructor is only intended for RANS turbulence model equations");
            }
            m_SpatialDimension = SpatDim;
            m_bcmap            = BcMap;

            velFunction = new Func <double[], double, double> [SpatDim][];
            for (int d = 0; d < SpatDim; d++)
            {
                velFunction[d] = m_bcmap.bndFunction[VariableNames.Velocity_d(d)];
            }

            scalarFunction      = m_bcmap.bndFunction[TurbulentVariable];
            m_ArgumentOrdering  = new string[] { TurbulentVariable };
            m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim),
                                                 TurbulentVariable0, TurbulentVariable0Mean);
        }
Example #13
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="SpatDim">Spatial dimension (either 2 or 3)</param>
        /// <param name="BcMap"></param>
        /// <param name="EoS">
        /// Null for multiphase.
        /// Has to be given for Low-Mach to calculate density.
        /// </param>
        public LinearizedScalarConvection(int SpatDim, IncompressibleBoundaryCondMap BcMap, MaterialLaw EoS)
        {
            m_SpatialDimension = SpatDim;
            m_bcmap            = BcMap;

            velFunction = new Func <double[], double, double> [SpatDim][];
            for (int d = 0; d < SpatDim; d++)
            {
                velFunction[d] = m_bcmap.bndFunction[VariableNames.Velocity_d(d)];
            }

            switch (BcMap.PhysMode)
            {
            case PhysicsMode.Multiphase:
                scalarFunction      = m_bcmap.bndFunction[VariableNames.LevelSet];
                m_ArgumentOrdering  = new string[] { VariableNames.LevelSet };
                m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim));
                break;

            case PhysicsMode.LowMach:
            case PhysicsMode.Combustion:
                scalarFunction      = m_bcmap.bndFunction[VariableNames.Temperature];
                m_ArgumentOrdering  = new string[] { VariableNames.Temperature };
                m_ParameterOrdering = ArrayTools.Cat(VariableNames.Velocity0Vector(SpatDim), VariableNames.Velocity0MeanVector(SpatDim),
                                                     VariableNames.Temperature0, VariableNames.Temperature0Mean);
                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
        /// <summary>
        /// flux at the boundary
        /// </summary>
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, double[] Uin)
        {
            IncompressibleBcType edgeType = m_bcmap.EdgeTag2Type[inp.EdgeTag];

            switch (edgeType)
            {
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann:
            case IncompressibleBcType.FreeSlip:
            case IncompressibleBcType.SlipSymmetry:
            case IncompressibleBcType.NavierSlip_Linear:
            case IncompressibleBcType.Velocity_Inlet: {
                // Fluss am Rand: f(u[d]) = n∙v∙u[d]
                // wobei n der Normalenvektor, v=(v1,v2) resp. v=(v1,v2,v3) der Linearisierungspunkt.
                //
                // Begründung: im Gegensatz zu obigem Code scheint dies besser zu funktionieren,
                // wenn ein Offset (m_UseBoundaryVelocityParameter == true) addiert wird.
                // Details: siehe Note 0022;

                double r = 0.0;
                double v1, v2, v3 = 0.0, u_d;

                if (m_UseBoundaryVelocityParameter)
                {
                    Debug.Assert(m_bcmap.PhysMode == PhysicsMode.LowMach || m_bcmap.PhysMode == PhysicsMode.Combustion || m_bcmap.PhysMode == PhysicsMode.Multiphase, "A boundary velocity is not implemented for variable density!");

                    u_d = Uin[0];

                    v1 = velFunction[inp.EdgeTag, 0](inp.X, inp.time) + inp.Parameters_IN[0 + 2 * m_SpatialDimension];
                    v2 = velFunction[inp.EdgeTag, 1](inp.X, inp.time) + inp.Parameters_IN[1 + 2 * m_SpatialDimension];
                    if (m_SpatialDimension == 3)
                    {
                        v3 = velFunction[inp.EdgeTag, 2](inp.X, inp.time) + inp.Parameters_IN[2 + 2 * m_SpatialDimension];
                    }

                    r += u_d * (v1 * inp.Normale[0] + v2 * inp.Normale[1]);
                    if (m_SpatialDimension == 3)
                    {
                        r += u_d * v3 * inp.Normale[2];
                    }
                }
                else
                {
                    // Setup params
                    // ============
                    Foundation.CommonParams inp2;
                    inp2.GridDat       = inp.GridDat;
                    inp2.Normale       = inp.Normale;
                    inp2.iEdge         = inp.iEdge;
                    inp2.Parameters_IN = inp.Parameters_IN;
                    inp2.X             = inp.X;
                    inp2.time          = inp.time;

                    // Dirichlet value for velocity
                    // ============================
                    double Uout = velFunction[inp.EdgeTag, m_component](inp.X, inp.time);

                    // Specify Parameters_OUT
                    // ======================
                    inp2.Parameters_OUT = new double[inp.Parameters_IN.Length];

                    // Outer values for Velocity and VelocityMean
                    for (int j = 0; j < m_SpatialDimension; j++)
                    {
                        inp2.Parameters_OUT[j] = velFunction[inp.EdgeTag, j](inp.X, inp.time);

                        // Velocity0MeanVectorOut is set to zero, i.e. always LambdaIn is used.
                        inp2.Parameters_OUT[m_SpatialDimension + j] = 0.0;
                    }

                    // Outer values for Scalar and ScalarMean
                    switch (m_bcmap.PhysMode)
                    {
                    case PhysicsMode.Viscoelastic:
                    case PhysicsMode.Incompressible:
                        break;

                    case PhysicsMode.LowMach:
                    case PhysicsMode.Multiphase: {
                        // opt1:
                        switch (edgeType)
                        {
                        case IncompressibleBcType.Velocity_Inlet:
                        case IncompressibleBcType.Wall:
                            inp2.Parameters_OUT[2 * m_SpatialDimension] = scalarFunction[inp.EdgeTag](inp.X, inp.time);
                            break;

                        case IncompressibleBcType.NoSlipNeumann:
                            inp2.Parameters_OUT[2 * m_SpatialDimension] = inp2.Parameters_IN[2 * m_SpatialDimension];
                            break;

                        default:
                            throw new ApplicationException();
                        }
                        // opt2:
                        // Inner values are used for the Scalar variable (even at Dirichlet boundaries of the Scalar variable).
                        // The Dirichlet value for the Scalar variable will be used while solving the Scalar equation, but not in the momentum equation.
                        //inp2.Parameters_OUT[2 * m_SpatialDimension] = inp2.Parameters_IN[2 * m_SpatialDimension];
                        // Use inner value for ScalarMean, i.e. LambdaIn is used.
                        inp2.Parameters_OUT[2 * m_SpatialDimension + 1] = inp.Parameters_IN[2 * m_SpatialDimension + 1];
                        break;
                    }

                    case PhysicsMode.Combustion: {
                        switch (edgeType)
                        {
                        case IncompressibleBcType.Velocity_Inlet:
                            // opt1: (using Dirichlet values)
                            inp2.Parameters_OUT[2 * m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                            for (int n = 1; n < NumberOfReactants + 1; n++)
                            {
                                // opt1: (using Dirichlet values)
                                inp2.Parameters_OUT[2 * m_SpatialDimension + n] = m_bcmap.bndFunction[VariableNames.MassFraction_n(n - 1)][inp.EdgeTag](inp.X, inp.time);
                            }
                            break;

                        case IncompressibleBcType.Wall:
                            // opt1: (using Dirichlet values for the temperature)
                            inp2.Parameters_OUT[2 * m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                            for (int n = 1; n < NumberOfReactants + 1; n++)
                            {
                                // using inner values for the mass fractions
                                inp2.Parameters_OUT[2 * m_SpatialDimension + n] = inp2.Parameters_IN[2 * m_SpatialDimension + n];
                            }
                            break;

                        case IncompressibleBcType.NoSlipNeumann:
                            for (int n = 0; n < NumberOfReactants + 1; n++)
                            {
                                // using inner values for the temperature and the mass fractions
                                inp2.Parameters_OUT[2 * m_SpatialDimension + n] = inp2.Parameters_IN[2 * m_SpatialDimension + n];
                            }
                            break;

                        default:
                            throw new ApplicationException();
                        }
                        for (int n = 0; n < NumberOfReactants + 1; n++)
                        {
                            // Use inner value for mean scalar input parameters, i.e. LambdaIn is used.
                            inp2.Parameters_OUT[2 * m_SpatialDimension + NumberOfReactants + 1 + n] = inp.Parameters_IN[2 * m_SpatialDimension + NumberOfReactants + 1 + n];
                        }
                        break;
                    }

                    default:
                        throw new NotImplementedException("PhysicsMode not implemented");
                    }

                    // Calculate BorderEdgeFlux as InnerEdgeFlux
                    // =========================================
                    r = InnerEdgeFlux(ref inp2, Uin, new double[] { Uout });
                }

                return(r);
            }

            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet: {
                double r = 0.0;
                double u1, u2, u3 = 0, u_d;

                if (m_UseBoundaryVelocityParameter)
                {
                    Debug.Assert(m_bcmap.PhysMode == PhysicsMode.LowMach || m_bcmap.PhysMode == PhysicsMode.Combustion || m_bcmap.PhysMode == PhysicsMode.Multiphase, "A boundary velocity is not implemented for variable density!");

                    u_d = Uin[0];
                    u1  = inp.Parameters_IN[0] + inp.Parameters_IN[0 + 2 * m_SpatialDimension];
                    u2  = inp.Parameters_IN[1] + inp.Parameters_IN[1 + 2 * m_SpatialDimension];
                    if (m_SpatialDimension == 3)
                    {
                        u3 = inp.Parameters_IN[2] + inp.Parameters_IN[2 + 2 * m_SpatialDimension];
                    }
                }
                else
                {
                    u_d = Uin[0];
                    u1  = inp.Parameters_IN[0];
                    u2  = inp.Parameters_IN[1];
                    if (m_SpatialDimension == 3)
                    {
                        u3 = inp.Parameters_IN[2];
                    }
                }

                r += u_d * (u1 * inp.Normale[0] + u2 * inp.Normale[1]);
                if (m_SpatialDimension == 3)
                {
                    r += u_d * u3 * inp.Normale[2];
                }

                if (m_bcmap.PhysMode == PhysicsMode.LowMach || m_bcmap.PhysMode == PhysicsMode.Multiphase)
                {
                    double rho = EoS.GetDensity(inp.Parameters_IN[2 * m_SpatialDimension]);
                    r *= rho;
                }

                if (m_bcmap.PhysMode == PhysicsMode.Combustion)
                {
                    double[] args = new double[NumberOfReactants + 1];
                    for (int n = 0; n < NumberOfReactants + 1; n++)
                    {
                        args[n] = inp.Parameters_IN[2 * m_SpatialDimension + n];
                    }
                    double rho = EoS.GetDensity(args);
                    r *= rho;
                }

                return(r);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
Example #15
0
        protected override double BorderEdgeFlux(ref Foundation.CommonParamsBnd inp, double[] Uin)
        {
            double res = 0.0;

            IncompressibleBcType edgeType = Bcmap.EdgeTag2Type[inp.EdgeTag];

            switch (edgeType)
            {
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann: {
                res = 0.0;
                break;
            }

            case IncompressibleBcType.Velocity_Inlet: {
                double TemperatureOut = 0.0;
                double Uout           = VelFunction[inp.EdgeTag](inp.X, inp.time);
                switch (Bcmap.PhysMode)
                {
                case PhysicsMode.LowMach:
                case PhysicsMode.Multiphase: {
                    // opt1:
                    TemperatureOut = Bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    res            = EoS.GetDensity(TemperatureOut) * Uout * inp.Normal[Component];
                    // opt2:
                    //double TemperatureIN = inp.Parameters_IN[0];
                    //double rhoIn = EoS.GetDensity(TemperatureIN);
                    //res = rhoIn * Uout * inp.Normale[Component];
                    break;
                }

                case PhysicsMode.Combustion:
                    // opt1:
                    TemperatureOut = Bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    double[] args = new double[NumberOfReactants + 1];
                    args[0] = TemperatureOut;
                    for (int n = 1; n < NumberOfReactants + 1; n++)
                    {
                        args[n] = Bcmap.bndFunction[VariableNames.MassFraction_n(n - 1)][inp.EdgeTag](inp.X, inp.time);
                    }
                    res = EoS.GetDensity(args) * Uout * inp.Normal[Component];
                    break;

                case PhysicsMode.Incompressible:
                    res = Uout * inp.Normal[Component];
                    break;

                default:
                    throw new ApplicationException("PhysicsMode not implemented");
                }
            }
            break;

            case IncompressibleBcType.Pressure_Outlet: {
                switch (Bcmap.PhysMode)
                {
                case PhysicsMode.Incompressible:
                    res = Uin[0] * inp.Normal[Component];
                    break;

                case PhysicsMode.LowMach:
                case PhysicsMode.Multiphase:
                    res = EoS.GetDensity(inp.Parameters_IN[0]) * Uin[0] * inp.Normal[Component];
                    break;

                case PhysicsMode.Combustion:
                    res = EoS.GetDensity(inp.Parameters_IN) * Uin[0] * inp.Normal[Component];
                    break;

                default:
                    throw new ApplicationException("PhysicsMode not implemented");
                }
            }
            break;

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }

            return(res);
        }
Example #16
0
        /// <summary>
        /// Ctor for low Mach number flows.
        /// </summary>
        /// <param name="Component"></param>
        /// <param name="Bcmap"></param>
        /// <param name="EoS"></param>
        public Divergence_CentralDifference(int Component, IncompressibleBoundaryCondMap Bcmap, MaterialLaw EoS, int NumberOfReactants = -1)
            : this(Component, Bcmap)
        {
            this.EoS = EoS;
            switch (Bcmap.PhysMode)
            {
            case PhysicsMode.Incompressible:
            case PhysicsMode.Multiphase:
                throw new ApplicationException("Wrong constructor");

            case PhysicsMode.LowMach:
                this.m_ParamterOrdering = new string[] { VariableNames.Temperature0 };
                break;

            case PhysicsMode.Combustion:
                this.m_ParamterOrdering = ArrayTools.Cat(new string[] { VariableNames.Temperature0 }, VariableNames.MassFractions0(NumberOfReactants));
                this.NumberOfReactants  = NumberOfReactants;
                if (NumberOfReactants == -1)
                {
                    throw new ArgumentException("NumberOfReactants must be specified for combustion flows.");
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
Example #17
0
 /// <summary>
 /// Ctor for incompressible flows.
 /// </summary>
 /// <param name="Component"></param>
 /// <param name="Bcmap"></param>
 public Divergence_CentralDifference(int Component, IncompressibleBoundaryCondMap Bcmap)
 {
     this.Component   = Component;
     this.Bcmap       = Bcmap;
     this.VelFunction = Bcmap.bndFunction[VariableNames.Velocity_d(Component)];
 }
Example #18
0
        double BorderEdgeFlux(ref Foundation.CommonParamsBnd inp, double[] Uin)
        {
            double res = 0.0;

            IncompressibleBcType edgeType = Bcmap.EdgeTag2Type[inp.EdgeTag];

            double[] DensityArgumentsIn;
            switch (edgeType)
            {
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann:
                res = 0.0;
                break;

            case IncompressibleBcType.Velocity_Inlet: {
                double TemperatureOut = 0.0;
                double Uout           = VelFunction[inp.EdgeTag](inp.X, inp.time);
                switch (Bcmap.PhysMode)
                {
                case PhysicsMode.Incompressible:
                    res = Uout * inp.Normal[Component];
                    break;

                case PhysicsMode.MixtureFraction:
                    // opt1:
                    double Zout = Bcmap.bndFunction[VariableNames.MixtureFraction][inp.EdgeTag](inp.X, inp.time);
                    res = EoS.getDensityFromZ(Zout) * Uout * inp.Normal[Component];
                    break;

                case PhysicsMode.LowMach:
                case PhysicsMode.Multiphase: {
                    // opt1:
                    TemperatureOut = Bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    res            = EoS.GetDensity(TemperatureOut) * Uout * inp.Normal[Component];
                    // opt2:
                    //double TemperatureIN = inp.Parameters_IN[0];
                    //double rhoIn = EoS.GetDensity(TemperatureIN);
                    //res = rhoIn * Uout * inp.Normale[Component];
                    break;
                }

                case PhysicsMode.Combustion: {
                    // opt1:
                    TemperatureOut = Bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    double[] argsa = new double[NumberOfSpecies - 1 + 1];
                    argsa[0] = TemperatureOut;
                    for (int n = 1; n < NumberOfSpecies; n++)
                    {
                        argsa[n] = Bcmap.bndFunction[VariableNames.MassFraction_n(n - 1)][inp.EdgeTag](inp.X, inp.time);
                    }
                    res = EoS.GetDensity(argsa) * Uout * inp.Normal[Component];
                    break;
                }

                default:
                    throw new ApplicationException("PhysicsMode not implemented");
                }
            }
            break;

            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Pressure_Outlet: {
                switch (Bcmap.PhysMode)
                {
                case PhysicsMode.Incompressible:
                    res = Uin[Component] * inp.Normal[Component];
                    break;

                case PhysicsMode.MixtureFraction:
                    double Zin = Uin[inp.D];
                    res = EoS.getDensityFromZ(Zin) * Uin[Component] * inp.Normal[Component];
                    break;

                case PhysicsMode.LowMach:
                case PhysicsMode.Multiphase:
                    DensityArgumentsIn = Uin.GetSubVector(m_SpatialDimension, 1);             // Only TemperatureIn
                    res = EoS.GetDensity(DensityArgumentsIn) * Uin[Component] * inp.Normal[Component];
                    break;

                case PhysicsMode.Combustion:
                    DensityArgumentsIn = Uin.GetSubVector(m_SpatialDimension, NumberOfSpecies);
                    res = EoS.GetDensity(DensityArgumentsIn) * Uin[Component] * inp.Normal[Component];
                    break;

                default:
                    throw new ApplicationException("PhysicsMode not implemented");
                }
            }
            break;

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }

            return(res);
        }
Example #19
0
        /// <summary>
        /// flux at the boundary
        /// </summary>
        protected override double BorderEdgeFlux(ref Foundation.CommonParamsBnd inp, double[] Uin)
        {
            IncompressibleBcType edgeType = m_bcmap.EdgeTag2Type[inp.EdgeTag];

            switch (edgeType)
            {
            case IncompressibleBcType.Wall: {
                if ((edgeType == IncompressibleBcType.Wall) && (m_bcmap.PhysMode == PhysicsMode.Multiphase))
                {
                    throw new ApplicationException("Use NoSlipNeumann boundary condition for multiphase flows instead of Wall.");
                }

                double r = 0.0;

                // Setup params
                // ============
                Foundation.CommonParams inp2;
                inp2.GridDat       = inp.GridDat;
                inp2.Normal        = inp.Normal;
                inp2.iEdge         = inp.iEdge;
                inp2.Parameters_IN = inp.Parameters_IN;
                inp2.X             = inp.X;
                inp2.time          = inp.time;
                inp2.jCellIn       = inp.jCellIn;
                inp2.jCellOut      = int.MinValue;

                // Boundary values for Parameters
                // ==============================
                inp2.Parameters_OUT = new double[inp.Parameters_IN.Length];

                // Velocity
                for (int j = 0; j < m_SpatialDimension; j++)
                {
                    // opt1:
                    inp2.Parameters_OUT[j] = m_bcmap.bndFunction[VariableNames.Velocity_d(j)][inp.EdgeTag](inp.X, inp.time);
                    // opt2: inner values
                    //inp2.Parameters_OUT[j] = inp2.Parameters_IN[j];
                    // Velocity0MeanVectorOut is set to zero, i.e. always LambdaIn is used.
                    inp2.Parameters_OUT[m_SpatialDimension + j] = 0.0;
                }

                // Skalar (e.g. temperature or MassFraction)
                switch (m_bcmap.PhysMode)
                {
                case PhysicsMode.LowMach: {
                    // opt1:
                    inp2.Parameters_OUT[2 * m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    // opt2: inner values
                    //inp2.Parameters_OUT[2 * m_SpatialDimension] = inp2.Parameters_IN[2 * m_SpatialDimension];
                    // Use inner value for TemperatureMean, i.e. LambdaIn is used.
                    inp2.Parameters_OUT[2 * m_SpatialDimension + 1] = inp.Parameters_IN[2 * m_SpatialDimension + 1];
                    break;
                }

                case PhysicsMode.Combustion: {
                    // opt1: (using Dirichlet values)
                    inp2.Parameters_OUT[2 * m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    for (int n = 1; n < NumberOfReactants + 1; n++)
                    {
                        //Using inner values
                        inp2.Parameters_OUT[2 * m_SpatialDimension + n] = inp.Parameters_IN[2 * m_SpatialDimension + n];
                    }
                    for (int n = 0; n < NumberOfReactants + 1; n++)
                    {
                        // Use inner value for mean scalar input parameters, i.e. LambdaIn is used.
                        inp2.Parameters_OUT[2 * m_SpatialDimension + NumberOfReactants + 1 + n] = inp.Parameters_IN[2 * m_SpatialDimension + NumberOfReactants + 1 + n];
                    }
                    break;
                }

                case PhysicsMode.Multiphase:
                    break;

                default:
                    throw new NotImplementedException();
                }

                // Dirichlet value for scalar
                // ==========================
                double[] Uout = new double[] { m_bcmap.bndFunction[Argument][inp.EdgeTag](inp.X, inp.time) };

                // Calculate BorderEdgeFlux as InnerEdgeFlux
                // =========================================
                r = InnerEdgeFlux(ref inp2, Uin, Uout);
                if (double.IsNaN(r))
                {
                    throw new NotFiniteNumberException();
                }
                return(r);
            }

            case IncompressibleBcType.Velocity_Inlet: {
                if ((edgeType == IncompressibleBcType.Wall) && (m_bcmap.PhysMode == PhysicsMode.Multiphase))
                {
                    throw new ApplicationException("Use NoSlipNeumann boundary condition for multiphase flows instead of Wall.");
                }

                double r = 0.0;

                // Setup params
                // ============
                Foundation.CommonParams inp2;
                inp2.GridDat       = inp.GridDat;
                inp2.Normal        = inp.Normal;
                inp2.iEdge         = inp.iEdge;
                inp2.Parameters_IN = inp.Parameters_IN;
                inp2.X             = inp.X;
                inp2.time          = inp.time;
                inp2.jCellIn       = inp.jCellIn;
                inp2.jCellOut      = int.MinValue;

                // Boundary values for Parameters
                // ==============================
                inp2.Parameters_OUT = new double[inp.Parameters_IN.Length];

                // Velocity
                for (int j = 0; j < m_SpatialDimension; j++)
                {
                    // opt1:
                    inp2.Parameters_OUT[j] = m_bcmap.bndFunction[VariableNames.Velocity_d(j)][inp.EdgeTag](inp.X, inp.time);
                    // opt2: inner values
                    //inp2.Parameters_OUT[j] = inp2.Parameters_IN[j];
                    // Velocity0MeanVectorOut is set to zero, i.e. always LambdaIn is used.
                    inp2.Parameters_OUT[m_SpatialDimension + j] = 0.0;
                }

                // Skalar (e.g. temperature or MassFraction)
                switch (m_bcmap.PhysMode)
                {
                case PhysicsMode.LowMach: {
                    // opt1:
                    inp2.Parameters_OUT[2 * m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    // opt2: inner values
                    //inp2.Parameters_OUT[2 * m_SpatialDimension] = inp2.Parameters_IN[2 * m_SpatialDimension];
                    // Use inner value for TemperatureMean, i.e. LambdaIn is used.
                    inp2.Parameters_OUT[2 * m_SpatialDimension + 1] = inp.Parameters_IN[2 * m_SpatialDimension + 1];
                    break;
                }

                case PhysicsMode.Combustion: {
                    // opt1: (using Dirichlet values)
                    inp2.Parameters_OUT[2 * m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    for (int n = 1; n < NumberOfReactants + 1; n++)
                    {
                        // opt1: (using Dirichlet values)
                        inp2.Parameters_OUT[2 * m_SpatialDimension + n] = m_bcmap.bndFunction[VariableNames.MassFraction_n(n - 1)][inp.EdgeTag](inp.X, inp.time);
                    }
                    for (int n = 0; n < NumberOfReactants + 1; n++)
                    {
                        // Use inner value for mean scalar input parameters, i.e. LambdaIn is used.
                        inp2.Parameters_OUT[2 * m_SpatialDimension + NumberOfReactants + 1 + n] = inp.Parameters_IN[2 * m_SpatialDimension + NumberOfReactants + 1 + n];
                    }
                    break;
                }

                case PhysicsMode.Multiphase:
                    break;

                default:
                    throw new NotImplementedException();
                }

                // Dirichlet value for scalar
                // ==========================
                double[] Uout = new double[] { m_bcmap.bndFunction[Argument][inp.EdgeTag](inp.X, inp.time) };

                // Calculate BorderEdgeFlux as InnerEdgeFlux
                // =========================================
                r = InnerEdgeFlux(ref inp2, Uin, Uout);
                if (double.IsNaN(r))
                {
                    throw new NotFiniteNumberException();
                }
                return(r);
            }

            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.NoSlipNeumann: {
                double r = 0.0;
                double u1, u2, u3 = 0;

                u1 = inp.Parameters_IN[0];
                u2 = inp.Parameters_IN[1];

                r += Uin[0] * (u1 * inp.Normal[0] + u2 * inp.Normal[1]);
                if (m_SpatialDimension == 3)
                {
                    u3 = inp.Parameters_IN[2];
                    r += Uin[0] * u3 * inp.Normal[2];
                }

                if (m_bcmap.PhysMode == PhysicsMode.LowMach)
                {
                    double rho = EoS.GetDensity(inp.Parameters_IN[2 * m_SpatialDimension]);
                    r *= rho;
                }

                if (m_bcmap.PhysMode == PhysicsMode.Combustion)
                {
                    double[] args = new double[NumberOfReactants + 1];
                    for (int n = 0; n < NumberOfReactants + 1; n++)
                    {
                        args[n] = inp.Parameters_IN[2 * m_SpatialDimension + n];
                    }
                    double rho = EoS.GetDensity(args);
                    r *= rho;
                }
                if (double.IsNaN(r))
                {
                    throw new NotFiniteNumberException();
                }
                return(r);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
Example #20
0
        /// <summary>
        /// Ctor
        /// </summary>
        /// <param name="SpatDim">Spatial dimension (either 2 or 3)</param>
        /// <param name="NumberOfReactants"></param>
        /// <param name="BcMap"></param>
        /// <param name="EoS">Null for multiphase. Has to be given for Low-Mach and combustion to calculate density.</param>
        /// <param name="idx">Index of scalar in array, </param>
        /// <param name="Argument">Variable name of the argument (e.g. "Temperature" or "MassFraction0")</param>
        public LinearizedScalarConvection2Jacobi(int SpatDim, int NumberOfReactants, IncompressibleBoundaryCondMap BcMap, MaterialLaw EoS, int idx)
        {
            this.NumberOfReactants = NumberOfReactants;
            m_SpatialDimension     = SpatDim;
            m_bcmap       = BcMap;
            argumentIndex = m_SpatialDimension + idx;

            velFunction = new Func <double[], double, double> [GridCommons.FIRST_PERIODIC_BC_TAG, SpatDim];

            for (int d = 0; d < SpatDim; d++)
            {
                velFunction.SetColumn(m_bcmap.bndFunction[VariableNames.Velocity_d(d)], d);
            }


            switch (BcMap.PhysMode)
            {
            case PhysicsMode.Multiphase:
                //this.Argument = VariableNames.LevelSet;
                m_ArgumentOrdering = new string[] { VariableNames.LevelSet };
                break;

            case PhysicsMode.LowMach:

                m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature);     // VelocityX,VelocityY,(VelocityZ), Temperature as variables.

                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            case PhysicsMode.MixtureFraction:
                ;
                m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.MixtureFraction);     // VelocityX,VelocityY,(VelocityZ), MixtureFraction as variables.

                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            case PhysicsMode.Combustion:
                m_ArgumentOrdering = ArrayTools.Cat(VariableNames.VelocityVector(SpatDim), VariableNames.Temperature, VariableNames.MassFractions(NumberOfReactants - 1));     // u,v,w,T, Y0,Y1,Y2,Y3  as variables (Y4 is calculated as Y4 = 1- (Y0+Y1+Y2+Y3)
                if (EoS == null)
                {
                    throw new ApplicationException("EoS has to be given for Low-Mach flows to calculate density.");
                }
                else
                {
                    this.EoS = EoS;
                }
                break;

            default:
                throw new NotImplementedException();
            }
        }
 /// <summary>
 /// Ctor for incompressible flows.
 /// </summary>
 /// <param name="component">component of the divergence</param>
 /// <param name="bcmap"></param>
 public Divergence_DerivativeSource_Flux(int component, IncompressibleBoundaryCondMap bcmap) //, double PresPenalty2) {
 {
     this.component   = component;
     this.bcmap       = bcmap;
     this.bndFunction = bcmap.bndFunction[VariableNames.Velocity_d(component)];
 }
Example #22
0
        /// <summary>
        /// Ctor.
        /// </summary>
        /// <param name="ReactionRateConstants">constants[0]=PreExpFactor, constants[1]=ActivationTemperature, constants[2]=MassFraction0Exponent, constants[3]=MassFraction1Exponent</param>
        /// <param name="StoichiometricCoefficients"></param>

        /// <param name="MolarMasses">Array of molar masses. 0 Fuel. 1 Oxidizer, 2 to ns products.</param>
        /// <param name="EoS">MaterialLawCombustion</param>
        /// <param name="NumberOfReactants">The number of reactants (i.e. ns)</param>
        /// <param name="SpeciesIndex">Index of the species being balanced. (I.e. 0 for fuel, 1 for oxidizer, 2 for CO2, 3 for water)</param>
        public ReactionSpeciesSourceJacobi(double[] ReactionRateConstants, double[] StoichiometricCoefficients, double[] MolarMasses, MaterialLawCombustion EoS, int NumberOfReactants, int SpeciesIndex, double TRef, double cpRef, bool VariableOneStepParameters)
        {
            m_ArgumentOrdering = ArrayTools.Cat(new string[] { VariableNames.Temperature }, VariableNames.MassFractions(NumberOfReactants - 1));// Y4 is not a variable!!!!;
            this.StoichiometricCoefficients = StoichiometricCoefficients;
            this.ReactionRateConstants      = ReactionRateConstants;
            this.SpeciesIndex = SpeciesIndex;
            this.MolarMasses  = MolarMasses;
            this.EoS          = EoS;
            this.m_Da         = ReactionRateConstants[0];
            this.TRef         = TRef;
            this.cpRef        = cpRef;
            this.VariableOneStepParameters = VariableOneStepParameters;
        }
Example #23
0
        /// <summary>
        /// flux at the boundary
        /// </summary>
        double BorderEdgeFlux(ref Foundation.CommonParamsBnd inp, double[] Uin)
        {
            IncompressibleBcType edgeType = m_bcmap.EdgeTag2Type[inp.EdgeTag];

            switch (edgeType)
            {
            case IncompressibleBcType.Wall: {
                if ((edgeType == IncompressibleBcType.Wall) && (m_bcmap.PhysMode == PhysicsMode.Multiphase))
                {
                    throw new ApplicationException("Use NoSlipNeumann boundary condition for multiphase flows instead of Wall.");
                }

                double r = 0.0;
                // Setup params
                // ============
                Foundation.CommonParams inp2;
                inp2.GridDat       = inp.GridDat;
                inp2.Normal        = inp.Normal;
                inp2.iEdge         = inp.iEdge;
                inp2.Parameters_IN = inp.Parameters_IN;
                inp2.X             = inp.X;
                inp2.time          = inp.time;
                inp2.jCellIn       = inp.jCellIn;
                inp2.jCellOut      = int.MinValue;

                // Boundary values for Parameters
                // ==============================
                inp2.Parameters_OUT = new double[inp.Parameters_IN.Length];

                // Dirichlet values for scalars and Velocities
                // ==========================
                double[] Uout = new double[Uin.Length];
                //Velocity
                for (int i = 0; i < m_SpatialDimension; i++)
                {
                    Uout[i] = m_bcmap.bndFunction[VariableNames.Velocity_d(i)][inp.EdgeTag](inp.X, inp.time);
                }

                switch (m_bcmap.PhysMode)
                {
                case PhysicsMode.MixtureFraction:
                    // opt1:
                    //inp2.Parameters_OUT = inp.Parameters_IN;
                    Uout[m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.MixtureFraction][inp.EdgeTag](inp.X, inp.time);
                    break;

                case PhysicsMode.LowMach: {
                    Uout[m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    break;
                }

                case PhysicsMode.Combustion: {
                    // opt1: (using Dirichlet values)
                    Uout[m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    for (int n = 1; n < NumberOfReactants - 1 + 1; n++)
                    {
                        //Using inner values for species
                        Uout[m_SpatialDimension + n] = Uin[m_SpatialDimension + n];
                    }
                    break;
                }

                case PhysicsMode.Multiphase:
                    break;

                default:
                    throw new NotImplementedException();
                }
                // Calculate BorderEdgeFlux as InnerEdgeFlux
                // =========================================

                r = InnerEdgeFlux(ref inp2, Uin, Uout);
                if (double.IsNaN(r))
                {
                    throw new NotFiniteNumberException();
                }
                return(r);
            }

            case IncompressibleBcType.Velocity_Inlet: {
                if ((edgeType == IncompressibleBcType.Wall) && (m_bcmap.PhysMode == PhysicsMode.Multiphase))
                {
                    throw new ApplicationException("Use NoSlipNeumann boundary condition for multiphase flows instead of Wall.");
                }

                double r = 0.0;

                // Setup params
                // ============
                Foundation.CommonParams inp2;
                inp2.GridDat       = inp.GridDat;
                inp2.Normal        = inp.Normal;
                inp2.iEdge         = inp.iEdge;
                inp2.Parameters_IN = inp.Parameters_IN;
                inp2.X             = inp.X;
                inp2.time          = inp.time;
                inp2.jCellIn       = inp.jCellIn;
                inp2.jCellOut      = int.MinValue;

                // Boundary values for Parameters
                // ==============================
                inp2.Parameters_OUT = new double[inp.Parameters_IN.Length];
                double[] Uout = new double[Uin.Length];

                // Velocity
                for (int j = 0; j < m_SpatialDimension; j++)
                {
                    // opt1:
                    Uout[j] = m_bcmap.bndFunction[VariableNames.Velocity_d(j)][inp.EdgeTag](inp.X, inp.time);
                }

                // Skalar (e.g. temperature or MassFraction)
                switch (m_bcmap.PhysMode)
                {
                case PhysicsMode.MixtureFraction: {
                    // opt1:
                    Uout[m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.MixtureFraction][inp.EdgeTag](inp.X, inp.time);
                    break;
                }

                case PhysicsMode.LowMach: {
                    // opt1:
                    Uout[m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    // opt2: inner values
                    //inp2.Parameters_OUT[2 * m_SpatialDimension] = inp2.Parameters_IN[2 * m_SpatialDimension];
                    break;
                }

                case PhysicsMode.Combustion: {
                    // opt1: (using Dirichlet values)
                    Uout[m_SpatialDimension] = m_bcmap.bndFunction[VariableNames.Temperature][inp.EdgeTag](inp.X, inp.time);
                    for (int n = 1; n < NumberOfReactants; n++)
                    {
                        // opt1: (using Dirichlet values)
                        Uout[m_SpatialDimension + n] = m_bcmap.bndFunction[VariableNames.MassFraction_n(n - 1)][inp.EdgeTag](inp.X, inp.time);
                    }
                    break;
                }

                case PhysicsMode.Multiphase:
                    break;

                default:
                    throw new NotImplementedException();
                }


                // Calculate BorderEdgeFlux as InnerEdgeFlux
                // =========================================
                r = InnerEdgeFlux(ref inp2, Uin, Uout);
                if (double.IsNaN(r))
                {
                    throw new NotFiniteNumberException();
                }
                return(r);
            }

            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.NoSlipNeumann: {
                double r = 0.0;
                double u1, u2, u3 = 0;

                u1 = Uin[0];
                u2 = Uin[1];

                r += Uin[argumentIndex] * (u1 * inp.Normal[0] + u2 * inp.Normal[1]);
                if (m_SpatialDimension == 3)
                {
                    u3 = Uin[2];
                    r += Uin[argumentIndex] * u3 * inp.Normal[2];
                }
                double rho = 1.0;
                switch (m_bcmap.PhysMode)
                {
                case PhysicsMode.Incompressible:
                    break;

                case PhysicsMode.MixtureFraction:
                    rho = EoS.getDensityFromZ(Uin[inp.D]);
                    break;

                case PhysicsMode.LowMach:
                    rho = EoS.GetDensity(Uin[argumentIndex]);
                    break;

                case PhysicsMode.Combustion:
                    double[] args = ArrayTools.GetSubVector(Uin, m_SpatialDimension, NumberOfReactants - 1 + 1);
                    rho = EoS.GetDensity(args);
                    break;

                default:
                    throw new NotImplementedException("not implemented physmode");
                }
                r *= rho;

                if (double.IsNaN(r))
                {
                    throw new NotFiniteNumberException();
                }
                return(r);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }