/// <summary> /// flux at inner edges /// </summary> protected double InnerEdgeFlux(ref Foundation.CommonParams inp, double[] Uin, double[] Uout) { double r = 0; double ScalarIn = GetScalar(Uin); double ScalarOut = GetScalar(Uout); for (int i = 0; i < m_SpatialDimension; ++i) { r += 0.5 * ScalarIn * Uin[i] * inp.Normal[i]; r += 0.5 * ScalarOut * Uout[i] * inp.Normal[i]; } // Calculate dissipative part // ========================== double[] VelocityMeanIn = Uin.GetSubVector(0, m_SpatialDimension); ////////////////////////////TODO CHECK!!!!!!!!!!!!!!!!!!!! double[] VelocityMeanOut = Uout.GetSubVector(0, m_SpatialDimension); double LambdaIn; double LambdaOut; double TemperatureMeanIn = Uin[m_SpatialDimension]; double TemperatureMeanOut = Uout[m_SpatialDimension]; LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, false, ScalarIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, false, ScalarOut); double Lambda = Math.Max(LambdaIn, LambdaOut); r += 0.5 * Lambda * (ScalarIn - ScalarOut); if (double.IsNaN(r)) { throw new NotFiniteNumberException(); } return(r); }
/// <summary> /// bla bla bla /// </summary> protected override double InnerEdgeFlux(ref CommonParams inp, double[] Uin, double[] Uout) { double r = 0.0; // Calculate central part // ====================== double rhoIn = 1.0; double rhoOut = 1.0; switch (m_bcmap.PhysMode) { case PhysicsMode.Viscoelastic: case PhysicsMode.Incompressible: break; case PhysicsMode.LowMach: case PhysicsMode.Multiphase: rhoIn = EoS.GetDensity(inp.Parameters_IN[2 * m_SpatialDimension]); rhoOut = EoS.GetDensity(inp.Parameters_OUT[2 * m_SpatialDimension]); break; case PhysicsMode.Combustion: double[] args_IN = new double[NumberOfReactants + 1]; for (int n = 0; n < NumberOfReactants + 1; n++) { args_IN[n] = inp.Parameters_IN[2 * m_SpatialDimension + n]; } double[] args_OUT = new double[NumberOfReactants + 1]; for (int n = 0; n < NumberOfReactants + 1; n++) { args_OUT[n] = inp.Parameters_OUT[2 * m_SpatialDimension + n]; } rhoIn = EoS.GetDensity(args_IN); rhoOut = EoS.GetDensity(args_OUT); break; default: throw new NotImplementedException("PhysicsMode not implemented"); } // 2 * {u_i * u_j} * n_j, // resp. 2 * {rho * u_i * u_j} * n_j for variable density r += rhoIn * Uin[0] * (inp.Parameters_IN[0] * inp.Normale[0] + inp.Parameters_IN[1] * inp.Normale[1]); r += rhoOut * Uout[0] * (inp.Parameters_OUT[0] * inp.Normale[0] + inp.Parameters_OUT[1] * inp.Normale[1]); if (m_SpatialDimension == 3) { r += rhoIn * Uin[0] * inp.Parameters_IN[2] * inp.Normale[2] + rhoOut * Uout[0] * inp.Parameters_OUT[2] * inp.Normale[2]; } // Calculate dissipative part // ========================== double[] VelocityMeanIn = new double[m_SpatialDimension]; double[] VelocityMeanOut = new double[m_SpatialDimension]; for (int d = 0; d < m_SpatialDimension; d++) { VelocityMeanIn[d] = inp.Parameters_IN[m_SpatialDimension + d]; VelocityMeanOut[d] = inp.Parameters_OUT[m_SpatialDimension + d]; } double LambdaIn; double LambdaOut; switch (m_bcmap.PhysMode) { case PhysicsMode.Viscoelastic: case PhysicsMode.Incompressible: LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normale, true); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normale, true); break; case PhysicsMode.LowMach: case PhysicsMode.Multiphase: double TemperatureMeanIn = inp.Parameters_IN[2 * m_SpatialDimension + 1]; double TemperatureMeanOut = inp.Parameters_OUT[2 * m_SpatialDimension + 1]; LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normale, EoS, true, TemperatureMeanIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normale, EoS, true, TemperatureMeanOut); break; case PhysicsMode.Combustion: double[] ScalarMeanIn = new double[NumberOfReactants + 1]; double[] ScalarMeanOut = new double[NumberOfReactants + 1]; for (int n = 0; n < NumberOfReactants + 1; n++) { ScalarMeanIn[n] = inp.Parameters_IN[2 * m_SpatialDimension + NumberOfReactants + 1 + n]; ScalarMeanOut[n] = inp.Parameters_OUT[2 * m_SpatialDimension + NumberOfReactants + 1 + n]; } LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normale, EoS, true, ScalarMeanIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normale, EoS, true, ScalarMeanOut); break; default: throw new NotImplementedException(); } double Lambda = Math.Max(LambdaIn, LambdaOut); double uJump = Uin[0] - Uout[0]; r += Lambda * uJump * LaxFriedrichsSchemeSwitch; r *= 0.5; return(r); }
/// <summary> /// flux at inner edges /// </summary> protected override double InnerEdgeFlux(ref Foundation.CommonParams inp, double[] Uin, double[] Uout) { double r = 0.0; // Calculate central part // ====================== // 2 * {u_j * phi} * n_j for Level-Set advection // 2 * {rho u_j * T} * n_j for Low-Mach advection double rhoIn = 1.0; double rhoOut = 1.0; if (m_bcmap.PhysMode == PhysicsMode.LowMach) { rhoIn = EoS.GetDensity(inp.Parameters_IN[2 * m_SpatialDimension]); rhoOut = EoS.GetDensity(inp.Parameters_OUT[2 * m_SpatialDimension]); } r += rhoIn * Uin[0] * (inp.Parameters_IN[0] * inp.Normal[0] + inp.Parameters_IN[1] * inp.Normal[1]); r += rhoOut * Uout[0] * (inp.Parameters_OUT[0] * inp.Normal[0] + inp.Parameters_OUT[1] * inp.Normal[1]); if (m_SpatialDimension == 3) { r += rhoIn * Uin[0] * inp.Parameters_IN[2] * inp.Normal[2] + rhoOut * Uout[0] * inp.Parameters_OUT[2] * inp.Normal[2]; } // Calculate dissipative part // ========================== IList <double> _VelocityMeanIn = new List <double>(); IList <double> _VelocityMeanOut = new List <double>(); for (int d = 0; d < m_SpatialDimension; d++) { _VelocityMeanIn.Add(inp.Parameters_IN[m_SpatialDimension + d]); _VelocityMeanOut.Add(inp.Parameters_OUT[m_SpatialDimension + d]); } double[] VelocityMeanIn = _VelocityMeanIn.ToArray(); double[] VelocityMeanOut = _VelocityMeanOut.ToArray(); double LambdaIn; double LambdaOut; switch (m_bcmap.PhysMode) { case PhysicsMode.Multiphase: LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, false); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, false); break; case PhysicsMode.LowMach: double ScalarMeanIn = inp.Parameters_IN[2 * m_SpatialDimension + 1]; double ScalarMeanOut = inp.Parameters_OUT[2 * m_SpatialDimension + 1]; LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, EoS, false, ScalarMeanIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, EoS, false, ScalarMeanOut); break; case PhysicsMode.RANS: Func <IEnumerable <double>, IEnumerable <double>, double> ScalarProduct = (a, b) => (a.Zip(b, (ai, bi) => ai * bi)).Sum(); LambdaIn = ScalarProduct(VelocityMeanIn, inp.Normal); LambdaOut = ScalarProduct(VelocityMeanOut, inp.Normal); break; default: throw new NotImplementedException(); } double Lambda = Math.Max(LambdaIn, LambdaOut); double Scalar_Jump = Uin[0] - Uout[0]; r += Lambda * Scalar_Jump; r *= 0.5; return(r); }
/// <summary> /// flux at inner edges /// </summary> double InnerEdgeFlux(ref Foundation.CommonParams inp, double[] Uin, double[] Uout) { double r = 0.0; int idx = argumentIndex; // Calculate central part // ====================== // 2 * (rho u_j * scalar) * n_j double rhoIn = 0.0; double rhoOut = 0.0; switch (m_bcmap.PhysMode) { case PhysicsMode.MixtureFraction: rhoIn = EoS.getDensityFromZ(Uin[inp.D]); rhoOut = EoS.getDensityFromZ(Uout[inp.D]); break; case PhysicsMode.LowMach: double[] DensityArgumentsIn = Uin.GetSubVector(m_SpatialDimension, 1); double[] DensityArgumentsOut = Uout.GetSubVector(m_SpatialDimension, 1); rhoIn = EoS.GetDensity(DensityArgumentsIn); rhoOut = EoS.GetDensity(DensityArgumentsOut); break; case PhysicsMode.Combustion: double[] DensityArgumentsIn2 = Uin.GetSubVector(m_SpatialDimension, NumberOfReactants); double[] DensityArgumentsOut2 = Uout.GetSubVector(m_SpatialDimension, NumberOfReactants); rhoIn = EoS.GetDensity(DensityArgumentsIn2); rhoOut = EoS.GetDensity(DensityArgumentsOut2); break; default: throw new NotImplementedException("PhysicsMode not implemented"); } Debug.Assert((rhoIn > 0.0) && (rhoOut > 0.0)); r += rhoIn * Uin[idx] * (Uin[0] * inp.Normal[0] + Uin[1] * inp.Normal[1]); r += rhoOut * Uout[idx] * (Uout[0] * inp.Normal[0] + Uout[1] * inp.Normal[1]); if (m_SpatialDimension == 3) { //r += rhoIn * Uin[idx] * (Uin[2] * inp.Normal[2] + Uout[2] * inp.Normal[2]); r += rhoIn * Uin[idx] * Uin[2] * inp.Normal[2] + rhoOut * Uout[idx] * Uout[2] * inp.Normal[2]; } // Calculate dissipative part // ========================== double[] VelocityMeanIn = Uin.GetSubVector(0, m_SpatialDimension); double[] VelocityMeanOut = Uout.GetSubVector(0, m_SpatialDimension); double LambdaIn; double LambdaOut; switch (m_bcmap.PhysMode) { case PhysicsMode.MixtureFraction: LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, false, rhoIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, false, rhoOut); break; case PhysicsMode.Multiphase: LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, false); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, false); break; case PhysicsMode.LowMach: double ScalarMeanIn = Uin[m_SpatialDimension]; double ScalarMeanOut = Uout[m_SpatialDimension]; LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, EoS, false, ScalarMeanIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, EoS, false, ScalarMeanOut); break; case PhysicsMode.Combustion: { double[] ScalarMeanIn_vec = Uin.GetSubVector(m_SpatialDimension, NumberOfReactants - 1 + 1); double[] ScalarMeanOut_vec = Uout.GetSubVector(m_SpatialDimension, NumberOfReactants - 1 + 1); LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, EoS, false, ScalarMeanIn_vec); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, EoS, false, ScalarMeanOut_vec); break; } default: throw new NotImplementedException(); } if (double.IsNaN(LambdaIn) || double.IsInfinity(LambdaIn) || double.IsNaN(LambdaOut) || double.IsInfinity(LambdaOut)) { throw new NotFiniteNumberException(); } double Lambda = Math.Max(LambdaIn, LambdaOut); r += Lambda * (Uin[idx] - Uout[idx]) * LaxFriedrichsSchemeSwitch; r *= 0.5; if (double.IsNaN(r)) { throw new NotFiniteNumberException(); } return(r); }
/// <summary> /// flux at inner edges /// </summary> protected override double InnerEdgeFlux(ref Foundation.CommonParams inp, double[] Uin, double[] Uout) { double r = 0.0; // Calculate central part // ====================== // 2 * (rho u_j * scalar) * n_j double rhoIn = 0.0; double rhoOut = 0.0; switch (m_bcmap.PhysMode) { case PhysicsMode.LowMach: rhoIn = EoS.GetDensity(inp.Parameters_IN[2 * m_SpatialDimension]); rhoOut = EoS.GetDensity(inp.Parameters_OUT[2 * m_SpatialDimension]); break; case PhysicsMode.Combustion: double[] args_IN = new double[NumberOfReactants + 1]; for (int n = 0; n < NumberOfReactants + 1; n++) { args_IN[n] = inp.Parameters_IN[2 * m_SpatialDimension + n]; } double[] args_OUT = new double[NumberOfReactants + 1]; for (int n = 0; n < NumberOfReactants + 1; n++) { args_OUT[n] = inp.Parameters_OUT[2 * m_SpatialDimension + n]; } rhoIn = EoS.GetDensity(args_IN); rhoOut = EoS.GetDensity(args_OUT); break; default: throw new NotImplementedException("PhysicsMode not implemented"); } r += rhoIn * Uin[0] * (inp.Parameters_IN[0] * inp.Normal[0] + inp.Parameters_IN[1] * inp.Normal[1]); r += rhoOut * Uout[0] * (inp.Parameters_OUT[0] * inp.Normal[0] + inp.Parameters_OUT[1] * inp.Normal[1]); if (m_SpatialDimension == 3) { r += rhoIn * Uin[0] * inp.Parameters_IN[2] * inp.Normal[2] + rhoOut * Uout[0] * inp.Parameters_OUT[2] * inp.Normal[2]; } // Calculate dissipative part // ========================== IList <double> _VelocityMeanIn = new List <double>(); IList <double> _VelocityMeanOut = new List <double>(); for (int d = 0; d < m_SpatialDimension; d++) { _VelocityMeanIn.Add(inp.Parameters_IN[m_SpatialDimension + d]); _VelocityMeanOut.Add(inp.Parameters_OUT[m_SpatialDimension + d]); } double[] VelocityMeanIn = _VelocityMeanIn.ToArray(); double[] VelocityMeanOut = _VelocityMeanOut.ToArray(); double LambdaIn; double LambdaOut; switch (m_bcmap.PhysMode) { case PhysicsMode.Multiphase: LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, false); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, false); break; case PhysicsMode.LowMach: double TemperatureMeanIn = inp.Parameters_IN[2 * m_SpatialDimension + 1]; double TemperatureMeanOut = inp.Parameters_OUT[2 * m_SpatialDimension + 1]; Debug.Assert(TemperatureMeanOut != 0); LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, EoS, false, TemperatureMeanIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, EoS, false, TemperatureMeanOut); if (double.IsNaN(LambdaIn) || double.IsInfinity(LambdaIn)) { throw new NotFiniteNumberException(); } if (double.IsNaN(LambdaOut) || double.IsInfinity(LambdaOut)) { throw new NotFiniteNumberException(); } break; case PhysicsMode.Combustion: double[] ScalarMeanIn = new double[NumberOfReactants + 1]; double[] ScalarMeanOut = new double[NumberOfReactants + 1]; for (int n = 0; n < NumberOfReactants + 1; n++) { ScalarMeanIn[n] = inp.Parameters_IN[2 * m_SpatialDimension + NumberOfReactants + 1 + n]; ScalarMeanOut[n] = inp.Parameters_OUT[2 * m_SpatialDimension + NumberOfReactants + 1 + n]; } LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, inp.Normal, EoS, false, ScalarMeanIn); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, inp.Normal, EoS, false, ScalarMeanOut); break; default: throw new NotImplementedException(); } double Lambda = Math.Max(LambdaIn, LambdaOut); r += Lambda * (Uin[0] - Uout[0]); r *= 0.5; if (double.IsNaN(r)) { throw new NotFiniteNumberException(); } return(r); }