예제 #1
0
파일: main.cpp 프로젝트: Zhonghua/hermes2d
Scalar res(int n, double *wt, 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] * (lam(u_prev->val[i]) * (u_prev->dx[i] * v->dx[i] + u_prev->dy[i] * v->dy[i])
                           - heat_src(e->x[i], e->y[i]) * v->val[i]);
    return result;
}
예제 #2
0
Scalar res_ss(int n, double *wt, Func<Real> *u_ext[], Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext, double t)
{
  Scalar result = 0;
  Func<Scalar>* Y_prev_newton = u_ext[0];
  for (int i = 0; i < n; i++) {
    result += wt[i] * (lam(Y_prev_newton->val[i]) * (Y_prev_newton->dx[i] * v->dx[i] + Y_prev_newton->dy[i] * v->dy[i])
                       - heat_src(e->x[i], e->y[i], t) * v->val[i]);
  }
  return result;
}
예제 #3
0
Scalar F_euler(int n, double *wt, Func<Real> *u_ext[], Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext)
{
  Scalar result = 0;
  Func<Scalar>* u_prev_newton = u_ext[0];
  Func<Scalar>* u_prev_time = ext->fn[0];
  for (int i = 0; i < n; i++)
    result += wt[i] * ((u_prev_newton->val[i] - u_prev_time->val[i]) * v->val[i] / TAU +
                      lam(u_prev_newton->val[i]) * (u_prev_newton->dx[i] * v->dx[i] + u_prev_newton->dy[i] * v->dy[i])
		      - heat_src(e->x[i], e->y[i]) * v->val[i]);
  return result;
}
예제 #4
0
Scalar res1(int n, double *wt, Func<Real> *u_ext[], Func<Real> *v, Geom<Real> *e, ExtData<Scalar> *ext)
{
  Scalar result = 0;
  Func<Scalar>* Y1_prev_newton = u_ext[0];
  Func<Scalar>* u_prev_time = ext->fn[0];
  for (int i = 0; i < n; i++)
    result += wt[i] * ((Y1_prev_newton->val[i] - u_prev_time->val[i]) * v->val[i] 
                       + GAMMA * TAU * (lam(Y1_prev_newton->val[i]) * (Y1_prev_newton->dx[i] * v->dx[i] 
                                                                       + Y1_prev_newton->dy[i] * v->dy[i])
                                        - heat_src(e->x[i], e->y[i], TIME+GAMMA*TAU) * v->val[i]));
  return result;
}
예제 #5
0
파일: forms.cpp 프로젝트: alieed/hermes
Scalar stac_residual(int n, double *wt, Func<Real> *u_ext[], 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 residual (time derivative term left out).
  Scalar result1 = 0, result2 = 0;
  for (int i = 0; i < n; i++) {
    result1 = result1 - wt[i] * lam(u_prev->val[i]) * (u_prev->dx[i] * v->dx[i] + u_prev->dy[i] * v->dy[i]);
    result2 = result2 + wt[i] * heat_src(e->x[i], e->y[i]) * v->val[i];
  }

  return result1 + result2;
}