Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions demos/adaptive_multigrid/adaptive_multigrid.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ With these helper functions complete, we can solve the system iteratively. In th

theta = 0.5
refinements = 15

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
refinements = 3

est_errors = []
sqrt_dofs = []
mg_iterations = []
Expand Down
6 changes: 6 additions & 0 deletions demos/benney_luke/benney_luke.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ Now we move on to defining parameters::
mu = 0.01
epsilon = 0.01

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
T = 0.025
Nx = 20

m = UnitIntervalMesh(Nx)
mesh = ExtrudedMesh(m, layers=Ny)
coords = mesh.coordinates
Expand Down
25 changes: 22 additions & 3 deletions demos/fast_diagonalisation/fast_diagonalisation_poisson.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ extruded hexahedral meshes, so we must create an :func:`~.ExtrudedMesh`. ::

from firedrake import *

base = UnitSquareMesh(8, 8, quadrilateral=True)
mesh = ExtrudedMesh(base, 8)
# Setup for faster test execution.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is polluting the demo.

  1. Can we just do it one place? Can there be only one branch (no else statement, just set the demo parameters before the if statment).
  2. Can we hide it so it does not appear in the html?

import os
if os.getenv("FIREDRAKE_CI") == "1":
base = UnitSquareMesh(4, 4, quadrilateral=True)
mesh = ExtrudedMesh(base, 4)
else:
base = UnitSquareMesh(8, 8, quadrilateral=True)
mesh = ExtrudedMesh(base, 8)


Defining the problem: the Poisson equation
Expand Down Expand Up @@ -88,7 +94,12 @@ using a sparse direct LU factorization. ::
}

fdm_lu_params = fdm_params(lu_params)
its = run_solve(5, fdm_lu_params)

if os.getenv("FIREDRAKE_CI") == "1":
its = run_solve(3, fdm_lu_params)
else:
its = run_solve(5, fdm_lu_params)

print(f"LU iterations {its}")


Expand Down Expand Up @@ -123,6 +134,10 @@ implemented via :class:`~.ASMExtrudedStarPC` as we have an extruded mesh::
print("FDM + ASM")
print("Degree\tIterations")
for degree in range(3, 6):

if os.getenv("FIREDRAKE_CI") == "1" and degree > 3:
break

its = run_solve(degree, fdm_asm_params)
print(f"{degree}\t{its}")

Expand Down Expand Up @@ -177,6 +192,10 @@ block, and the two-level additive Schwarz method on the facets. ::
print('FDM + SC + ASM')
print("Degree\tIterations")
for degree in range(3, 6):

if os.getenv("FIREDRAKE_CI") == "1" and degree > 3:
break

its = run_solve(degree, fdm_sc_asm_params)
print(f"{degree}\t{its}")

Expand Down
6 changes: 6 additions & 0 deletions demos/ma-demo/ma-demo.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ mesh of quadrilaterals. ::

from firedrake import *
n = 100

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
n = 20

mesh = UnitSquareMesh(n, n, quadrilateral=True)

We construct the quadratic function space for :math:`u`, ::
Expand Down
5 changes: 5 additions & 0 deletions demos/matrix_free/rayleigh-benard.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ temperature. ::

N = 128

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
N = 16

M = UnitSquareMesh(N, N)

V = VectorFunctionSpace(M, "CG", 2)
Expand Down
26 changes: 24 additions & 2 deletions demos/netgen/netgen_mesh.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,19 @@ Now using the two of the predefined CSG geometries included in Netgen, a rectang
geo.SetMaterial(2, "inner")
geo.SetDomainMaxH(2, 0.02)

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
geo.SetDomainMaxH(2, 0.1)

Notice that the ``leftdomain`` and ``rightdomain`` attribute in the ``AddRectangle`` and ``AddCircle`` methods are used to set a domain index for the domain on the left and right side respectively of the rectangle and circle perimeter. It is worth mentioning that the perimeters are parametrised in a counterclockwise direction.
We can now construct a mesh for the geometry we have defined and save it to a PVD file for visualisation. We will do so using the ``GenerateMesh`` method inside of the ``SplineGeometry`` class: ::

