protected override double BorderEdgeFlux(ref CommonParamsBnd inp, double[] Uin)
        {
            double c = 0.0;

            for (int d = 0; d < m_SpatialDimension; d++)
            {
                c += inp.Parameters_IN[d] * inp.Normal[d];
            }

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

            switch (edgeType)
            {
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.Velocity_Inlet:  {
                double kinE_Diri = 0.0;
                for (int i = 0; i < m_SpatialDimension; i++)
                {
                    Func <double[], double, double> boundVel = this.VelFunction[inp.EdgeTag, i];
                    kinE_Diri += 0.5 * (boundVel(inp.X, inp.time) * boundVel(inp.X, inp.time));
                }
                return(c * rho * kinE_Diri);
            }

            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.Pressure_Dirichlet: {
                return(c * rho * Uin[0]);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
示例#2
0
        /// <summary>
        /// A central difference at Dirichlet boundary regions (<see cref="IncompressibleBcType.Pressure_Outlet"/>),
        /// an open end everywhere else.
        /// </summary>
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, double[] Uin)
        {
            IncompressibleBcType edgType = m_bcmap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Pressure_Outlet:
                // Atmospheric outlet/pressure outlet: inhom. Dirichlet
                // ++++++++++++++++++++++++++++++++++++++++++++++++++++
                return(pressureFunction[inp.EdgeTag](inp.X, inp.time) * inp.Normal[m_d]);

            case IncompressibleBcType.Outflow:
                throw new ArithmeticException("Tests on channel flow indicate that b.c. " + edgType + " is ill-posed, fk 25may16.");

            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.FreeSlip:
            case IncompressibleBcType.SlipSymmetry:
            case IncompressibleBcType.NavierSlip_Linear:
            case IncompressibleBcType.NoSlipNeumann:
                // hom. Neumann b.c.
                // +++++++++++++++++
                return(Uin[0] * inp.Normal[m_d]);

            default:
                throw new NotImplementedException();
            }
        }
示例#3
0
        /// <summary>
        /// flux at the boundary
        /// </summary>
        double BorderEdgeFlux(ref CommonParamsBnd inp, double[] Uin)
        {
            var _Uin = new Vector(Uin);

            Debug.Assert(inp.D == _Uin.Dim);

            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: {
                var _Uot = new Vector(inp.D);
                for (int d = 0; d < inp.D; d++)
                {
                    _Uot[d] = velFunction[inp.EdgeTag, d](inp.X, inp.time);
                }

                return((_Uot * inp.Normal) * _Uot[m_component] * m_rho);
            }

            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet: {
                return((_Uin * inp.Normal) * _Uin[m_component] * m_rho);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
示例#4
0
        protected override double BorderEdgeFlux(ref Foundation.CommonParamsBnd inp, double[] Uin)
        {
            IncompressibleBcType edgeType = bcmap.EdgeTag2Type[inp.EdgeTag];

            switch (edgeType)
            {
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.Velocity_Inlet: {
                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;

                // Boundary conditions scalar
                // ==========================

                inp2.Parameters_OUT = new double[2 * SpatDimension + 2];

                double ScalarOut = scalarFunction[inp.EdgeTag](inp.X, 0.0);
                inp2.Parameters_OUT[2 * SpatDimension] = scalarFunction[inp.EdgeTag](inp.X, inp.time);
                // ScalarMeanOut = ScalarMeanIn
                inp2.Parameters_OUT[2 * SpatDimension + 1] = inp.Parameters_IN[2 * SpatDimension + 1];

                // Boundary conditions velocity
                // ============================

                for (int j = 0; j < SpatDimension; j++)
                {
                    inp2.Parameters_OUT[j] = velFunction[inp.EdgeTag, j](inp.X, inp.time);
                    // VelocityMeanOut = VelocityMeanIn
                    inp2.Parameters_OUT[SpatDimension + j] = inp.Parameters_IN[SpatDimension + j];
                }

                return(InnerEdgeFlux(ref inp2, Uin, new double[] { ScalarOut }));
            }

            case IncompressibleBcType.Pressure_Outlet: {
                double r = 0.0;

                double Scalar0 = inp.Parameters_IN[2 * SpatDimension];
                double rho     = EoS.GetDensity(Scalar0);
                double Scalar  = Uin[0];

                for (int j = 0; j < SpatDimension; j++)
                {
                    double u_j = inp.Parameters_IN[j];
                    r += rho * Scalar * u_j * inp.Normale[j];
                }

                return(r);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
示例#5
0
        public double BoundaryEdgeForm(ref CommonParamsBnd inp, double[] Tin, double[,] Grad_Tin, double Vin, double[] Grad_Vin)
        {
            double res = 0;

            int jIn = inp.jCellIn;

            double h = inp.GridDat.iGeomCells.h_min[jIn];

            IncompressibleBcType edgType = m_BcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:


                // Atmospheric outlet/pressure outflow: hom. Neumann
                res += Tin[0] * inp.Normale[0];
                res += Tin[1] * inp.Normale[1];
                break;

            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:

                double VelocityX = VelFunction[inp.EdgeTag, 0](inp.X, inp.time);
                double VelocityY = VelFunction[inp.EdgeTag, 1](inp.X, inp.time);

                switch (Component)
                {
                case 0:
                    res += Tin[0] * inp.Normale[0];
                    res += Tin[1] * inp.Normale[1];
                    //alpha penalty for boundary (no beta penalty)
                    res += -pen2 / h * (Tin[2] - VelocityX);

                    break;

                case 1:
                    res += Tin[0] * inp.Normale[0];
                    res += Tin[1] * inp.Normale[1];
                    //alpha penalty for boundary (no beta penalty)
                    res += -pen2 / h * (Tin[2] - VelocityY);

                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            default:
                throw new NotImplementedException("unsupported/unknown b.c. - missing implementation;");
            }
            return(InverseReynolds * res * Vin);
        }
示例#6
0
        public double BoundaryEdgeForm(ref CommonParamsBnd inp, double[] Uin, double[,] GradUin, double Vin, double[] GradVin)
        {
            double res = 0;
            IncompressibleBcType edgType = m_BcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.Velocity_Inlet:

                res += Uin[0] * inp.Normale[0] * Vin;
                break;
            }
            return(res);
        }
示例#7
0
        public double BoundaryEdgeForm(ref CommonParamsBnd inp, double[] _uA, double[,] _Grad_uA, double _vA, double[] _Grad_vA)
        {
            double Acc = 0.0;

            double pnlty   = 2 * GetPenalty(inp.jCellIn, -1, inp.GridDat.Cells.cj);
            double lambdaA = EoS.GetViscosity(inp.Parameters_IN[0]);
            IncompressibleBcType edgType = BcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall: {
                // inhom. Dirichlet b.c.
                // =====================

                double T_D = TemperatureFunction[inp.EdgeTag](inp.X);
                for (int d = 0; d < inp.D; d++)
                {
                    double nd = inp.Normale[d];
                    Acc += (lambdaA * _Grad_uA[0, d]) * (_vA) * nd;
                    Acc += (lambdaA * _Grad_vA[d]) * (_uA[0] - T_D) * nd;
                }

                Acc -= lambdaA * (_uA[0] - T_D) * (_vA - 0) * pnlty;

                break;
            }

            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.NoSlipNeumann: {
                Acc = 0.0;
                break;
            }

            default:
                throw new NotSupportedException();
            }

            Acc *= 1.0 / (Reynolds * Prandtl);

            return(-Acc);
        }
        protected override bool IsDirichlet(ref BoSSS.Foundation.CommonParamsBnd inp)
        {
            IncompressibleBcType edgType = m_BcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.Outflow:
                return(true);

            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann:
                return(false);

            default:
                throw new NotImplementedException("unsupported/unknown b.c. - missing implementation;");
            }
        }
示例#9
0
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, Double[] Uin)
        {
            double[] Vel_IN   = inp.Parameters_IN.GetSubVector(0, m_D);
            double   Press_IN = inp.Parameters_IN[m_D];

            double acc = 0;

            IncompressibleBcType edgType = m_bcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Wall: {
                //for (int d = 0; d < m_D; d++) {
                //    acc -= Press_IN * Vel_IN[d] * inp.Normale[d];
                //}
                break;
            }

            case IncompressibleBcType.Velocity_Inlet: {
                for (int d = 0; d < m_D; d++)
                {
                    double VelD = VelocFunction[inp.EdgeTag, d](inp.X, inp.time);
                    acc -= Press_IN * VelD * inp.Normal[d];
                }
                break;
            }

            case IncompressibleBcType.Pressure_Outlet: {
                double pD = PressFunction[inp.EdgeTag](inp.X, inp.time);
                for (int d = 0; d < m_D; d++)
                {
                    acc -= pD * Vel_IN[d] * inp.Normal[d];
                }
                break;
            }

            default: {
                throw new NotImplementedException("ToDo");
            }
            }

            return(-acc);
        }
        /// <summary>
        ///
        /// </summary>
        protected override void BorderEdgeFlux_(ref CommonParamsBnd inp, double[] Uin, out double FluxInCell)
        {
            IncompressibleBcType edgeType = bcmap.EdgeTag2Type[inp.EdgeTag];

            switch (edgeType)
            {
            case IncompressibleBcType.Outflow:
                throw new ArithmeticException("Tests on channel flow indicate that b.c. " + edgeType + " is ill-posed, fk 25may16.");

            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Pressure_Outlet:
            {
                FluxInCell = 0.0;
                break;
            }

            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.NavierSlip_Linear: {
                double u_j_In  = Uin[0];
                double u_j_Out = this.bndFunction[inp.EdgeTag](inp.X, inp.time);

                FluxInCell = -(u_j_In - u_j_Out) * inp.Normal[component];
                break;
            }

            case IncompressibleBcType.Wall:
            case IncompressibleBcType.FreeSlip:
            case IncompressibleBcType.SlipSymmetry:
            case IncompressibleBcType.NoSlipNeumann:
            {
                double u_j_In = Uin[0];
                FluxInCell = -u_j_In * inp.Normal[component];
                break;
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
示例#11
0
        /// <summary>
        /// A central difference at Dirichlet boundary regions (<see cref="IncompressibleBcType.Pressure_Outlet"/>),
        /// an open end everywhere else.
        /// </summary>
        protected override double BorderEdgeFlux(double time, double[] x, double[] normal, byte EdgeTag, double[] Uin, int jEdge)
        {
            IncompressibleBcType edgType = m_bcmap.EdgeTag2Type[EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Pressure_Outlet:
                // Atmospheric outlet/pressure outlet: inhom. Dirichlet
                // ++++++++++++++++++++++++++++++++++++++++++++++++++++
                return(pressureFunction[EdgeTag](x, 0) * normal[m_d]);

            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:
                // inhom. Neumann b.c.
                // +++++++++++++++++++
                return(Uin[0] * normal[m_d]);

            default:
                throw new NotImplementedException();
            }
        }
示例#12
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);
        }
示例#13
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);
        }
