{ "cells": [ { "cell_type": "markdown", "id": "3471b94b", "metadata": { "cell_style": "center", "slideshow": { "slide_type": "slide" } }, "source": [ "# 2023-10-25 Multigrid" ] }, { "cell_type": "markdown", "id": "4159be0e", "metadata": { "cell_style": "split", "slideshow": { "slide_type": "" } }, "source": [ "## Last time\n", "\n", "* Preconditioning building blocks\n", "* Domain decomposition\n", "* PETSc discussion\n", "\n", "## Today\n", "* Software licensing\n", "* Projects\n", "* Multigrid\n", " * Spectral perspective\n", " * Factorization perspective\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "e82d841d", "metadata": { "hideOutput": true, "slideshow": { "slide_type": "skip" } }, "outputs": [ { "data": { "text/plain": [ "advdiff_matrix (generic function with 1 method)" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "using Plots\n", "default(linewidth=3)\n", "using LinearAlgebra\n", "using SparseArrays\n", "\n", "function my_spy(A)\n", " cmax = norm(vec(A), Inf)\n", " s = max(1, ceil(120 / size(A, 1)))\n", " spy(A, marker=(:square, s), c=:diverging_rainbow_bgymr_45_85_c67_n256, clims=(-cmax, cmax))\n", "end\n", "\n", "function advdiff_matrix(n; kappa=1, wind=[0, 0])\n", " h = 2 / (n + 1)\n", " rows = Vector{Int64}()\n", " cols = Vector{Int64}()\n", " vals = Vector{Float64}()\n", " idx((i, j),) = (i-1)*n + j\n", " in_domain((i, j),) = 1 <= i <= n && 1 <= j <= n\n", " stencil_advect = [-wind[1], -wind[2], 0, wind[1], wind[2]] / h\n", " stencil_diffuse = [-1, -1, 4, -1, -1] * kappa / h^2\n", " stencil = stencil_advect + stencil_diffuse\n", " for i in 1:n\n", " for j in 1:n\n", " neighbors = [(i-1, j), (i, j-1), (i, j), (i+1, j), (i, j+1)]\n", " mask = in_domain.(neighbors)\n", " append!(rows, idx.(repeat([(i,j)], 5))[mask])\n", " append!(cols, idx.(neighbors)[mask])\n", " append!(vals, stencil[mask])\n", " end\n", " end\n", " sparse(rows, cols, vals)\n", "end" ] }, { "cell_type": "markdown", "id": "29e05a3f", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# Licensing and Copyright" ] }, { "cell_type": "markdown", "id": "87446123", "metadata": { "cell_style": "split" }, "source": [ "* In the US, all creative works are subject to copyright. This includes code.\n", "* At CU, you own copyright for anything you create in coursework or on your own time.\n", "* CU asserts copyright on work you while employed (e.g., as a GRA)\n", " * My group has an exemption letter that applies in some cases.\n", "* **No permissions** are granted by default, even if you post your code publicly on GitHub." ] }, { "cell_type": "markdown", "id": "ffb979d9", "metadata": { "cell_style": "split", "slideshow": { "slide_type": "" } }, "source": [ "
" ] }, { "cell_type": "markdown", "id": "05dcb88e", "metadata": {}, "source": [ "Almost all licenses require these conditions (from BSD-2-Clause)\n", "1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n", "2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution." ] }, { "cell_type": "markdown", "id": "66ef5772", "metadata": { "slideshow": { "slide_type": "slide" } }, "source": [ "# License compatibility" ] }, { "cell_type": "markdown", "id": "fdecb8ef", "metadata": { "cell_style": "split" }, "source": [ "@github copilot, with "public code" blocked, emits large chunks of my copyrighted code, with no attribution, no LGPL license. For example, the simple prompt "sparse matrix transpose, cs_" produces my cs_transpose in CSparse. My code on left, github on right. Not OK. pic.twitter.com/sqpOThi8nf
— Tim Davis (@DocSparse) October 16, 2022