![](https://secure.gravatar.com/avatar/abbf30a6e2a3b5a2641e8c41f75c4e15.jpg?s=120&d=mm&r=g)
Hi all, I was debugging some simulation stuff and was comparing the DivV field to that calculated within Enzo for a 2D simulation, and found them to be different. I noticed that in the definition of DivV the dimensionality of the data doesn't play into the calculation, and instead it assumes that the contribution from the z dimension will be zero. Anyways, if I comment out the z contribution, it matches the calculation from within Enzo. def _DivV(field, data): # We need to set up stencils if data.pf["HydroMethod"] == 2: sl_left = slice(None,-2,None) sl_right = slice(1,-1,None) div_fac = 1.0 else: sl_left = slice(None,-2,None) sl_right = slice(2,None,None) div_fac = 2.0 ds = div_fac * data['dx'].flat[0] f = data["x-velocity"][sl_right,1:-1,1:-1]/ds f -= data["x-velocity"][sl_left ,1:-1,1:-1]/ds ds = div_fac * data['dy'].flat[0] f += data["y-velocity"][1:-1,sl_right,1:-1]/ds f -= data["y-velocity"][1:-1,sl_left ,1:-1]/ds If I comment out the following lines, I get matching results to within Enzo. ds = div_fac * data['dz'].flat[0] f += data["z-velocity"][1:-1,1:-1,sl_right]/ds f -= data["z-velocity"][1:-1,1:-1,sl_left ]/ds Since DivV needs the ValidateSpatial, I'm assuming that there is something going wrong in the calculation of the ghost zones here. Does anyone have an idea of what might be going on? I could see us using a fix that does something like: if len(data.pf.dimensions) > 2: ds = div_fac * data['dz'].flat[0] f += data["z-velocity"][1:-1,1:-1,sl_right]/ds f -= data["z-velocity"][1:-1,1:-1,sl_left ]/ds but I'm not sure if that would be the right way to handle it. Any thoughts? Sam
![](https://secure.gravatar.com/avatar/de7fc87f71ab749c9b2487ad6c533c87.jpg?s=120&d=mm&r=g)
Hi Sam, I looked over the ValidateSpatial briefly, but I'm not sure I understand it. However,
I could see us using a fix that does something like: if len(data.pf.dimensions) > 2: ds = div_fac * data['dz'].flat[0] f += data["z-velocity"][1:-1,1:-1,sl_right]/ds f -= data["z-velocity"][1:-1,1:-1,sl_left ]/ds
seems pretty reasonable to me. j
![](https://secure.gravatar.com/avatar/c1ca883bfb6bc32bcd9a65c5ec9b0bf9.jpg?s=120&d=mm&r=g)
Hey Sam, It's not clear to me why it doesn't work without the if statement around the z dimension. What data would it be getting in that case? Either way, I think adding the if statement is good, because the calculation does not need to be done. Perhaps for generality, it's worth putting the y dimension calculation in an if statement as well so that this also works in 1D. Britton On Tue, Jul 12, 2011 at 7:05 PM, j s oishi <jsoishi@gmail.com> wrote:
Hi Sam,
I looked over the ValidateSpatial briefly, but I'm not sure I understand it. However,
I could see us using a fix that does something like: if len(data.pf.dimensions) > 2: ds = div_fac * data['dz'].flat[0] f += data["z-velocity"][1:-1,1:-1,sl_right]/ds f -= data["z-velocity"][1:-1,1:-1,sl_left ]/ds
seems pretty reasonable to me.
j _______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
![](https://secure.gravatar.com/avatar/abbf30a6e2a3b5a2641e8c41f75c4e15.jpg?s=120&d=mm&r=g)
Jeff, Britton, Thanks for the responses. It's not clear to me what data it was grabbing before either. I've gone ahead and pushed the changes for DivV using pf.dimensionality to determine what to include for both 1D and 2D. Best, Sam On Wed, Jul 13, 2011 at 3:50 AM, Britton Smith <brittonsmith@gmail.com>wrote:
Hey Sam,
It's not clear to me why it doesn't work without the if statement around the z dimension. What data would it be getting in that case?
Either way, I think adding the if statement is good, because the calculation does not need to be done. Perhaps for generality, it's worth putting the y dimension calculation in an if statement as well so that this also works in 1D.
Britton
On Tue, Jul 12, 2011 at 7:05 PM, j s oishi <jsoishi@gmail.com> wrote:
Hi Sam,
I looked over the ValidateSpatial briefly, but I'm not sure I understand it. However,
I could see us using a fix that does something like: if len(data.pf.dimensions) > 2: ds = div_fac * data['dz'].flat[0] f += data["z-velocity"][1:-1,1:-1,sl_right]/ds f -= data["z-velocity"][1:-1,1:-1,sl_left ]/ds
seems pretty reasonable to me.
j _______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
_______________________________________________ Yt-dev mailing list Yt-dev@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org
participants (3)
-
Britton Smith
-
j s oishi
-
Sam Skillman