{ "cells": [ { "cell_type": "markdown", "source": [ "# Tutorial 9: Stokes equation" ], "metadata": {} }, { "cell_type": "markdown", "source": [ " This tutorial is under construction, but the code below is already functional.\n", "\n", "Driver that computes the lid-driven cavity benchmark at low Reynolds numbers\n", "when using a mixed FE Q(k)/Pdisc(k-1)." ], "metadata": {} }, { "cell_type": "markdown", "source": [ "Load Gridap library" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "using Gridap" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Discrete model" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "n = 100\n", "domain = (0,1,0,1)\n", "partition = (n,n)\n", "model = CartesianDiscreteModel(domain, partition)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Define Dirichlet boundaries" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "labels = get_face_labeling(model)\n", "add_tag_from_tags!(labels,\"diri1\",[6,])\n", "add_tag_from_tags!(labels,\"diri0\",[1,2,3,4,5,7,8])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Define test FESpaces (Q2/P1(disc) pair)" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "V = TestFESpace(\n", " reffe=:QLagrangian, conformity=:H1, valuetype=VectorValue{2,Float64},\n", " model=model, labels=labels, order=2, dirichlet_tags=[\"diri0\",\"diri1\"])\n", "Q = TestFESpace(\n", " reffe=:PLagrangian, conformity=:L2, valuetype=Float64,\n", " model=model, order=1, constraint=:zeromean)\n", "Y = MultiFieldFESpace([V,Q])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Define trial FESpaces from Dirichlet values" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "u0 = VectorValue(0,0)\n", "u1 = VectorValue(1,0)\n", "U = TrialFESpace(V,[u0,u1])\n", "P = TrialFESpace(Q)\n", "X = MultiFieldFESpace([U,P])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Define integration mesh and quadrature" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "trian = get_triangulation(model); degree = 2\n", "quad = CellQuadrature(trian,degree)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Define and solve the FE problem" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "function a(x,y)\n", " v,q = y\n", " u,p = x\n", " ∇(v)⊙∇(u) - (∇⋅v)*p + q*(∇⋅u)\n", "end\n", "t_Ω = LinearFETerm(a,trian,quad)\n", "op = AffineFEOperator(X,Y,t_Ω)\n", "uh, ph = solve(op)" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "Export results to vtk" ], "metadata": {} }, { "outputs": [], "cell_type": "code", "source": [ "writevtk(trian,\"results\",order=2,cellfields=[\"uh\"=>uh,\"ph\"=>ph])" ], "metadata": {}, "execution_count": null }, { "cell_type": "markdown", "source": [ "---\n", "\n", "*This notebook was generated using [Literate.jl](https://github.com/fredrikekre/Literate.jl).*" ], "metadata": {} } ], "nbformat_minor": 3, "metadata": { "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.3.1" }, "kernelspec": { "name": "julia-1.3", "display_name": "Julia 1.3.1", "language": "julia" } }, "nbformat": 4 }