SimplePETSc

This page is based on a Jupyter notebook.

The following shows running a simple steady-state diffusion benchmark running on 2 cores.

import os(click to toggle)
import os
from pathlib import Path
from subprocess import run

import matplotlib.pyplot as plt
import numpy as np
import ogstools as ot
prj_name = "square_1e1_neumann"(click to toggle)
prj_name = "square_1e1_neumann"
data_dir = os.environ.get("OGS_DATA_DIR", "../../../Data")
prj_file = f"{data_dir}/EllipticPETSc/{prj_name}.prj"
out_dir = Path(os.environ.get("OGS_TESTRUNNER_OUT_DIR", "_out"))(click to toggle)
out_dir = Path(os.environ.get("OGS_TESTRUNNER_OUT_DIR", "_out"))
if not out_dir.exists():
    out_dir.mkdir(parents=True)

print(f"mpirun --bind-to none -np 2 ogs {prj_file} > out.txt")
run(f"mpirun --bind-to none -np 2 ogs {prj_file} > out.txt", shell=True, check=True)
mpirun --bind-to none -np 2 ogs /var/lib/gitlab-runner/builds/e3EQ9HiK/0/ogs/ogs/Tests/Data/EllipticPETSc/square_1e1_neumann.prj > out.txt
CompletedProcess(args='mpirun --bind-to none -np 2 ogs /var/lib/gitlab-runner/builds/e3EQ9HiK/0/ogs/ogs/Tests/Data/EllipticPETSc/square_1e1_neumann.prj > out.txt', returncode=0)
mesh_series = ot.MeshSeries(f"{prj_name}.pvd")(click to toggle)
mesh_series = ot.MeshSeries(f"{prj_name}.pvd")
points_coords = np.array([[0.3, 0.5, 0.0], [0.24, 0.21, 0.0]])
points_labels = ["pt0", "pt1"]

fig, ax = plt.subplots(nrows=1, ncols=1)

mesh_series.plot_probe(
    points_coords,
    ot.variables.pressure,
    labels=["{label} linear interpolated" for label in points_labels],
    time_unit="a",
    interp_method="linear",
    ax=fig.axes[0],
    colors=["b", "r"],
    linestyles=["-", "-"],
)
  0%|          | 0/2 [00:00<?, ?it/s]

png


This article was written by Lars Bilke. If you are missing something or you find an error please let us know.
Generated with Hugo 0.122.0 in CI job 511216 | Last revision: November 9, 2021