refine_and_coarsen_optmise

I hopefully made refine_and_coarsen_optmise easier to read and less error prone.

One thing though: in the comment line it is written `  // 2 * expected order of the finite`, whereas it was implemented without 2 (line 572 in the new file). So it is either a bug in the code or a wrong comment.