public static IBMRungeKutta CreateRungeKuttaTimeStepper( this TimesteppingStrategies strategy, IBMControl control, OperatorFactory equationSystem, CNSFieldSet fieldSet, CoordinateMapping parameterMap, ISpeciesMap speciesMap, IList <TimeStepConstraint> timeStepConstraints) { ImmersedSpeciesMap ibmSpeciesMap = speciesMap as ImmersedSpeciesMap; if (ibmSpeciesMap == null) { throw new ArgumentException( "Only supported for species maps of type 'ImmersedSpeciesMap'", "speciesMap"); } IBMOperatorFactory ibmFactory = equationSystem as IBMOperatorFactory; if (ibmFactory == null) { throw new Exception(); } CoordinateMapping variableMap = new CoordinateMapping(fieldSet.ConservativeVariables); switch (strategy) { case TimesteppingStrategies.LieSplitting: case TimesteppingStrategies.StrangSplitting: return(new IBMSplitRungeKutta( equationSystem.GetJoinedOperator().ToSpatialOperator(fieldSet), ibmFactory.GetImmersedBoundaryOperator().ToSpatialOperator(fieldSet), variableMap, parameterMap, ibmSpeciesMap, timeStepConstraints)); case TimesteppingStrategies.MovingFrameFlux: return(new IBMMovingFrameRungeKutta( equationSystem.GetJoinedOperator().ToSpatialOperator(fieldSet), ibmFactory.GetImmersedBoundaryOperator().ToSpatialOperator(fieldSet), variableMap, parameterMap, ibmSpeciesMap, timeStepConstraints)); default: throw new System.NotImplementedException(); } }
public static IBMControl PistonControl(int dgDegree, int rkDegree, ConvectiveFluxTypes convectiveFlux, TimesteppingStrategies timeSteppingStrategy, double agglomerationThreshold) { double pistonVelocity = 1.0; double initialLevelSetPosition = 0.1; //double initialLevelSetPosition = 0.5; IBMControl c = new IBMControl(); c.DbPath = null; c.savetodb = false; c.ProjectName = "Piston"; c.ProjectDescription = "Vertical moving at flow velocity through constant flow field"; c.DomainType = DomainTypes.MovingImmersedBoundary; c.ActiveOperators = Operators.Convection; c.ConvectiveFluxType = convectiveFlux; c.EquationOfState = IdealGas.Air; c.MachNumber = 1.0 / Math.Sqrt(c.EquationOfState.HeatCapacityRatio); c.TimesteppingStrategy = timeSteppingStrategy; c.ExplicitScheme = ExplicitSchemes.RungeKutta; c.ExplicitOrder = rkDegree; c.AddVariable(Variables.Density, dgDegree); c.AddVariable(Variables.Momentum.xComponent, dgDegree); c.AddVariable(Variables.Momentum.yComponent, dgDegree); c.AddVariable(Variables.Energy, dgDegree); c.AddVariable(IBMVariables.LevelSet, 1); c.GridFunc = delegate { double[] xNodes = GenericBlas.Linspace(0.0, 2.0, 4); double[] yNodes = GenericBlas.Linspace(-1.0, 1.0, 4); var grid = Grid2D.Cartesian2DGrid(xNodes, yNodes, periodicX: false, periodicY: true); grid.EdgeTagNames.Add(1, "adiabaticSlipWall"); grid.EdgeTagNames.Add(2, "supersonicInlet"); grid.DefineEdgeTags(X => 2); return(grid); }; c.CutCellQuadratureType = XQuadFactoryHelper.MomentFittingVariants.Classic; c.LevelSetQuadratureOrder = 10; c.LevelSetBoundaryTag = "adiabaticSlipWall"; c.AgglomerationThreshold = agglomerationThreshold; c.InitialValues_Evaluators.Add(Variables.Density, X => 1.0); c.InitialValues_Evaluators.Add(Variables.Velocity.xComponent, X => pistonVelocity); c.InitialValues_Evaluators.Add(Variables.Velocity.yComponent, X => 0.0); c.InitialValues_Evaluators.Add(Variables.Pressure, X => 1.0); c.LevelSetFunction = delegate(double[] X, double time) { double newLevelSetPosition = initialLevelSetPosition + pistonVelocity * time; return(X[0] - newLevelSetPosition); }; c.LevelSetVelocity = (X, t) => new Vector(pistonVelocity, 0.0); c.AddBoundaryValue("adiabaticSlipWall", Variables.Velocity.xComponent, X => pistonVelocity); c.AddBoundaryValue("adiabaticSlipWall", Variables.Velocity.yComponent, X => 0.0); c.AddBoundaryValue("supersonicInlet", Variables.Density, X => 1.0); c.AddBoundaryValue("supersonicInlet", Variables.Velocity[0], X => pistonVelocity); c.AddBoundaryValue("supersonicInlet", Variables.Velocity[1], X => 0.0); c.AddBoundaryValue("supersonicInlet", Variables.Pressure, X => 1.0); c.Queries.Add("L2ErrorDensity", IBMQueries.L2Error(Variables.Density, (X, t) => 1.0)); c.Queries.Add("L2ErrorXMomentum", IBMQueries.L2Error(Variables.Momentum.xComponent, (X, t) => 1.0)); c.Queries.Add("L2ErrorYMomentum", IBMQueries.L2Error(Variables.Momentum.yComponent, (X, t) => 0.0)); c.Queries.Add("L2ErrorPressure", IBMQueries.L2Error(state => state.Pressure, (X, t) => 1.0)); c.dtMin = 0.0; c.dtMax = 1.0; c.CFLFraction = 0.1; c.Endtime = 0.75; c.NoOfTimesteps = int.MaxValue; return(c); }