示例#14
0
        public override double BoundaryEdgeForm(ref Foundation.CommonParamsBnd inp, double[] _uA, double[,] _Grad_uA, double _vA, double[] _Grad_vA)
        {
            double Acc = 0.0;

            double pnlty = 2 * this.penalty(inp.jCellIn, -1);//, inp.GridDat.Cells.cj);
            double muA   = this.Viscosity(inp.Parameters_IN);
            IncompressibleBcType edgType = base.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann: {
                // inhom. Dirichlet b.c.
                // +++++++++++++++++++++
                double g_D = this.g_Diri(inp.X, inp.time, inp.EdgeTag, base.m_iComp);

                for (int i = 0; i < inp.D; i++)
                {
                    // consistency
                    Acc += (muA * _Grad_uA[i, m_iComp]) * (_vA) * inp.Normale[i];
                    // symmetry
                    switch (ViscSolverMode)
                    {
                    case ViscositySolverMode.FullyCoupled:
                        Acc += (muA * _Grad_vA[i]) * (_uA[i] - this.g_Diri(inp.X, inp.time, inp.EdgeTag, i)) * inp.Normale[m_iComp];
                        break;

                    case ViscositySolverMode.Segregated:
                        if (i == m_iComp)
                        {
                            Acc += (muA * _Grad_vA[i]) * (_uA[i] - this.g_Diri(inp.X, inp.time, inp.EdgeTag, i)) * inp.Normale[m_iComp];
                        }
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
                Acc *= base.m_alpha;

                // penalty
                Acc -= muA * (_uA[m_iComp] - this.g_Diri(inp.X, inp.time, inp.EdgeTag, base.m_iComp)) * (_vA - 0) * pnlty;

                break;
            }

            case IncompressibleBcType.FreeSlip:
            case IncompressibleBcType.SlipSymmetry: {
                int    D = inp.D;
                double g_D;

                for (int dN = 0; dN < D; dN++)
                {
                    for (int dD = 0; dD < D; dD++)
                    {
                        // consistency
                        Acc += muA * (inp.Normale[dN] * _Grad_uA[dD, dN] * inp.Normale[dD]) * (_vA * inp.Normale[m_iComp]) * base.m_alpha;
                        // symmetry
                        switch (ViscSolverMode)
                        {
                        case ViscositySolverMode.FullyCoupled:
                            g_D  = this.g_Diri(inp.X, inp.time, inp.EdgeTag, dD);
                            Acc += muA * (inp.Normale[dN] * _Grad_vA[dN] * inp.Normale[m_iComp]) * (_uA[dD] - g_D) * inp.Normale[dD] * base.m_alpha;
                            break;

                        case ViscositySolverMode.Segregated:
                        default:
                            throw new NotImplementedException();
                        }
                    }
                    g_D = this.g_Diri(inp.X, inp.time, inp.EdgeTag, dN);
                    // penalty
                    Acc -= muA * ((_uA[dN] - g_D) * inp.Normale[dN]) * ((_vA - 0) * inp.Normale[m_iComp]) * pnlty;
                }

                break;
            }

            case IncompressibleBcType.NavierSlip_Linear: {
                double ls = Lslip[inp.jCellIn];
                if (ls == 0.0)
                {
                    goto case IncompressibleBcType.Velocity_Inlet;
                }
                else
                {
                    goto case IncompressibleBcType.FreeSlip;
                }
            }
            //case IncompressibleBcType.NavierSlip_localized: {

            //        double ls = Lslip[inp.jCellIn];
            //        if(ls > 0.0) {
            //            m_beta = muA / ls;
            //            goto case IncompressibleBcType.NavierSlip_Linear;
            //        } else {
            //            goto case IncompressibleBcType.Velocity_Inlet;
            //        }
            //    }
            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet: {
                if (base.g_Neu_Override == null)
                {
                    // Inner values of velocity gradient are taken, i.e.
                    // no boundary condition for the velocity (resp. velocity gradient) is imposed.
                    for (int i = 0; i < inp.D; i++)
                    {
                        Acc += (muA * _Grad_uA[i, m_iComp]) * (_vA) * inp.Normale[i];
                    }
                }
                else
                {
                    double g_N = g_Neu(inp.X, inp.Normale, inp.EdgeTag);
                    Acc += muA * g_N * _vA;
                }
                Acc *= base.m_alpha;

                break;
            }

            default:
                throw new NotSupportedException();
            }

            return(-Acc);
        }
示例#15
0
        public override double BoundaryEdgeForm(ref Foundation.CommonParamsBnd inp, double[] _uA, double[,] _Grad_uA, double _vA, double[] _Grad_vA)
        {
            double Acc = 0.0;

            double pnlty = 2 * this.penalty(inp.jCellIn, -1);//, inp.GridDat.Cells.cj);
            double muA   = this.Viscosity(inp.Parameters_IN);
            IncompressibleBcType edgType = base.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann: {
                // inhom. Dirichlet b.c.
                // +++++++++++++++++++++

                double g_D = base.g_Diri(inp.X, inp.time, inp.EdgeTag, m_iComp);

                for (int d = 0; d < inp.D; d++)
                {
                    double nd = inp.Normale[d];
                    //Acc += (muA * _Grad_uA[0, d]) * (_vA) * nd;
                    //Acc += (muA * _Grad_vA[d]) * (_uA[0] - g_D) * nd;
                    Acc += (muA * _Grad_uA[m_iComp, d]) * (_vA) * nd;
                    Acc += (muA * _Grad_vA[d]) * (_uA[m_iComp] - g_D) * nd;
                }
                Acc *= base.m_alpha;

                //Acc -= muA * (_uA[0] - g_D) * (_vA - 0) * pnlty;
                Acc -= muA * (_uA[m_iComp] - g_D) * (_vA - 0) * pnlty;
                break;
            }

            case IncompressibleBcType.FreeSlip:
            case IncompressibleBcType.SlipSymmetry: {
                int    D = inp.D;
                double g_D;

                for (int dN = 0; dN < D; dN++)
                {
                    g_D = base.g_Diri(inp.X, inp.time, inp.EdgeTag, dN);

                    for (int dD = 0; dD < D; dD++)
                    {
                        // consistency
                        Acc += muA * (inp.Normale[dN] * _Grad_uA[dN, dD] * inp.Normale[dD]) * (_vA * inp.Normale[m_iComp]) * base.m_alpha;
                        // symmetry
                        Acc += muA * (inp.Normale[m_iComp] * _Grad_vA[dD] * inp.Normale[dD]) * (_uA[dN] - g_D) * inp.Normale[dN] * base.m_alpha;
                    }

                    // penalty
                    Acc -= muA * ((_uA[dN] - g_D) * inp.Normale[dN]) * ((_vA - 0) * inp.Normale[m_iComp]) * pnlty;
                }
                break;
            }

            case IncompressibleBcType.NavierSlip_Linear: {
                double ls = Lslip[inp.jCellIn];
                if (ls == 0.0)
                {
                    goto case IncompressibleBcType.Velocity_Inlet;
                }

                if (ls > 0)
                {
                    m_beta = muA / ls;
                }

                int    D = inp.D;
                double g_D;

                for (int dN = 0; dN < D; dN++)
                {
                    g_D = base.g_Diri(inp.X, inp.time, inp.EdgeTag, dN);

                    for (int dD = 0; dD < D; dD++)
                    {
                        // consistency
                        Acc += muA * (inp.Normale[dN] * _Grad_uA[dN, dD] * inp.Normale[dD]) * (_vA * inp.Normale[m_iComp]) * base.m_alpha;
                        // symmetry
                        Acc += muA * (inp.Normale[m_iComp] * _Grad_vA[dD] * inp.Normale[dD]) * (_uA[dN] - g_D) * inp.Normale[dN] * base.m_alpha;
                    }

                    // penalty
                    Acc -= muA * ((_uA[dN] - g_D) * inp.Normale[dN]) * ((_vA - 0) * inp.Normale[m_iComp]) * pnlty;
                }


                double[,] P = new double[D, D];
                for (int d1 = 0; d1 < D; d1++)
                {
                    for (int d2 = 0; d2 < D; d2++)
                    {
                        double nn = inp.Normale[d1] * inp.Normale[d2];
                        if (d1 == d2)
                        {
                            P[d1, d2] = 1 - nn;
                        }
                        else
                        {
                            P[d1, d2] = -nn;
                        }
                    }
                }

                // tangential dissipation force term
                for (int d1 = 0; d1 < D; d1++)
                {
                    for (int d2 = 0; d2 < D; d2++)
                    {
                        g_D  = base.g_Diri(inp.X, inp.time, inp.EdgeTag, d2);
                        Acc -= (m_beta * P[d1, d2] * (_uA[d2] - g_D)) * (P[d1, m_iComp] * _vA) * base.m_alpha;
                    }
                }

                break;
            }
            //case IncompressibleBcType.NavierSlip_localized: {

            //    double ls = Lslip[inp.jCellIn];
            //    if(ls > 0.0) {
            //        m_beta = muA / ls;
            //        goto case IncompressibleBcType.NavierSlip_Linear;
            //    } else {
            //        goto case IncompressibleBcType.Velocity_Inlet;
            //    }
            //}
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet: {
                // Atmospheric outlet/pressure outflow: hom. Neumann
                // +++++++++++++++++++++++++++++++++++++++++++++++++
                double g_N = g_Neu(inp.X, inp.Normale, inp.EdgeTag);

                Acc += muA * g_N * _vA * base.m_alpha;

                break;
            }

            case IncompressibleBcType.Pressure_Dirichlet: {
                // Dirichlet boundary condition for pressure.
                // Inner values of velocity gradient are taken, i.e.
                // no boundary condition for the velocity (resp. velocity gradient) is imposed.

                for (int d = 0; d < inp.D; d++)
                {
                    //Acc += (muA * _Grad_uA[0, d]) * (_vA) * inp.Normale[d];
                    Acc += (muA * _Grad_uA[m_iComp, d]) * (_vA) * inp.Normale[d];
                }
                Acc *= base.m_alpha;

                break;
            }

            default:
                throw new NotImplementedException();
            }

            return(-Acc);
        }