ngmsh = geo.GenerateMesh(maxh=0.1)
if os.getenv("FIREDRAKE_CI") == "1":
ngmsh = geo.GenerateMesh(maxh=0.3)
else:
ngmsh = geo.GenerateMesh(maxh=0.1)

# Generating a Firedrake mesh from the NetGen mesh
msh = Mesh(ngmsh)
VTKFile("output/MeshExample1.pvd").write(msh)
Expand Down Expand Up @@ -141,6 +150,10 @@ We begin by defining some quantities of interest such as the desired tolerance,

tolerance = 1e-16
max_iterations = 10

if os.getenv("FIREDRAKE_CI") == "1":
max_iterations = 3

exact = 3.375610652693620492628**2

We create a function to solve the eigenvalue problem using SLEPc. We begin initialising the ``FunctionSpace``, the bilinear forms and linear functionals needed in the variational problem.
Expand Down Expand Up @@ -256,7 +269,12 @@ The `+,-,*` operators have respectively the meaning of union, set difference, an
sphere = Sphere(Pnt(0.6, 0.6, 0.6), 0.5)
geo = CSGeometry()
geo.Add(cube-sphere)
ngmsh = geo.GenerateMesh(maxh=0.1)

if os.getenv("FIREDRAKE_CI") == "1":
ngmsh = geo.GenerateMesh(maxh=0.3)
else:
ngmsh = geo.GenerateMesh(maxh=0.1)

msh = Mesh(ngmsh)
VTKFile("output/MeshExample3.pvd").write(msh)

Expand Down Expand Up @@ -399,6 +417,10 @@ It is also possible to construct high-order meshes using the ``SplineGeometry``,
if COMM_WORLD.rank == 0:
geo = CSG2d()
circle = Circle(center=(1,1), radius=0.1, bc="curve").Maxh(0.01)

if os.getenv("FIREDRAKE_CI") == "1":
circle = Circle(center=(1,1), radius=0.1, bc="curve").Maxh(0.05)

