Yeji:

I am trying to implement HLLC flux in the code for tutorial step-67.
I have implemented the flux just as described in the textbook.
However, this code results 'dt' to 'inf' and not a number errors...
Screenshot 2024-04-14 at 2.06.49 PM.png

It looks like I am missing something but not sure what it could be as I am not insightful enough to see the issue by myself..

Rather than trying to find the problem in your code, let me outline how you find out what is wrong. Finding out why a function computes inf as an answer is actually one of the easier tasks. That's because once you have an infinity, it doesn't tend to go away: If a variable is infinity, all the things you compute from it will also be infinities of some sort. So all you have to figure out is where the infinity is first created.

Let's say you have a function that perhaps reads like this:

double hllc(double a, double b, double c) {
  d = sqrt(a+b+c)
  e = sin(a*d)
  f = acos(d+e)
  return f;
}

In a place where you call this function, the function returns inf when you think that it should not. So for given arguments a,b,c, you now know that f=inf. This is wrong, so we may as well abort the program at this point. Make it so:

double hllc(double a, double b, double c) {
  d = sqrt(a+b+c)
  e = sin(a*d)
  f = acos(d+e)
  Assert (numbers::is_finite(f), ExcMessage ("f is infinite!"));
  return f;
}

When you run your program, it should not abort in the Assert line because you already know that the function returns inf.

Since you know that f was computed from d and e, using the acos function, there are only two possibilities for d to be inf: either the inputs to acos were already inf, or the argument to acos was out of range (it needs to be between -1 and +1). Test this:

double hllc(double a, double b, double c) {
  d = sqrt(a+b+c)
  e = sin(a*d)
  Assert (numbers::is_finite(d), ExcMessage ("d is infinite!"));
  Assert (numbers::is_finite(e), ExcMessage ("e is infinite!"));
  Assert ((d+e >= -1) && (d+e <= +1), ExcMessage ("d+e out of range!"));
  f = acos(d+e)
  Assert (numbers::is_finite(f), ExcMessage ("f is infinite!"));
  return f;
}

Your program should now abort in one of the three new assertions. Depending on which one, you have now gained knowledge which variable seems to be wrong. Use this to add more assertions further up the chain. For example

double hllc(double a, double b, double c) {
  Assert (numbers::is_finite(a), ExcMessage ("a is infinite!"));
  Assert (numbers::is_finite(b), ExcMessage ("b is infinite!"));
  Assert (numbers::is_finite(c), ExcMessage ("c is infinite!"));
  Assert (a+b+c>=0, ExcMessage ("a+b+c out of range!"));
  d = sqrt(a+b+c)
  Assert (numbers::is_finite(a), ExcMessage ("a is infinite!"));
  Assert (numbers::is_finite(d), ExcMessage ("d is infinite!"));
  e = sin(a*d)
  Assert (numbers::is_finite(d), ExcMessage ("d is infinite!"));
  Assert (numbers::is_finite(e), ExcMessage ("e is infinite!"));
  Assert ((d+e >= -1) && (d+e <= +1), ExcMessage ("d+e out of range!"));
  f = acos(d+e)
  Assert (numbers::is_finite(f), ExcMessage ("f is infinite!"));
  return f;
}

The point is that you work yourself bottom-up until you figure out in which place the infinity is being created. When you know which line creates the infinity, you can start thinking about what it is that's wrong.

Best
 W.

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/cdf0f27c-9534-4f80-ac56-b152cb7dc83a%40colostate.edu.

Reply via email to