示例#16
0
        public override double BoundaryEdgeForm(ref Foundation.CommonParamsBnd inp, double[] _uA, double[,] _Grad_uA, double _vA, double[] _Grad_vA)
        {
            double Acc = 0.0;

            double pnlty = 2 * this.penalty(inp.jCellIn, -1);//, inp.GridDat.Cells.cj);
            double muA   = this.Viscosity(inp.Parameters_IN);
            IncompressibleBcType edgType = base.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann: {
                // inhom. Dirichlet b.c.
                // +++++++++++++++++++++
                double g_D = this.g_Diri(inp.X, inp.time, inp.EdgeTag, base.m_iComp);

                for (int i = 0; i < inp.D; i++)
                {
                    // consistency
                    Acc += (muA * _Grad_uA[i, i]) * (_vA) * inp.Normale[m_iComp];
                    // symmetry
                    switch (ViscSolverMode)
                    {
                    case ViscositySolverMode.FullyCoupled:
                        Acc += (muA * _Grad_vA[m_iComp]) * (_uA[i] - this.g_Diri(inp.X, inp.time, inp.EdgeTag, i)) * inp.Normale[i];
                        break;

                    case ViscositySolverMode.Segregated:
                        if (i == m_iComp)
                        {
                            Acc += (muA * _Grad_vA[m_iComp]) * (_uA[i] - this.g_Diri(inp.X, inp.time, inp.EdgeTag, i)) * inp.Normale[i];
                        }
                        break;

                    default:
                        throw new NotImplementedException();
                    }
                }
                Acc *= base.m_alpha;

                // penalty
                Acc -= muA * (_uA[m_iComp] - this.g_Diri(inp.X, inp.time, inp.EdgeTag, base.m_iComp)) * (_vA - 0) * pnlty;

                break;
            }

            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet: {
                if (base.g_Neu_Override == null)
                {
                    // Inner values of velocity gradient are taken, i.e.
                    // no boundary condition for the velocity (resp. velocity gradient) is imposed.
                    for (int i = 0; i < inp.D; i++)
                    {
                        Acc += (muA * _Grad_uA[i, i]) * (_vA) * inp.Normale[m_iComp];
                    }
                }
                else
                {
                    double g_N = g_Neu(inp.X, inp.Normale, inp.EdgeTag);
                    Acc += muA * g_N * _vA;
                }
                Acc *= base.m_alpha;

                break;
            }

            default:
                throw new NotSupportedException();
            }

            return(Acc * (2.0 / 3.0));
        }