rect = Rectangle(pmin=(0,1), pmax=(1,2),
bottom="b", left="l", top="t", right="r")
geo.Add(rect-circle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ We define a function to adapt the mesh by refining elements with large error ind
Finally, we run the adaptive loop until the upper and lower bounds agree to within a tolerance. ::

max_iterations = 20

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
max_iterations = 2

error_estimators = []
dofs = []
err = 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,16 @@ which is necessary for vertex-star relaxation in parallel. ::
print = PETSc.Sys.Print

distribution_parameters = {"overlap_type": (DistributedMeshOverlapType.VERTEX, 1)}
num_refinements = 2
base = UnitSquareMesh(16, 16, distribution_parameters=distribution_parameters)
mh = MeshHierarchy(base, num_refinements)

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
base = UnitSquareMesh(8, 8, distribution_parameters=distribution_parameters)
mh = MeshHierarchy(base, 1)
else:
base = UnitSquareMesh(16, 16, distribution_parameters=distribution_parameters)
mh = MeshHierarchy(base, 2)

mesh = mh[-1]
n = FacetNormal(mesh)
(x, y) = SpatialCoordinate(mesh)
Expand Down Expand Up @@ -396,7 +403,11 @@ precision. ::
problem = NonlinearVariationalProblem(F, w, bcs, Jp=Jp)
solver = NonlinearVariationalSolver(problem, solver_parameters=sp, pre_apply_bcs=False)

for Re_ in [1, 500] + list(range(1000, 5001, 1000)):
for Re_ in [1, 500] + list(range(1000, 5001, 1000)):

if os.getenv("FIREDRAKE_CI") == "1" and Re_ > 500:
break

Re.assign(Re_)

# Solve
Expand Down
26 changes: 26 additions & 0 deletions demos/saddle_point_pc/saddle_point_systems.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,12 @@ solving it ::

print("Naive preconditioning")
for n in range(8):

# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1" and n == 3:
break

solver, w = build_problem(n, parameters, block_matrix=False)
solver.solve()

Expand Down Expand Up @@ -280,6 +286,10 @@ applying the action of blocks, so we can use a block matrix format. ::

print("Exact full Schur complement")
for n in range(8):

if os.getenv("FIREDRAKE_CI") == "1" and n == 3:
break

solver, w = build_problem(n, parameters, block_matrix=True)
solver.solve()
print(w.function_space().mesh().unique().num_cells(), solver.snes.ksp.getIterationNumber())
Expand Down Expand Up @@ -365,6 +375,10 @@ Let's see what happens. ::

print("Schur complement with S_p")
for n in range(8):

if os.getenv("FIREDRAKE_CI") == "1" and n == 3:
break

solver, w = build_problem(n, parameters, block_matrix=True)
solver.solve()
print(w.function_space().mesh().unique().num_cells(), solver.snes.ksp.getIterationNumber())
Expand Down Expand Up @@ -420,6 +434,10 @@ and so we no longer need a flexible Krylov method. ::

print("Schur complement with S_p and inexact inner inverses")
for n in range(8):

if os.getenv("FIREDRAKE_CI") == "1" and n == 3:
break

solver, w = build_problem(n, parameters, block_matrix=True)
solver.solve()
print(w.function_space().mesh().unique().num_cells(), solver.snes.ksp.getIterationNumber())
Expand Down Expand Up @@ -485,6 +503,10 @@ variable. We can provide it as an :class:`~.AuxiliaryOperatorPC` via a python pr

print("DG approximation for S_p")
for n in range(8):

if os.getenv("FIREDRAKE_CI") == "1" and n == 3:
break

solver, w = build_problem(n, parameters, aP=None, block_matrix=False)
solver.solve()
print(w.function_space().mesh().unique().num_cells(), solver.snes.ksp.getIterationNumber())
Expand Down Expand Up @@ -569,6 +591,10 @@ Let's see what the iteration count looks like now. ::

print("Riesz-map preconditioner")
for n in range(8):

if os.getenv("FIREDRAKE_CI") == "1" and n == 3:
break

solver, w = build_problem(n, parameters, aP=riesz, block_matrix=True)
solver.solve()
print(w.function_space().mesh().unique().num_cells(), solver.snes.ksp.getIterationNumber())
Expand Down
20 changes: 15 additions & 5 deletions demos/vlasov_poisson_1d/vp1d.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,21 @@ We then use this to build a solver. ::
We are getting close to the time loop. We set up some timestepping
parameters. ::

T = 50.0 # maximum timestep

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not accurate. The comment should say T = final time

t = 0. # model time
ndump = 100 # frequency of file dumps
dumpn = 0 # dump counter
nsteps = 5000
import os

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's surprising that one of our slowest demos is 1D.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's 2D (extruded) with a lot of timesteps.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5,000 timesteps of a three-stage RK method with two solves in each stage will do that

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. The splitting method has quite a small stability limit on the timestep.

if os.getenv("FIREDRAKE_CI") == "1":
# Setup for a faster test execution.
T = 0.5 # maximum timestep
t = 0. # model time
ndump = 50 # frequency of file dumps
dumpn = 0 # dump counter
nsteps = 50
else:
T = 50.0 # maximum timestep
t = 0. # model time
ndump = 100 # frequency of file dumps
dumpn = 0 # dump counter
nsteps = 5000

dt = T/nsteps
dtc.assign(dt)

Expand Down
17 changes: 14 additions & 3 deletions docs/notebooks/07-geometric-multigrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@
# %%
from firedrake import *

coarse_mesh = RectangleMesh(15, 10, 1.5, 1)
# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
coarse_mesh = RectangleMesh(5, 4, 1.5, 1)
else:
coarse_mesh = RectangleMesh(15, 10, 1.5, 1)

# %% [markdown]
# Having made the coarse mesh, we create the hierarchy of meshes. The second argument tells Firedrake how many levels of refinement to use. Here we refine three times, so that in total we have four meshes.
Expand Down Expand Up @@ -116,7 +121,10 @@

# %%
def create_solver(parameters=None):
coarse_mesh = RectangleMesh(15, 10, 1.5, 1)
if os.getenv("FIREDRAKE_CI") == "1":
coarse_mesh = RectangleMesh(5, 4, 1.5, 1)
else:
coarse_mesh = RectangleMesh(15, 10, 1.5, 1)
hierarchy = MeshHierarchy(coarse_mesh, 3)

mesh = hierarchy[-1]
Expand Down Expand Up @@ -277,7 +285,10 @@ def form(self, pc, test, trial):

# %%
def create_solver(parameters=None):
coarse_mesh = RectangleMesh(15, 10, 1.5, 1)
if os.getenv("FIREDRAKE_CI") == "1":
coarse_mesh = RectangleMesh(5, 4, 1.5, 1)
else:
coarse_mesh = RectangleMesh(15, 10, 1.5, 1)
hierarchy = MeshHierarchy(coarse_mesh, 3)

mesh = hierarchy[-1]
Expand Down
7 changes: 6 additions & 1 deletion docs/notebooks/09-hybridisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,12 @@
# So now we need to specify the number of refinements (say 4). Let's also set the mesh `degree` to be cubic. With this choice of coordinate space, we can better resolve the actual curvature of the sphere using bendy quadrilateral elements:

# %%
mesh = CubedSphereMesh(radius=R0, refinement_level=4, degree=3)
# Use a coarser mesh when running CI tests.
import os
if os.getenv("FIREDRAKE_CI") == "1":
mesh = CubedSphereMesh(radius=R0, refinement_level=2, degree=3)
else:
mesh = CubedSphereMesh(radius=R0, refinement_level=4, degree=3)
Comment on lines +97 to +101

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just set the refinement_level inside the if-statement.


# %% [markdown]
# And now we just initialize the global normals on this mesh:
Expand Down
15 changes: 14 additions & 1 deletion docs/notebooks/10-sum-factorisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@
# We can create a hexahedral mesh by extruding a quadrilateral mesh.

# %%
mesh = ExtrudedMesh(UnitSquareMesh(10, 10, quadrilateral=True), 10)
# Setup for faster test execution.
import os
if os.getenv("FIREDRAKE_CI") == "1":
mesh = ExtrudedMesh(UnitSquareMesh(2, 2, quadrilateral=True), 2)
else:
mesh = ExtrudedMesh(UnitSquareMesh(10, 10, quadrilateral=True), 10)
Comment on lines +68 to +72

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mesh size in the actual demo can become 2. The purpose of demo is just to measure flops


# %% [markdown]
# Let's choose the continuous Lagrange element of degree 5 as our function space.
Expand Down Expand Up @@ -160,6 +165,10 @@ def gauss_lobatto_legendre_cube_rule(dimension, degree):
# %%
flops = defaultdict(list)
ps = range(1, 33) # polynomial degrees

if os.getenv("FIREDRAKE_CI") == "1":
ps = [1, 2, 4, 8]

modes = {
'gll': {'mode': 'spectral', 'variant': 'spectral', 'rule': gauss_lobatto_legendre_cube_rule},
'spectral': {'mode': 'spectral', 'variant': None, 'rule': lambda *args: None},
Expand Down Expand Up @@ -194,6 +203,10 @@ def gauss_lobatto_legendre_cube_rule(dimension, degree):
# This might take some time to run
flops_curl = defaultdict(list)
ps_curl = range(1, 17)

if os.getenv("FIREDRAKE_CI") == "1":
ps_curl = [1, 2, 4]

for p in ps_curl:
for mode in modes:
element = FiniteElement('NCE', mesh.ufl_cell(), degree=p, variant=modes[mode]['variant'])
Expand Down
Loading
Loading