//private static int count = 0; //private static StreamWriter writer; /// <summary> /// Calculates the boundary value for an isolating slip wall according /// to the first variant described in VegtVen2002. The basic idea is to /// impose \f$ \vec{u} \cdot \vec{n} = 0\f$ (slip wall) by /// setting the edge momentum to /// \f$ \vec{m}^+ = \vec{m}^- - 2((\rho \vec{u})^- \cdot \vec{n})\vec{n}\f$ /// which mimics a mirrored flow at the other side of the wall. /// </summary> public override StateVector GetBoundaryState(double time, Vector x, Vector normal, StateVector stateIn) { //Convection.OptimizedHLLCFlux.AdiabaticSlipWall.Start(); Vector normalVector = normal; Debug.Assert(normal.Dim == stateIn.Dimension); int D = normal.Dim; StateVector stateOut; if (WallVelocities == null) { // VegtVen2002, page 14, second equation ilPSP.Vector mOut = stateIn.Momentum - 2.0 * (stateIn.Momentum * normalVector) * normalVector; stateOut = new StateVector(stateIn.Material, stateIn.Density, mOut, stateIn.Energy); } else { ilPSP.Vector uWall = new ilPSP.Vector(D); for (int d = 0; d < D; d++) { uWall[d] = WallVelocities[d](x, time); } ilPSP.Vector uOut = stateIn.Velocity - 2.0 * ((stateIn.Velocity - uWall) * normalVector) * normalVector; stateOut = StateVector.FromPrimitiveQuantities( stateIn.Material, stateIn.Density, uOut, stateIn.Pressure); } //Console.WriteLine(String.Format("{0}: \t x = ({1:0.0000}, {2:0.0000}) \t stateOut = ({3:0.0000}, {4:0.0000}, {5:0.0000}, {6:0.0000}) \t normal = ({7:0.0000}, {8:0.0000})", count, x.x, x.y, stateOut.Density, stateOut.Momentum.x, stateOut.Momentum.y, stateOut.Energy, normal.x, normal.y)); //count++; //// StreamWriter //if (writer == null) { // writer = new StreamWriter("QuadraturePoints.txt"); //} //string resultLine; //resultLine = x.x + "\t" + x.y + "\t" + stateOut.Density + "\t" + stateOut.Momentum.x + "\t" + stateOut.Momentum.y + "\t" + stateOut.Energy + "\t" + normal.x + "\t" + normal.y; //writer.WriteLine(resultLine); //writer.Flush(); //Convection.OptimizedHLLCFlux.AdiabaticSlipWall.Stop(); return(stateOut); }
/// <summary> /// On a no-slip wall, all velocity (and thus momentum) components /// vanish. The density can be extrapolated and we can impose a fixed /// temperature by setting \f$ T^* = T^-\f$ which is equivalent /// to \f$ e^* = e^-\f$ /// </summary> /// <param name="time"> /// <see cref="BoundaryCondition.GetBoundaryState"/> /// </param> /// <param name="x"> /// <see cref="BoundaryCondition.GetBoundaryState"/> /// </param> /// <param name="normal"> /// <see cref="BoundaryCondition.GetBoundaryState"/> /// </param> /// <param name="stateIn"> /// <see cref="BoundaryCondition.GetBoundaryState"/> /// </param> /// <returns> /// \f$ (\rho^-, 0[, 0[, 0]], \rho^- e^*)^T\f$ where /// \f$ e* = (\gamma - 1.0) T^*\f$ /// </returns> public override StateVector GetBoundaryState(double time, Vector x, Vector normal, StateVector stateIn) { double gamma = config.EquationOfState.HeatCapacityRatio; double innerEnergy = TemperatureFunction(x, time) / (gamma - 1.0); double MachScaling = gamma * config.MachNumber * config.MachNumber; Debug.Assert(stateIn.Dimension == normal.Dim); int D = normal.Dim; if (WallVelocities == null) { // Kinetic energy is zero at a no-slip boundary, we can omit it return(new StateVector( stateIn.Material, stateIn.Density, new Vector(), stateIn.Density * innerEnergy)); } else { Vector velocity = new Vector(D); for (int d = 0; d < D; d++) { velocity[d] = WallVelocities[d](x, time); } #if DEBUG ilPSP.Vector n = new ilPSP.Vector(normal); if (Math.Abs(velocity * n) > 1e-10) { throw new Exception( "Wall velocity must be tangent to the wall"); } #endif // Kinetic energy is zero is solely determined by wall velocity return(new StateVector( stateIn.Material, stateIn.Density, stateIn.Density * velocity, stateIn.Density * (innerEnergy + 0.5 * MachScaling * velocity * velocity))); } }
/// <summary> /// Calculates the state at the boundary from the prescribed stagnation /// pressure and the prescribed stagnation temperature. The calculation /// follows FerzigerPeric2001 (p. 315ff). The flow is prescribed to be /// normal to the edge. /// </summary> /// <returns> /// \f$ /// T^+ = T_t(x) \frac{p_t(x)}{p^-}^{\frac{1.0 - \gamma}{\gamma}} /// \f$ /// \f$ /// |\vec{u^+}| = \sqrt{\frac{2 T^+}{(\gamma - 1) \mathrm{Ma}_\infty^2} \left(\frac{T_t(x)}{T^+} -1\right)} /// \f$ /// \f$ \rho^+ = \frac{p^- }{T^+}\f$ /// \f$ /// (\rho^+, -\rho^+ |\vec{u^+}| \vec{n}, \frac{p}{\kappa - 1} + \frac{rho^+ |\vec{u^+}|^2}{2})^T /// \f$ /// </returns> public override StateVector GetBoundaryState(double time, Vector x, Vector normal, StateVector stateIn) { double gamma = config.EquationOfState.HeatCapacityRatio; double Mach = config.MachNumber; ilPSP.Vector inwardNormal = new ilPSP.Vector(stateIn.Dimension); for (int i = 0; i < normal.Dim; i++) { inwardNormal[i] = -normal[i]; } double p0 = TotalPressureFunction(x, time); double T0 = TotalTemperatureFunction(x, time); double p = stateIn.Pressure; double T = TotalTemperatureFunction(x, time) * Math.Pow(p0 / p, (1.0 - gamma) / gamma); double rho = p / T; double VelocitySquare = 2.0 * T / ((gamma - 1.0) * (Mach * Mach)) * (T0 / T - 1.0); Vector velocityOut = Math.Sqrt(VelocitySquare) * inwardNormal; return(StateVector.FromPrimitiveQuantities(stateIn.Material, rho, velocityOut, p)); }
public override double _DerivativeSource(ilPSP.Vector x, double[] Parameters, double[,] GradientU) { return(base._DerivativeSource(x, Parameters, GradientU) * scale); }