Exemplo n.º 1
0
// Surface linear forms representing the solid part of the boundary.
// The flux in the local coordinates is (0, p_b, 0, 0) where p_b stands for pressure on the boundary.
// The first function does the calculation, the next ones are added to the weakform and they call the first function, asking for
// the correct element of the vector.
double bdy_flux_solid_wall_comp(int element, int n, double *wt, Func<scalar> *ue[], Func<double> *v, Geom<double> *e, ExtData<double> *ext)
{
  double result = 0;
  double w01, w11, w21, w31;
  for (int i = 0; i < n; i++) 
  {
    w01 = ext->fn[0]->val[i];
    
    w11 = ext->fn[1]->val[i];

    w21 = ext->fn[2]->val[i];

    w31 = ext->fn[3]->val[i];

    double p_b = calc_pressure(w01, w11, w21, w31);
    
    //Ondrej's code.
    double flux[4];
    double alpha = atan2(e->ny[i], e->nx[i]);
    double mat_rot_inv[4][4];
    double flux_local[4];
    flux_local[0] = 0;
    flux_local[1] = p_b;
    flux_local[2] = 0;
    flux_local[3] = 0;
    num_flux.T_rot(mat_rot_inv, -alpha);
    num_flux.dot_vector(flux, mat_rot_inv, flux_local);

    result -= wt[i] * v->val[i] * flux[element];
  }
  return result * TAU;
}
Exemplo n.º 2
0
// Experimental "vector valued" linear form. Calculates and caches all components, returns the first one.
double bdy_flux_solid_wall_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;
  double w01, w11, w21, w31;
  for (int i = 0; i < n; i++) 
  {
    w01 = ue[0]->val[i];
    
    w11 = ue[1]->val[i];

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

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

    double p_b = calc_pressure(w01, w11, w21, w31);
    
    //Ondrej's code.
    double flux[4];
    double alpha = atan2(e->ny[i], e->nx[i]);
    double mat_rot_inv[4][4];
    double flux_local[4];
    flux_local[0] = 0;
    flux_local[1] = p_b;
    flux_local[2] = 0;
    flux_local[3] = 0;
    num_flux.T_rot(mat_rot_inv, -alpha);
    num_flux.dot_vector(flux, mat_rot_inv, flux_local);

    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];
}