Example #1
0
        /// <summary>
        /// Common settings for all tests within this set of test cases
        /// </summary>
        /// <param name="dgDegree"></param>
        /// <param name="eos"></param>
        /// <returns></returns>
        private static RinglebControl GetTemplate(int dgDegree, StiffenedGas eos)
        {
            RinglebControl c = new RinglebControl();

            c.DbPath   = "../../Tests/Ringleb/ringlebTests.zip";
            c.savetodb = false;

            c.ActiveOperators = Operators.Convection;
            c.EquationOfState = eos;
            c.ExplicitScheme  = ExplicitSchemes.RungeKutta;
            c.ExplicitOrder   = 4;

            c.MachNumber = 1 / Math.Sqrt(c.EquationOfState.HeatCapacityRatio);

            c.AddVariable(CompressibleVariables.Density, dgDegree);
            c.AddVariable(CompressibleVariables.Momentum.xComponent, dgDegree);
            c.AddVariable(CompressibleVariables.Momentum.yComponent, dgDegree);
            c.AddVariable(CompressibleVariables.Energy, dgDegree);
            c.AddVariable(CNSVariables.Pressure, dgDegree);
            c.AddVariable(CNSVariables.Entropy, dgDegree);

            Func <double[], RinglebExactSolution.FlowState> solution = X => RinglebExactSolution.GetFlowState(
                X[0],
                X[1],
                eos.HeatCapacityRatio,
                eos.ReferencePressure,
                c.RinglebReferenceSpeedOfSound,
                c.RinglebReferenceTotalPressure);

            c.InitialValues_Evaluators.Add(CompressibleVariables.Density, X => solution(X).Density);
            c.InitialValues_Evaluators.Add(CompressibleVariables.Momentum.xComponent, X => solution(X).Momentum[0]);
            c.InitialValues_Evaluators.Add(CompressibleVariables.Momentum.yComponent, X => solution(X).Momentum[1]);
            c.InitialValues_Evaluators.Add(CompressibleVariables.Energy, X => solution(X).Energy);

            c.AddBoundaryValue("ringleb");

            c.Queries.Add("L2ErrorDensity", QueryLibrary.L2Error(CompressibleVariables.Density, (X, t) => solution(X).Density));
            c.Queries.Add("L2ErrorPressure", QueryLibrary.L2Error(CNSVariables.Pressure, (X, t) => solution(X).Pressure));

            c.dtMin         = 0.0;
            c.dtMax         = 1.0;
            c.CFLFraction   = 0.5;
            c.Endtime       = double.MaxValue;
            c.NoOfTimesteps = 50;

            return(c);
        }
        /// <summary>
        /// Uses <see cref="RinglebExactSolution"/> in order to construct the
        /// boundary state corresponding to the exact solution of the Ringleb
        /// problem.
        /// </summary>
        /// <param name="time"></param>
        /// <param name="x"></param>
        /// <param name="normal"></param>
        /// <param name="stateIn"></param>
        /// <returns></returns>
        public override StateVector GetBoundaryState(double time, double[] x, double[] normal, StateVector stateIn)
        {
            double kappa = control.EquationOfState.HeatCapacityRatio;
            double pi    = control.EquationOfState.ReferencePressure;
            double a0    = control.RinglebReferenceSpeedOfSound;
            double p0    = control.RinglebReferenceTotalPressure;

            RinglebExactSolution.FlowState ringlebState = RinglebExactSolution.GetFlowState(
                x[0], x[1], kappa, pi, a0, p0);

            double   rho = ringlebState.Density;
            Vector3D v   = new Vector3D(ringlebState.Velocity[0], ringlebState.Velocity[1], 0.0);

            return(new StateVector(
                       stateIn.Material,
                       rho,
                       rho * v,
                       (ringlebState.Pressure + kappa * pi) / (kappa - 1.0) + 0.5 * rho * v * v));
        }