yt.geometry_tests / test_art_octre.py

from yt.mods import *
from yt.geometry.oct_container import RAMSESOctreeContainer
import yt.geometry.selection_routines as sel
from art_header import read_header
from art_header import _count_art_octs
from art_header import _read_art_level_info

parameter_filename = '/u/cmoody3/data/art_snapshots/SFG1/10MpcBox_csf512_a0.330.d'
root_grid_mask_offset,root_grid_offset,child_grid_offset,min_level,max_level = read_header(parameter_filename)
f = open(parameter_filename,'rb')
nhydrovars, inoll, level_oct_offsets, level_child_offsets =_count_art_octs(f, child_grid_offset,min_level, max_level)

NX = na.ones(3)*128
LE = na.array([0.0, 0.0, 0.0], dtype='float64')
RE = na.array([1.0, 1.0, 1.0], dtype='float64')

nocts = 0
for level in range(max_level):
    # read level info into POS
    # 1 is the CPU, -1 is not used, 1 is the domain ID
    le,fln= _read_art_level_info(f, level_oct_offsets,level,root_level=15)
    nocts += le.shape[0]

art_oct = RAMSESOctreeContainer(NX, LE, RE)
art_oct.allocate_domains(na.ones(3)*nocts)

for level in range(max_level):
    # read level info into POSx
    # 1 is the CPU, -1 is not used, 1 is the domain ID
    le,fln= _read_art_level_info(f, level_oct_offsets,level,root_level=15)
    # int curdom, int curlevel, int ng,
    #       np.ndarray[np.float64_t, ndim=2] pos,
    #        int local_domain):
    art_oct.add(1, level, -1, le, 1)

# Now let's test a selector
class Empty(object):
    pass

sp_obj = Empty()
sp_obj.center = [0.5, 0.5, 0.5]
sp_obj.radius = 0.1
sp = sel.SphereSelector(sp_obj)

mask = na.zeros(sp.nocts, dtype="bool")

cells = art_oct.count_cells(sp, mask)
nc = cells.sum()
print nc, sp.nocts
# 1 is domain_id
icoords = art_oct.icoords(1, mask, nc)
ires = art_oct.ires(1, mask, nc)

print icoords
print ires
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.