Esempio n. 1
0
        /// <summary>
        /// The Volume Form, see <see cref="BoSSS.Foundation.IVolumeForm"/>
        /// </summary>
        /// <param name="cpv"></param>
        /// <param name="U"></param>
        /// <param name="GradU"></param>
        /// <param name="V"></param>
        /// <param name="GradV"></param>
        /// <returns></returns>
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            Debug.Assert(GradU.GetLength(0) == 1);
            Debug.Assert(GradU.GetLength(1) == D);
            double Acc = 0;

            double GradPhiGradU      = 0;
            double GradPhiGradV      = 0;
            double AbsGradPhiSquared = 0;
            double StandardForm      = 0;

            /// Weak Form
            for (int d = 0; d < D; d++)
            {
                GradPhiGradU      += cpv.Parameters[d] * GradU[0, d];
                GradPhiGradV      += cpv.Parameters[d] * GradV[d];
                AbsGradPhiSquared += cpv.Parameters[d] * cpv.Parameters[d];
                StandardForm      += GradU[0, d] * GradV[d];
            }
            Acc += GradPhiGradU * GradPhiGradV / (AbsGradPhiSquared + myEps);
            Acc += IsotropicViscosity * StandardForm;

            /// Strong Form, added due to Chessa et al. 2002
            //Acc -= GradPhiGradU / (Math.Sqrt(AbsGradPhiSquared) + myEps) * Math.Sign(cpv.Parameters[D]) * V;

            return(Acc);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
        {
            int D = output.Length;

            Array.Clear(output, 0, D);
            output[m_d] = U[0];
        }
Esempio n. 3
0
        //static double[] LaplaceU(double uxx, double uyy, double vxx, double vyy) {

        //    double[] LapU = new double[2];

        //    LapU[0] = uxx + uyy;
        //    LapU[1] = vxx + vyy;

        //    return LapU;
        //}


        public double VolumeForm(ref CommonParamsVol cpv, Double[] U, Double[,] GradU, Double V, Double[] GradV)
        {
            double[] Vel = cpv.Parameters.GetSubVector(0, m_D);
            double[,] GradVel = VelocityGradient(cpv.Parameters.GetSubVector(m_D, m_D), cpv.Parameters.GetSubVector(2 * m_D, m_D));

            double[] LapU = new double[2];
            LapU[0] = cpv.Parameters[3 * m_D] + cpv.Parameters[4 * m_D + 1];
            LapU[1] = cpv.Parameters[5 * m_D] + cpv.Parameters[6 * m_D + 1];

            double[] DivGradUT = new double[2];
            DivGradUT[0] = cpv.Parameters[3 * m_D] + cpv.Parameters[5 * m_D + 1];
            DivGradUT[1] = cpv.Parameters[4 * m_D] + cpv.Parameters[6 * m_D + 1];

            double ret = 0;

            for (int d = 0; d < m_D; d++)
            {
                ret += DivGradUT[d] * Vel[d];
                if (transposedTerm)
                {
                    ret += LapU[d] * Vel[d];
                }
                for (int dd = 0; dd < m_D; dd++)
                {
                    ret += GradVel[dd, d] * GradVel[d, dd];
                    if (transposedTerm)
                    {
                        ret += GradVel[d, dd] * GradVel[d, dd];
                    }
                }
            }

            return(-mu * ret * V);
        }
Esempio n. 4
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            int D = cpv.D;

            Debug.Assert(GradU.GetLength(0) == 1);
            Debug.Assert(GradU.GetLength(1) == D);

            double AbsGradU = 0;
            double Acc      = 0;

            for (int d = 0; d < D; d++)
            {
                AbsGradU += GradU[0, d] * GradU[0, d];
                Acc      += GradU[0, d] * GradV[d];
            }
            AbsGradU = Math.Sqrt(AbsGradU);

            Acc *= DiffusionRate(AbsGradU, CutCells[cpv.jCell]);
#if DEBUG
            if (Acc.IsNaN())
            {
                throw new ArithmeticException();
            }
#endif
            return(-Acc);
        }
Esempio n. 5
0
        // Calculating the integral
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] Grad_U, double V, double[] GradV)
        {
            //-2 * (1-beta) * 0.5 * (d u_i / d x_j + d u_j / d x_i)


            double res;

            switch (Component)
            {
            case 0:
                res = U[0] * GradV[0] + U[1] * GradV[0];
                break;

            case 1:
                res = (U[0] * GradV[1] + U[1] * GradV[0]);
                break;

            case 2:
                res = U[0] * GradV[1] + U[1] * GradV[1];
                break;

            default:
                throw new NotImplementedException();
            }

            return(2 * m_ViscosityNonNewton * 0.5 * res);
        }
