Ignore:
Timestamp:
Jun 19, 2011, 3:51:16 PM (14 years ago)
Author:
paul
Message:

Rewrote structure of forcing term computation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_work/development/2010-projects/anuga_1d/pipe/pipe_domain_ext.c

    r8186 r8187  
    1212void compute_flux_godunov(double[], double[], double, double, double, double, double[]);
    1313void compute_flux_wb(double[], double[], double, double, double, double, double[]);
    14 double forcingterm_press_naive(double[], double[], double);
    15 double forcingterm_fs_naive(double[], double[], double);
     14double forcingterm_formula_press_naive(double[], double[], double);
     15double forcingterm_formula_fs_naive(double[], double[], double);
     16double compute_forcingterm(double[], double[], double);
    1617int _flux_function_pipe(double *, double *, double *, double *, double, double, double, double *, double *);
    1718
     
    2324#define flux_formula1 flux_formula_press1
    2425#define compute_flux compute_flux_godunov
    25 #define forcingterm forcingterm_press_naive
    26 
     26#define forcingterm_formula_press forcingterm_formula_press_naive
     27#define forcingterm_formula_fs forcingterm_formula_fs_naive
     28#define compute_forcingterm compute_forcingterm_press
    2729
    2830// Some formulae
     
    9799// *********************************************************************
    98100
    99 
    100 // *********************************************************************
    101 // Forcing terms
     101// *********************************************************************
     102// Forcing term formulae
    102103
    103104// Pressurised forcing terms
    104105// Naive version
    105 double forcingterm_press_naive(double *q_m, double *q_p, double g) {
     106double forcingterm_formula_press_naive(double *q_m, double *q_p, double g) {
     107 
     108  return g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * (q_m[5]-q_p[5]) + g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * 0.5*(q_m[5]+q_p[5]) * (q_m[6]-q_p[6]) * 1/(0.5*(q_m[6]+q_p[6]));
     109}
     110
     111// Free surface forcing terms
     112// Naive version
     113double forcingterm_formula_fs_naive(double *q_m, double *q_p, double g) {
     114  return -0.5*0.5 * g * (q_m[3] + q_p[3]) * (q_m[5] + q_p[5]) * (q_m[2] - q_p[2]) + 0.5 * g * (q_m[3] + q_p[3]) * (q_m[3] + q_p[3]) * 0.5*0.5 * (q_m[5] - q_p[5]);
     115}
     116// *********************************************************************
     117
     118// *********************************************************************
     119// Forcing term computation
     120
     121// Pressurised forcing terms computation
     122double compute_forcingterm_press(double *q_m, double *q_p, double g) {
    106123  double ret;
    107 
    108   ret = g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * (q_m[5]-q_p[5]) + g * (0.5*(q_m[3]+q_p[3]) - 0.5*(q_m[6]+q_p[6])) * 0.5*(q_m[5]+q_p[5]) * (q_m[6]-q_p[6]) * 1/(0.5*(q_m[6]+q_p[6]));
    109 
    110   // Add in the free surface pressure term with h=t
    111   // Does this overwite q_p,q_m in the caller? If so, we don't want that!
     124  double h_m, h_p;
     125
     126  // Compute pressurised forcing term
     127  ret = forcingterm_formula_press(q_m, q_p, g);
     128
     129  // Add in free surface forcing term with h = t
     130  // This is a hack: We temporarily change h (q[3]) to t (q[6])
     131  // then call fs forcing term, then change h back.
     132  h_p = q_p[3];
     133  h_m = q_m[3];
    112134  q_p[3] = q_p[6];
    113135  q_m[3] = q_m[6];
    114   ret += forcingterm_fs_naive(q_m, q_p, g);
     136  ret += forcingterm_formula_fs(q_m, q_p, g);
     137  q_p[3] = h_p;
     138  q_m[3] = h_m;
    115139
    116140  return ret;
    117141}
    118142
    119 // Free surface forcing terms
    120 // Naive version
    121 double forcingterm_fs_naive(double *q_m, double *q_p, double g) {
    122   return -0.5*0.5 * g * (q_m[3] + q_p[3]) * (q_m[5] + q_p[5]) * (q_m[2] - q_p[2]) + 0.5 * g * (q_m[3] + q_p[3]) * (q_m[3] + q_p[3]) * 0.5*0.5 * (q_m[5] - q_p[5]);
     143// Free surface forcing terms computation
     144double compute_forcingterm_fs(double *q_m, double *q_p, double g) {
     145  return forcingterm_formula_fs(q_m, q_p, g);
    123146}
    124147// *********************************************************************
     
    174197
    175198  // Add in Forcing terms 
    176   edgeflux[1] -= forcingterm(q_rightm, q_leftp, g);
     199  edgeflux[1] -= compute_forcingterm(q_rightm, q_leftp, g);
    177200
    178201  // Maximal wavespeed
Note: See TracChangeset for help on using the changeset viewer.