private static IBMControl ControlCutNextToCut(bool agglomeration) { IBMControl c = new IBMControl(); c.savetodb = false; int dgDegree = 2; double vortexSpeed = 1.0; // IBM Settings c.CutCellQuadratureType = XQuadFactoryHelper.MomentFittingVariants.Classic; c.LevelSetQuadratureOrder = 5; c.AgglomerationThreshold = agglomeration ? 0.3 : 0.0; c.DomainType = DomainTypes.StaticImmersedBoundary; c.ActiveOperators = Operators.Convection; c.ConvectiveFluxType = ConvectiveFluxTypes.Rusanov; c.ExplicitScheme = ExplicitSchemes.RungeKutta; c.ExplicitOrder = 1; c.EquationOfState = IdealGas.Air; c.MachNumber = 1 / Math.Sqrt(c.EquationOfState.HeatCapacityRatio); 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, 2); c.GridFunc = delegate { GridCommons grid = Grid2D.Cartesian2DGrid( GenericBlas.Linspace(-5.0, 5.0, 21), GenericBlas.Linspace(-0.5, 0.5, 3)); grid.EdgeTagNames.Add(1, "supersonicInlet"); grid.DefineEdgeTags(X => 1); return(grid); }; c.LevelSetBoundaryTag = "supersonicInlet"; IsentropicVortexExactSolution solution = new IsentropicVortexExactSolution(c, vortexSpeed); c.InitialValues_Evaluators.Add(Variables.Density, X => solution.rho()(X, 0.0)); c.InitialValues_Evaluators.Add(Variables.Velocity.xComponent, X => solution.u()(X, 0.0)); c.InitialValues_Evaluators.Add(Variables.Velocity.yComponent, X => solution.v()(X, 0.0)); c.InitialValues_Evaluators.Add(Variables.Pressure, X => solution.p()(X, 0.0)); if (agglomeration) { c.LevelSetFunction = (X, t) => - ((X[1] - 0.17) * (X[1] - 0.17) - 0.1); } else { c.LevelSetFunction = (X, t) => - (X[1] * X[1] - 0.2); } c.AddBoundaryValue("supersonicInlet", Variables.Density, solution.rho()); c.AddBoundaryValue("supersonicInlet", Variables.Velocity[0], solution.u()); c.AddBoundaryValue("supersonicInlet", Variables.Velocity[1], solution.v()); c.AddBoundaryValue("supersonicInlet", Variables.Pressure, solution.p()); c.Queries.Add("L2ErrorDensity", IBMQueries.L2Error(Variables.Density, solution.rho())); c.Queries.Add("L2ErrorPressure", IBMQueries.L2Error(state => state.Pressure, solution.p())); c.Queries.Add("L2ErrorEntropy", IBMQueries.L2Error(state => state.Entropy, (X, t) => 1.0)); c.dtMin = 0.0; c.dtMax = 1.0; c.CFLFraction = 0.2; c.Endtime = double.MaxValue; c.NoOfTimesteps = 100; return(c); }
private static IBMControl ControlTemplate(int dgDegree, int divisions, double levelSetPosition) { IBMControl c = new IBMControl(); c.savetodb = false; double vortexSpeed = 1.0; c.DomainType = DomainTypes.StaticImmersedBoundary; c.ActiveOperators = Operators.Convection; c.ConvectiveFluxType = ConvectiveFluxTypes.Rusanov; c.ExplicitScheme = ExplicitSchemes.RungeKutta; c.ExplicitOrder = 1; c.EquationOfState = IdealGas.Air; c.MachNumber = 1.0 / Math.Sqrt(c.EquationOfState.HeatCapacityRatio); 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 { int noOfCellsPerDirection = (2 << divisions) * 10; GridCommons grid = Grid2D.Cartesian2DGrid( GenericBlas.Linspace(-10.0, 10.0, noOfCellsPerDirection + 1), GenericBlas.Linspace(-10.0, 10.0, noOfCellsPerDirection + 1)); grid.EdgeTagNames.Add(1, "supersonicInlet"); grid.DefineEdgeTags(X => 1); return(grid); }; c.LevelSetBoundaryTag = "supersonicInlet"; IsentropicVortexExactSolution solution = new IsentropicVortexExactSolution(c, vortexSpeed); c.InitialValues_Evaluators.Add(Variables.Density, X => solution.rho()(X, 0.0)); c.InitialValues_Evaluators.Add(Variables.Velocity.xComponent, X => solution.u()(X, 0.0)); c.InitialValues_Evaluators.Add(Variables.Velocity.yComponent, X => solution.v()(X, 0.0)); c.InitialValues_Evaluators.Add(Variables.Pressure, X => solution.p()(X, 0.0)); c.LevelSetFunction = (X, t) => X[1] - levelSetPosition; c.AddBoundaryValue("supersonicInlet", Variables.Density, solution.rho()); c.AddBoundaryValue("supersonicInlet", Variables.Velocity[0], solution.u()); c.AddBoundaryValue("supersonicInlet", Variables.Velocity[1], solution.v()); c.AddBoundaryValue("supersonicInlet", Variables.Pressure, solution.p()); c.Queries.Add("L2ErrorDensity", IBMQueries.L2Error(Variables.Density, solution.rho())); c.Queries.Add("L2ErrorPressure", IBMQueries.L2Error(state => state.Pressure, solution.p())); c.Queries.Add("L2ErrorEntropy", IBMQueries.L2Error(state => state.Entropy, (X, t) => 1.0)); c.dtMin = 0.0; c.dtMax = 1.0; c.CFLFraction = 0.2; c.Endtime = 0.5; c.NoOfTimesteps = 100; return(c); }