Esempio n. 6
0
        // Calculating the fluxes
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            switch (Component)
            {
            case 0:
                return(-U[0] * V);

            case 1:
                return(-U[0] * V);

            case 2:
                return(-U[0] * V);

            case 3:
                return(-U[0] * V);

            default:
                throw new NotImplementedException();
            }
            //switch (Component)
            //{
            //    case 0:
            //        return (U[0] - GradU[1, 0]) * V;
            //    case 1:
            //        return (U[0] - GradU[1, 1]) * V;
            //    case 2:
            //        return (U[0] - GradU[1, 0]) * V;
            //    case 3:
            //        return (U[0] - GradU[1, 1]) * V;

            //    default:
            //        throw new NotImplementedException();
            //}
        }
Esempio n. 7
0
 protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
 {
     for (int d = 0; d < m_SpatialDimension; d++)
     {
         output[d] = U[0] * inp.Parameters[d];
     }
 }
Esempio n. 8
0
 protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
 {
     for (int d = D - 1; d >= 0; d--)
     {
         output[d] = inp.Parameters[d] * U[0];
     }
 }
Esempio n. 9
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            double Acc = 0;
            double Diffusivity;
            double rho = 0.0;

            rho = EoS.GetDensity(cpv.Parameters);
            switch (Mode)
            {
            case DiffusionMode.Temperature:
                Diffusivity = ((MaterialLawLowMach)EoS).GetHeatConductivity(cpv.Parameters[0]);
                for (int d = 0; d < cpv.D; d++)
                {
                    Acc -= Diffusivity * GradU[0, d] * GradV[d];
                }
                break;

            case DiffusionMode.MassFraction:
                Diffusivity = ((MaterialLawLowMach)EoS).GetDiffusivity(cpv.Parameters[0]);
                for (int d = 0; d < cpv.D; d++)
                {
                    Acc -= Diffusivity * rho * GradU[0, d] * GradV[d];
                }
                break;

            default:
                throw new NotImplementedException();
            }
            Acc *= 1.0 / (m_Reynolds * m_Schmidt);
            return(-Acc);
        }
Esempio n. 10
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            int D = cpv.D;

            // diffusive
            double acc = 0.0;

            for (int d = 0; d < D; d++)
            {
                acc -= GradU[0, d] * GradV[d] * muA;
            }

            // temporal
            acc -= (1 / dt) * U[0] * V;


            // convective
            //for (int d = 0; d < D; d++)
            //{
            //    acc += cpv.Parameters[d] * GradU[0, d] * V;
            //}


            return(acc);
        }
        /// <summary>
        /// Calculating the integral of the volume part
        /// </summary>
        public double VolumeForm(ref CommonParamsVol cpv, double[] T, double[,] Grad_T, double V, double[] GradV)
        {
            double Grad1;
            double Grad2;
            double Grad3;
            double Grad4;

            if (m_useFDJacobian)
            {
                Grad1 = cpv.Parameters[0];
                Grad2 = cpv.Parameters[1];
                Grad3 = cpv.Parameters[2];
                Grad4 = cpv.Parameters[3];
            }
            else
            {
                GetVelocityGrad(out Grad1, out Grad2, out Grad3, out Grad4, Grad_T);
            }

            double res = 0.0;

            res = ((Grad1 * T[0] + Grad2 * T[1]) + (Grad3 * T[2] + Grad4 * T[3]));

            return(-m_Weissenberg * res * V);
        }
Esempio n. 12
0
        protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
        {
            double u0 = inp.Parameters[0];

            output[0] = Direction.x * (u0 * U[0] * 0.5);
            output[1] = Direction.y * (u0 * U[0] * 0.5);
        }
Esempio n. 13
0
        /// <summary>
        /// returns
        /// \f[
        ///   \vec{v} \cdot u_d,
        /// \f]
        /// where \f$ \vec{v}\f$  is the linearization point.
        /// For variable density the result is multiplied by \f$ \rho\f$ .
        /// </summary>
        protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
        {
            output[0] = U[0] * inp.Parameters[0];
            output[1] = U[0] * inp.Parameters[1];
            if (m_SpatialDimension == 3)
            {
                output[2] = U[0] * inp.Parameters[2];
            }

            if (m_bcmap.PhysMode == PhysicsMode.LowMach || m_bcmap.PhysMode == PhysicsMode.Multiphase)
            {
                double rho = EoS.GetDensity(inp.Parameters[2 * m_SpatialDimension]);
                for (int d = 0; d < m_SpatialDimension; d++)
                {
                    output[d] *= 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[2 * m_SpatialDimension + n];
                }
                double rho = EoS.GetDensity(args);
                for (int d = 0; d < m_SpatialDimension; d++)
                {
                    output[d] *= rho;
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        /// Calculating the integral of the volume part
        /// </summary>
        public virtual double VolumeForm(ref CommonParamsVol cpv, double[] T, double[,] Grad_T, double V, double[] GradV)
        {
            double res = 0.0;

            res = T[0];

            return(res * V);
        }
Esempio n. 15
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            double Acc = 0.0;

            Acc += -U[0] * V;

            return(Acc);
        }
Esempio n. 16
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            double Acc = 0.0;

            Acc += 1e-8 * (cpv.Parameters[0] - U[0]) * V;

            return(Acc);
        }
Esempio n. 17
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] T, double[,] GradT, double V, double[] GradV)
        {
            double res = 0.0;

            res += cpv.Parameters[0] * GradT[0, 0] + cpv.Parameters[1] * GradT[0, 1];

            return(m_Weissenberg * res * V);
        }
