This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Demonstrates the use of the h5py, numpy, and VTK Python modules to write a VTK | |
structured data file. | |
""" | |
import vtk | |
import numpy as np | |
import h5py | |
fname = "chkpt.0012.h5" | |
dset = "prim/rho" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
def density(r): | |
if density.outside: | |
return 0.0 | |
else: | |
z = density.rho_c * np.sin(r/R) / (r/R) if r > 1e-8 else 0.0 | |
if z < 0.0: | |
density.outside = True |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
if __name__ == "__main__": | |
import sys | |
import numpy as np | |
from matplotlib import pyplot as plt | |
infile = sys.argv[1] | |
data = np.loadtxt(infile) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int H5Lexists_safe(hid_t base, const char *path) | |
// ----------------------------------------------------------------------------- | |
// The HDF5 specification only allows H5Lexists to be called on an immediate | |
// child of the current object. However, you may wish to see whether a whole | |
// relative path exists, returning false if any of the intermediate links are | |
// not present. This function does that. | |
// http://www.hdfgroup.org/HDF5/doc/RM/RM_H5L.html#Link-Exists | |
// ----------------------------------------------------------------------------- | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*------------------------------------------------------------------------------ | |
* FILE: euler.c | |
* | |
* Copyright (C) 2011 Jonathan Zrake, NYU CCPP: zrake <at> nyu <dot> edu | |
* | |
* This program is free software: you can redistribute it and/or modify it under | |
* the terms of the GNU General Public License as published by the Free Software | |
* Foundation, either version 3 of the License, or (at your option) any later | |
* version. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <stdexcept> | |
class ZrakeFailed : public std::runtime_error | |
{ | |
public: | |
ZrakeFailed(const std::string &msg) : std::runtime_error("zraker failed. " + msg) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# ------------------------------------------------------------------------------ | |
# | |
# Authors: Jonathan Zrake, Bez Laderman: NYU CCPP | |
# Date: May 7th, 2012 | |
# | |
# This piece of code implements the left and right eigenvectors of the ideal | |
# special relativistic hydrodynamics equations. The formulas are an exact | |
# translation of those given in the literature: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void TakeScreenshot(const char *fname) | |
{ | |
printf("writing a screenshot to %s\n", fname); | |
int dimx = glutGet(GLUT_WINDOW_WIDTH); | |
int dimy = glutGet(GLUT_WINDOW_HEIGHT); | |
size_t imsize = 3*dimx*dimy; | |
char *pixels = (char*) malloc(imsize*sizeof(char)); | |
glReadPixels(0, 0, dimx, dimy, GL_RGB, GL_UNSIGNED_BYTE, pixels); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ----------------------------------------------------------------------------- | |
* | |
* AUTHOR: Jonathan Zrake, NYU CCPP: [email protected] | |
* | |
* | |
* USAGE: $> ./tetrun [number of trials] | |
* | |
* | |
* DESCRIPTION: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void draw_vbo() | |
{ | |
GLuint vbo,ibo; | |
GLfloat verts[8][3] = {{0.0, 0.0, 0.0}, | |
{0.0, 0.0, 0.1}, | |
{0.0, 0.1, 0.0}, | |
{0.0, 0.1, 0.1}, | |
{0.1, 0.0, 0.0}, | |
{0.1, 0.0, 0.1}, | |
{0.1, 0.1, 0.0}, |