ianhinder / Kranc

A Mathematica package for generating code for solving time dependent partial differential equations
http://kranccode.org
GNU General Public License v2.0
28 stars 10 forks source link

calc_every != 0 does not properly work during CCTK_EVOL #139

Open rhaas80 opened 7 years ago

rhaas80 commented 7 years ago

Currently Kranc always inserts this fragment (in Kranc/Tools/CodeGen/CodeGenCalculation.m)

             ConditionalOnParameterTextual[
               "cctk_iteration % " <> functionName <> "_calc_every != " <>
               functionName <> "_calc_offset", "return;\n"],

which is however not correct in CCTK_EVOL since there the data that will appear as cctk_iteration = it is cctk_iteration+1. calc_offset does not help since it would have to be 1 for rl>rl_finest and 0 for rl==rk_finest.

As far as I know the only way to fix is to either make the condition dependent on EVOL vs POSTSTEP or to run at every single timestep.

rhaas80 commented 7 years ago

Actually, moving the offset into the computation should do the trick:

ConditionalOnParameterTextual[
  "(cctk_iteration - " <> functionName <> "_calc_offset) % " <> functionName <> "_calc_every != 0"
  , "return;\n"],
rhaas80 commented 1 year ago

No, that does not work either since it would compute eg for level 2 at iteration 1 (assuming offset is 1) but it would need to compute at iteration 3 for a calc_every of 4.