{ "metadata": { "name": "" }, "nbformat": 3, "nbformat_minor": 0, "worksheets": [ { "cells": [ { "cell_type": "code", "collapsed": false, "input": [ "from pyne.mesh import Mesh\n", "import numpy as np" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 1 }, { "cell_type": "code", "collapsed": false, "input": [ "def cantor(n):\n", " return [0.] + cant(0., 1., n) + [1.]\n", "\n", "def cant(x, y, n):\n", " if n == 0:\n", " return []\n", " new_pts = [2.*x/3. + y/3., x/3. + 2.*y/3.]\n", " return cant(x, new_pts[0], n-1) + new_pts + cant(new_pts[1], y, n-1)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 2 }, { "cell_type": "code", "collapsed": false, "input": [ "c5 = cantor(5)\n", "c7 = cantor(7)\n", "c8 = cantor(8)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 3 }, { "cell_type": "code", "collapsed": false, "input": [ "points = c5" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 4 }, { "cell_type": "code", "collapsed": false, "input": [ "my_mesh = Mesh(structured_coords=[points]*3, structured=True)\n", "flux_tag = my_mesh.mesh.createTag(\"flux\", 1, float)" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 6 }, { "cell_type": "code", "collapsed": false, "input": [ "for ent in my_mesh.structured_iterate_hex(\"xyz\"):\n", " coords = my_mesh.mesh.getVtxCoords(ent)\n", " flux_tag[ent] = sum(coords**2) " ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 7 }, { "cell_type": "code", "collapsed": false, "input": [ "my_mesh.mesh.save(\"c5.h5m\")" ], "language": "python", "metadata": {}, "outputs": [], "prompt_number": 8 }, { "cell_type": "code", "collapsed": false, "input": [], "language": "python", "metadata": {}, "outputs": [] } ], "metadata": {} } ] }