Esempio n. 18
0
        protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
        {
            Vector o;

            o         = FlowField(inp.Xglobal, inp.Parameters, inp.Parameters) * U[0];
            output[0] = o.x;
            output[1] = o.y;
        }
Esempio n. 19
0
        /// <summary>
        /// returns
        /// \f[
        ///   \vec{v} \cdot u_d,
        /// \f]
        /// where \f$ \vec{v}\f$  is the linearization point.
        /// For variable density the result is multiplied by \f$ \rho\f$ .
        /// </summary>
        void Flux(ref CommonParamsVol inp, double[] U, double[] output)
        {
            var _U = new Vector(U);

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

            output.SetV(_U * _U[m_component] * m_rho);
        }
Esempio n. 20
0
        /// <summary>
        /// Stress divergence volume term
        /// </summary>
        protected override void Flux(ref CommonParamsVol inp, double[] T, double[] output)
        {
            int D = output.Length;

            Array.Clear(output, 0, D);

            output[0] = InverseReynolds * T[0];
            output[1] = InverseReynolds * T[1];
        }
Esempio n. 21
0
 protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
 {
     output[0] = U[0] * inp.Parameters[0];
     output[1] = U[0] * inp.Parameters[1];
     if (m_SpatialDimension == 3)
     {
         output[2] = U[0] * inp.Parameters[2];
     }
 }
Esempio n. 22
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            double acc = 0.0;

            acc += -We * cpv.Parameters[0] * U[0] * V;


            return(acc);
        }
Esempio n. 23
0
        double IVolumeForm.VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            double acc = 0;

            for (int d = 0; d < cpv.D; d++)
            {
                acc += GradU[0, d] * GradV[d] * cpv.Parameters[0];
            }
            return(acc);
        }
Esempio n. 24
0
            public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
            {
                double phi  = U[0];
                double phi0 = cpv.Parameters[0];

                double Acc = 0;

                Acc += 3 * phi0.Pow2() * phi - phi; // linearized around c0 (Taylor expansion)

                return(Acc * V);
            }
Esempio n. 25
0
        protected override void Flux(ref CommonParamsVol inp, Double[] U, Double[] output)
        {
            double[] Vel   = inp.Parameters.GetSubVector(0, m_D);
            double   Press = inp.Parameters[m_D];

            for (int d = 0; d < m_D; d++)
            {
                output[d] = Press * Vel[d];        // pressure term
            }
            //output.ScaleV(-1.0);
        }
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            //return cpv / Math.Abs(GradU);
            double Acc = 0;

            for (int d = 0; d < D; d++)
            {
                Acc += GradU[0, d] * GradU[0, d];
            }
            return(cpv.Parameters[0] * V *Math.Sqrt(Acc));
        }
Esempio n. 27
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] T, double[,] GradT, double V, double[] GradV)
        {
            double res = 0.0;

            Vector Velocity = new Vector(T, 1, cpv.D);
            Vector _GradT = GradT.GetRowPt(0);

            res += Velocity*_GradT;

            return m_Weissenberg * res * V;
        }
Esempio n. 28
0
        protected override void Flux(ref CommonParamsVol inp, double[] U, double[] output)
        {
            double u = U[0];
            int    D = inp.D;

            Debug.Assert(m_ConvectionVelocityField.Length == D);
            for (int d = 0; d < D; d++)
            {
                output[d] = m_ConvectionVelocityField[d](inp.Xglobal, inp.time) * u;
            }
        }
Esempio n. 29
0
        public double VolumeForm(ref CommonParamsVol cpv, double[] U, double[,] GradU, double V, double[] GradV)
        {
            double Acc = 0;
            double HeatConductivity = EoS.GetViscosity(cpv.Parameters[0]);

            for (int d = 0; d < cpv.D; d++)
            {
                Acc -= HeatConductivity * GradU[0, d] * GradV[d];
            }
            Acc *= 1.0 / (Reynolds * Prandtl);
            return(-Acc);
        }
        // calculating the fluxes
        protected override void Flux(ref CommonParamsVol inp, double[] T, double[] output)
        {
            int D = output.Length;

            Array.Clear(output, 0, D);

            double u = inp.Parameters[0];
            double v = inp.Parameters[1];

            output[0] = m_Weissenberg * u * T[0];
            output[1] = m_Weissenberg * v * T[0];
        }