Hello! I am taking a scientific computing class, where we are doing some programming in C, and right now our assignment is to add commentary to an existing program explaining what every line does (starting at the line that says Start here!). As you can see in the code below, I have done some of the commentary. However, I am confused about what some of the lines and their various symbols mean. For instance, what does the arrow (->) do? How do I describe its function in the lines below? Also, besides the obvious of setting the left side equal to the right side, what do these two lines:
norm_solution = fabs(u0) + fabs(v0);
r = LTE/(EPSILON_REL*norm_solution + EPSILON_ABS);
do in the code? Do you think I'm just supposed to put the obvious as my answer? Or is there something else major I am missing? And last, can someone tell me if the commentary I have made is correct? I want to make sure I'm getting what this code means.
Thank you in advance for any help you can provide!!
void compute_dt(TIMESTEP *timestep, double u0, double v0, double u1,
double v1, double u2, double v2) // based on LTE
{
double dt = timestep->dt, dt_new;
double r, LTE, norm_solution;
double EPSILON_REL = 1.e-6, EPSILON_ABS = 2.2e-16;
// COMMENT: Start here!
LTE = (16./15.)*(fabs(u2-u1) + fabs(v2-v1));
// Sets the norm of the LTE to the norm of (u2,v2)-(u1,v1)
norm_solution = fabs(u0) + fabs(v0);
//
r = LTE/(EPSILON_REL*norm_solution + EPSILON_ABS);
//
if (r <= 2.) {
// Tells the loop to run for values of r less than or equal to 2
timestep->REDO_STEP = NO;
//
dt_new = dt/pow(r, 1./5.); /* since LTE ~ dt^5 */
// Sets the new dt equal to the normal dt divided by r to the 1/5 power
dt = min(dt_new, 2.*dt);
// Sets the normal dt equal to the minimum of the new dt and two times
// the normal dt.
}
else {
// else if r > 2 the code will do the following threee statements
timestep->REDO_STEP = YES;
//
timestep->LAST_STEP = NO;
//
dt /= 2.;
// Sets dt equal to itself divided by 2.
}
timestep->dt = dt;
//
}