[Yt-svn] yt: Several fixes for RAMSES data. Segfaults for multi-domain h...
hg at spacepope.org
hg at spacepope.org
Wed Dec 1 13:11:33 PST 2010
hg Repository: yt
details: yt/rev/d9996eb07097
changeset: 3563:d9996eb07097
user: Matthew Turk <matthewturk at gmail.com>
date:
Wed Dec 01 13:11:29 2010 -0800
description:
Several fixes for RAMSES data. Segfaults for multi-domain have *changed*, but
should no longer occur all the time, only at de-allocation.
As it stands, these are the caveats for RAMSES data as I see them:
* Particles do not work; this should be very simple to implement, I just
haven't yet.
* Memory is very poorly conserved, and parallelism will not help with memory,
only with speed.
* There may be an issue with reading values; I am finding a few values with
negative densities in my sample dataset, but the remainder of the densities
look to be reasonable. I will not rule this out as a possible bug in the
dataset, though.
* Units for density, time, length and velocities should be correct; I don't
know how to correctly set conversion of the pressure field to cgs.
diffstat:
yt/frontends/ramses/_ramses_reader.cpp | 1499 +++++++-------
yt/frontends/ramses/_ramses_reader.pyx | 37 +-
yt/frontends/ramses/data_structures.py | 42 +-
yt/frontends/ramses/fields.py | 39 +-
yt/frontends/ramses/ramses_headers/RAMSES_hydro_data.hh | 17 +-
5 files changed, 871 insertions(+), 763 deletions(-)
diffs (truncated from 4694 to 300 lines):
diff -r 6f5877b2b32e -r d9996eb07097 yt/frontends/ramses/_ramses_reader.cpp
--- a/yt/frontends/ramses/_ramses_reader.cpp Wed Dec 01 09:40:43 2010 -0800
+++ b/yt/frontends/ramses/_ramses_reader.cpp Wed Dec 01 13:11:29 2010 -0800
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.13.beta0 on Thu Aug 26 14:34:14 2010 */
+/* Generated by Cython 0.13.beta0 on Wed Dec 1 13:02:43 2010 */
#define PY_SSIZE_T_CLEAN
#include "Python.h"
@@ -390,7 +390,7 @@
int nfields;
};
-/* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":694
+/* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":703
* return to_fill
*
* cdef class ProtoSubgrid: # <<<<<<<<<<<<<<
@@ -928,6 +928,7 @@
static char __pyx_k__is_finest[] = "is_finest";
static char __pyx_k__left_edge[] = "left_edge";
static char __pyx_k__signature[] = "signature";
+static char __pyx_k__traceback[] = "traceback";
static char __pyx_k__ValueError[] = "ValueError";
static char __pyx_k__child_mask[] = "child_mask";
static char __pyx_k__dimensions[] = "dimensions";
@@ -945,6 +946,7 @@
static char __pyx_k__grid_levels[] = "grid_levels";
static char __pyx_k__hydro_datas[] = "hydro_datas";
static char __pyx_k__m_var_array[] = "m_var_array";
+static char __pyx_k__print_stack[] = "print_stack";
static char __pyx_k__right_edges[] = "right_edges";
static char __pyx_k__start_index[] = "start_index";
static char __pyx_k__RuntimeError[] = "RuntimeError";
@@ -1045,6 +1047,7 @@
static PyObject *__pyx_n_s__omega_m;
static PyObject *__pyx_n_s__ones;
static PyObject *__pyx_n_s__order;
+static PyObject *__pyx_n_s__print_stack;
static PyObject *__pyx_n_s__range;
static PyObject *__pyx_n_s__read;
static PyObject *__pyx_n_s__readonly;
@@ -1061,6 +1064,7 @@
static PyObject *__pyx_n_s__suboffsets;
static PyObject *__pyx_n_s__time;
static PyObject *__pyx_n_s__top_grid_dims;
+static PyObject *__pyx_n_s__traceback;
static PyObject *__pyx_n_s__trees;
static PyObject *__pyx_n_s__type_num;
static PyObject *__pyx_n_s__unit_d;
@@ -1292,7 +1296,7 @@
RAMSES::HYDRO::RAMSES_hydro_data *__pyx_v_local_hydro_data;
std::string *__pyx_v_field_name;
int __pyx_r;
- long __pyx_t_1;
+ unsigned int __pyx_t_1;
int __pyx_t_2;
unsigned int __pyx_t_3;
int __pyx_t_4;
@@ -1375,104 +1379,112 @@
* malloc(sizeof(RAMSES_hydro_data**) * self.rsnap.m_header.ncpu)
* self.ndomains = self.rsnap.m_header.ncpu # <<<<<<<<<<<<<<
* #for ii in range(self.ndomains): self.trees[ii] = NULL
- * for idomain in range(1, self.rsnap.m_header.ncpu + 1):
+ * # Note we don't do ncpu + 1
*/
((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->ndomains = ((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap->m_header.ncpu;
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":400
- * self.ndomains = self.rsnap.m_header.ncpu
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":401
* #for ii in range(self.ndomains): self.trees[ii] = NULL
- * for idomain in range(1, self.rsnap.m_header.ncpu + 1): # <<<<<<<<<<<<<<
- * local_tree = new RAMSES_tree(deref(self.rsnap), idomain,
- * self.rsnap.m_header.levelmax, 0)
- */
- __pyx_t_1 = (((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap->m_header.ncpu + 1);
- for (__pyx_t_2 = 1; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+ * # Note we don't do ncpu + 1
+ * for idomain in range(self.rsnap.m_header.ncpu): # <<<<<<<<<<<<<<
+ * # we don't delete local_tree
+ * local_tree = new RAMSES_tree(deref(self.rsnap), idomain + 1,
+ */
+ __pyx_t_1 = ((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap->m_header.ncpu;
+ for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
__pyx_v_idomain = __pyx_t_2;
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":402
- * for idomain in range(1, self.rsnap.m_header.ncpu + 1):
- * local_tree = new RAMSES_tree(deref(self.rsnap), idomain,
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":404
+ * # we don't delete local_tree
+ * local_tree = new RAMSES_tree(deref(self.rsnap), idomain + 1,
* self.rsnap.m_header.levelmax, 0) # <<<<<<<<<<<<<<
* local_tree.read()
* local_hydro_data = new RAMSES_hydro_data(deref(local_tree))
*/
- __pyx_v_local_tree = new RAMSES::AMR::RAMSES_tree((*((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap), __pyx_v_idomain, ((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap->m_header.levelmax, 0);
-
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":403
- * local_tree = new RAMSES_tree(deref(self.rsnap), idomain,
+ __pyx_v_local_tree = new RAMSES::AMR::RAMSES_tree((*((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap), (__pyx_v_idomain + 1), ((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap->m_header.levelmax, 0);
+
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":405
+ * local_tree = new RAMSES_tree(deref(self.rsnap), idomain + 1,
* self.rsnap.m_header.levelmax, 0)
* local_tree.read() # <<<<<<<<<<<<<<
* local_hydro_data = new RAMSES_hydro_data(deref(local_tree))
- * self.hydro_datas[idomain - 1] = <RAMSES_hydro_data **>\
+ * self.hydro_datas[idomain] = <RAMSES_hydro_data **>\
*/
__pyx_v_local_tree->read();
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":404
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":406
* self.rsnap.m_header.levelmax, 0)
* local_tree.read()
* local_hydro_data = new RAMSES_hydro_data(deref(local_tree)) # <<<<<<<<<<<<<<
- * self.hydro_datas[idomain - 1] = <RAMSES_hydro_data **>\
+ * self.hydro_datas[idomain] = <RAMSES_hydro_data **>\
* malloc(sizeof(RAMSES_hydro_data*) * local_hydro_data.m_nvars)
*/
__pyx_v_local_hydro_data = new RAMSES::HYDRO::RAMSES_hydro_data((*__pyx_v_local_tree));
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":405
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":407
* local_tree.read()
* local_hydro_data = new RAMSES_hydro_data(deref(local_tree))
- * self.hydro_datas[idomain - 1] = <RAMSES_hydro_data **>\ # <<<<<<<<<<<<<<
+ * self.hydro_datas[idomain] = <RAMSES_hydro_data **>\ # <<<<<<<<<<<<<<
* malloc(sizeof(RAMSES_hydro_data*) * local_hydro_data.m_nvars)
* for ii in range(local_hydro_data.m_nvars):
*/
- (((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->hydro_datas[(__pyx_v_idomain - 1)]) = ((RAMSES::HYDRO::RAMSES_hydro_data **)malloc(((sizeof(RAMSES::HYDRO::RAMSES_hydro_data *)) * __pyx_v_local_hydro_data->m_nvars)));
-
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":407
- * self.hydro_datas[idomain - 1] = <RAMSES_hydro_data **>\
+ (((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->hydro_datas[__pyx_v_idomain]) = ((RAMSES::HYDRO::RAMSES_hydro_data **)malloc(((sizeof(RAMSES::HYDRO::RAMSES_hydro_data *)) * __pyx_v_local_hydro_data->m_nvars)));
+
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":409
+ * self.hydro_datas[idomain] = <RAMSES_hydro_data **>\
* malloc(sizeof(RAMSES_hydro_data*) * local_hydro_data.m_nvars)
* for ii in range(local_hydro_data.m_nvars): # <<<<<<<<<<<<<<
- * self.hydro_datas[idomain - 1][ii] = \
+ * self.hydro_datas[idomain][ii] = \
* new RAMSES_hydro_data(deref(local_tree))
*/
__pyx_t_3 = __pyx_v_local_hydro_data->m_nvars;
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) {
__pyx_v_ii = __pyx_t_4;
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":408
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":410
* malloc(sizeof(RAMSES_hydro_data*) * local_hydro_data.m_nvars)
* for ii in range(local_hydro_data.m_nvars):
- * self.hydro_datas[idomain - 1][ii] = \ # <<<<<<<<<<<<<<
+ * self.hydro_datas[idomain][ii] = \ # <<<<<<<<<<<<<<
* new RAMSES_hydro_data(deref(local_tree))
- * self.trees[idomain - 1] = local_tree
- */
- ((((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->hydro_datas[(__pyx_v_idomain - 1)])[__pyx_v_ii]) = new RAMSES::HYDRO::RAMSES_hydro_data((*__pyx_v_local_tree));
- }
-
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":410
- * self.hydro_datas[idomain - 1][ii] = \
+ * self.trees[idomain] = local_tree
+ */
+ ((((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->hydro_datas[__pyx_v_idomain])[__pyx_v_ii]) = new RAMSES::HYDRO::RAMSES_hydro_data((*__pyx_v_local_tree));
+ }
+
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":412
+ * self.hydro_datas[idomain][ii] = \
* new RAMSES_hydro_data(deref(local_tree))
- * self.trees[idomain - 1] = local_tree # <<<<<<<<<<<<<<
- * # We do not delete anything
- * if idomain < self.rsnap.m_header.ncpu: del local_hydro_data
- */
- (((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->trees[(__pyx_v_idomain - 1)]) = __pyx_v_local_tree;
-
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":412
- * self.trees[idomain - 1] = local_tree
- * # We do not delete anything
- * if idomain < self.rsnap.m_header.ncpu: del local_hydro_data # <<<<<<<<<<<<<<
+ * self.trees[idomain] = local_tree # <<<<<<<<<<<<<<
+ * # We do not delete the final snapshot, which we'll use later
+ * if idomain + 1 < self.rsnap.m_header.ncpu:
+ */
+ (((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->trees[__pyx_v_idomain]) = __pyx_v_local_tree;
+
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":414
+ * self.trees[idomain] = local_tree
+ * # We do not delete the final snapshot, which we'll use later
+ * if idomain + 1 < self.rsnap.m_header.ncpu: # <<<<<<<<<<<<<<
+ * del local_hydro_data
+ * # Only once, we read all the field names
+ */
+ __pyx_t_5 = ((__pyx_v_idomain + 1) < ((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap->m_header.ncpu);
+ if (__pyx_t_5) {
+
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":415
+ * # We do not delete the final snapshot, which we'll use later
+ * if idomain + 1 < self.rsnap.m_header.ncpu:
+ * del local_hydro_data # <<<<<<<<<<<<<<
* # Only once, we read all the field names
* self.nfields = local_hydro_data.m_nvars
*/
- __pyx_t_5 = (__pyx_v_idomain < ((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->rsnap->m_header.ncpu);
- if (__pyx_t_5) {
delete __pyx_v_local_hydro_data;
goto __pyx_L10;
}
__pyx_L10:;
}
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":414
- * if idomain < self.rsnap.m_header.ncpu: del local_hydro_data
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":417
+ * del local_hydro_data
* # Only once, we read all the field names
* self.nfields = local_hydro_data.m_nvars # <<<<<<<<<<<<<<
* cdef string *field_name
@@ -1480,14 +1492,14 @@
*/
((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->nfields = __pyx_v_local_hydro_data->m_nvars;
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":416
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":419
* self.nfields = local_hydro_data.m_nvars
* cdef string *field_name
* self.field_names = [] # <<<<<<<<<<<<<<
* self.field_ind = {}
* self.loaded = <int **> malloc(sizeof(int) * local_hydro_data.m_nvars)
*/
- __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_6));
__Pyx_GIVEREF(((PyObject *)__pyx_t_6));
__Pyx_GOTREF(((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->field_names);
@@ -1495,14 +1507,14 @@
((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->field_names = ((PyObject *)__pyx_t_6);
__pyx_t_6 = 0;
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":417
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":420
* cdef string *field_name
* self.field_names = []
* self.field_ind = {} # <<<<<<<<<<<<<<
* self.loaded = <int **> malloc(sizeof(int) * local_hydro_data.m_nvars)
* for idomain in range(self.ndomains):
*/
- __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
__Pyx_GOTREF(((PyObject *)__pyx_t_6));
__Pyx_GIVEREF(((PyObject *)__pyx_t_6));
__Pyx_GOTREF(((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->field_ind);
@@ -1510,7 +1522,7 @@
((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->field_ind = ((PyObject *)__pyx_t_6);
__pyx_t_6 = 0;
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":418
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":421
* self.field_names = []
* self.field_ind = {}
* self.loaded = <int **> malloc(sizeof(int) * local_hydro_data.m_nvars) # <<<<<<<<<<<<<<
@@ -1519,7 +1531,7 @@
*/
((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->loaded = ((int **)malloc(((sizeof(int)) * __pyx_v_local_hydro_data->m_nvars)));
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":419
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":422
* self.field_ind = {}
* self.loaded = <int **> malloc(sizeof(int) * local_hydro_data.m_nvars)
* for idomain in range(self.ndomains): # <<<<<<<<<<<<<<
@@ -1530,7 +1542,7 @@
for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_2; __pyx_t_4+=1) {
__pyx_v_idomain = __pyx_t_4;
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":420
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":423
* self.loaded = <int **> malloc(sizeof(int) * local_hydro_data.m_nvars)
* for idomain in range(self.ndomains):
* self.loaded[idomain] = <int *> malloc( # <<<<<<<<<<<<<<
@@ -1539,18 +1551,18 @@
*/
(((struct __pyx_obj_2yt_9frontends_6ramses_14_ramses_reader_RAMSES_tree_proxy *)__pyx_v_self)->loaded[__pyx_v_idomain]) = ((int *)malloc(((sizeof(int)) * __pyx_v_local_hydro_data->m_nvars)));
- /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":422
+ /* "/Users/matthewturk/ytdays2010/yt/yt/frontends/ramses/_ramses_reader.pyx":425
* self.loaded[idomain] = <int *> malloc(
* sizeof(int) * local_hydro_data.m_nvars)
* for ifield in range(local_hydro_data.m_nvars): # <<<<<<<<<<<<<<
* self.loaded[idomain][ifield] = 0
* for ifield in range(local_hydro_data.m_nvars):
*/
- __pyx_t_3 = __pyx_v_local_hydro_data->m_nvars;
- for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_3; __pyx_t_7+=1) {
+ __pyx_t_1 = __pyx_v_local_hydro_data->m_nvars;
+ for (__pyx_t_7 = 0; __pyx_t_7 < __pyx_t_1; __pyx_t_7+=1) {
__pyx_v_ifield = __pyx_t_7;
More information about the yt-svn
mailing list