<commit_before>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Solving incompressible flow with adaptive mixed finite elements in FEniCS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This Jupyter notebook shows how to solve the lid-driven cavity benchmark for incompressible flow by solving the Navier-Stokes equations using mixed finite elements in FEniCS with goal-oriented adaptive mesh refinement (AMR)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "|Nomenclature||\n",
    "|------------|-|\n",
    "|$\\mathbf{x}$| point in the spatial domain|\n",
    "|$\\mathbf{u} = \\mathbf{u}(\\mathbf{x})$| velocity vector field|\n",
    "|$p = p(\\mathbf{x})$| pressure field|\n",
    "|$\\mu$| constant dynamic viscosity of the fluid|\n",
    "|$\\Omega$| spatial domain |\n",
    "|$\\mathbf{w} = \\begin{pmatrix} \\mathbf{u} \\\\ p \\end{pmatrix}$| system solution|\n",
    "|$\\mathbf{W}$| mixed finite element function space |\n",
    "|$\\boldsymbol{\\psi} = \\begin{pmatrix} \\boldsymbol{\\psi}_u \\\\ \\psi_p \\end{pmatrix}$| mixed finite element basis functions|\n",
    "|$\\Omega_h$| discrete spatial domain, i.e. the mesh |\n",
    "|$M$| goal functional |\n",
    "|$\\epsilon_M$| error tolerance for goal-oriented AMR |"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Navier-stokes equations for incompressible flow"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The steady incompressible Navier-Stokes equations can be written as\n",
    "\n",
    "\\begin{align*} \n",
    "    \\left( \\mathbf{u}\\cdot\\nabla \\right)\\mathbf{u} + \\nabla p - 2\\mu \\nabla \\cdot \\mathbf{D}(\\mathbf{u}) &= 0 \\quad \\\\\n",
    "    \\nabla \\cdot \\mathbf{u} &= 0 \\quad  \\\\\n",
    "\\end{align*}\n",
    "\n",
    "where  $\\mathbf{D}(\\mathbf{u}) = \\mathrm{sym}(\\mathbf{u}) = \\frac{1}{2}\\left(\\nabla \\mathbf{u} +  \\left( \\nabla \\mathbf{u} \\right)^{\\mathrm{T}} \\right)$ is the Newtonian fluid's rate of strain tensor. [3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Python packages"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Import the Python packages for use in this notebook."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [<commit_msg>Fix typo in definition of D(u)<commit_after>{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Solving incompressible flow with adaptive mixed finite elements in FEniCS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "This Jupyter notebook shows how to solve the lid-driven cavity benchmark for incompressible flow by solving the Navier-Stokes equations using mixed finite elements in FEniCS with goal-oriented adaptive mesh refinement (AMR)."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "|Nomenclature||\n",
    "|------------|-|\n",
    "|$\\mathbf{x}$| point in the spatial domain|\n",
    "|$\\mathbf{u} = \\mathbf{u}(\\mathbf{x})$| velocity vector field|\n",
    "|$p = p(\\mathbf{x})$| pressure field|\n",
    "|$\\mu$| constant dynamic viscosity of the fluid|\n",
    "|$\\Omega$| spatial domain |\n",
    "|$\\mathbf{w} = \\begin{pmatrix} \\mathbf{u} \\\\ p \\end{pmatrix}$| system solution|\n",
    "|$\\mathbf{W}$| mixed finite element function space |\n",
    "|$\\boldsymbol{\\psi} = \\begin{pmatrix} \\boldsymbol{\\psi}_u \\\\ \\psi_p \\end{pmatrix}$| mixed finite element basis functions|\n",
    "|$\\Omega_h$| discrete spatial domain, i.e. the mesh |\n",
    "|$M$| goal functional |\n",
    "|$\\epsilon_M$| error tolerance for goal-oriented AMR |"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## The Navier-stokes equations for incompressible flow"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The steady incompressible Navier-Stokes equations can be written as\n",
    "\n",
    "\\begin{align*} \n",
    "    \\left( \\mathbf{u}\\cdot\\nabla \\right)\\mathbf{u} + \\nabla p - 2\\mu \\nabla \\cdot \\mathbf{D}(\\mathbf{u}) &= 0 \\quad \\\\\n",
    "    \\nabla \\cdot \\mathbf{u} &= 0 \\quad  \\\\\n",
    "\\end{align*}\n",
    "\n",
    "where  $\\mathbf{D}(\\mathbf{u}) = \\mathrm{sym}(\\nabla\\mathbf{u}) = \\frac{1}{2}\\left(\\nabla \\mathbf{u} +  \\left( \\nabla \\mathbf{u} \\right)^{\\mathrm{T}} \\right)$ is the Newtonian fluid's rate of strain tensor. [3]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Python packages"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Import the Python packages for use in this notebook."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
{'fraction_non_alphanumeric': 0.23273761169780666, 'fraction_numerical': 0.002437043054427295, 'mean_word_length': 2.626656848306333, 'pattern_counts': {'":': 50, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3017176', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1679, 'n_words': 431}