Пример #1
0
 /// <summary>
 /// Constructs a new Euler flux
 /// </summary>
 /// <param name="config">Configuration options</param>
 /// <param name="boundaryMap">Boundary value definition</param>
 /// <param name="equationComponent">
 /// Concerned component of the Euler equations
 /// </param>
 /// <param name="speciesMap">
 /// Mapping that determines the active species in some point.
 /// </param>
 protected EulerFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, IEulerEquationComponent equationComponent, ISpeciesMap speciesMap)
 {
     this.config            = config;
     this.boundaryMap       = boundaryMap;
     this.equationComponent = equationComponent;
     this.speciesMap        = speciesMap;
 }
Пример #2
0
 /// <summary>
 /// Constructs a new Euler flux
 /// </summary>
 /// <param name="config">Configuration options</param>
 /// <param name="boundaryMap">Boundary value definition</param>
 /// <param name="equationComponent">
 /// Concerned component of the Euler equations
 /// </param>
 /// <param name="material">
 /// Mapping that determines the active species in some point.
 /// </param>
 protected EulerFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, IEulerEquationComponent equationComponent, Material material)
 {
     this.config            = config;
     this.boundaryMap       = boundaryMap;
     this.equationComponent = equationComponent;
     this.material          = material;
 }
Пример #3
0
 /// <summary>
 /// <see cref="EulerFlux.EulerFlux"/>
 /// </summary>
 /// <param name="config">
 /// <see cref="EulerFlux.EulerFlux"/>
 /// </param>
 /// <param name="boundaryMap">
 /// <see cref="EulerFlux.EulerFlux"/>
 /// </param>
 /// <param name="equationComponent">
 /// <see cref="EulerFlux.EulerFlux"/>
 /// </param>
 /// <param name="speciesMap">
 /// <see cref="EulerFlux.EulerFlux"/>
 /// </param>
 public GodunovFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, IEulerEquationComponent equationComponent, ISpeciesMap speciesMap)
     : base(config, boundaryMap, equationComponent, speciesMap)
 {
     if (config.EquationOfState is IdealGas == false)
     {
         throw new Exception("Riemann solver currently only supports ideal gases");
     }
 }
Пример #4
0
 /// <summary>
 /// <see cref="EulerFlux"/>
 /// </summary>
 /// <param name="config"><see cref="EulerFlux"/></param>
 /// <param name="boundaryMap"><see cref="EulerFlux"/></param>
 /// <param name="equationComponent"><see cref="EulerFlux"/></param>
 /// <param name="speciesMap"><see cref="EulerFlux"/></param>
 protected HLLCFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, IEulerEquationComponent equationComponent, ISpeciesMap speciesMap)
     : base(config, boundaryMap, equationComponent, speciesMap.GetMaterial(double.NaN))
 {
     if (config.EquationOfState is IdealGas == false)
     {
         throw new Exception("HLLC flux currently only works for ideal gases");
     }
 }
Пример #5
0
        /// <summary>
        /// Factory for residual loggers. The instantiated objects depend on the
        /// defined <paramref name="loggerType"/>.
        /// </summary>
        /// <param name="loggerType">
        /// The type of logger to be instantiated
        /// </param>
        /// <param name="program">
        /// The program requesting the residual logger.
        /// </param>
        /// <param name="config">Configuration options</param>
        /// <param name="differentialOperator">
        /// The differential operator that defines the system of equations to
        /// be solved. May be null if <paramref name="loggerType"/> does
        /// <b>not</b> contain <see cref="ResidualLoggerTypes.Rigorous"/>.
        /// </param>
        /// <returns>
        /// A list of residual loggers, see <see cref="ResidualLogger"/>.
        /// </returns>
        public static IEnumerable <IResidualLogger> Instantiate <T>(
            this ResidualLoggerTypes loggerType,
            Application <T> program,
            CompressibleControl config,
            SpatialOperator differentialOperator,
            DGField[] consVars,
            CoordinateMapping paramMap)
            where T : CompressibleControl, new()
        {
            if (loggerType.HasFlag(ResidualLoggerTypes.ChangeRate) &&
                loggerType.HasFlag(ResidualLoggerTypes.Rigorous))
            {
                throw new Exception(
                          "Residual types \"changeRate\" and \"rigorous\" are mutually exclusive");
            }

            if (loggerType == ResidualLoggerTypes.None)
            {
                yield return(new NullResidualLogger(
                                 program.ResLogger, program.CurrentSessionInfo, consVars));
            }
            else
            {
                if (loggerType.HasFlag(ResidualLoggerTypes.ChangeRate))
                {
                    loggerType ^= ResidualLoggerTypes.ChangeRate;
                    yield return(new ChangeRateResidualLogger(
                                     program.ResLogger, program.CurrentSessionInfo, consVars, config.ResidualInterval));
                }

                if (loggerType.HasFlag(ResidualLoggerTypes.Rigorous))
                {
                    loggerType ^= ResidualLoggerTypes.Rigorous;
                    yield return(new RigorousResidualLogger <T>(
                                     program,
                                     consVars,
                                     paramMap,
                                     config.ResidualInterval,
                                     differentialOperator));
                }

                if (loggerType.HasFlag(ResidualLoggerTypes.Query))
                {
                    loggerType ^= ResidualLoggerTypes.Query;
                    yield return(new QueryLogger(
                                     program.ResLogger, program));
                }

                if (loggerType != ResidualLoggerTypes.None)
                {
                    throw new NotImplementedException(
                              "Residual logging for residual type " + loggerType + " not implemented");
                }
            }
        }