示例#17
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:
            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;

                // Dirichlet value for scalar
                // ==========================
                double Uout = scalarFunction[inp.EdgeTag](inp.X, inp.time);

                // 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] = velFunction[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;
                }

                // Temperature
                switch (m_bcmap.PhysMode)
                {
                case PhysicsMode.LowMach: {
                    // opt1:
                    inp2.Parameters_OUT[2 * m_SpatialDimension] = scalarFunction[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.Multiphase:
                case PhysicsMode.RANS:
                    break;

                default:
                    throw new NotImplementedException();
                }

                // 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:
            case IncompressibleBcType.NoSlipNeumann: {
                double r = 0.0;
                double u1, u2, u3 = 0, phi;

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

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

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

                return(r);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
示例#18
0
        /// <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!");
            }
        }
示例#19
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!");
            }
        }
示例#20
0
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, double[] Uin)
        {
            //double flux;

            //double U_dot_Normal = 0;
            //for (int d = D - 1; d >= 0; d--) {
            //    U_dot_Normal += (inp.Parameters_IN[d] * inp.Normale[d]);
            //}
            //flux = Uin[0] * U_dot_Normal;

            //return flux;



            double flux;
            var    normal  = inp.Normale;
            var    EdgeTag = inp.EdgeTag;
            var    x       = inp.X;

            IncompressibleBcType edgeType = BcMap.EdgeTag2Type[EdgeTag];

            double U_dot_Normal = 0;

            //for (int d = D - 1; d >= 0; d--) {
            //    U_dot_Normal += (inp.Parameters_IN[d] * normal[d]);
            //}

            //if (U_dot_Normal >= 0) {
            //    // flux is 'going out of this cell'
            //    flux = Uin[0] * U_dot_Normal;
            //}
            //else {
            //    // flux is 'coming into this cell'
            //    flux = Uin[0] * U_dot_Normal; // original
            //}

            switch (edgeType)
            {
            case IncompressibleBcType.Wall:
                flux = 0.0;
                break;

            case IncompressibleBcType.Velocity_Inlet:

                double Umean_dot_Normal = 0;
                for (int d = D - 1; d >= 0; d--)
                {
                    Umean_dot_Normal += inp.Parameters_IN[D + d] * normal[d];
                }

                flux = 0;
                if (Umean_dot_Normal >= 0)
                {
                    for (int d = D - 1; d >= 0; d--)
                    {
                        flux += inp.Parameters_IN[d] * normal[d];
                    }
                    flux *= Uin[0];
                }
                else
                {
                    for (int d = D - 1; d >= 0; d--)
                    {
                        flux += inp.Parameters_IN[d] * normal[d];
                    }
                    flux *= LevelSetFunction[EdgeTag](x, 0);
                }
                //for (int d = D - 1; d >= 0; d--) {
                //    U_dot_Normal += (VelFunction[EdgeTag, d](x) * normal[d]);
                //}
                //flux = LevelSetFunction[EdgeTag](x) * U_dot_Normal;
                break;

            case IncompressibleBcType.Outflow:
                for (int d = D - 1; d >= 0; d--)
                {
                    U_dot_Normal += (inp.Parameters_IN[d] * normal[d]);
                }
                flux = Uin[0] * U_dot_Normal;
                break;

            case IncompressibleBcType.Pressure_Outlet:
                // In some bad cases this might cause similar stability problems as the inflow without a BC
                // Probably Dirichlet BC's are more suitable here
                for (int d = D - 1; d >= 0; d--)
                {
                    U_dot_Normal += (inp.Parameters_IN[d] * normal[d]);
                }
                flux = Uin[0] * U_dot_Normal;
                break;

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


            return(flux);
        }
示例#21
0
        /// <summary>
        /// Stress divergence border edge term
        /// </summary>
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, double[] Tin)
        {
            double res = 0;

            int jIn = inp.jCellIn;

            double h = inp.GridDat.iGeomCells.h_min[jIn];

            IncompressibleBcType edgType = m_BcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:


                // Atmospheric outlet/pressure outflow: hom. Neumann
                res += Tin[0] * inp.Normal[0];
                res += Tin[1] * inp.Normal[1];
                break;

            case IncompressibleBcType.FreeSlip:

                //Free slip wall for symmetry line of symmetric channel

                //double VelocityX2 = VelFunction[inp.EdgeTag, 0](inp.X, inp.time);
                //double VelocityY2 = VelFunction[inp.EdgeTag, 1](inp.X, inp.time);

                switch (Component)
                {
                case 0:
                    res += inp.Normal[0] * Tin[0] * inp.Normal[0] * inp.Normal[0];
                    res += inp.Normal[0] * Tin[1] * inp.Normal[1] * inp.Normal[0];
                    res += inp.Normal[0] * Tin[1] * inp.Normal[0] * inp.Normal[1];
                    res += inp.Normal[0] * Tin[3] * inp.Normal[1] * inp.Normal[1];
                    //res += -pen2 / h * (Tin[2] - VelocityX2) * inp.Normale[0] - pen2 / h * (Tin[2] - VelocityX2) * inp.Normale[1];
                    //res += 0;

                    break;

                case 1:
                    res += inp.Normal[1] * Tin[3] * inp.Normal[0] * inp.Normal[0];
                    res += inp.Normal[1] * Tin[0] * inp.Normal[1] * inp.Normal[0];
                    res += inp.Normal[1] * Tin[0] * inp.Normal[0] * inp.Normal[1];
                    res += inp.Normal[1] * Tin[1] * inp.Normal[1] * inp.Normal[1];
                    //res += -pen2 / h * (Tin[2] - VelocityY2) * inp.Normale[0] - pen2 / h * (Tin[2] - VelocityY2) * inp.Normale[1];
                    //res += Tin[1] * inp.Normale[1];
                    //res += 0;

                    break;

                default:
                    throw new NotImplementedException();
                }

                break;

            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:

                double VelocityX = VelFunction[inp.EdgeTag, 0](inp.X, inp.time);
                double VelocityY = VelFunction[inp.EdgeTag, 1](inp.X, inp.time);

                switch (Component)
                {
                case 0:
                    res += Tin[0] * inp.Normal[0];
                    res += Tin[1] * inp.Normal[1];
                    //alpha penalty for boundary (no beta penalty)
                    res += -pen2 / h * (Tin[2] - VelocityX);

                    break;

                case 1:
                    res += Tin[0] * inp.Normal[0];
                    res += Tin[1] * inp.Normal[1];
                    //alpha penalty for boundary (no beta penalty)
                    res += -pen2 / h * (Tin[2] - VelocityY);

                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            default:
                throw new NotImplementedException("unsupported/unknown b.c. - missing implementation;");
            }
            return(InverseReynolds * res);
        }
