
Thanks, David. That does help. On Thu, 27 May 2010, David Collins wrote:
The best place to look is in yt/lagos/UniversalFields.py, and look at the DivV example. That takes one ghost zone on the 3 velocity components. I've pasted it below for convenience
The HydroMethod business at the top is to switch between the cell centered PPM (HydroMethod==0) or the staggered face-centered Zeus data (HydroMethod == 2)
The object that 'data' then returns is larger than the grid patch it represents in each direction by the number passed to ValidateSpatial. ValidateSpatial gets passed to add_field with the Validators argument, and expects the number of ghost zones and the list of fields to get ghost zones for.
Hope that helps, d.
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 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 new_field = na.zeros(data["x-velocity"].shape, dtype='float64') new_field[1:-1,1:-1,1:-1] = f return new_field def _convertDivV(data): return data.convert("cm")**-1.0 add_field("DivV", function=_DivV, validators=[ValidateSpatial(1, ["x-velocity","y-velocity","z-velocity"])], units=r"\rm{s}^{-1}", take_log=False, convert_function=_convertDivV)
On Thu, May 27, 2010 at 3:48 PM, Andrew Cunningham <ajc4@pas.rochester.edu> wrote:
I'd like to make a derived field that is the gradient of a primitive field. Is there an example of how I can do this? I'm not sure how to handle ghost cells for something like this.
I spoke with Jeff and he indicated that there was a vorticity example somewhere, but I cannot find it.
Thanks.
_______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org
-- Sent from my Stone Tablet and carried by my Pterodactyl. _______________________________________________ yt-users mailing list yt-users@lists.spacepope.org http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org