<commit_before>{
 "metadata": {
  "name": "multigrid-examples"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import print_function\n",
      "\n",
      "import numpy as np\n",
      "\n",
      "import mesh.patch as patch\n",
      "import multigrid.MG as MG"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "ImportError",
       "evalue": "No module named MG",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mImportError\u001b[0m                               Traceback (most recent call last)",
        "\u001b[1;32m<ipython-input-8-68613611740b>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      4\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      5\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mmesh\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mpatch\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mpatch\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 6\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mmultigrid\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mMG\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mMG\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
        "\u001b[1;31mImportError\u001b[0m: No module named MG"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "We want to solve $\\phi_{xx} + \\phi_{yy} = -2[(1-6x^2)y^2(1-y^2) + (1-6y^2)x^2(1-x^2)]$ on $[0,1]\\times[0,1]$ with homogeneous Dirichlet boundary conditions (this example comes from \"A Multigrid Tutorial\")."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "nx = ny = 256\n",
      "mg = MG.CellCenterMG2d(nx, ny, \n",
      "                       xl_BC_type=\"dirichlet\", xr_BC_type=\"dirichlet\",\n",
      "                       yl_BC_type=\"dirichlet\", yr_BC_type=\"dirichlet\", verbose=1)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "NameError",
       "evalue": "name 'multigrid' is not defined",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
        "\u001b[1;32m<ipython-input-6-219f7218ffd7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[0mnx\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mny\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;36m256\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m mg = multigrid.CellCenterMG2d(nx, ny, \n\u001b[0m\u001b[0;32m      3\u001b[0m                               \u001b[0mxl_BC_type\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"dirichlet\"\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mxr_BC_type\u001b[0m\u001b[1;33m=\u001b[0m\u001b[1;34m\"dirichlet\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      4\u001b[0m                               yl_BC_type=\"dirichlet\", yr_BC_type=\"dirichlet\", verbose=1)\n",
        "\u001b[1;31mNameError\u001b[0m: name 'multigrid' is not defined"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "initialize the solution to zero and set the RHS.  To make life easier, the CellCenterMG2d object has the coordinates of the solution grid (including ghost cells) as mg.x2d and mg.y2d (these are two-dimensional arrays)."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def rhs(x, y):\n",
      "    return -2.0*((1.0-6.0*x**2)*y**2*(1.0-y**2) + (1.0-6.0*y**2)*x**2*(1.0-x**2))\n",
      "\n",
      "mg.init_RHS(f(mg.x2d, mg.y2d))\n",
      "mg.init_zeros()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "we can now solve -- there are actually two different techniques we can do here.  We can just do pure smoothing on the solution grid using mg.smooth(mg.nlevels-1, N), where N is the number of smoothing iterations.  To get the solution N will need to be large and this will take a long time.\n",
      "\n",
      "Alternately, we can do a V-cycle multigrid solution using mg.solve()"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "mg.solve()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "NameError",
       "evalue": "name 'mg' is not defined",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mNameError\u001b[0m                                 Traceback (most recent call last)",
        "\u001b[1;32m<ipython-input-7-7df1ab60aba4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mmg\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msolve\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
        "\u001b[1;31mNameError\u001b[0m: name 'mg' is not defined"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}<commit_msg>a notebook version of mg_test.py<commit_after>{
 "metadata": {
  "name": "multigrid-examples"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%pylab inline"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "Welcome to pylab, a matplotlib-based Python environment [backend: module://IPython.zmq.pylab.backend_inline].\n",
        "For more information, type 'help(pylab)'.\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from __future__ import print_function\n",
      "\n",
      "import numpy as np\n",
      "\n",
      "import mesh.patch as patch\n",
      "import multigrid.MG as MG"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "We want to solve $\\phi_{xx} + \\phi_{yy} = -2[(1-6x^2)y^2(1-y^2) + (1-6y^2)x^2(1-x^2)]$ on $[0,1]\\times[0,1]$ with homogeneous Dirichlet boundary conditions (this example comes from \"A Multigrid Tutorial\")."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "nx = ny = 256\n",
      "mg = MG.CellCenterMG2d(nx, ny, \n",
      "                       xl_BC_type=\"dirichlet\", xr_BC_type=\"dirichlet\",\n",
      "                       yl_BC_type=\"dirichlet\", yr_BC_type=\"dirichlet\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 9
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "initialize the solution to zero and set the RHS.  To make life easier, the CellCenterMG2d object has the coordinates of the solution grid (including ghost cells) as mg.x2d and mg.y2d (these are two-dimensional arrays)."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def rhs(x, y):\n",
      "    return -2.0*((1.0-6.0*x**2)*y**2*(1.0-y**2) + (1.0-6.0*y**2)*x**2*(1.0-x**2))\n",
      "\n",
      "mg.init_RHS(rhs(mg.x2d, mg.y2d))\n",
      "mg.init_zeros()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Source norm =  1.09751581367\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "raw",
     "metadata": {},
     "source": [
      "we can now solve -- there are actually two different techniques we can do here.  We can just do pure smoothing on the solution grid using mg.smooth(mg.nlevels-1, N), where N is the number of smoothing iterations.  To get the solution N will need to be large and this will take a long time.\n",
      "\n",
      "Alternately, we can do a V-cycle multigrid solution using mg.solve()"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "mg.solve()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "source norm =  1.09751581367\n",
        "<<< beginning V-cycle (cycle 1) >>>\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 1.09752\n",
        "  after G-S, residual L2 norm = 1.50231\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 1.06162\n",
        "  after G-S, residual L2 norm = 1.43215\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 1.01137\n",
        "  after G-S, residual L2 norm = 1.28187\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 0.903531\n",
        "  after G-S, residual L2 norm = 0.960758\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 0.673611\n",
        "  after G-S, residual L2 norm = 0.443977\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 0.307211\n",
        "  after G-S, residual L2 norm = 0.0727216\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 0.0484181\n",
        "  after G-S, residual L2 norm = 3.96107e-05\n",
        "\n",
        "  bottom solve:\n",
        "  level = 0, nx = 2, ny = 2\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 3.38303e-05\n",
        "  after G-S, residual L2 norm = 1.03701e-09\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 0.0680535\n",
        "  after G-S, residual L2 norm = 0.00088157\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 0.466616\n",
        "  after G-S, residual L2 norm = 0.0071749\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 1.11459\n",
        "  after G-S, residual L2 norm = 0.0161876\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 1.79744\n",
        "  after G-S, residual L2 norm = 0.0220213\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 2.60326\n",
        "  after G-S, residual L2 norm = 0.0251865\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 3.69799\n",
        "  after G-S, residual L2 norm = 0.02687\n",
        "\n",
        "cycle 1: relative err = 1, residual err = 0.0244826\n",
        "\n",
        "<<< beginning V-cycle (cycle 2) >>>\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 0.02687\n",
        "  after G-S, residual L2 norm = 0.0257902\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 0.0182181\n",
        "  after G-S, residual L2 norm = 0.0236543\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 0.0166908\n",
        "  after G-S, residual L2 norm = 0.0197734\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 0.0139226\n",
        "  after G-S, residual L2 norm = 0.0135776\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 0.00951831\n",
        "  after G-S, residual L2 norm = 0.00611516\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 0.00424463\n",
        "  after G-S, residual L2 norm = 0.00106741\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 0.000710814\n",
        "  after G-S, residual L2 norm = 5.81825e-07\n",
        "\n",
        "  bottom solve:\n",
        "  level = 0, nx = 2, ny = 2\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 4.96919e-07\n",
        "  after G-S, residual L2 norm = 1.52312e-11\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 0.000999182\n",
        "  after G-S, residual L2 norm = 1.29509e-05\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 0.00676028\n",
        "  after G-S, residual L2 norm = 0.000104835\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 0.0170092\n",
        "  after G-S, residual L2 norm = 0.00026234\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 0.0288135\n",
        "  after G-S, residual L2 norm = 0.000394483\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 0.0422498\n",
        "  after G-S, residual L2 norm = 0.000486365\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 0.0594766\n",
        "  after G-S, residual L2 norm = 0.000544087\n",
        "\n",
        "cycle 2: relative err = 13.7395, residual err = 0.000495745\n",
        "\n",
        "<<< beginning V-cycle (cycle 3) >>>\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 0.000544087\n",
        "  after G-S, residual L2 norm = 0.000509584\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 0.000359788\n",
        "  after G-S, residual L2 norm = 0.000446485\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 0.000314789\n",
        "  after G-S, residual L2 norm = 0.000349254\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 0.000245728\n",
        "  after G-S, residual L2 norm = 0.000222329\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 0.000155893\n",
        "  after G-S, residual L2 norm = 9.51109e-05\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 6.6169e-05\n",
        "  after G-S, residual L2 norm = 1.71101e-05\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 1.13952e-05\n",
        "  after G-S, residual L2 norm = 9.33005e-09\n",
        "\n",
        "  bottom solve:\n",
        "  level = 0, nx = 2, ny = 2\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 7.96855e-09\n",
        "  after G-S, residual L2 norm = 2.44231e-13\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 1.60197e-05\n",
        "  after G-S, residual L2 norm = 2.07713e-07\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 0.00010911\n",
        "  after G-S, residual L2 norm = 1.72417e-06\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 0.000289054\n",
        "  after G-S, residual L2 norm = 4.76628e-06\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 0.000505016\n",
        "  after G-S, residual L2 norm = 7.60062e-06\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 0.000747643\n",
        "  after G-S, residual L2 norm = 9.86076e-06\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 0.00104428\n",
        "  after G-S, residual L2 norm = 1.14661e-05\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "cycle 3: relative err = 34.3476, residual err = 1.04474e-05\n",
        "\n",
        "<<< beginning V-cycle (cycle 4) >>>\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 1.14661e-05\n",
        "  after G-S, residual L2 norm = 1.05447e-05\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 7.44281e-06\n",
        "  after G-S, residual L2 norm = 8.95505e-06\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 6.31131e-06\n",
        "  after G-S, residual L2 norm = 6.73455e-06\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 4.73798e-06\n",
        "  after G-S, residual L2 norm = 4.0918e-06\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 2.87103e-06\n",
        "  after G-S, residual L2 norm = 1.63196e-06\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 1.13722e-06\n",
        "  after G-S, residual L2 norm = 2.96104e-07\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 1.97219e-07\n",
        "  after G-S, residual L2 norm = 1.61504e-10\n",
        "\n",
        "  bottom solve:\n",
        "  level = 0, nx = 2, ny = 2\n",
        "\n",
        "  level = 1, nx = 4, ny = 4"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  before G-S, residual L2 norm = 1.37937e-10\n",
        "  after G-S, residual L2 norm = 4.22743e-15\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 2.77282e-07\n",
        "  after G-S, residual L2 norm = 3.59611e-09\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 1.9248e-06\n",
        "  after G-S, residual L2 norm = 3.11363e-08\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 5.40733e-06\n",
        "  after G-S, residual L2 norm = 9.54482e-08\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 9.57897e-06\n",
        "  after G-S, residual L2 norm = 1.56638e-07\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 1.41416e-05\n",
        "  after G-S, residual L2 norm = 2.07773e-07\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 1.95088e-05\n",
        "  after G-S, residual L2 norm = 2.46453e-07\n",
        "\n",
        "cycle 4: relative err = 0.174098, residual err = 2.24555e-07\n",
        "\n",
        "<<< beginning V-cycle (cycle 5) >>>\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 2.46453e-07\n",
        "  after G-S, residual L2 norm = 2.24911e-07\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 1.58746e-07\n",
        "  after G-S, residual L2 norm = 1.88625e-07\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 1.32945e-07\n",
        "  after G-S, residual L2 norm = 1.39771e-07\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 9.83693e-08\n",
        "  after G-S, residual L2 norm = 8.26903e-08\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 5.80625e-08\n",
        "  after G-S, residual L2 norm = 3.03473e-08\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 2.11691e-08\n",
        "  after G-S, residual L2 norm = 5.46752e-09\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 3.64181e-09\n",
        "  after G-S, residual L2 norm = 2.98263e-12\n",
        "\n",
        "  bottom solve:\n",
        "  level = 0, nx = 2, ny = 2\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 2.5474e-12\n",
        "  after G-S, residual L2 norm = 7.80674e-17\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 5.12074e-09\n",
        "  after G-S, residual L2 norm = 6.64232e-11\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 3.65289e-08\n",
        "  after G-S, residual L2 norm = 6.05223e-10\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 1.09602e-07\n",
        "  after G-S, residual L2 norm = 2.05415e-09\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 1.95324e-07\n",
        "  after G-S, residual L2 norm = 3.42102e-09\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 2.84412e-07\n",
        "  after G-S, residual L2 norm = 4.55217e-09\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 3.84782e-07\n",
        "  after G-S, residual L2 norm = 5.41489e-09\n",
        "\n",
        "cycle 5: relative err = 0.00539124, residual err = 4.93377e-09\n",
        "\n",
        "<<< beginning V-cycle (cycle 6) >>>\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 5.41489e-09\n",
        "  after G-S, residual L2 norm = 4.94814e-09\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 3.49296e-09\n",
        "  after G-S, residual L2 norm = 4.15445e-09\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 2.92888e-09\n",
        "  after G-S, residual L2 norm = 3.07478e-09\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 2.16499e-09\n",
        "  after G-S, residual L2 norm = 1.78803e-09\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 1.25622e-09\n",
        "  after G-S, residual L2 norm = 6.02198e-10\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 4.20281e-10\n",
        "  after G-S, residual L2 norm = 1.06557e-10\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 7.09787e-11\n",
        "  after G-S, residual L2 norm = 5.81351e-14\n",
        "\n",
        "  bottom solve:\n",
        "  level = 0, nx = 2, ny = 2\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 4.96521e-14\n",
        "  after G-S, residual L2 norm = 1.52156e-18\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 9.98119e-11\n",
        "  after G-S, residual L2 norm = 1.29488e-12\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 7.35324e-10\n",
        "  after G-S, residual L2 norm = 1.24537e-11\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 2.36118e-09\n",
        "  after G-S, residual L2 norm = 4.63904e-11\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 4.22932e-09\n",
        "  after G-S, residual L2 norm = 7.80374e-11\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 6.04804e-09\n",
        "  after G-S, residual L2 norm = 1.03327e-10\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 7.98638e-09\n",
        "  after G-S, residual L2 norm = 1.21994e-10\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "cycle 6: relative err = 7.51414e-05, residual err = 1.11155e-10\n",
        "\n",
        "<<< beginning V-cycle (cycle 7) >>>\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 1.21994e-10\n",
        "  after G-S, residual L2 norm = 1.12199e-10\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 7.92186e-11\n",
        "  after G-S, residual L2 norm = 9.49345e-11\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 6.69499e-11\n",
        "  after G-S, residual L2 norm = 7.051e-11\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 4.96666e-11\n",
        "  after G-S, residual L2 norm = 4.04509e-11\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 2.84315e-11\n",
        "  after G-S, residual L2 norm = 1.25763e-11\n",
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 8.77795e-12\n",
        "  after G-S, residual L2 norm = 2.17056e-12\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 1.44588e-12\n",
        "  after G-S, residual L2 norm = 1.18429e-15\n",
        "\n",
        "  bottom solve:\n",
        "  level = 0, nx = 2, ny = 2\n",
        "\n",
        "  level = 1, nx = 4, ny = 4\n",
        "  before G-S, residual L2 norm = 1.01149e-15\n",
        "  after G-S, residual L2 norm = 3.09948e-20\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "  level = 2, nx = 8, ny = 8\n",
        "  before G-S, residual L2 norm = 2.0334e-12\n",
        "  after G-S, residual L2 norm = 2.63826e-14\n",
        "\n",
        "  level = 3, nx = 16, ny = 16\n",
        "  before G-S, residual L2 norm = 1.5505e-11\n",
        "  after G-S, residual L2 norm = 2.67606e-13\n",
        "\n",
        "  level = 4, nx = 32, ny = 32\n",
        "  before G-S, residual L2 norm = 5.31227e-11\n",
        "  after G-S, residual L2 norm = 1.08104e-12\n",
        "\n",
        "  level = 5, nx = 64, ny = 64\n",
        "  before G-S, residual L2 norm = 9.57868e-11\n",
        "  after G-S, residual L2 norm = 1.83429e-12\n",
        "\n",
        "  level = 6, nx = 128, ny = 128\n",
        "  before G-S, residual L2 norm = 1.34682e-10\n",
        "  after G-S, residual L2 norm = 2.41243e-12\n",
        "\n",
        "  level = 7, nx = 256, ny = 256\n",
        "  before G-S, residual L2 norm = 1.73494e-10\n",
        "  after G-S, residual L2 norm = 2.84299e-12\n",
        "\n",
        "cycle 7: relative err = 7.06226e-07, residual err = 2.59039e-12\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "phi = mg.get_solution()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "pylab.imshow(phi[mg.ilo:mg.ihi+1,mg.jlo:mg.jhi+1], origin=\"lower\")"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "pyout",
       "prompt_number": 7,
       "text": [
        "<matplotlib.image.AxesImage at 0x4670350>"
       ]
      },
      {
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAQ<KEY>"
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}
{'fraction_non_alphanumeric': 0.19107034464153233, 'fraction_numerical': 0.10824846563701356, 'mean_word_length': 1.5639806328895036, 'pattern_counts': {'":': 182, '<': 32, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4368851', 'n_tokens_mistral': 14135, 'n_tokens_neox': 11897, 'n_words': 2759}