[Yt-svn] commit/yt: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Thu Jun 30 18:44:18 PDT 2011
2 new changesets in yt:
http://bitbucket.org/yt_analysis/yt/changeset/4f8304c718cb/
changeset: 4f8304c718cb
branch: yt
user: MatthewTurk
date: 2011-07-01 01:52:48
summary: Adding vorticity and reverting to an older version of data_point_utilities.c.
This fixes a regression *I* introduced, where the FillRegion routine would
sometimes never complete.
affected #: 2 files (3.0 KB)
--- a/yt/data_objects/universal_fields.py Thu Jun 30 12:36:03 2011 -0700
+++ b/yt/data_objects/universal_fields.py Thu Jun 30 16:52:48 2011 -0700
@@ -930,3 +930,47 @@
ValidateDataField("By"),
ValidateDataField("Bz")])
+def _VorticitySquared(field, data):
+ mylog.debug("Generating vorticity on %s", 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
+ new_field = na.zeros(data["x-velocity"].shape)
+ dvzdy = (data["z-velocity"][1:-1,sl_right,1:-1] -
+ data["z-velocity"][1:-1,sl_left,1:-1]) \
+ / (div_fac*data["dy"].flat[0])
+ dvydz = (data["y-velocity"][1:-1,1:-1,sl_right] -
+ data["y-velocity"][1:-1,1:-1,sl_left]) \
+ / (div_fac*data["dz"].flat[0])
+ new_field[1:-1,1:-1,1:-1] += (dvzdy - dvydz)**2.0
+ del dvzdy, dvydz
+ dvxdz = (data["x-velocity"][1:-1,1:-1,sl_right] -
+ data["x-velocity"][1:-1,1:-1,sl_left]) \
+ / (div_fac*data["dz"].flat[0])
+ dvzdx = (data["z-velocity"][sl_right,1:-1,1:-1] -
+ data["z-velocity"][sl_left,1:-1,1:-1]) \
+ / (div_fac*data["dx"].flat[0])
+ new_field[1:-1,1:-1,1:-1] += (dvxdz - dvzdx)**2.0
+ del dvxdz, dvzdx
+ dvydx = (data["y-velocity"][sl_right,1:-1,1:-1] -
+ data["y-velocity"][sl_left,1:-1,1:-1]) \
+ / (div_fac*data["dx"].flat[0])
+ dvxdy = (data["x-velocity"][1:-1,sl_right,1:-1] -
+ data["x-velocity"][1:-1,sl_left,1:-1]) \
+ / (div_fac*data["dy"].flat[0])
+ new_field[1:-1,1:-1,1:-1] += (dvydx - dvxdy)**2.0
+ del dvydx, dvxdy
+ new_field = na.abs(new_field)
+ return new_field
+def _convertVorticitySquared(data):
+ return data.convert("cm")**-2.0
+add_field("VorticitySquared", function=_VorticitySquared,
+ validators=[ValidateSpatial(1)],
+ units=r"\rm{s}^{-2}",
+ convert_function=_convertVorticitySquared)
--- a/yt/utilities/data_point_utilities.c Thu Jun 30 12:36:03 2011 -0700
+++ b/yt/utilities/data_point_utilities.c Thu Jun 30 16:52:48 2011 -0700
@@ -1,5 +1,5 @@
/************************************************************************
-* Copyright (C) 2007-2011 Matthew Turk. All Rights Reserved.
+* Copyright (C) 2007-2009 Matthew Turk. All Rights Reserved.
*
* This file is part of yt.
*
@@ -880,7 +880,7 @@
npy_int64 gxs, gys, gzs, gxe, gye, gze;
npy_int64 cxs, cys, czs, cxe, cye, cze;
npy_int64 ixs, iys, izs, ixe, iye, ize;
- int gxi, gyi, gzi, cxi, cyi, czi;
+ npy_int64 gxi, gyi, gzi, cxi, cyi, czi;
npy_int64 cdx, cdy, cdz;
npy_int64 dw[3];
int i;
@@ -1014,17 +1014,17 @@
ci = (cxi % dw[0]);
ci = (ci < 0) ? ci + dw[0] : ci;
if ( ci < gxs*refratio || ci >= gxe*refratio) continue;
- gxi = ((int) (ci / refratio)) - gxs;
+ gxi = floor(ci / refratio) - gxs;
for(cyi=cys;cyi<=cye;cyi++) {
cj = cyi % dw[1];
cj = (cj < 0) ? cj + dw[1] : cj;
if ( cj < gys*refratio || cj >= gye*refratio) continue;
- gyi = ((int) (cj / refratio)) - gys;
+ gyi = floor(cj / refratio) - gys;
for(czi=czs;czi<=cze;czi++) {
ck = czi % dw[2];
ck = (ck < 0) ? ck + dw[2] : ck;
if ( ck < gzs*refratio || ck >= gze*refratio) continue;
- gzi = ((int) (ck / refratio)) - gzs;
+ gzi = floor(ck / refratio) - gzs;
if ((ll) || (*(npy_int32*)PyArray_GETPTR3(mask, gxi,gyi,gzi) > 0))
{
for(n=0;n<n_fields;n++){
@@ -1214,75 +1214,43 @@
cye = (cys + cdy - 1);
cze = (czs + cdz - 1);
+ /* It turns out that C89 doesn't define a mechanism for choosing the sign
+ of the remainder.
+ */
int x_loc, y_loc; // For access into the buffer
-
- /* We check here if the domain is important or not.
- If it's not, then, well, we get to use the fast version. */
- if (dw[0] == dw[1] == dw[2] == 0) {
- for(gxi=gxs,cxi=gxs*refratio;gxi<gxe;gxi++,cxi+=refratio) {
- for(gyi=gys,cyi=gys*refratio;gyi<gye;gyi++,cyi+=refratio) {
- for(gzi=gzs,czi=gzs*refratio;gzi<gze;gzi++,czi+=refratio) {
- if ((refratio!=1) &&
- (*(npy_int32*)PyArray_GETPTR3(mask, gxi,gyi,gzi)==0)) continue;
- switch (axis) {
- case 0: x_loc = cyi-cys; y_loc = czi-czs; break;
- case 1: x_loc = cxi-cxs; y_loc = czi-czs; break;
- case 2: x_loc = cxi-cys; y_loc = cyi-cys; break;
- }
- //fprintf(stderr, "%d %d %d %d %d\n", x_loc, y_loc, gxi, gyi, gzi);
- for(ri=0;ri<refratio;ri++){
- for(rj=0;rj<refratio;rj++){
- for(n=0;n<n_fields;n++){
- for(n=0;n<n_fields;n++){
- *(npy_float64*) PyArray_GETPTR2(c_data[n], x_loc+ri, y_loc+rj)
- += *(npy_float64*) PyArray_GETPTR3(g_data[n],
- gxi-gxs, gyi-gys, gzi-gzs) * dls[n];
- }
- }
- }
- }
- total+=1;
- }
- }
- }
- } else {
- /* Gotta go the slow route. */
- for(cxi=gxs*refratio;cxi<=cxe;cxi++) {
- /* It turns out that C89 doesn't define a mechanism for choosing the sign
- of the remainder.
- */
+ for(cxi=cxs;cxi<=cxe;cxi++) {
ci = (cxi % dw[0]);
ci = (ci < 0) ? ci + dw[0] : ci;
- if ( ci >= gxe*refratio) break;
+ if ( ci < gxs*refratio || ci >= gxe*refratio) continue;
gxi = floor(ci / refratio) - gxs;
- for(cyi=gys*refratio;cyi<=cye;cyi++) {
- cj = cyi % dw[1];
- cj = (cj < 0) ? cj + dw[1] : cj;
- if ( cj >= gye*refratio) break;
- gyi = floor(cj / refratio) - gys;
- for(czi=gzs*refratio;czi<=cze;czi++) {
- ck = czi % dw[2];
- ck = (ck < 0) ? ck + dw[2] : ck;
- if ( ck >= gze*refratio) break;
- gzi = floor(ck / refratio) - gzs;
- if (refratio == 1 || *(npy_int32*)PyArray_GETPTR3(mask, gxi,gyi,gzi) > 0)
- {
- switch (axis) {
- case 0: x_loc = cyi-cys; y_loc = czi-czs; break;
- case 1: x_loc = cxi-cxs; y_loc = czi-czs; break;
- case 2: x_loc = cxi-cys; y_loc = cyi-cys; break;
- }
- for(n=0;n<n_fields;n++){
- *(npy_float64*) PyArray_GETPTR2(c_data[n], x_loc, y_loc)
- += *(npy_float64*) PyArray_GETPTR3(g_data[n], gxi, gyi, gzi)
- * dls[n] / refratio;
- }
- total += 1;
+ for(cyi=cys;cyi<=cye;cyi++) {
+ cj = cyi % dw[1];
+ cj = (cj < 0) ? cj + dw[1] : cj;
+ if ( cj < gys*refratio || cj >= gye*refratio) continue;
+ gyi = floor(cj / refratio) - gys;
+ for(czi=czs;czi<=cze;czi++) {
+ ck = czi % dw[2];
+ ck = (ck < 0) ? ck + dw[2] : ck;
+ if ( ck < gzs*refratio || ck >= gze*refratio) continue;
+ gzi = floor(ck / refratio) - gzs;
+ if (refratio == 1 || *(npy_int32*)PyArray_GETPTR3(mask, gxi,gyi,gzi) > 0)
+ {
+ switch (axis) {
+ case 0: x_loc = cyi-cys; y_loc = czi-czs; break;
+ case 1: x_loc = cxi-cxs; y_loc = czi-czs; break;
+ case 2: x_loc = cxi-cys; y_loc = cyi-cys; break;
+ }
+ for(n=0;n<n_fields;n++){
+ *(npy_float64*) PyArray_GETPTR2(c_data[n], x_loc, y_loc)
+ += *(npy_float64*) PyArray_GETPTR3(g_data[n], gxi, gyi, gzi)
+ * dls[n] / refratio;
+ }
+ total += 1;
+ }
}
- }
}
- }
}
+
Py_DECREF(g_start);
Py_DECREF(c_start);
Py_DECREF(g_dims);
http://bitbucket.org/yt_analysis/yt/changeset/486d7131f1c2/
changeset: 486d7131f1c2
branch: yt
user: MatthewTurk
date: 2011-07-01 03:44:11
summary: Removing race condition recently introduced by me.
affected #: 1 file (1 byte)
--- a/yt/gui/reason/extdirect_repl.py Thu Jun 30 16:52:48 2011 -0700
+++ b/yt/gui/reason/extdirect_repl.py Thu Jun 30 18:44:11 2011 -0700
@@ -112,17 +112,17 @@
except Queue.Empty:
if self.repl.stopped: return
continue
- print "Received the task", task
+ #print "Received the task", task
if task['type'] == 'code':
self.execute_one(task['code'], task['hide'])
self.queue.task_done()
elif task['type'] == 'add_widget':
#print "Adding new widget"
+ self.queue.task_done()
new_code = self.repl._add_widget(
task['name'], task['widget_data_name'])
#print "Got this command:", new_code
self.execute_one(new_code, hide=True)
- self.queue.task_done()
#print "Executed!"
def wait(self):
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list