Beispiel #1
0
// Experimental "vector valued" linear form. Calculates and caches all components, returns the first one.
double linear_form_interface_vector(int n, double *wt, Func<double> *ue[], Func<double> *v, Geom<double> *e, ExtData<double> *ext)
{
  double *result = new double[4];
  result[0] = result[1] = result[2] = result[3] = 0;
  double w_l[4], w_r[4];
  for (int i = 0; i < n; i++) 
  {
    w_l[0] = ue[0]->get_val_central(i);
    w_r[0] = ue[0]->get_val_neighbor(i);
    
    w_l[1] = ue[1]->get_val_central(i);
    w_r[1] = ue[1]->get_val_neighbor(i);

    w_l[2] = ue[2]->get_val_central(i);
    w_r[2] = ue[2]->get_val_neighbor(i);

    w_l[3] = ue[3]->get_val_central(i);
    w_r[3] = ue[3]->get_val_neighbor(i);

    double flux[4];
    num_flux.numerical_flux(flux,w_l,w_r,e->nx[i], e->ny[i]);

    result[0] -= wt[i] * v->val[i] * flux[0] * TAU;
    result[1] -= wt[i] * v->val[i] * flux[1] * TAU;
    result[2] -= wt[i] * v->val[i] * flux[2] * TAU;
    result[3] -= wt[i] * v->val[i] * flux[3] * TAU;
  }
  DiscreteProblem::surf_forms_cache[DiscreteProblem::surf_forms_key] = result;
  return -result[0];
}
Beispiel #2
0
// Experimental "vector valued" linear form. Calculates and caches all components, returns the first one.
double bdy_flux_inlet_outlet_comp_vector(int n, double *wt, Func<scalar> *ue[], Func<double> *v, Geom<double> *e, ExtData<double> *ext)
{
  double *result = new double[4];
  result[0] = result[1] = result[2] = result[3] = 0;
  // Left (inner) state.
  double w_l[4];
  // Right (boundary) state.
  double w_r[4];
  // Eulerian flux.
  double flux[4];

  for (int i = 0; i < n; i++) 
  {
    // Left (inner) state from the previous time level solution.
    w_l[0] = ue[0]->val[i];
    
    w_l[1] = ue[1]->val[i];

    w_l[2] = ue[2]->val[i];

    w_l[3] = ue[3]->val[i];

    w_r[0] = bc_density(e->y[i]);

    w_r[1] = bc_density_vel_x(e->y[i]);

    w_r[2] = bc_density_vel_y(e->y[i]);

    w_r[3] = bc_energy(e->y[i]);
    
    num_flux.numerical_flux(flux,w_l,w_r,e->nx[i], e->ny[i]);

    result[0] -= wt[i] * v->val[i] * flux[0] * TAU;
    result[1] -= wt[i] * v->val[i] * flux[1] * TAU;
    result[2] -= wt[i] * v->val[i] * flux[2] * TAU;
    result[3] -= wt[i] * v->val[i] * flux[3] * TAU;
  }
  DiscreteProblem::surf_forms_cache[DiscreteProblem::surf_forms_key] = result;
  return -result[0];
}