-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from luca-heltai/fix-warnings
Fix warnings
- Loading branch information
Showing
6 changed files
with
145 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"attachments": {}, | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Manufactured solutions for Stokes problem\n", | ||
"\n", | ||
"When solving numerically the stokes problem \n", | ||
"\n", | ||
"$$\n", | ||
"\\begin{aligned}\n", | ||
"-\\Delta \\boldsymbol{u} + \\nabla p & = f \\\\\n", | ||
"\\nabla \\cdot \\boldsymbol{u} &= 0,\n", | ||
"\\end{aligned}\n", | ||
"$$\n", | ||
"\n", | ||
"we can construct manufactured solutions that satisfy the divergence free\n", | ||
"constraint, by taking a solution $\\boldsymbol{u}$ that is the curl of a scalar\n", | ||
"field (in two-dimensions) or the curl of a vector field in three dimensions.\n", | ||
"\n", | ||
"For two dimensions: \n", | ||
"\n", | ||
"$$\n", | ||
"\\begin{split}\n", | ||
"\\boldsymbol{u}_x & = \\partial_y g \\\\\n", | ||
"\\boldsymbol{u}_y & = -\\partial_x g\n", | ||
"\\end{split}\n", | ||
"$$\n", | ||
"\n", | ||
"which satisfy by construction $\\nabla \\cdot \\boldsymbol{u} = 0$ for $g\\in\n", | ||
"C^2(\\Omega)$.\n", | ||
"\n", | ||
"We can then build a forcing term $f$ that would force the system to have this\n", | ||
"exact solution, by using the equality $f = -\\Delta \\boldsymbol{u} + \\nabla p$.\n", | ||
"\n", | ||
"If we want to use these in input files for the `stokes` executable of the\n", | ||
"`fsi-suite`, we must replace the `**` with `^`, and we must write them in a\n", | ||
"format that deal.II understands. This is done in the following cells, where we\n", | ||
"first compute symbolically the differential operators, and then produce an\n", | ||
"output that is readable by deal.II." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from sympy import *\n", | ||
"import textwrap" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"def write_parameters(precursor, p):\n", | ||
" # ux, uy, and p are the exact solution of the velocity and pressure\n", | ||
" ux = diff(precursor, y)\n", | ||
" uy = -diff(precursor, x)\n", | ||
"\n", | ||
" # lap_u_x and lap_u_y are minus the laplacian of ux and uy\n", | ||
" lap_u_x = - diff(ux, x, 2) - diff(ux, y, 2)\n", | ||
" lap_u_y = - diff(uy, x, 2) - diff(uy, y, 2)\n", | ||
"\n", | ||
" # fx and fy are the resulting forcing terms\n", | ||
" fx = lap_u_x + diff(p, x)\n", | ||
" fy = lap_u_y + diff(p, y)\n", | ||
"\n", | ||
" def prm(ux, uy, p, fx, fy):\n", | ||
" def to_prm(x):\n", | ||
" text = str(x).replace('**', '^')\n", | ||
" start_len = len(\" set Forcing term = \")\n", | ||
" return ' \\\\\\n'.join(textwrap.wrap(text, 80-start_len, break_long_words=False, \n", | ||
" subsequent_indent=' '*start_len))\n", | ||
"\n", | ||
" print(\n", | ||
" \"subsection Functions\\n set Exact solution = \", to_prm(ux), \";\",\n", | ||
" to_prm(uy), \";\", to_prm(p), \"\\n\",\n", | ||
" \" set Forcing term = \", to_prm(fx), \";\",\n", | ||
" to_prm(fy), \"; 0\", \"\\nend\\n\"\n", | ||
" )\n", | ||
" \n", | ||
" prm(ux, uy, p, fx, fy)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Spatial variables\n", | ||
"x,y = symbols('x y')\n", | ||
"\n", | ||
"# Precursor of th exact solution. We take the curl of this function to have a \n", | ||
"# divergence free velocity field\n", | ||
"precursor = sin(pi*x)**2*sin(pi*y)**2\n", | ||
"pressure = cos(2*pi*x)*cos(2*pi*y)\n", | ||
"\n", | ||
"write_parameters(precursor, pressure)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.15" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters