[FLASH-USERS] ensuring div B = 0 when adjusting evolution

Klaus Weide klaus at flash.uchicago.edu
Wed Jun 7 13:19:42 EDT 2017


On Wed, 7 Jun 2017, Slavin, Jonathan wrote:

> Hi all,
> 
> Just thought that I'd let you know that I got my multiple explosion runs
> working.  What made all the difference is setting the time step to a very
> small value, I used the initial dt value.  So this involved adding
> use Driver_data, ONLY : dr_dtInit
> 
> and changing the declaration of dt to
> real, intent(inout) :: dt
> (Can one change a value of a variable declared intent(in)?)

Jon,

Even if your compiler allowed you to do that (many don't), it would be 
wrong to change the value of a variable that is declared intent(in). The 
caller of the subroutine could get the modified value returned, or not, 
and it may depend on the compiler {,version,optimization level,(...)}
what happens.

Additionally, IF you made your change

   real, intent(in) :: dt   ->   real, intent(inout) :: dt

in (your copy of) Simulation_adjustEvolution.F90 but NOT also in
Simulation_interface.F90, then you have created code that is not valid 
Fortran. Again the compiler is free to do what it wants in this case -
return the changed value, keep the old value, trigger a runtime error, ...
I am pointing this out because compilers often do not detect these errors.

I agree with Tomasz Plewa's response that implementing your heating in the 
'Heat' unit would be preferable. Your routine would be called in the right 
place by Driver_evolveFlash, AND you would have an 'official' way of 
influencing the time step by implementing / modifying Heat_computeDt 
(which already gets called from Driver_computeDt).

I think of Simulation_adjustEvolution as a convenient interface to 
implement small adjustments to the solution ('small' in some sense - 
updating some additional purely diagnostic variables would count, for 
example.) I think it should not be used to 'sneak in' significant physics 
operators or source terms.

Klaus



More information about the flash-users mailing list