示例#22
0
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, Double[] Uin)
        {
            double[] Vel_IN = inp.Parameters_IN.GetSubVector(0, m_D);
            double[,] GradVel_IN = VelocityGradient(inp.Parameters_IN.GetSubVector(m_D, m_D), inp.Parameters_IN.GetSubVector(2 * m_D, m_D));
            //double Press_IN = inp.Parameters_IN[3 * m_D];

            double acc = 0;

            IncompressibleBcType edgType = m_bcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Wall: {
                //for (int d = 0; d < m_D; d++) {
                //    //acc -= Press_IN * Vel_IN[d] * inp.Normale[d];
                //    for (int dd = 0; dd < m_D; dd++) {
                //        acc += mu * (GradVel_IN[d, dd] * Vel_IN[dd]) * inp.Normale[d];
                //        //acc += mu * (GradVel_IN[dd, d] * Vel_IN[dd]) * inp.Normale[d];  // transposed term
                //    }
                //}
                break;
            }

            case IncompressibleBcType.Velocity_Inlet: {
                for (int d = 0; d < m_D; d++)
                {
                    //acc -= Press_IN * Vel_IN[d] * inp.Normale[d];
                    for (int dd = 0; dd < m_D; dd++)
                    {
                        double VelD = VelFunction[inp.EdgeTag, dd](inp.X, inp.time);
                        acc += mu * (GradVel_IN[d, dd] * VelD) * inp.Normal[d];
                        if (transposedTerm)
                        {
                            acc += mu * (GradVel_IN[dd, d] * VelD) * inp.Normal[d];          // transposed term
                        }
                    }
                }
                break;
            }

            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.Pressure_Dirichlet: {
                for (int d = 0; d < m_D; d++)
                {
                    //acc -= Press_IN * Vel_IN[d] * inp.Normale[d];
                    for (int dd = 0; dd < m_D; dd++)
                    {
                        acc += mu * (GradVel_IN[d, dd] * Vel_IN[dd]) * inp.Normal[d];
                        if (transposedTerm)
                        {
                            acc += mu * (GradVel_IN[dd, d] * Vel_IN[dd]) * inp.Normal[d];          // transposed term
                        }
                    }
                }
                break;
            }

            default: {
                throw new NotImplementedException("ToDo");
            }
            }

            return(-acc);
        }
