-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
750ecac
commit 16b332e
Showing
1 changed file
with
344 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,344 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3aa9653d", | ||
"metadata": {}, | ||
"source": [ | ||
"# Mixed methods in NGSolve" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "44eefa62", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from ngsolve import *\n", | ||
"from ngsolve.webgui import Draw" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "781071c3", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"application/vnd.jupyter.widget-view+json": { | ||
"model_id": "7211179e9b3848d4ac27a4ae95d392de", | ||
"version_major": 2, | ||
"version_minor": 0 | ||
}, | ||
"text/plain": [ | ||
"WebGuiWidget(value={'gui_settings': {}, 'ngsolve_version': '6.2.2402-37-g45ed24bde', 'mesh_dim': 2, 'order2d':…" | ||
] | ||
}, | ||
"metadata": {}, | ||
"output_type": "display_data" | ||
}, | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"BaseWebGuiScene" | ||
] | ||
}, | ||
"execution_count": 2, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
} | ||
], | ||
"source": [ | ||
"mesh = Mesh(unit_square.GenerateMesh(maxh=0.3))\n", | ||
"Draw(mesh)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "a7932da4", | ||
"metadata": {}, | ||
"source": [ | ||
"## Product spaces\n", | ||
"In NGSolve spaces maybe tensorized by using the `*` symbol" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "f4193eee", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"h1 dofs: 61\n", | ||
"l2 dofs: 144\n", | ||
"total dofs: 205 = 205\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"order = 2\n", | ||
"fesh1 = H1(mesh, order = order)\n", | ||
"print(\"h1 dofs: \", fesh1.ndof)\n", | ||
"fesl2 = VectorL2(mesh, order = order-1)\n", | ||
"print(\"l2 dofs: \", fesl2.ndof)\n", | ||
"\n", | ||
"fes = fesh1*fesl2\n", | ||
"print(\"total dofs: \", fes.ndof,\" = \", fesh1.ndof+fesl2.ndof)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "21f78dbb", | ||
"metadata": {}, | ||
"source": [ | ||
"To assemble bilinear forms we need test and trial functions. From product spaces test and trial functions are returned as tuples:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "9ca83c3a", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"(p,v), (q,w) = fes.TnT()\n", | ||
"bfgrad = BilinearForm(grad(p)*w*dx).Assemble()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "40449cbf", | ||
"metadata": {}, | ||
"source": [ | ||
"The matrix is still an operator on the large space!" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "461940c7", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<matplotlib.image.AxesImage at 0x7d8fdbca3af0>" | ||
] | ||
}, | ||
"execution_count": 5, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
}, | ||
{ | ||
"data": { | ||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAQYAAAD8CAY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JRU5ErkJggg==\n", | ||
"text/plain": [ | ||
"<Figure size 432x288 with 1 Axes>" | ||
] | ||
}, | ||
"metadata": { | ||
"needs_background": "light" | ||
}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"import matplotlib.pyplot as pl\n", | ||
"pl.spy(bfgrad.mat.ToDense())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "3380c813", | ||
"metadata": {}, | ||
"source": [ | ||
"Gridfunctions on product spaces consist of components" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 6, | ||
"id": "17f55a9d", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"length of whole vector: 205\n", | ||
"length of first component: 61\n", | ||
"length of second component: 144\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"gfu = GridFunction(fes)\n", | ||
"print(\"length of whole vector: \",len(gfu.vec))\n", | ||
"gfup = gfu.components[0]\n", | ||
"print(\"length of first component: \",len(gfup.vec))\n", | ||
"gfuv = gfu.components[1]\n", | ||
"print(\"length of second component: \",len(gfuv.vec))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "e7e5ba85", | ||
"metadata": {}, | ||
"source": [ | ||
"Restriction and embedding operators are available:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 7, | ||
"id": "c314b8ac", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"(205, 61)\n", | ||
"(205, 144)\n", | ||
"(61, 205)\n", | ||
"(144, 205)\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"emb_p = fes.Embedding(0)\n", | ||
"emb_v = fes.Embedding(1)\n", | ||
"\n", | ||
"print(emb_p.shape)\n", | ||
"print(emb_v.shape)\n", | ||
"\n", | ||
"res_p = fes.Restriction(0)\n", | ||
"res_v = fes.Restriction(1)\n", | ||
"\n", | ||
"print(res_p.shape)\n", | ||
"print(res_v.shape)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "127988c2", | ||
"metadata": {}, | ||
"source": [ | ||
"## Mixed operators\n", | ||
"\n", | ||
"Alternatively one may define mixed operators. Note that in this case the test and trial functions must be obtained from the base spaces." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 27, | ||
"id": "f829c585", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"fesh1 = H1(mesh,order=order)\n", | ||
"feshdiv = HDiv(mesh,order=order)\n", | ||
"\n", | ||
"p_,q_ = fesh1.TnT()\n", | ||
"v_,w_ = feshdiv.TnT()\n", | ||
"\n", | ||
"bfgrad = BilinearForm(grad(p_)*w_*dx).Assemble()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 28, | ||
"id": "82c547e2", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"data": { | ||
"text/plain": [ | ||
"<matplotlib.image.AxesImage at 0x7d8fd31fd3f0>" | ||
] | ||
}, | ||
"execution_count": 28, | ||
"metadata": {}, | ||
"output_type": "execute_result" | ||
}, | ||
{ | ||
"data": { | ||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAHEAAAD8CAYAAABAUEvWAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAAsTAAALEwEAmpwYAAAPsUlEQVR4nO2de+gmVRnHP0+7aqWSmossruIaYhjUurt4IRErKpXIghAjSMLYCIWiP2IXocsfQgVd/8jY0i6QmlnmIktmFvRX6v5yNS9trpfFFXXXyi4G1a5Pf8y8u+P85nrOmXeeOe/5wMvv/c2cOXPe+c55zjnPuYmqkpg2rxk7AQl/kogRkESMgCRiBCQRIyCJGAOqOuoHuBjYBewGNlecvxHYBzxcOHYCcDfweP73eO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FRL9cBJRXr3rzAeBWc11G3CFiBwlImvJthu6r2fclcfbhi+6TG1zHe1dt//FWLiuxn+RiKwj29TkaeATAKr6iIjcCjwKHACuVtWDg6Q8cQjX1fhvaAh/HXCdT6IS/UgemwgwJ+IYq0H5NjfGuLbI5JZAqWLsisXYmMuJif6YE7EpV9VV5328ML6OAh/HeKiiw5yIPiyqWY1KxEXFnIhtHpDQ/YtV5tDXvBaZh3UwJ6Ivi2hSoxNxEUkiRoDJxn6XIf19VvYNde8mymuuzr7PwwMVXU5MZWJikkxSxLFXQqyi3EE8z2WkJyliHYtoSiEyERcVUyLW5aTykmFN57pOVnXNtaFXd5xd44MpERNuJBEjIIkYAaZEbPLCNJVFXXse6vaY6oPvFghD1KBNiTg1rDRpkogRMBkRrXlpfJzbRfMfIjdPRsQ+WDFz8yJKERcNk/2JXalzNlszvVDd3zj735coc2Iyp4nJMWlzWtXwtmhKodrRUDaxrmlPOTECkogRkESMgMmKWPR6hFibZgjKXpm6xepn312ZrIiJwyQRI8CkiG2N9Vl1vMoE+VTVQzqli+kIYTKbMClioh9JxAgw6bFpMztta4K7mtSQZi+NAE/0IokYAUnECJisiE3r2Viiy3BK33RPVsQ6Fq1DGCIUcRERC+ZHRPYDLwMvdrzkxIjDnqmqx3YMm1HsARjzA+xIYfuFnX2SOY2AJGIEWBJxawrbOyxgpGKT8MNSTkw4kkSMgCRiBCQRIyCJGAH/B1ixKyRUn0b2AAAAAElFTkSuQmCC\n", | ||
"text/plain": [ | ||
"<Figure size 432x288 with 1 Axes>" | ||
] | ||
}, | ||
"metadata": { | ||
"needs_background": "light" | ||
}, | ||
"output_type": "display_data" | ||
} | ||
], | ||
"source": [ | ||
"pl.spy(bfgrad.mat.ToDense())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "07678ea5", | ||
"metadata": {}, | ||
"source": [ | ||
"Matrices may also be transposed:" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 29, | ||
"id": "7e840338", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"6.409741197293665e-15\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"n = specialcf.normal(2)\n", | ||
"bfdiv = BilinearForm(-div(v_)*q_*dx+v_.Trace()*n*q_*ds).Assemble()\n", | ||
"print((bfdiv.mat.T.ToDense()-bfgrad.mat.ToDense()).Norm())" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0e334862", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"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.10.12" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |