/// <summary> /// Returns name of nested form. /// </summary> public override string ToString() { return(volForm.GetType().FullName); }
private double Diff(ref double PertubVar, double Var, ref CommonParamsVol clonedParams, double[] Utmp, double[,] GradUtmp, double V, double[] GradV, double delta, double f0, int d, int iVar) { // add perturbation double bkup = PertubVar; PertubVar += delta; Debug.Assert(delta > 0); // flux eval double f1 = m_VolForm.VolumeForm(ref clonedParams, Utmp, GradUtmp, V, GradV); #if DEBUG if (double.IsInfinity(f1)) { throw new ArithmeticException(); } if (double.IsNaN(f1)) { throw new ArithmeticException(); } #endif // compute finite difference double dU_iVar = (f1 - f0) / delta; if (double.IsInfinity(dU_iVar)) { throw new ArithmeticException("Got INF while differentiation of volume part of " + m_VolForm.GetType().Name); } if (double.IsNaN(dU_iVar)) { throw new ArithmeticException("Got NAN while differentiation of volume part of " + m_VolForm.GetType().Name); } // restore un-perturbed state PertubVar = bkup; // test /* * if(V == 1 && GradV.L2Norm() == 0) { * double u = Utmp[1]; * double v = Utmp[2]; * double Tx = GradUtmp[0, 0]; * double Ty = GradUtmp[0, 1]; * * double soll; * if(d < 0 && iVar == 1) { * soll = Tx; * } else if(d < 0 && iVar == 2) { * soll = Ty; * } else if(d == 0 && iVar == 0) { * soll = u; * } else if(d == 1 && iVar == 0) { * soll = v; * } else { * soll = 0; * } * * Debug.Assert((dU_iVar - soll).Abs() < delta*1000); * * } */ // inner product double ret = 0; ret += dU_iVar * Var; ret -= dU_iVar * PertubVar; // subtract affine contribution return(ret); }