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 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)

command = f"mpirun --bind-to none -np 2 ogs {prj_file} > out.txt"
print(command)
run(command, shell=True, check=True)
mpirun --bind-to none -np 2 ogs /var/lib/gitlab-runner/builds/vZ6vnZiU/1/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/vZ6vnZiU/1/ogs/ogs/Tests/Data/EllipticPETSc/square_1e1_neumann.prj > out.txt', returncode=0)
mesh_series = ot.MeshSeries(f"{prj_name}.pvd").scale(time=("s", "a"))(click to toggle)
mesh_series = ot.MeshSeries(f"{prj_name}.pvd").scale(time=("s", "a"))
points_coords = np.array([[0.3, 0.5, 0.0], [0.24, 0.21, 0.0]])
labels = [f"{label} linear interpolated" for label in ["pt0", "pt1"]]

ms_pts = ot.MeshSeries.extract_probe(mesh_series, points_coords)
fig = ot.plot.line(
    ms_pts, "time", ot.variables.pressure, labels=labels, colors=["b", "r"]
)

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 570044 | Last revision: November 9, 2021