Skip to content

Commit

Permalink
add notebook example mixed
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulSt committed Feb 12, 2022
1 parent 81b2613 commit 3740933
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions doc/notebooks/embTrefftz.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,14 @@
" f.Assemble()"
]
},
{
"cell_type": "markdown",
"id": "4f1de24c",
"metadata": {},
"source": [
"### Trefftz embedding"
]
},
{
"cell_type": "markdown",
"id": "19d5d04a",
Expand Down Expand Up @@ -235,6 +243,61 @@
"error = sqrt(Integrate((tgfu-exact)**2, mesh))\n",
"print(\"embedded Trefftz error \",error)"
]
},
{
"cell_type": "markdown",
"id": "8f34efc5",
"metadata": {},
"source": [
"### Trefftz embedding"
]
},
{
"cell_type": "markdown",
"id": "c02fb15b",
"metadata": {},
"source": [
"We can also construct the embedding by finding the kernel of\n",
"$$\n",
"\\begin{align} \\label{def:matrices}\n",
" (\\bW)_{ij}&=\\inner{\\calL\\phi_j,\\tilde\\phi_i}_{0,h},\\qquad \\forall \\tilde\\phi_i\\in V^{p-2}(\\Th)\n",
"\\end{align}\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "558432aa",
"metadata": {},
"outputs": [],
"source": [
"eps=10**-9\n",
"Lap = lambda u : sum(Trace(u.Operator('hesse')))\n",
"u = fes.TrialFunction()\n",
"fes2 = L2(mesh, order=order-2, dgjumps=True)\n",
"v = fes2.TestFunction()\n",
"op = Lap(u)*v*dx\n",
"with TaskManager():\n",
" PP = TrefftzEmbedding(op,fes,test_fes=fes2)\n",
"PPT = PP.CreateTranspose()\n",
"with TaskManager():\n",
" TA = PPT@a.mat@PP\n",
" TU = TA.Inverse(inverse='sparsecholesky')*(PPT*f.vec)\n",
" tgfu = GridFunction(fes)\n",
" tgfu.vec.data = PP*TU"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c58dd2a5",
"metadata": {},
"outputs": [],
"source": [
"error = sqrt(Integrate((tgfu-exact)**2, mesh))\n",
"print(\"embedded Trefftz error \",error)"
]
}
],
"metadata": {
Expand Down

0 comments on commit 3740933

Please # to comment.