Skip to content

Commit

Permalink
Various fixes (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgensd authored Nov 7, 2022
1 parent 17cd652 commit 90469de
Show file tree
Hide file tree
Showing 7 changed files with 715 additions and 18 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# List of Python demos (without file extenion) from the repo `demo` to include in the jupyterbook.
# These files should be listed in `docs/_toc.yml`
DEMOS = "assembly_strategies"

# We use --set-kernel with jupytext to make it possible for binder to pick it up
doc: # Generate Sphinx HTML documentation, including API docs
@for demo in ${DEMOS}; do \
jupytext --to=ipynb --set-kernel=python3 demo/$$demo.py --output=docs/$$demo.ipynb ;\
done
jupytext --pre-commit --sync --set-kernel=python3
jupyter book build -W docs

clean-pytest: # Remove output from pytest
Expand Down
17 changes: 10 additions & 7 deletions demo/assembly_bcs.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# cell_metadata_filter: -all
# text_representation:
# extension: .py
# format_name: light
Expand All @@ -24,7 +24,9 @@
# 1. Using matrix-vector products of pre-assembled matrices to compute the RHS
# 2. Assemble the matrix and vector separately
# We start by importing the necessary modules
#

# This is a test to check notebooks
import matplotlib.pyplot as plt
import time
import seaborn
Expand Down Expand Up @@ -287,30 +289,31 @@ def create_plot(results: dict, outfile: str):
plt.figure()
df_rhs = df[df["side"] == "rhs"]
plot = seaborn.catplot(data=df_rhs, kind="swarm", x="label",
y="time (s)", hue="method")
y="time (s)", hue="method", title="RHS assembly")
plot.set(yscale="log")
plt.grid()
plt.savefig(f"{outfile}_rhs.png")

plt.figure()
df_lhs = df[df["side"] == "lhs"]
plot = seaborn.catplot(data=df_lhs, kind="swarm", x="label",
y="time (s)", hue="method")
y="time (s)", hue="method", title="LHS assembly")
plot.set(yscale="log")
plt.grid()
plt.savefig(f"{outfile}_lhs.png")

plt.figure()
df_total = df[df["side"] == "total"]
plot = seaborn.catplot(data=df_total, kind="swarm", x="label",
y="time (s)", hue="method")
y="time (s)", hue="method", title="Total assembly")
plot.set(yscale="log")
plt.grid()
plt.savefig(f"{outfile}_total.png")

# -


# -
# We start by running the comparison for an increasing number of degrees of freedom on a fixed grid.
if __name__ == "__main__":
N = 100
N = 40
results_p = run_parameter_sweep(N, N, N, repeats=3, min_degree=1, max_degree=3)
create_plot(results_p, "results")
9 changes: 4 additions & 5 deletions demo/assembly_strategies.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---
# jupyter:
# jupytext:
# formats: ipynb,py:light
# cell_metadata_filter: -all
# text_representation:
# extension: .py
# format_name: light
Expand Down Expand Up @@ -187,12 +187,11 @@ def create_plot(results: dict, outfile: str):
import matplotlib.pyplot as plt
plt.grid()
plt.savefig(outfile)


# -

# We start by running the comparison for an increasing number of degrees of freedom on a fixed grid.


if __name__ == "__main__":
results_p = run_parameter_sweep(30, 25, 23, repeats=3, min_degree=1, max_degree=4)
create_plot(results_p, "P_sweep.png")
Expand All @@ -203,8 +202,8 @@ def create_plot(results: dict, outfile: str):
# We note that the run for $P=1$ is relatively small, and therefore run $P=1$ on a larger mesh

if __name__ == "__main__":
results_p1 = run_parameter_sweep(100, 100, 80, 3, 1, 1)
results_p1 = run_parameter_sweep(50, 40, 45, 3, 1, 1)
create_plot(results_p1, "P1.png")

# We observe that the run-time of both strategies for $P=1$ are more or less the
# We observe that the run-time of both strategies for $P = 1$ are more or less the
# same for larger matrices.
1 change: 1 addition & 0 deletions docs/_toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ parts:
chapters:
- file: "splitting_schemes"
- file: "assembly_strategies"
- file: "assembly_bcs"

- caption: Python API
chapters:
Expand Down
Loading

0 comments on commit 90469de

Please sign in to comment.