示例#23
0
        //__________________________________________________________________________________________________________________

        public double BoundaryEdgeForm(ref CommonParamsBnd inp, double[] Tin, double[,] GradTin, double Vin, double[] GradVin)
        {
            double res = 0;
            IncompressibleBcType edgType = m_BcMap.EdgeTag2Type[inp.EdgeTag];
            double u = inp.Parameters_IN[0];
            double v = inp.Parameters_IN[1];

            switch (edgType)
            {
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.Wall:

                // Atmospheric outlet/pressure outflow: hom. Neumann

                res += u * Tin[0] * inp.Normale[0];
                res += v * Tin[0] * inp.Normale[1];
                res *= m_Weissenberg;
                break;


            case IncompressibleBcType.Velocity_Inlet:

                // 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;

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

                // Outer values for Velocity and VelocityMean
                Debug.Assert(inp.Normale.Length == 2);
                for (int j = 0; j < 2; 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[Component + j] = 0.0;
                }

                //Dirichlet value for Stresses
                //============================

                switch (Component)
                {
                case 0:
                    double StressXX = StressFunction[inp.EdgeTag, 0](inp.X, inp.time);
                    res += InnerEdgeForm(ref inp2, Tin, new double[] { StressXX }, GradTin, GradTin, Vin, 0, GradVin, GradVin);
                    //res += InnerEdgeForm(ref inp2, Tin, Tin, GradTin, GradTin, Vin, 0, GradVin, GradVin);
                    break;

                case 1:
                    double StressXY = StressFunction[inp.EdgeTag, 1](inp.X, inp.time);
                    res += InnerEdgeForm(ref inp2, Tin, new double[] { StressXY }, GradTin, GradTin, Vin, 0, GradVin, GradVin);
                    //res += InnerEdgeForm(ref inp2, Tin, Tin, GradTin, GradTin, Vin, 0, GradVin, GradVin);
                    break;

                case 2:
                    double StressYY = StressFunction[inp.EdgeTag, 2](inp.X, inp.time);
                    res += InnerEdgeForm(ref inp2, Tin, new double[] { StressYY }, GradTin, GradTin, Vin, 0, GradVin, GradVin);
                    //res += InnerEdgeForm(ref inp2, Tin, Tin, GradTin, GradTin, Vin, 0, GradVin, GradVin);
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            default:
                throw new NotImplementedException("unsupported/unknown b.c. - missing implementation;");
            }

            return(res);
        }
示例#24
0
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, Double[] Uin)
        {
            IncompressibleBcType edgeType = m_bcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgeType)
            {
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.Velocity_Inlet: {
                double r = 0.0;

                // Setup params
                // ============
                CommonParams inp2 = new CommonParams();;
                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;

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


                // Dirichlet value for scalar (kinetic energy)
                double kinE_Diri = 0.0;
                for (int i = 0; i < m_SpatialDimension; i++)
                {
                    Func <double[], double, double> boundVel = this.VelFunction[inp.EdgeTag, i];
                    kinE_Diri += boundVel(inp.X, inp.time) * boundVel(inp.X, inp.time);
                }

                double Uout = kinE_Diri / 2.0;


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

                    // VelocityMeanOut = VelocityMeanIn
                    inp2.Parameters_OUT[m_SpatialDimension + j] = inp.Parameters_IN[m_SpatialDimension + j];
                }

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

                return(r);
            }

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

                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.Normal[0] + u2 * inp.Normal[1]);
                if (m_SpatialDimension == 3)
                {
                    r += u_d * u3 * inp.Normal[2];
                }

                return(r);
            }

            default:
                throw new NotImplementedException("Boundary condition not implemented!");
            }
        }
        public override double BoundaryEdgeForm(ref BoSSS.Foundation.CommonParamsBnd inp, double[] _uA, double[,] _Grad_uA, double _vA, double[] _Grad_vA)
        {
            double Acc = 0.0;

            double pnlty = 2 * this.penalty(inp.GridDat, inp.jCellIn, -1, inp.iEdge);//, inp.GridDat.Cells.cj);
            double muA   = this.Viscosity(inp.Parameters_IN);
            IncompressibleBcType edgType = base.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:
            case IncompressibleBcType.NoSlipNeumann: {
                // inhom. Dirichlet b.c.
                // +++++++++++++++++++++

                double g_D = base.g_Diri(inp.X, inp.time, inp.EdgeTag, m_iComp);
                //switch (base.m_implMode) {
                //    case ViscosityImplementation.H:
                //    case ViscosityImplementation.SWIP: {
                for (int d = 0; d < inp.D; d++)
                {
                    double nd = inp.Normal[d];
                    Acc += (muA * _Grad_uA[0, d]) * (_vA) * nd;
                    Acc += (muA * _Grad_vA[d]) * (_uA[0] - g_D) * nd;
                    //Acc += (muA * _Grad_uA[m_iComp, d]) * (_vA) * nd;
                    //Acc += (muA * _Grad_vA[d]) * (_uA[m_iComp] - g_D) * nd;
                }
                Acc *= base.m_alpha;

                Acc -= muA * (_uA[0] - g_D) * (_vA - 0) * pnlty;
                //Acc -= muA * (_uA[m_iComp] - g_D) * (_vA - 0) * pnlty;
                //            break;
                //        }
                //    default:
                //        throw new NotImplementedException();

                //}
                break;
            }

            case IncompressibleBcType.FreeSlip: {
                //switch (base.m_implMode) {
                //    case ViscosityImplementation.H:
                //    case ViscosityImplementation.SWIP: {
                // consistency
                for (int d = 0; d < inp.D; d++)
                {
                    Acc += (inp.Normal[m_iComp] * muA * _Grad_uA[0, d] * inp.Normal[d]) * (_vA * inp.Normal[m_iComp]) * base.m_alpha;
                }

                // penalty
                Acc -= muA * (_uA[0] - 0) * inp.Normal[m_iComp] * inp.Normal[m_iComp] * (_vA - 0) * pnlty;

                break;
                //    }
                //    default:
                //        throw new NotImplementedException();
                //}
                //break;
            }

            case IncompressibleBcType.NavierSlip_Linear: {
                double[,] P = new double[inp.D, inp.D];
                for (int d1 = 0; d1 < inp.D; d1++)
                {
                    for (int d2 = 0; d2 < inp.D; d2++)
                    {
                        double nn = inp.Normal[d1] * inp.Normal[d2];
                        if (d1 == d2)
                        {
                            P[d1, d2] = 1 - nn;
                        }
                        else
                        {
                            P[d1, d2] = -nn;
                        }
                    }
                }

                double g_D = base.g_Diri(inp.X, inp.time, inp.EdgeTag, m_iComp);
                //switch (base.m_implMode) {
                //    case ViscosityImplementation.H:
                //    case ViscosityImplementation.SWIP: {
                for (int d = 0; d < inp.D; d++)
                {
                    // consistency
                    Acc += muA * (inp.Normal[m_iComp] * _Grad_uA[0, d] * inp.Normal[d]) * (_vA * inp.Normal[m_iComp]);
                    // symmetry
                    Acc += muA * (inp.Normal[m_iComp] * _Grad_vA[d] * inp.Normal[d]) * (_uA[0] - g_D) * inp.Normal[m_iComp];
                }
                Acc *= base.m_alpha;
                // penalty
                Acc -= muA * ((_uA[0] - g_D) * inp.Normal[m_iComp]) * ((_vA - 0) * inp.Normal[m_iComp]) * pnlty;

                // tangential dissipation force term
                Acc -= (m_beta * P[0, m_iComp] * (_uA[0] - g_D)) * (P[0, m_iComp] * _vA) * base.m_alpha;

                //for (int d = 0; d < inp.D; d++) {
                //    // no-penetration term
                //    Acc += (inp.Normale[m_iComp] * muA * _Grad_uA[0, d] * inp.Normale[d]) * (_vA * inp.Normale[m_iComp]) * base.m_alpha;
                //    // tangential dissipation force term
                //    Acc -= (m_beta * P[0, d] * (_uA[0] - g_D)) * (P[0, d] * _vA) * base.m_alpha;
                //}
                //        break;
                //    }
                //default:
                //    throw new NotImplementedException();
                //}
                break;
            }

            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet: {
                // Atmospheric outlet/pressure outflow: hom. Neumann
                // +++++++++++++++++++++++++++++++++++++++++++++++++
                double g_N = g_Neu(inp.X, inp.Normal, inp.EdgeTag);
                //switch (base.m_implMode) {
                //    case ViscosityImplementation.H:
                //    case ViscosityImplementation.SWIP: {
                Acc += muA * g_N * _vA * base.m_alpha;
                break;
                //        }

                //    default:
                //        throw new NotImplementedException();

                //}

                //break;
            }

            case IncompressibleBcType.Pressure_Dirichlet: {
                // Dirichlet boundary condition for pressure.
                // Inner values of velocity gradient are taken, i.e.
                // no boundary condition for the velocity (resp. velocity gradient) is imposed.
                //switch (base.m_implMode) {
                //    case ViscosityImplementation.H:
                //    case ViscosityImplementation.SWIP: {
                for (int d = 0; d < inp.D; d++)
                {
                    Acc += (muA * _Grad_uA[0, d]) * (_vA) * inp.Normal[d];
                    //Acc += (muA * _Grad_uA[m_iComp, d]) * (_vA) * inp.Normale[d];
                }
                Acc *= base.m_alpha;
                //          break;
                //        }
                //    default:
                //        throw new NotImplementedException();
                //}
                break;
            }

            default:
                throw new NotImplementedException();
            }

            return(-Acc);
        }
示例#26
0
        public double BoundaryEdgeForm(ref CommonParamsBnd inp, double[] Uin, double[,] _Grad_uA, double Vin, double[] _Grad_vA)
        {
            double res = 0;
            IncompressibleBcType edgType = m_BcMap.EdgeTag2Type[inp.EdgeTag];

            double n1 = 0;
            double n2 = 0;

            double Vel1 = 0;
            double Vel2 = 0;

            double VelocityX = VelFunction[inp.EdgeTag, 0](inp.X, inp.time);
            double VelocityY = VelFunction[inp.EdgeTag, 1](inp.X, inp.time);

            switch (Component)
            {
            case 0:
                n1   = inp.Normale[0];
                n2   = inp.Normale[0];
                Vel1 = VelocityX;
                Vel2 = VelocityX;
                break;

            case 1:
                n1   = inp.Normale[1];
                n2   = inp.Normale[0];
                Vel1 = VelocityX;
                Vel2 = VelocityY;
                break;

            case 2:
                n1   = inp.Normale[1];
                n2   = inp.Normale[1];
                Vel1 = VelocityY;
                Vel2 = VelocityY;
                break;

            default:
                throw new NotImplementedException();
            }

            switch (edgType)
            {
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:

                // Atmospheric outlet/pressure outflow: hom. Neumann
                res += Uin[0] * n1 + Uin[1] * n2;
                break;

            case IncompressibleBcType.FreeSlip:
                if (Component == 1)
                {
                    res += Uin[0] * n1 + Uin[1] * n2;
                }

                break;

            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:

                // Dirichlet value for Velocity
                // ============================
                if (Component == 1)
                {
                    res += 0.5 * ((Uin[0] + Vel1) * n1 + (Uin[1] + Vel2) * n2);
                    //res += Vel1 * n1 + Vel2 * n2;// + Vel1 * n2 + Vel2 * n1;
                }
                else
                {
                    res += 0.5 * ((Uin[0] + Vel1) * n1 + (Uin[1] + Vel2) * n2);
                    //res += Vel1 * n1 + Vel2 * n2;
                }

                break;

            default:
                throw new NotImplementedException("unsupported/unknown b.c. - missing implementation;");
            }

            return(-2 * m_ViscosityNonNewton * 0.5 * res * Vin);
        }
