//List<int> cellElo = new List<int>(); protected void ComputeScaling(ref CommonParams inp, out double scaleIN, out double scaleOT) { Debug.Assert(Math.Sign(muA) == Math.Sign(muB)); switch (this.m_mode) { case Mode.SWIP: { scaleIN = muB / (muA + muB); scaleOT = muA / (muA + muB); return; } case Mode.SIP: { // Konventionell: scaleIN = 0.5; scaleOT = 0.5; return; } /* * case Mode.VolumeScaled: { * double volIN = this.m_LsTrk._Regions.GetSpeciesVolume(inp.jCell, this.NegativeSpecies); * double volOT = this.m_LsTrk._Regions.GetSpeciesVolume(inp.jCell, this.PositiveSpecies); * * scaleIN = volIN / (volIN + volOT); * scaleOT = volOT / (volIN + volOT); * Debug.Assert(Math.Abs(scaleIN + scaleOT - 1.0) <= 1.0e-8); * return; * } */ default: throw new NotImplementedException(); } }
public override double InnerEdgeForm(ref CommonParams cp, double[] U_Neg, double[] U_Pos, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { double M = ComputeEvaporationMass(cp.Parameters_IN.GetSubVector(2 * m_D, m_D + 3), cp.Parameters_OUT.GetSubVector(2 * m_D, m_D + 3), cp.Normal, cp.jCellIn); if (M == 0.0) { return(0.0); } double[] VelocityMeanIn = new double[m_D]; double[] VelocityMeanOut = new double[m_D]; for (int d = 0; d < m_D; d++) { VelocityMeanIn[d] = cp.Parameters_IN[m_D + d]; VelocityMeanOut[d] = cp.Parameters_OUT[m_D + d]; } double LambdaIn; double LambdaOut; LambdaIn = LambdaConvection.GetLambda(VelocityMeanIn, cp.Normal, false); LambdaOut = LambdaConvection.GetLambda(VelocityMeanOut, cp.Normal, false); double Lambda = Math.Max(LambdaIn, LambdaOut); double uJump = -M * ((1 / m_rhoA) - (1 / m_rhoB)) * cp.Normal[m_d]; double flx = Lambda * uJump * 0.8; return(-flx * (m_rhoA * vA - m_rhoB * vB)); }
double GetPenalty(ref CommonParams inp) { //double penaltySizeFactor_A = 1.0 / this.ccBB.Get_hminBB(this.SpcId, inp.jCellIn); //double penaltySizeFactor_B = 1.0 / this.ccBB.Get_hminBB(this.SpcId, inp.jCellOut); double penaltySizeFactor_A = 1.0 / this.m_LenScales[inp.jCellIn]; double penaltySizeFactor_B = 1.0 / this.m_LenScales[inp.jCellOut]; Debug.Assert(!double.IsNaN(penaltySizeFactor_A)); Debug.Assert(!double.IsNaN(penaltySizeFactor_B)); Debug.Assert(!double.IsInfinity(penaltySizeFactor_A)); Debug.Assert(!double.IsInfinity(penaltySizeFactor_B)); double penaltySizeFactor = Math.Max(penaltySizeFactor_A, penaltySizeFactor_B); double penalty_muFactor; switch (this.m_Mode) { case XLaplace_Interface.Mode.SIP: //case XLaplace_Interface.Mode.VolumeScaled: case XLaplace_Interface.Mode.SWIP: penalty_muFactor = species_Mu; break; default: throw new NotImplementedException(); } return(this.penatly_baseFactor * penaltySizeFactor * penalty_muFactor); }
void ComputeScaling(ref CommonParams inp, out double scaleIN, out double scaleOT) { switch (this.m_Mode) { case XLaplace_Interface.Mode.SIP: case XLaplace_Interface.Mode.SWIP: { scaleIN = 0.5; scaleOT = 0.5; return; } /* * case XLaplace_Interface.Mode.VolumeScaled: { * double volIN = LsTrk._Regions.GetSpeciesVolume(inp.jCellIn, this.SpcId); * double volOT = LsTrk._Regions.GetSpeciesVolume(inp.jCellOut, this.SpcId); * * scaleIN = volIN / (volIN + volOT); * scaleOT = volOT / (volIN + volOT); * * Debug.Assert(Math.Abs(scaleIN + scaleOT - 1.0) <= 1.0e-8); * return; * } */ default: throw new NotImplementedException(); } }
/// <summary> /// Stress divergence inner edge term /// </summary> protected override double InnerEdgeFlux(ref CommonParams inp, double[] Tin, double[] Tout) { double res = 0; int jIn = inp.jCellIn; int jOt = inp.jCellOut; double h_min_in_loc = inp.GridDat.iGeomCells.h_min[jIn]; double h_min_ot_loc = inp.GridDat.iGeomCells.h_min[jOt]; double h_Edge = ((GridData.EdgeData)(inp.GridDat.iGeomEdges)).h_min_Edge[inp.iEdge]; double h = Math.Min(h_min_in_loc, h_min_ot_loc); double h2 = Math.Min(h, h_Edge); res += 0.5 * (Tin[0] + Tout[0]) * inp.Normal[0] + 0.5 * (Tin[1] + Tout[1]) * inp.Normal[1]; // central difference for stress divergence switch (Component) { case 0: res += -pen2 / h2 * (Tin[2] - Tout[2]); break; case 1: res += -pen2 / h2 * (Tin[2] - Tout[2]); break; default: throw new NotImplementedException(); } return(InverseReynolds * res); }
protected override double InnerEdgeFlux(ref CommonParams inp, double[] Uin, double[] Uout) { double Umean_dot_Normal = 0; for (int d = D - 1; d >= 0; d--) { Umean_dot_Normal += (inp.Parameters_IN[d] + inp.Parameters_OUT[d]) * inp.Normale[d]; } Umean_dot_Normal *= 0.5; double flux = 0; if (Umean_dot_Normal >= 0) { for (int d = D - 1; d >= 0; d--) { flux += inp.Parameters_IN[d] * inp.Normale[d]; } flux *= Uin[0]; } else { for (int d = D - 1; d >= 0; d--) { flux += inp.Parameters_OUT[d] * inp.Normale[d]; } flux *= Uout[0]; } return(flux); }
public ASRApi(AppSettings settings, CommonParams common, DataParams data, BusinessParams business) { _settings = settings; _common = common; _data = data; _business = business; }
public double InnerEdgeForm(ref CommonParams inp, double[] _uIN, double[] _uOUT, double[,] _Grad_uIN, double[,] _Grad_uOUT, double _vIN, double _vOUT, double[] _Grad_vIN, double[] _Grad_vOUT) { double[] Normale = inp.Normale.CloneAs(); //double[,] T__in, double[,] T_out, double[,] S, double[] U0__in, double[] U0_out double[,] T__in = new double[2, 2]; double[,] T_out = new double[2, 2]; double[,] S__in = new double[2, 2]; double[,] S_out = new double[2, 2]; T__in[0, 0] = _uIN[0]; // stress_XX T__in[1, 0] = _uIN[1]; // stress_XY T__in[0, 1] = _uIN[1]; // stress_XY T__in[1, 1] = _uIN[2]; // stress_YY T_out[0, 0] = _uOUT[0]; // stress_XX T_out[1, 0] = _uOUT[1]; // stress_XY T_out[0, 1] = _uOUT[1]; // stress_XY T_out[1, 1] = _uOUT[2]; // stress_YY S__in[ComponentRow, ComponentCol] = _vIN; S_out[ComponentRow, ComponentCol] = _vOUT; double flxIn = MyCellBoundaryForm(Normale, T__in, T_out, S__in, inp.Parameters_IN, inp.Parameters_OUT, false, 0); Normale.ScaleV(-1.0); double flxOt = MyCellBoundaryForm(Normale, T_out, T__in, S_out, inp.Parameters_OUT, inp.Parameters_IN, false, 0); return(flxIn + flxOt); }
protected double GetPenalty(ref CommonParams inp) { double PosCellLengthScale = LengthScaleS[inp.jCellOut]; double NegCellLengthScale = LengthScaleS[inp.jCellIn]; double penaltySizeFactor_A = 1.0 / NegCellLengthScale; double penaltySizeFactor_B = 1.0 / PosCellLengthScale; Debug.Assert(!double.IsNaN(penaltySizeFactor_A)); Debug.Assert(!double.IsNaN(penaltySizeFactor_B)); Debug.Assert(!double.IsInfinity(penaltySizeFactor_A)); Debug.Assert(!double.IsInfinity(penaltySizeFactor_B)); double penaltySizeFactor = Math.Max(penaltySizeFactor_A, penaltySizeFactor_B); double penalty_muFactor; switch (this.m_mode) { case Mode.SWIP: penalty_muFactor = (2.0 * muA * muB) / (muA + muB); break; case Mode.SIP: //case Mode.VolumeScaled: penalty_muFactor = Math.Max(Math.Abs(muA), Math.Abs(muB)) * Math.Sign(muA); break; default: throw new NotImplementedException(); } return(this.penatly_baseFactor * penaltySizeFactor * penalty_muFactor); }
public ASRApi BuildASR() { if (_settings == null) { throw new Exception("App setting can not null."); } if (string.IsNullOrEmpty(_language)) { throw new Exception("Language set can not null."); } CommonParams common = new CommonParams() { app_id = _settings.AppID, uid = _uid, }; DataParams data = new DataParams() { format = _format, encoding = _encoding }; BusinessParams business = new BusinessParams() { language = _language, domain = _domain, accent = _accent, }; ASRApi api = new ASRApi(_settings, common, data, business); api.OnError += _onError; api.OnMessage += _onMessage; return(api); }
public override double InnerEdgeForm(ref CommonParams inp, double[] U_Neg, double[] U_Pos, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { double FlxNeg = 0; // we are not interested in "A" double FlxPos = U_Pos[0] * inp.Normal[0]; return(FlxNeg * vA - FlxPos * vB); }
public double InnerEdgeForm(ref CommonParams inp, double[] _uA, double[] _uB, double[,] _Grad_uA, double[,] _Grad_uB, double _vA, double _vB, double[] _Grad_vA, double[] _Grad_vB) { double Acc = 0.0; double pnlty = GetPenalty(inp.jCellIn, inp.jCellOut);//, inp.GridDat.Cells.cj); double DiffusivityA; double DiffusivityB; double DiffusivityMax; double[] difusivityArguments_IN = prmsOK ? inp.Parameters_IN : _uA; double[] difusivityArguments_OUT = prmsOK ? inp.Parameters_OUT : _uB; DiffusivityA = Diffusivity(difusivityArguments_IN); DiffusivityB = Diffusivity(difusivityArguments_OUT); foreach (var Diffusivity in new double[] { DiffusivityA, DiffusivityB }) { Debug.Assert(!double.IsNaN(Diffusivity)); Debug.Assert(!double.IsInfinity(Diffusivity)); } for (int d = 0; d < inp.D; d++) { // consistency term Acc += 0.5 * (DiffusivityA * _Grad_uA[i, d] + DiffusivityB * _Grad_uB[i, d]) * (_vA - _vB) * inp.Normal[d]; // symmetry term Acc += 0.5 * (DiffusivityA * _Grad_vA[d] + DiffusivityB * _Grad_vB[d]) * (_uA[i] - _uB[i]) * inp.Normal[d]; } // penalty term DiffusivityMax = (Math.Abs(DiffusivityA) > Math.Abs(DiffusivityB)) ? DiffusivityA : DiffusivityB; Acc -= (_uA[i] - _uB[i]) * (_vA - _vB) * pnlty * DiffusivityMax; return(-Acc); }
/// <summary> /// Penalty Term enforcing the Dirichlet value at the interface /// Note: this Form is written only in terms of uA, since there is no XDG-field involved /// </summary> /// <param name="inp">inp.ParamsNeg[0] is the Dirichlet value from the parameter-field</param> /// <param name="uA">the unknown</param> /// <param name="uB">not needed</param> /// <param name="Grad_uA">not needed</param> /// <param name="Grad_uB">not needed</param> /// <param name="vA">test function</param> /// <param name="vB">not needed</param> /// <param name="Grad_vA">not needed</param> /// <param name="Grad_vB">not needed</param> /// <returns>the evaluated penalty flux</returns> public double InnerEdgeForm(ref CommonParams inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { double NegCellLengthScale = NegCellLengthScaleS[inp.jCellIn]; double PosCellLengthScale = (PosCellLengthScaleS != null) ? PosCellLengthScaleS[inp.jCellOut] : NegCellLengthScaleS[inp.jCellOut]; double hmin; if (NegCellLengthScale.IsNaN()) { hmin = PosCellLengthScale; } else if (PosCellLengthScale.IsNaN()) { hmin = NegCellLengthScale; } else { hmin = Math.Min(NegCellLengthScale, PosCellLengthScale); } //return PenaltyBase * 2 / hmin * (uA[0] + uB[0] - inp.ParamsNeg[0] - inp.ParamsPos[0]) * (vA+vB) /4 ; return(PenaltyBase * 2 / hmin * (uA[0] - inp.Parameters_IN[0]) * (vA)); //return PenaltyBase * 2 / hmin * (uB[0] - inp.ParamsPos[0]) * (vB); }
public static void ApplyArgument(string arg) { char[] splitter = { '=' }; string[] sp = arg.ToLower().Split(splitter); if (sp.Length == 1) { ApplyArgumentsInFile(arg); return; } else if (sp.Length != 2) { throw new InvalidParameterException("Invalid command-line argument " + arg); } string parameter = sp[0]; string value = sp[1]; if (CommonParams.ApplyArgument(parameter, value)) { return; } if (String.Compare(parameter, "secretLength", StringComparison.OrdinalIgnoreCase) == 0) { Parameters.secretLength = Convert.ToInt32(value); return; } throw new InvalidParameterException("Invalid command-line parameter " + parameter); }
public double InnerEdgeForm(ref CommonParams inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { double S0 = 0; // velocity in normal direction, at the interface for (int d = 0; d < D; d++) { S0 += inp.Normal[d] * inp.Parameters_IN[d]; } double NegCellLengthScale = NegCellLengthScaleS[inp.jCellIn]; double PosCellLengthScale = PosCellLengthScaleS[inp.jCellOut]; double hmin; if (NegCellLengthScale.IsNaN()) { hmin = PosCellLengthScale; } else if (PosCellLengthScale.IsNaN()) { hmin = NegCellLengthScale; } else { hmin = Math.Min(NegCellLengthScale, PosCellLengthScale); } double penalty = PenaltyBase / hmin; return(penalty * (uA[0] - S0) * vA); }
public double InnerEdgeForm(ref CommonParams inp, double[] U_Neg, double[] U_Pos, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { double FlxNeg = -U_Neg[0] * inp.Normal[0] * alpha_A; double FlxPos = -U_Pos[0] * inp.Normal[0] * alpha_B; return(FlxNeg * vA - FlxPos * vB); }
/// <summary> /// default-implementation /// </summary> public double InnerEdgeForm(ref CommonParams inp, //public override double EdgeForm(ref Linear2ndDerivativeCouplingFlux.CommonParams inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { double[] N = inp.Normal; double hCellMin = this.m_LsTrk.GridDat.Cells.h_min[inp.jCellIn]; // symmetric interior penalty // ========================== int D = N.Length; double Grad_uA_xN = 0, Grad_uB_xN = 0, Grad_vA_xN = 0, Grad_vB_xN = 0; for (int d = 0; d < D; d++) { Grad_uA_xN += Grad_uA[0, d] * N[d]; Grad_uB_xN += Grad_uB[0, d] * N[d]; Grad_vA_xN += Grad_vA[d] * N[d]; Grad_vB_xN += Grad_vB[d] * N[d]; } double NegCellLengthScale = NegCellLengthScaleS[inp.jCellIn]; double PosCellLengthScale = PosCellLengthScaleS[inp.jCellOut]; double hCutCellMin = Math.Min(NegCellLengthScale, PosCellLengthScale); Debug.Assert(!(double.IsInfinity(hCutCellMin) || double.IsNaN(hCutCellMin))); if (hCutCellMin <= 1.0e-10 * hCellMin) { // very small cell -- clipping hCutCellMin = hCellMin; } double Ret = 0.0; Ret -= 0.5 * (m_muA * Grad_uA_xN + m_muB * Grad_uB_xN) * (vA - vB); // consistency term Ret -= 0.5 * (m_muA * Grad_vA_xN + m_muB * Grad_vB_xN) * (uA[0] - uB[0]); // symmetry term Ret += (m_penalty / hCutCellMin) * (uA[0] - uB[0]) * (vA - vB) * (Math.Abs(m_muA) > Math.Abs(m_muB) ? m_muA : m_muB); // penalty term // moving-mesh-contribution // ======================== double s = m_NormalVel(inp.X, inp.time); double movingFlux; if (s > 0) // select DOWN-wind! { movingFlux = (-s) * uB[0]; } else { movingFlux = (-s) * uA[0]; } Debug.Assert(!(double.IsInfinity(Ret) || double.IsNaN(Ret))); return(Ret); }
public double InnerEdgeForm(ref CommonParams inp, double[] PhiIn, double[] PhiOt, double[,] GradPhiIn, double[,] GradPhiOt, double vIn, double vOt, double[] Grad_vIn, double[] Grad_vOt) { double signIn = Math.Sign(m_PhiMean[inp.jCellIn]); double signOt = Math.Sign(m_PhiMean[inp.jCellOut]); double Flux; if (signIn != signOt || (signIn * signOt == 0)) { // central difference Flux = 0.5 * (PhiIn[0] + PhiOt[0]) * (inp.Normal[this.m_Direction]); } else { Debug.Assert(Math.Abs(signIn) == 1); Debug.Assert(Math.Abs(signOt) == 1); Debug.Assert(signIn == signOt); double sign = signIn; double delta = (m_PhiMean[inp.jCellIn] - m_PhiMean[inp.jCellOut]) * sign; if (delta < 0) { Flux = PhiIn[0] * (inp.Normal[this.m_Direction]); } else { Flux = PhiOt[0] * (inp.Normal[this.m_Direction]); } } return(Flux * (vIn - vOt)); }
public static void PrintUsage() { Console.Out.WriteLine("Usage: TrIncSrv.exe [filename or param=value]... where filename contains"); Console.Out.WriteLine(" lines of the form param=value and param must be one of the following."); Console.Out.WriteLine(); CommonParams.PrintUsage(); }
/// <summary> /// Implementation of the LinearDualValueFlux for Inner-Edges, based on <see cref="IEdgeForm"/> /// </summary> /// <param name="inp"><see cref="IEdgeForm"/></param> /// <param name="_uA"><see cref="IEdgeForm"/></param> /// <param name="_uB"><see cref="IEdgeForm"/></param> /// <param name="_Grad_uA"><see cref="IEdgeForm"/></param> /// <param name="_Grad_uB"><see cref="IEdgeForm"/></param> /// <param name="_vA"><see cref="IEdgeForm"/></param> /// <param name="_vB"><see cref="IEdgeForm"/></param> /// <param name="_Grad_vA"><see cref="IEdgeForm"/></param> /// <param name="_Grad_vB"><see cref="IEdgeForm"/></param> /// <returns></returns> public double InnerEdgeForm(ref CommonParams inp, double[] _uA, double[] _uB, double[,] _Grad_uA, double[,] _Grad_uB, double _vA, double _vB, double[] _Grad_vA, double[] _Grad_vB) { double Flx_InCell, Flx_OutCell; this.InnerEdgeFlux(ref inp, _uA, _uB, out Flx_InCell, out Flx_OutCell); return(Flx_InCell * _vA + Flx_OutCell * _vB); }
public static void ApplyArgument(string arg) { char[] splitter = { '=' }; string[] sp = arg.ToLower().Split(splitter); if (sp.Length == 1) { ApplyArgumentsInFile(arg); return; } else if (sp.Length != 2) { throw new InvalidParameterException("Invalid command-line argument " + arg); } string parameter = sp[0]; string value = sp[1]; if (CommonParams.ApplyArgument(parameter, value)) { return; } throw new InvalidParameterException("Invalid command-line parameter " + parameter); }
private double GetCoeff(ref double d1, ref double d2, ref CommonParams inp) { int D = inp.Normale.Length; Debug.Assert(this.NoArgs == this.ArgumentOrdering.Count); Debug.Assert(uA.Length == NoArgs); Debug.Assert(uB.Length == NoArgs); Debug.Assert(Grad_uA.GetLength(0) == NoArgs); Debug.Assert(Grad_uB.GetLength(0) == NoArgs); Debug.Assert(Grad_uA.GetLength(1) == D); Debug.Assert(Grad_uB.GetLength(1) == D); Debug.Assert(Grad_vA.Length == D); Debug.Assert(Grad_vB.Length == D); Debug.Assert(this.edgeForm.InnerEdgeForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB) == 0.0); d2 = 1; // set test function double a1 = this.edgeForm.InnerEdgeForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB); // probe for the source/affine part Debug.Assert((this.InnerEdgeTerms & (TermActivationFlags.GradV | TermActivationFlags.V)) != 0 || a1 == 0); d1 = 1; // set trial function double a = this.edgeForm.InnerEdgeForm(ref inp, uA, uB, Grad_uA, Grad_uB, vA, vB, Grad_vA, Grad_vB); // probe for the bilinear+affine part d1 = 0; // reset d2 = 0; // reset return(a - a1); }
protected override double InnerEdgeFlux(ref CommonParams inp, double[] Tin, double[] Tout) { double res = 0; double u = 0.5 * (inp.Parameters_IN[0] + inp.Parameters_OUT[0]); double v = 0.5 * (inp.Parameters_IN[1] + inp.Parameters_OUT[1]); Vector n = new Vector(inp.Normale[0], inp.Normale[1]); Vector velocityVector = new Vector(u, v); if (velocityVector * n > 0) { //Outflow res += u * (m_alpha * Tin[0] + (1 - m_alpha) * Tout[0]) * inp.Normale[0]; res += v * (m_alpha * Tin[0] + (1 - m_alpha) * Tout[0]) * inp.Normale[1]; } else { //Inflow res += u * (m_alpha * Tout[0] + (1 - m_alpha) * Tin[0]) * inp.Normale[0]; res += v * (m_alpha * Tout[0] + (1 - m_alpha) * Tin[0]) * inp.Normale[1]; } return(m_Weissenberg * res); }
override public double InnerEdgeForm(ref CommonParams inp, double[] _uA, double[] _uB, double[,] _Grad_uA, double[,] _Grad_uB, double _vA, double _vB, double[] _Grad_vA, double[] _Grad_vB) { double Acc = 0.0; double muA = this.Nu(inp.X, inp.Parameters_IN, inp.jCellIn); double muB = this.Nu(inp.X, inp.Parameters_OUT, inp.jCellOut); double scaleIN, scaleOT; ComputeScaling(ref inp, out scaleIN, out scaleOT); for (int d = 0; d < inp.D; d++) { Acc += (scaleIN * muA * _Grad_uA[0, d] + scaleOT * muB * _Grad_uB[0, d]) * (_vA - _vB) * inp.Normal[d]; // consistency term Acc += (scaleIN * muA * _Grad_vA[d] + scaleOT * muB * _Grad_vB[d]) * (_uA[0] - _uB[0]) * inp.Normal[d]; // symmetry term } Acc *= this.m_alpha; Acc -= (_uA[0] - _uB[0]) * (_vA - _vB) * this.GetPenalty(ref inp); // penalty term return(Acc); }
public override double InnerEdgeForm(ref CommonParams cp, double[] U_Neg, double[] U_Pos, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { throw new NotImplementedException("TODO"); //double M = ComputeEvaporationMass(cp.ParamsNeg, cp.ParamsPos, cp.n, cp.jCell); //double s; //if (hVapA > 0) { // s = (M / rhoB) * cp.n[m_d] + U_Pos[0]; //} else { // s = (M / rhoA) * cp.n[m_d] + U_Neg[0]; //} //double FlxNeg; //double FlxPos; //if (hVapA > 0) { // FlxNeg = -s * U_Neg[0]; // FlxPos = -FlxNeg; //} else { // FlxNeg = -s * U_Pos[0]; // FlxPos = -FlxNeg; //} //return FlxNeg * vA - FlxPos * vB; }
public virtual double InnerEdgeForm(ref CommonParams inp, double[] uA, double[] uB, double[,] Grad_uA, double[,] Grad_uB, double vA, double vB, double[] Grad_vA, double[] Grad_vB) { double[] N = inp.Normal; double Grad_uA_xN = 0, Grad_uB_xN = 0, Grad_vA_xN = 0, Grad_vB_xN = 0; int D = N.Length; Debug.Assert(Grad_uA.GetLength(0) == this.ArgumentOrdering.Count); Debug.Assert(Grad_uB.GetLength(0) == this.ArgumentOrdering.Count); Debug.Assert(Grad_uA.GetLength(1) == D); Debug.Assert(Grad_uB.GetLength(1) == D); for (int d = 0; d < D; d++) { Grad_uA_xN += Grad_uA[0, d] * N[d]; Grad_uB_xN += Grad_uB[0, d] * N[d]; Grad_vA_xN += Grad_vA[d] * N[d]; Grad_vB_xN += Grad_vB[d] * N[d]; } double omega_A, omega_B; ComputeScaling(ref inp, out omega_A, out omega_B); double Ret = 0.0; Ret += (muA * omega_A * Grad_uA_xN + muB * omega_B * Grad_uB_xN) * (vA - vB); Ret += (muA * omega_A * Grad_vA_xN + muB * omega_B * Grad_vB_xN) * (uA[0] - uB[0]); // Ret -= GetPenalty(ref inp) * (uA[0] - uB[0]) * (vA - vB); return(Ret); }
/// <summary> /// /// </summary> /// <param name="inp"> /// </param> /// <param name="uIn"> /// ExtensionVelocity /// </param> /// <param name="uOut"></param> /// <param name="Grad_uIn"></param> /// <param name="Grad_uOut"></param> /// <param name="vIn"></param> /// <param name="vOut"></param> /// <param name="Grad_vA"></param> /// <param name="Grad_vB"></param> /// <returns></returns> public override double InnerEdgeForm(ref CommonParams inp, double[] uIn, double[] uOut, double[,] Grad_uIn, double[,] Grad_uOut, double vIn, double vOut, double[] Grad_vA, double[] Grad_vB) { double Acc = 0.0; double AbsGrad_uIn = 0; double AbsGrad_uOut = 0; for (int d = 0; d < inp.D; d++) { AbsGrad_uIn += Grad_uIn[0, d] * Grad_uIn[0, d]; AbsGrad_uOut += Grad_uOut[0, d] * Grad_uOut[0, d]; } AbsGrad_uIn = Math.Sqrt(AbsGrad_uIn); AbsGrad_uOut = Math.Sqrt(AbsGrad_uOut); //Central Differences bool eval = NearFieldBitMask[inp.jCellIn] && NearFieldBitMask[inp.jCellOut]; for (int d = 0; d < inp.D; d++) { /// Central Differences Acc += 0.5 * (DiffusionRate(AbsGrad_uIn, eval) * Grad_uIn[0, d] * inp.Normale[d] + DiffusionRate(AbsGrad_uOut, eval) * Grad_uOut[0, d] * inp.Normale[d]) * (vIn - vOut); /// Inner Values //Acc += DiffusionRate(AbsGrad_uA, eval) * Grad_uA[0, d] * inp.Normale[d] * vA - DiffusionRate(AbsGrad_uB, eval) * Grad_uB[0, d] * inp.Normale[d] * vB; // consistency term //The Volume Integrals are already non-symmetric, so theres nothing to symmetrize here //Acc += 0.5 * (DiffusionRate(AbsGrad_uA, eval) * Grad_vA[d] + DiffusionRate(AbsGrad_uB, eval) * Grad_vB[d]) * (uA[0] - uB[0]) * inp.Normale[d]; // symmetry term } return(Acc); }
public double InnerEdgeForm(ref CommonParams inp, double[] _uA, double[] _uB, double[,] _Grad_uA, double[,] _Grad_uB, double _vA, double _vB, double[] _Grad_vA, double[] _Grad_vB) { double Acc = 0.0; double pnlty = GetPenalty(inp.jCellIn, inp.jCellOut, inp.GridDat.Cells.cj); double lambdaA = EoS.GetViscosity(inp.Parameters_IN[0]); double lambdaB = EoS.GetViscosity(inp.Parameters_OUT[0]); for (int d = 0; d < inp.D; d++) { // consistency term Acc += 0.5 * (lambdaA * _Grad_uA[0, d] + lambdaB * _Grad_uB[0, d]) * (_vA - _vB) * inp.Normale[d]; // symmetry term Acc += 0.5 * (lambdaA * _Grad_vA[d] + lambdaB * _Grad_vB[d]) * (_uA[0] - _uB[0]) * inp.Normale[d]; } // penalty term double lambdaMax = (Math.Abs(lambdaA) > Math.Abs(lambdaB)) ? lambdaA : lambdaB; Acc -= (_uA[0] - _uB[0]) * (_vA - _vB) * pnlty * lambdaMax; Acc *= 1.0 / (Reynolds * Prandtl); return(-Acc); }
public double InnerEdgeForm(ref CommonParams cp, double[] U_Neg, double[] U_Pos, double[,] Grad_uA, double[,] Grad_uB, double v_Neg, double v_Pos, double[] Grad_vA, double[] Grad_vB) { double uAxN = GenericBlas.InnerProd(U_Neg, cp.Normal); var parameters_P = m_getParticleParams(cp.X, cp.time); double[] uLevSet = new double[] { parameters_P[0], parameters_P[1] }; double wLevSet = parameters_P[2]; pRadius = parameters_P[3]; double[] _uLevSet = new double[D]; _uLevSet[0] = uLevSet[0] + pRadius * wLevSet * -cp.Normal[1]; _uLevSet[1] = uLevSet[1] + pRadius * wLevSet * cp.Normal[0]; double uBxN = GenericBlas.InnerProd(_uLevSet, cp.Normal); // transform from species B to A: we call this the "A-fictitious" value double uAxN_fict; uAxN_fict = uBxN; double FlxNeg = -DirichletFlux(uAxN, uAxN_fict); // flux on A-side //double FlxPos = 0; return(FlxNeg * v_Neg); }
public double InnerEdgeForm(ref CommonParams inp, double[] Uin, double[] Uout, double[,] GradUin, double[,] GradUout, double Vin, double Vout, double[] GradVin, double[] GradVout) { double res = 0; switch (Component) { case 0: res = 0.5 * ((Uin[0] + Uout[0]) * inp.Normale[0] + (Uin[1] + Uout[1]) * inp.Normale[0]) // central difference fo grad(u) and grad(u)^T + pen1[0] * ((Uin[0] - Uout[0]) * inp.Normale[0]) + pen1[1] * ((Uin[0] - Uout[0]) * inp.Normale[1]) // beta Penalty for grad(u) + pen1[0] * ((Uin[1] - Uout[1]) * inp.Normale[0]) + pen1[1] * ((Uin[1] - Uout[1]) * inp.Normale[1]); // beta penalty for grad(u)^T break; case 1: res = 0.5 * ((Uin[0] + Uout[0]) * inp.Normale[1] + (Uin[1] + Uout[1]) * inp.Normale[0]) + pen1[0] * ((Uin[0] - Uout[0]) * inp.Normale[0]) + pen1[1] * ((Uin[0] - Uout[0]) * inp.Normale[1]) + pen1[0] * ((Uin[1] - Uout[1]) * inp.Normale[0]) + pen1[1] * ((Uin[1] - Uout[1]) * inp.Normale[1]); break; case 2: res = 0.5 * ((Uin[0] + Uout[0]) * inp.Normale[1] + (Uin[1] + Uout[1]) * inp.Normale[1]) + pen1[0] * ((Uin[0] - Uout[0]) * inp.Normale[0]) + pen1[1] * ((Uin[0] - Uout[0]) * inp.Normale[1]) + pen1[0] * ((Uin[1] - Uout[1]) * inp.Normale[0]) + pen1[1] * ((Uin[1] - Uout[1]) * inp.Normale[1]); break; default: throw new NotImplementedException(); } return(-2 * m_ViscosityNonNewton * 0.5 * res * (Vin - Vout)); }
/// <summary> /// Создать полную копию общих параметров /// </summary> public CommonParams Clone() { CommonParams commonParams = new CommonParams(); commonParams.ServerUse = ServerUse; commonParams.ServerHost = ServerHost; commonParams.ServerPort = ServerPort; commonParams.ServerUser = ServerUser; commonParams.ServerPwd = ServerPwd; commonParams.ServerTimeout = ServerTimeout; commonParams.WaitForStop = WaitForStop; commonParams.RefrParams = RefrParams; return commonParams; }
/// <summary> /// Конструктор /// </summary> public Settings() { Params = new CommonParams(); CommLines = new List<CommLine>(); }