Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
FEniCS GitHub Actions committed Oct 16, 2023
1 parent c65dfb9 commit 9188230
Show file tree
Hide file tree
Showing 30 changed files with 106 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
# We begin by using {py:func}`create_rectangle
# <dolfinx.mesh.create_rectangle>` to create a rectangular
# {py:class}`Mesh <dolfinx.mesh.Mesh>` of the domain, and creating a
# finite element {py:class}`FunctionSpaceBase <dolfinx.fem.FunctionSpaceBase>`
# finite element {py:class}`FunctionSpace <dolfinx.fem.FunctionSpace>`
# $V$ on the mesh.

msh = mesh.create_rectangle(comm=MPI.COMM_WORLD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def lid_velocity_expression(x):
return np.stack((np.ones(x.shape[1]), np.zeros(x.shape[1])))
# -

# Two {py:class}`function spaces <dolfinx.fem.FunctionSpaceBase>` are
# Two {py:class}`function spaces <dolfinx.fem.FunctionSpace>` are
# defined using different finite elements. `P2` corresponds to a
# continuous piecewise quadratic basis (vector) and `P1` to a continuous
# piecewise linear basis (scalar).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import dolfinx
import ufl
from dolfinx import la
from dolfinx.fem import (Expression, Function, FunctionSpaceBase, dirichletbc,
from dolfinx.fem import (Expression, Function, FunctionSpace, dirichletbc,
form, functionspace, locate_dofs_topological)
from dolfinx.fem.petsc import (apply_lifting, assemble_matrix, assemble_vector,
set_bc)
Expand All @@ -53,7 +53,7 @@
# modes.


def build_nullspace(V: FunctionSpaceBase):
def build_nullspace(V: FunctionSpace):
"""Build PETSc nullspace for 3D elasticity"""

# Create vectors that will span the nullspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
"cells": [
{
"cell_type": "markdown",
"id": "ce68694f",
"id": "374302b8",
"metadata": {},
"source": [
"# Mixed formulation for the Poisson equation"
]
},
{
"cell_type": "markdown",
"id": "a0015332",
"id": "d50ade29",
"metadata": {},
"source": [
"This demo illustrates how to solve Poisson equation using a mixed\n",
Expand Down Expand Up @@ -89,7 +89,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cad6b09f",
"id": "123f3b00",
"metadata": {},
"outputs": [],
"source": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# This demo is implemented in {download}`demo_poisson.py`. It
# illustrates how to:
#
# - Create a {py:class}`function space <dolfinx.fem.FunctionSpaceBase>`
# - Create a {py:class}`function space <dolfinx.fem.FunctionSpace>`
# - Solve a linear partial differential equation
#
# ## Equation and problem definition
Expand Down Expand Up @@ -76,7 +76,7 @@
# We create a rectangular {py:class}`Mesh <dolfinx.mesh.Mesh>` using
# {py:func}`create_rectangle <dolfinx.mesh.create_rectangle>`, and
# create a finite element {py:class}`function space
# <dolfinx.fem.FunctionSpaceBase>` $V$ on the mesh.
# <dolfinx.fem.FunctionSpace>` $V$ on the mesh.

# +
msh = mesh.create_rectangle(comm=MPI.COMM_WORLD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

# A unit square mesh with 96 cells edges in each direction is created,
# and on this mesh a
# {py:class}`FunctionSpaceBase <dolfinx.fem.FunctionSpaceBase>` `ME` is built
# {py:class}`FunctionSpace <dolfinx.fem.FunctionSpace>` `ME` is built
# using a pair of linear Lagrange elements.

msh = create_unit_square(MPI.COMM_WORLD, 96, 96, CellType.triangle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ def create_tnt_quad(degree):
# the solution.


def poisson_error(V: fem.FunctionSpaceBase):
def poisson_error(V: fem.FunctionSpace):
msh = V.mesh
u, v = TrialFunction(V), TestFunction(V)

Expand Down
6 changes: 2 additions & 4 deletions dolfinx/main/python/_modules/dolfinx/fem.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ <h1>Source code for dolfinx.fem</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">dolfinx.fem.dofmap</span> <span class="kn">import</span> <span class="n">DofMap</span>
<span class="kn">from</span> <span class="nn">dolfinx.fem.forms</span> <span class="kn">import</span> <span class="n">Form</span><span class="p">,</span> <span class="n">extract_function_spaces</span><span class="p">,</span> <span class="n">form</span>
<span class="kn">from</span> <span class="nn">dolfinx.fem.function</span> <span class="kn">import</span> <span class="p">(</span><span class="n">Constant</span><span class="p">,</span> <span class="n">ElementMetaData</span><span class="p">,</span> <span class="n">Expression</span><span class="p">,</span>
<span class="n">Function</span><span class="p">,</span> <span class="n">FunctionSpace</span><span class="p">,</span> <span class="n">FunctionSpaceBase</span><span class="p">,</span>
<span class="n">VectorFunctionSpace</span><span class="p">,</span> <span class="n">functionspace</span><span class="p">)</span>
<span class="n">Function</span><span class="p">,</span> <span class="n">FunctionSpace</span><span class="p">,</span> <span class="n">functionspace</span><span class="p">)</span>


<div class="viewcode-block" id="create_sparsity_pattern"><a class="viewcode-back" href="../../generated/dolfinx.fem.html#dolfinx.fem.create_sparsity_pattern">[docs]</a><span class="k">def</span> <span class="nf">create_sparsity_pattern</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="n">Form</span><span class="p">):</span>
Expand All @@ -117,8 +116,7 @@ <h1>Source code for dolfinx.fem</h1><div class="highlight"><pre>

<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
<span class="s2">&quot;Constant&quot;</span><span class="p">,</span> <span class="s2">&quot;Expression&quot;</span><span class="p">,</span> <span class="s2">&quot;Function&quot;</span><span class="p">,</span> <span class="s2">&quot;ElementMetaData&quot;</span><span class="p">,</span> <span class="s2">&quot;create_matrix&quot;</span><span class="p">,</span>
<span class="s2">&quot;functionspace&quot;</span><span class="p">,</span> <span class="s2">&quot;FunctionSpace&quot;</span><span class="p">,</span> <span class="s2">&quot;FunctionSpaceBase&quot;</span><span class="p">,</span> <span class="s2">&quot;VectorFunctionSpace&quot;</span><span class="p">,</span>
<span class="s2">&quot;create_sparsity_pattern&quot;</span><span class="p">,</span>
<span class="s2">&quot;functionspace&quot;</span><span class="p">,</span> <span class="s2">&quot;FunctionSpace&quot;</span><span class="p">,</span> <span class="s2">&quot;create_sparsity_pattern&quot;</span><span class="p">,</span>
<span class="s2">&quot;assemble_scalar&quot;</span><span class="p">,</span> <span class="s2">&quot;assemble_matrix&quot;</span><span class="p">,</span> <span class="s2">&quot;assemble_vector&quot;</span><span class="p">,</span> <span class="s2">&quot;apply_lifting&quot;</span><span class="p">,</span> <span class="s2">&quot;set_bc&quot;</span><span class="p">,</span>
<span class="s2">&quot;DirichletBC&quot;</span><span class="p">,</span> <span class="s2">&quot;dirichletbc&quot;</span><span class="p">,</span> <span class="s2">&quot;bcs_by_block&quot;</span><span class="p">,</span> <span class="s2">&quot;DofMap&quot;</span><span class="p">,</span> <span class="s2">&quot;Form&quot;</span><span class="p">,</span>
<span class="s2">&quot;form&quot;</span><span class="p">,</span> <span class="s2">&quot;IntegralType&quot;</span><span class="p">,</span> <span class="s2">&quot;create_vector&quot;</span><span class="p">,</span>
Expand Down
14 changes: 7 additions & 7 deletions dolfinx/main/python/_modules/dolfinx/fem/bcs.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ <h1>Source code for dolfinx.fem.bcs</h1><div class="highlight"><pre>
<span class="kn">from</span> <span class="nn">dolfinx</span> <span class="kn">import</span> <span class="n">cpp</span> <span class="k">as</span> <span class="n">_cpp</span>


<div class="viewcode-block" id="locate_dofs_geometrical"><a class="viewcode-back" href="../../../generated/dolfinx.fem.html#dolfinx.fem.locate_dofs_geometrical">[docs]</a><span class="k">def</span> <span class="nf">locate_dofs_geometrical</span><span class="p">(</span><span class="n">V</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">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpaceBase</span><span class="p">,</span>
<span class="n">typing</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpaceBase</span><span class="p">]],</span>
<div class="viewcode-block" id="locate_dofs_geometrical"><a class="viewcode-back" href="../../../generated/dolfinx.fem.html#dolfinx.fem.locate_dofs_geometrical">[docs]</a><span class="k">def</span> <span class="nf">locate_dofs_geometrical</span><span class="p">(</span><span class="n">V</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">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpace</span><span class="p">,</span>
<span class="n">typing</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpace</span><span class="p">]],</span>
<span class="n">marker</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Callable</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Locate degrees-of-freedom geometrically using a marker function.</span>

Expand Down Expand Up @@ -132,8 +132,8 @@ <h1>Source code for dolfinx.fem.bcs</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">_cpp</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">locate_dofs_geometrical</span><span class="p">(</span><span class="n">_V</span><span class="p">,</span> <span class="n">marker</span><span class="p">)</span></div>


<div class="viewcode-block" id="locate_dofs_topological"><a class="viewcode-back" href="../../../generated/dolfinx.fem.html#dolfinx.fem.locate_dofs_topological">[docs]</a><span class="k">def</span> <span class="nf">locate_dofs_topological</span><span class="p">(</span><span class="n">V</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">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpaceBase</span><span class="p">,</span>
<span class="n">typing</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpaceBase</span><span class="p">]],</span>
<div class="viewcode-block" id="locate_dofs_topological"><a class="viewcode-back" href="../../../generated/dolfinx.fem.html#dolfinx.fem.locate_dofs_topological">[docs]</a><span class="k">def</span> <span class="nf">locate_dofs_topological</span><span class="p">(</span><span class="n">V</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">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpace</span><span class="p">,</span>
<span class="n">typing</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpace</span><span class="p">]],</span>
<span class="n">entity_dim</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">entities</span><span class="p">:</span> <span class="n">numpy</span><span class="o">.</span><span class="n">typing</span><span class="o">.</span><span class="n">NDArray</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">],</span>
<span class="n">remote</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">True</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Locate degrees-of-freedom belonging to mesh entities topologically.</span>
Expand Down Expand Up @@ -194,14 +194,14 @@ <h1>Source code for dolfinx.fem.bcs</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cpp_object</span><span class="o">.</span><span class="n">value</span>

