Is there a standard approach to testing codes with refined regions? Specifically, I am interested in testing whether the refinement is working correctly.

For the sake of simplicity, let's consider a (time-independent) boundary value problem in a domain with only one refined area, and a case with a known exact solution. Let's consider a finite difference method with a uniform grid size. Assume I've already verified that the code obtains the correct convergence rate for a uniform grid with the exact solution I have.

Now consider a uniform grid of size $h$ in the fine region and $H$ in the coarse region. I can compare the error (however it might be defined) between that case and the case where the grid is uniform with resolution $h$. Hopefully, the accuracy degradation is not "too bad". I don't know precisely what "too bad" in this case might mean, however, and hence my question. There may be a better approach altogether than what I am thinking here.


It is difficult to assess the correctness of a code for only a single value of the mesh sizes $h$, $H$. Rather, one typically evaluates the accuracy for a sequence of mesh sizes $h,H \rightarrow 0$ by comparing against the exact solution to which your numerical approximations have to converge.

| cite | improve this answer | |
  • $\begingroup$ Thanks for the answer. I have done this for a set value of $H / h$, say, 2. The code converges at the same rate as a mesh which is coarse everywhere (though the magnitude of the error is usually lower depending on the test case, as I recall; I should check). I'm not sure if this is comprehensive enough. Perhaps I should edit my question to state that. $\endgroup$ – Ben Trettel May 8 '15 at 16:12
  • $\begingroup$ This seems like a reasonable idea to verify convergence and efficiency. Why are you not satisfied with this? $\endgroup$ – Wolfgang Bangerth May 8 '15 at 19:01
  • $\begingroup$ I've had a nagging feeling that I'm missing something. But now I don't think I am. A few tests are probably necessary: 1. convergence for fixed $H / h$, 2. checking the behavior of the error and computational cost in the previous case (The error should be lower than solely a coarse grid, and higher than solely a fine grid; and hopefully the cost is reduced compared against a fine grid), and testing that any connections between different domains works correctly (if relevant). $\endgroup$ – Ben Trettel May 8 '15 at 19:42
  • $\begingroup$ Yes, these seem sensible criteria. $\endgroup$ – Wolfgang Bangerth May 8 '15 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.