Scalar jac(int n, double *wt, Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext) { Scalar result = 0; Func<Scalar>* u_prev = ext->fn[0]; for (int i = 0; i < n; i++) result += wt[i] * (dlam_du(u_prev->val[i]) * u->val[i] * (u_prev->dx[i] * v->dx[i] + u_prev->dy[i] * v->dy[i]) + lam(u_prev->val[i]) * (u->dx[i] * v->dx[i] + u->dy[i] * v->dy[i])); return result; }
Scalar J_cranic(int n, double *wt, Func<Real> *u_ext[], Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext) { Scalar result = 0; Func<Scalar>* u_prev_newton = u_ext[0]; for (int i = 0; i < n; i++) result += wt[i] * (u->val[i] * v->val[i] / TAU + 0.5 * dlam_du(u_prev_newton->val[i]) * u->val[i] * (u_prev_newton->dx[i] * v->dx[i] + u_prev_newton->dy[i] * v->dy[i]) + 0.5 * lam(u_prev_newton->val[i]) * (u->dx[i] * v->dx[i] + u->dy[i] * v->dy[i])); return result; }
Scalar jac2(int n, double *wt, Func<Real> *u_ext[], Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext) { Scalar result = 0; Func<Scalar>* Y2_prev_newton = u_ext[0]; for (int i = 0; i < n; i++) result += wt[i] * (u->val[i] * v->val[i] + GAMMA * TAU * (dlam_du(Y2_prev_newton->val[i]) * u->val[i] * (Y2_prev_newton->dx[i] * v->dx[i] + Y2_prev_newton->dy[i] * v->dy[i]) + lam(Y2_prev_newton->val[i]) * (u->dx[i] * v->dx[i] + u->dy[i] * v->dy[i]))); return result; }
Scalar jac_sdirk(int n, double *wt, Func<Real> *u_ext[], Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext) { Scalar result = 0; Func<Scalar>* u_prev_newton = u_ext[0]; for (int i = 0; i < n; i++) result += wt[i] * (u->val[i] * v->val[i] / TAU + BUTCHER_A_11 * (dlam_du(u_prev_newton->val[i]) * u->val[i] * (u_prev_newton->dx[i] * v->dx[i] + u_prev_newton->dy[i] * v->dy[i]) + lam(u_prev_newton->val[i]) * (u->dx[i] * v->dx[i] + u->dy[i] * v->dy[i]))); return result; }
Scalar stac_jacobian(int n, double *wt, Func<Real> *u_ext[], Func<Real> *u, Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext) { Func<Scalar>* u_prev = u_ext[0]; // This is a temporary workaround. The stage time t_n + h * c_i // can be accessed via u_stage_time->val[0]; // In this particular case the stage time is not needed as // the form does not depend explicitly on time. Func<Scalar>* u_stage_time = ext->fn[0]; // Stationary part of the Jacobian matrix (time derivative term left out). Scalar result1 = 0, result2 = 0; for (int i = 0; i < n; i++) { result1 += -wt[i] * dlam_du(u_prev->val[i]) * u->val[i] * (u_prev->dx[i] * v->dx[i] + u_prev->dy[i] * v->dy[i]); result2 += -wt[i] * lam(u_prev->val[i]) * (u->dx[i] * v->dx[i] + u->dy[i] * v->dy[i]); } return result1 + result2; }