<span class="nd">@property</span>
<span class="k">def</span> <span class="nf">function_space</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpaceBase</span><span class="p">:</span>
<span class="k">def</span> <span class="nf">function_space</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpace</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;The function space on which the boundary condition is defined&quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cpp_object</span><span class="o">.</span><span class="n">function_space</span></div>


<div class="viewcode-block" id="dirichletbc"><a class="viewcode-back" href="../../../generated/dolfinx.fem.html#dolfinx.fem.dirichletbc">[docs]</a><span class="k">def</span> <span class="nf">dirichletbc</span><span class="p">(</span><span class="n">value</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">Function</span><span class="p">,</span> <span class="n">Constant</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">],</span>
<span class="n">dofs</span><span class="p">:</span> <span class="n">numpy</span><span class="o">.</span><span class="n">typing</span><span class="o">.</span><span class="n">NDArray</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">],</span>
<span class="n">V</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="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpaceBase</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">DirichletBC</span><span class="p">:</span>
<span class="n">V</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="n">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpace</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">DirichletBC</span><span class="p">:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Create a representation of Dirichlet boundary condition which</span>
<span class="sd"> is imposed on a linear system.</span>

Expand Down Expand Up @@ -259,7 +259,7 @@ <h1>Source code for dolfinx.fem.bcs</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">DirichletBC</span><span class="p">(</span><span class="n">bc</span><span class="p">)</span></div>