Пример #6
0
        public static SpatialOperator BuildEulerOperator(IGridData gridData, CompressibleControl control)
        {
            // Boundary condition map
            Material material = control.GetMaterial();
            IBoundaryConditionMap boundaryMap = new CompressibleBoundaryCondMap(gridData, control, material);

            // Initialize operator
            SpatialOperator EulerOperator = new SpatialOperator(
                new string[] { CompressibleVariables.Density, CompressibleVariables.Momentum.xComponent, CompressibleVariables.Momentum.yComponent, CompressibleVariables.Energy },
                new string[] { },
                new string[] { CompressibleVariables.Density, CompressibleVariables.Momentum.xComponent, CompressibleVariables.Momentum.yComponent, CompressibleVariables.Energy },
                QuadOrderFunc.NonLinearWithoutParameters(2)
                );

            // Map fluxes
            EulerOperator.EquationComponents[CompressibleVariables.Density].Add(new OptimizedHLLCDensityFlux(boundaryMap, material));
            EulerOperator.EquationComponents[CompressibleVariables.Momentum.xComponent].Add(new OptimizedHLLCMomentumFlux(boundaryMap, 0, material));
            EulerOperator.EquationComponents[CompressibleVariables.Momentum.yComponent].Add(new OptimizedHLLCMomentumFlux(boundaryMap, 1, material));
            EulerOperator.EquationComponents[CompressibleVariables.Energy].Add(new OptimizedHLLCEnergyFlux(boundaryMap, material));

            EulerOperator.Commit();

            return(EulerOperator);
        }
Пример #7
0
        public static bool ShouldTerminate(this IEnumerable <IResidualLogger> loggers, IDictionary <string, double> residuals, CompressibleControl control)
        {
            if (control.ResidualBasedTerminationCriteria.Count > 0 &&
                residuals.Count > 0)
            {
                bool terminate = true;
                foreach (var keyThresholdPair in control.ResidualBasedTerminationCriteria)
                {
                    if (!residuals.ContainsKey(keyThresholdPair.Key))
                    {
                        throw new Exception(String.Format(
                                                "A termination criterion is based on {0} was found"
                                                + " but the corresponding residual value was"
                                                + " not calculated.",
                                                keyThresholdPair.Key));
                    }

                    terminate &= residuals[keyThresholdPair.Key] < keyThresholdPair.Value;
                }

                if (terminate)
                {
                    Console.WriteLine("All residual criteria fulfilled, stopping calculation.");
                    return(true);
                }
            }

            return(false);
        }
Пример #8
0
 public MovingFrameRusanovFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, IEulerEquationComponent equationComponent, ImmersedSpeciesMap speciesMap)
     : base(config, boundaryMap, equationComponent, speciesMap.GetMaterial(double.NaN))
 {
     this.levelSetVelocity = speciesMap.Control.LevelSetVelocity;
 }
Пример #9
0
 /// <summary>
 /// <see cref="HLLCFlux"/>
 /// </summary>
 /// <param name="config"><see cref="HLLCFlux"/></param>
 /// <param name="boundaryMap"><see cref="HLLCFlux"/></param>
 /// <param name="equationComponent"><see cref="HLLCFlux"/></param>
 /// <param name="speciesMap"><see cref="HLLCFlux"/></param>
 public HLLCEnergyFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, EulerEnergyComponent equationComponent, ISpeciesMap speciesMap)
     : base(config, boundaryMap, equationComponent, speciesMap)
 {
 }
Пример #10
0
 /// <summary>
 /// <see cref="HLLCFlux"/>
 /// </summary>
 /// <param name="config"><see cref="HLLCFlux"/></param>
 /// <param name="boundaryMap"><see cref="HLLCFlux"/></param>
 /// <param name="equationComponent"><see cref="HLLCFlux"/></param>
 /// <param name="speciesMap"><see cref="HLLCFlux"/></param>
 public HLLCMomentumFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, EulerMomentumComponent equationComponent, ISpeciesMap speciesMap)
     : base(config, boundaryMap, equationComponent, speciesMap)
 {
     this.momentumComponent = equationComponent.MomentumComponent;
 }
Пример #11
0
 /// <summary>
 /// <see cref="EulerFlux"/>
 /// </summary>
 /// <param name="config"><see cref="EulerFlux"/></param>
 /// <param name="boundaryMap"><see cref="EulerFlux"/></param>
 /// <param name="equationComponent"><see cref="EulerFlux"/></param>
 /// <param name="speciesMap"><see cref="EulerFlux"/></param>
 public RusanovFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, IEulerEquationComponent equationComponent, ISpeciesMap speciesMap)
     : base(config, boundaryMap, equationComponent, speciesMap)
 {
 }
Пример #12
0
 /// <summary>
 /// <see cref="EulerFlux"/>
 /// </summary>
 /// <param name="config"><see cref="EulerFlux"/></param>
 /// <param name="boundaryMap"><see cref="EulerFlux"/></param>
 /// <param name="equationComponent"><see cref="EulerFlux"/></param>
 /// <param name="speciesMap"><see cref="EulerFlux"/></param>
 public HLLFlux(CompressibleControl config, IBoundaryConditionMap boundaryMap, IEulerEquationComponent equationComponent, ISpeciesMap speciesMap)
     : base(config, boundaryMap, equationComponent, speciesMap.GetMaterial(double.NaN))
 {
 }