Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FEniCS GitHub Actions committed Nov 22, 2024
1 parent d3c9125 commit a5b960d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 54 deletions.
4 changes: 2 additions & 2 deletions dolfinx/main/cpp/demos/demo_biharmonic.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ <h3>Weak formulation<a class="headerlink" href="#weak-formulation" title="Link t
\forall \ K \in \mathcal{T} \right\}
\]</div>
<p>and considering the boundary conditions</p>
<div class="amsmath math notranslate nohighlight" id="equation-fc7f4505-b7af-407b-8eb4-e943c955e11d">
<span class="eqno">(1)<a class="headerlink" href="#equation-fc7f4505-b7af-407b-8eb4-e943c955e11d" title="Permalink to this equation"></a></span>\[\begin{align}
<div class="amsmath math notranslate nohighlight" id="equation-6ee20623-18e1-4ca2-adcb-daeb1b8d0195">
<span class="eqno">(1)<a class="headerlink" href="#equation-6ee20623-18e1-4ca2-adcb-daeb1b8d0195" title="Permalink to this equation"></a></span>\[\begin{align}
u &amp;= 0 \quad {\rm on} \ \partial\Omega, \\
\nabla^{2} u &amp;= 0 \quad {\rm on} \ \partial\Omega,
\end{align}\]</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "0e64ffcc",
"id": "26c0da24",
"metadata": {},
"source": [
"# Matrix-free conjugate gradient solver for the Poisson equation\n",
Expand Down Expand Up @@ -72,7 +72,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "96b9ec5c",
"id": "295562af",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -82,7 +82,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "ec3b4ecd",
"id": "fca403c1",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -92,7 +92,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d1c0a0bc",
"id": "cec5fb84",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -104,7 +104,7 @@
},
{
"cell_type": "markdown",
"id": "e30032e1",
"id": "e5c432c5",
"metadata": {},
"source": [
"We begin by using {py:func}`create_rectangle\n",
Expand All @@ -117,7 +117,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "0c64678f",
"id": "5dda917f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -130,7 +130,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c8f585df",
"id": "812a9730",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -141,7 +141,7 @@
},
{
"cell_type": "markdown",
"id": "3b936590",
"id": "81395806",
"metadata": {},
"source": [
"The second argument to {py:class}`functionspace\n",
Expand All @@ -160,7 +160,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "30926970",
"id": "b190ad9e",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -171,7 +171,7 @@
},
{
"cell_type": "markdown",
"id": "d098590f",
"id": "2e566c01",
"metadata": {},
"source": [
"We now find the degrees of freedom that are associated with the boundary\n",
Expand All @@ -182,7 +182,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f1fb85d3",
"id": "6846619f",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -191,7 +191,7 @@
},
{
"cell_type": "markdown",
"id": "26ccaae9",
"id": "3dabae92",
"metadata": {},
"source": [
"and use {py:func}`dirichletbc <dolfinx.fem.dirichletbc>` to define the\n",
Expand All @@ -204,7 +204,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c78b56a7",
"id": "2c43d1fc",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -215,7 +215,7 @@
},
{
"cell_type": "markdown",
"id": "f730fbb8",
"id": "a9f125a8",
"metadata": {},
"source": [
"Next, we express the variational problem using UFL."
Expand All @@ -224,7 +224,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4217b2c5",
"id": "9cf64ec3",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -239,7 +239,7 @@
},
{
"cell_type": "markdown",
"id": "891a4cb9",
"id": "ec562ac9",
"metadata": {},
"source": [
"For the matrix-free solvers we also define a second linear form `M` as\n",
Expand All @@ -255,7 +255,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "8f547343",
"id": "b2543728",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -266,7 +266,7 @@
},
{
"cell_type": "markdown",
"id": "7f090374",
"id": "a282a560",
"metadata": {},
"source": [
"### Matrix-free conjugate gradient solver\n",
Expand All @@ -280,7 +280,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6f434761",
"id": "ae214234",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -295,7 +295,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3696de03",
"id": "d495e6ab",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -306,7 +306,7 @@
},
{
"cell_type": "markdown",
"id": "2b2ed21b",
"id": "86736618",
"metadata": {
"lines_to_next_cell": 2
},
Expand All @@ -318,7 +318,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7aeeb477",
"id": "37df6cac",
"metadata": {
"lines_to_next_cell": 2
},
Expand All @@ -341,7 +341,7 @@
},
{
"cell_type": "markdown",
"id": "6c34d791",
"id": "762c2b3e",
"metadata": {
"lines_to_next_cell": 2
},
Expand All @@ -357,7 +357,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "7601c9aa",
"id": "16f3ab3a",
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -403,7 +403,7 @@
},
{
"cell_type": "markdown",
"id": "05b7f4fc",
"id": "fb304422",
"metadata": {},
"source": [
"This matrix-free solver is now used to compute the finite element solution.\n",
Expand All @@ -414,7 +414,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "83295580",
"id": "aa6a0723",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -426,7 +426,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "97e0e829",
"id": "9d4c09b8",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -437,7 +437,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9e812a2c",
"id": "bb9ab3d8",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -449,7 +449,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "575eb6d9",
"id": "4435c4bc",
"metadata": {},
"outputs": [],
"source": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"cells": [
{
"cell_type": "markdown",
"id": "20ed2e1e",
"id": "b8cfd165",
"metadata": {},
"source": [
"# Mixed formulation for the Poisson equation"
]
},
{
"cell_type": "markdown",
"id": "1367ec53",
"id": "1604cbcb",
"metadata": {},
"source": [
"This demo illustrates how to solve Poisson equation using a mixed\n",
Expand All @@ -22,7 +22,7 @@
},
{
"cell_type": "markdown",
"id": "677039b7",
"id": "6be8d024",
"metadata": {},
"source": [
"```{admonition} Download sources\n",
Expand Down Expand Up @@ -103,7 +103,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f9b6eaa5",
"id": "670378d2",
"metadata": {},
"outputs": [],
"source": [
Expand Down
15 changes: 1 addition & 14 deletions dolfinx/main/python/_modules/dolfinx/fem/function.html
Original file line number Diff line number Diff line change
Expand Up @@ -697,8 +697,6 @@ <h1>Source code for dolfinx.fem.function</h1><div class="highlight"><pre>
<span class="k">else</span><span class="p">:</span>
<span class="n">basix_e</span> <span class="o">=</span> <span class="n">ufl_e</span><span class="o">.</span><span class="n">basix_element</span><span class="o">.</span><span class="n">_e</span>
<span class="n">bs</span> <span class="o">=</span> <span class="n">ufl_e</span><span class="o">.</span><span class="n">reference_value_shape</span> <span class="k">if</span> <span class="n">ufl_e</span><span class="o">.</span><span class="n">block_size</span> <span class="o">&gt;</span> <span class="mi">1</span> <span class="k">else</span> <span class="kc">None</span>
<span class="c1"># bs = [ufl_e.block_size] if ufl_e.block_size &gt; 1 else None</span>
<span class="c1"># print(bs, ufl_e.reference_value_shape)</span>
<span class="k">return</span> <span class="n">CppElement</span><span class="p">(</span><span class="n">basix_e</span><span class="p">,</span> <span class="n">bs</span><span class="p">,</span> <span class="n">ufl_e</span><span class="o">.</span><span class="n">is_symmetric</span><span class="p">)</span>


Expand All @@ -707,16 +705,12 @@ <h1>Source code for dolfinx.fem.function</h1><div class="highlight"><pre>
<span class="k">def</span> <span class="nf">functionspace</span><span class="p">(</span>
<span class="n">mesh</span><span class="p">:</span> <span class="n">Mesh</span><span class="p">,</span>
<span class="n">element</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Union</span><span class="p">[</span><span class="n">ufl</span><span class="o">.</span><span class="n">FiniteElementBase</span><span class="p">,</span> <span class="n">ElementMetaData</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="nb">int</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">,</span> <span class="nb">bool</span><span class="p">]],</span>
<span class="n">form_compiler_options</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">typing</span><span class="o">.</span><span class="n">Any</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="n">jit_options</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Optional</span><span class="p">[</span><span class="nb">dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">typing</span><span class="o">.</span><span class="n">Any</span><span class="p">]]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
<span class="p">)</span> <span class="o">-&gt;</span> <span class="n">FunctionSpace</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Create a finite element function space.</span>

<span class="sd"> Args:</span>
<span class="sd"> mesh: Mesh that space is defined on.</span>
<span class="sd"> element: Finite element description.</span>
<span class="sd"> form_compiler_options: Options passed to the form compiler.</span>
<span class="sd"> jit_options: Options controlling just-in-time compilation.</span>

<span class="sd"> Returns:</span>
<span class="sd"> A function space.</span>
Expand All @@ -735,14 +729,7 @@ <h1>Source code for dolfinx.fem.function</h1><div class="highlight"><pre>
<span class="k">if</span> <span class="n">ufl_e</span><span class="o">.</span><span class="n">cell</span> <span class="o">!=</span> <span class="n">mesh</span><span class="o">.</span><span class="n">ufl_domain</span><span class="p">()</span><span class="o">.</span><span class="n">ufl_cell</span><span class="p">():</span>
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Non-matching UFL cell and mesh cell shapes.&quot;</span><span class="p">)</span>

<span class="c1"># ufl_space = ufl.FunctionSpace(mesh.ufl_domain(), ufl_e)</span>
<span class="c1"># value_shape = ufl_space.value_shape</span>

<span class="c1"># Compile dofmap and element and create DOLFINx objects</span>
<span class="k">if</span> <span class="n">form_compiler_options</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="n">form_compiler_options</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">()</span>
<span class="n">form_compiler_options</span><span class="p">[</span><span class="s2">&quot;scalar_type&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">dtype</span>

<span class="c1"># Create DOLFINx objects</span>
<span class="n">cpp_element</span> <span class="o">=</span> <span class="n">_create_dolfinx_element</span><span class="p">(</span><span class="n">mesh</span><span class="o">.</span><span class="n">topology</span><span class="o">.</span><span class="n">cell_type</span><span class="p">,</span> <span class="n">ufl_e</span><span class="p">,</span> <span class="n">dtype</span><span class="p">)</span>
<span class="n">cpp_dofmap</span> <span class="o">=</span> <span class="n">_cpp</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">create_dofmap</span><span class="p">(</span><span class="n">mesh</span><span class="o">.</span><span class="n">comm</span><span class="p">,</span> <span class="n">mesh</span><span class="o">.</span><span class="n">topology</span><span class="o">.</span><span class="n">_cpp_object</span><span class="p">,</span> <span class="n">cpp_element</span><span class="p">)</span>

Expand Down
Loading

0 comments on commit a5b960d

Please sign in to comment.