<div class="viewcode-block" id="bcs_by_block"><a class="viewcode-back" href="../../../generated/dolfinx.fem.html#dolfinx.fem.bcs_by_block">[docs]</a><span class="k">def</span> <span class="nf">bcs_by_block</span><span class="p">(</span><span class="n">spaces</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Iterable</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">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpaceBase</span><span class="p">,</span> <span class="kc">None</span><span class="p">]],</span>
<div class="viewcode-block" id="bcs_by_block"><a class="viewcode-back" href="../../../generated/dolfinx.fem.html#dolfinx.fem.bcs_by_block">[docs]</a><span class="k">def</span> <span class="nf">bcs_by_block</span><span class="p">(</span><span class="n">spaces</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Iterable</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">dolfinx</span><span class="o">.</span><span class="n">fem</span><span class="o">.</span><span class="n">FunctionSpace</span><span class="p">,</span> <span class="kc">None</span><span class="p">]],</span>
<span class="n">bcs</span><span class="p">:</span> <span class="n">typing</span><span class="o">.</span><span class="n">Iterable</span><span class="p">[</span><span class="n">DirichletBC</span><span class="p">])</span> <span class="o">-&gt;</span> <span class="n">typing</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">typing</span><span class="o">.</span><span class="n">List</span><span class="p">[</span><span class="n">DirichletBC</span><span class="p">]]:</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Arrange Dirichlet boundary conditions by the function space that</span>
<span class="sd"> they constrain.</span>
Expand Down
Loading

0 comments on commit 9188230

Please sign in to comment.