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

Klaus Weide klaus at flash.uchicago.edu
Tue May 30 18:01:27 EDT 2017


On Fri, 26 May 2017, Joshua Wall wrote:

> Hello Jon,
> 
>      There's two ways to do the EOS update. One is to call Eos_wrapped at
> the end of the block loop on each block you update as you go through the
> loop. Make sure you pass which mode you want based on the variables you
> updated, which here sounds like pressure and internal energy.

That's usually the way to do it.

> So that would
> look something like:
> 
> 
> do blk=1, numBlocks
> 
> blockID = blockList(blk)
> 
> call Grid_getBlkLimits(blockID, blkLimits, blkLimitsGC)
> 
> call Grid_getBlkPtr(blockID, solnData)
>    do i
>      do j
>        do k
> 
>           solnData(DENS_VAR,i,j,k) = stuff
>           solnData(EINT_VAR,i,j,k) = stuff

To make sure the Eos_wrapped call below does not get confused,
one should also modify ENER_VAR when modifying EINT_VAR.
Usually by adding the same amount to both variables.
(Even more variables should be modified if using 3T Hydro
and Eos.)

>
>          end do
>       end do
>     end do
> 
>     call Eos_wrapped(MODE_DENS_EI, blkLimits, blockID)
> 
> end do
> 
> The other way to do it is to:
> 
>  call Grid_fillGuardCells(CENTER, ALL_DIR, LEAF, doEos=.true.,
> eosMode=MODE_DENS_EI)

1. This call is not valid as written, or at least extremely confusing.
I assume the "LEAF" is meant as a value for the (optional) 
"selectBlockType" dummy argument; if that is true, the call should be 
written as

|  call Grid_fillGuardCells(CENTER, ALL_DIR, selectBlockType=LEAF, 
|   doEos=.true.,eosMode=MODE_DENS_EI)

Otherwise the compiler will interpret it as ...,minLayers=LEAF,...,
which is probably not intended.

1. This call does *not* apply the Eos to interior cells, but only to
(some) guard cells. In some previous version of FLASH, the doEos may have
applied to all cells (interior+guard), but that has not been the case
for several releases. Now the Eos is only applied to guard cells that
correspond to neighboring blocks at a different refinement.

> This method ensures that whatever happens next, not only is the EOS updated
> all values for each cell, *but also those values are valid in guard cells
> on other processors*. I mention this method because using the Eos_wrapped
> and forgetting to fill guard cells after has been a "gotcha" moment for me
> in the past, and was a very tricky error to track down. But guard cell
> filling is also expensive, so if you know its safe to not do it,
> Eos_wrapped is the way to go.

The general rule should be:

 * call Eos_wrapped at the end of your code, if you have modified any 
   variables that could make the thermodynamic state inconsistent;
 * call Grid_fillGuardCells at the beginning of your code if you need
   to refer to any variables in guard cells - with or without doEos
   depending on the needs of your code.

unless you *really* understand the consequences of deviating from this 
convention.

Klaus



More information about the flash-users mailing list