示例#27
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!");
            }
        }
        protected override double BorderEdgeFlux(ref CommonParamsBnd inp, double[] Tin)
        {
            double res = 0;

            int jIn = inp.jCellIn;

            double h = inp.GridDat.iGeomCells.h_min[jIn];

            IncompressibleBcType edgType = m_BcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:


                // Atmospheric outlet/pressure outflow: hom. Neumann
                res += Tin[0] * inp.Normale[0];
                res += Tin[1] * inp.Normale[1];
                break;

            case IncompressibleBcType.Velocity_Inlet:
            case IncompressibleBcType.Wall:

                double VelocityX = VelFunction[inp.EdgeTag, 0](inp.X, inp.time);
                double VelocityY = VelFunction[inp.EdgeTag, 1](inp.X, inp.time);

                // Dirichlet value for Stresses
                // ============================
                //double StressXX = StressFunction[inp.EdgeTag, 0](inp.X, inp.time);
                //double StressXY = StressFunction[inp.EdgeTag, 1](inp.X, inp.time);
                //double StressYY = StressFunction[inp.EdgeTag, 2](inp.X, inp.time);

                switch (Component)
                {
                case 0:
                    //res += StressXX * inp.Normale[0];
                    //res += StressXY * inp.Normale[1];
                    res += Tin[0] * inp.Normale[0];
                    res += Tin[1] * inp.Normale[1];
                    //res += 0.5 * (StressXX + Tin[0]) * inp.Normale[0];
                    //res += 0.5 * (StressXY + Tin[1]) * inp.Normale[1];
                    //res += -pen2/h * (Tin[2] - VelocityX) * inp.Normale[0] - pen2/h * (Tin[2] - VelocityX) * inp.Normale[1]; //alpha penalty for boundary (no beta penalty)
                    //res += -pen2 * (Tin[2] - VelocityX); // / h

                    break;

                case 1:
                    //res += StressXY * inp.Normale[0];
                    //res += StressYY * inp.Normale[1];
                    res += Tin[0] * inp.Normale[0];
                    res += Tin[1] * inp.Normale[1];
                    //res += 0.5 * (StressXY + Tin[0]) * inp.Normale[0];
                    //res += 0.5 * (StressYY + Tin[1]) * inp.Normale[1];
                    //res += -pen2/h * (Tin[2] - VelocityY) * inp.Normale[0] - pen2 / h * (Tin[2] - VelocityY) * inp.Normale[1]; //alpha penalty for boundary (no beta penalty)
                    //res += -pen2* (Tin[2] - VelocityY); // / h

                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            default:
                throw new NotImplementedException("unsupported/unknown b.c. - missing implementation;");
            }
            return(InverseReynolds * res);
        }
示例#29
0
        public double BoundaryEdgeForm(ref CommonParamsBnd inp, double[] _uA, double[,] _Grad_uA, double _vA, double[] _Grad_vA)
        {
            double Acc = 0.0;

            double pnlty = 2 * GetPenalty(inp.jCellIn, -1);//, inp.GridDat.Cells.cj);
            double DiffusivityA;

            switch (Mode)
            {
            case DiffusionMode.Temperature:
                DiffusivityA = ((MaterialLawLowMach)EoS).GetHeatConductivity(inp.Parameters_IN[0]);
                break;

            case DiffusionMode.MassFraction:
                DiffusivityA = ((MaterialLawLowMach)EoS).GetDiffusivity(inp.Parameters_IN[0]);
                break;

            default:
                throw new NotImplementedException();
            }
            IncompressibleBcType edgType = BcMap.EdgeTag2Type[inp.EdgeTag];

            switch (edgType)
            {
            case IncompressibleBcType.Wall: {
                double u_D;
                switch (Mode)
                {
                case DiffusionMode.Temperature:
                    // inhom. Dirichlet b.c.
                    // =====================
                    u_D = ArgumentFunction[inp.EdgeTag](inp.X, 0);
                    for (int d = 0; d < inp.D; d++)
                    {
                        Acc += (DiffusivityA * _Grad_uA[0, d]) * (_vA) * inp.Normale[d];
                        Acc += (DiffusivityA * _Grad_vA[d]) * (_uA[0] - u_D) * inp.Normale[d];
                    }

                    Acc -= DiffusivityA * (_uA[0] - u_D) * (_vA - 0) * pnlty;
                    break;

                case DiffusionMode.MassFraction:
                    //Neumann boundary condition
                    Acc = 0.0;
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;
            }

            case IncompressibleBcType.Velocity_Inlet: {
                // inhom. Dirichlet b.c.
                // =====================

                double u_D;
                switch (Mode)
                {
                case DiffusionMode.Temperature:
                    u_D = ArgumentFunction[inp.EdgeTag](inp.X, inp.time);
                    for (int d = 0; d < inp.D; d++)
                    {
                        Acc += (DiffusivityA * _Grad_uA[0, d]) * (_vA) * inp.Normale[d];
                        Acc += (DiffusivityA * _Grad_vA[d]) * (_uA[0] - u_D) * inp.Normale[d];
                    }

                    Acc -= DiffusivityA * (_uA[0] - u_D) * (_vA - 0) * pnlty;
                    break;

                case DiffusionMode.MassFraction:
                    double rhoA = 0.0;
                    rhoA = EoS.GetDensity(inp.Parameters_IN);
                    u_D  = ArgumentFunction[inp.EdgeTag](inp.X, inp.time);
                    for (int d = 0; d < inp.D; d++)
                    {
                        Acc += (DiffusivityA * rhoA * _Grad_uA[0, d]) * (_vA) * inp.Normale[d];
                        Acc += (DiffusivityA * rhoA * _Grad_vA[d]) * (_uA[0] - u_D) * inp.Normale[d];
                    }

                    Acc -= DiffusivityA * rhoA * (_uA[0] - u_D) * (_vA - 0) * pnlty;
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;
            }

            case IncompressibleBcType.Outflow:
            case IncompressibleBcType.Pressure_Outlet:
            case IncompressibleBcType.Pressure_Dirichlet:
            case IncompressibleBcType.NoSlipNeumann: {
                Acc = 0.0;
                break;
            }

            default:
                throw new NotSupportedException();
            }

            Acc *= 1.0 / (m_Reynolds * m_Schmidt);
            return(-Acc);
        }