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"))
out_dir.mkdir(parents=True, exist_ok=True)

command = f"mpirun --bind-to none -np 2 ogs {prj_file} -o {out_dir} > {out_dir}/out.txt"
print(command)
run(command, shell=True, check=True)
mpirun --bind-to none -np 2 ogs /var/lib/gitlab-runner/builds/vZ6vnZiU/0/ogs/ogs/Tests/Data/EllipticPETSc/square_1e1_neumann.prj -o /var/lib/gitlab-runner/builds/vZ6vnZiU/0/ogs/build/release-petsc/Tests/Data/Notebooks/SimplePETSc > /var/lib/gitlab-runner/builds/vZ6vnZiU/0/ogs/build/release-petsc/Tests/Data/Notebooks/SimplePETSc/out.txt
CompletedProcess(args='mpirun --bind-to none -np 2 ogs /var/lib/gitlab-runner/builds/vZ6vnZiU/0/ogs/ogs/Tests/Data/EllipticPETSc/square_1e1_neumann.prj -o /var/lib/gitlab-runner/builds/vZ6vnZiU/0/ogs/build/release-petsc/Tests/Data/Notebooks/SimplePETSc > /var/lib/gitlab-runner/builds/vZ6vnZiU/0/ogs/build/release-petsc/Tests/Data/Notebooks/SimplePETSc/out.txt', returncode=0)
mesh_series = ot.MeshSeries(f"{out_dir}/{prj_name}.pvd").scale(time="a")(click to toggle)
mesh_series = ot.MeshSeries(f"{out_dir}/{prj_name}.pvd").scale(time="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.probe(mesh_series, points_coords)
fig = ot.plot.line(
    ms_pts, "time", ot.variables.pressure, labels=labels, colors=["b", "r"]
)
[0] info: Reading meshes took 0.0008774789999999033 s
[0] info: Collection of 9 regular elements and computing element map took 1.330000000132614e-06 s
[0] info: Collection of 24 nodes and computing offsets took 6.399999998851769e-07 s
[0] info: Make nodes unique (16 unique nodes) / computing map took 6.439999999940937e-06 s
[0] info: Reset nodes in regular elements took 5.650000000079203e-06 s
[0] info: creation of merged mesh took 2.959999999996299e-06 s
[0] info: merge properties into merged mesh took 9.0699999999444e-06 s
[0] info: writing mesh took 0.002116910999999888 s
[0] info: Reading meshes took 0.0009195909999999419 s
[0] info: Collection of 9 regular elements and computing element map took 1.0299999999574538e-06 s
[0] info: Collection of 24 nodes and computing offsets took 6.999999999646178e-07 s
[0] info: Make nodes unique (16 unique nodes) / computing map took 5.040000000011702e-06 s
[0] info: Reset nodes in regular elements took 5.550000000020816e-06 s
[0] info: creation of merged mesh took 2.45999999992641e-06 s
[0] info: merge properties into merged mesh took 8.970999999968754e-06 s
[0] info: writing mesh took 0.002037787999999985 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.150.1 in CI job 743172 | Last revision: November 9, 2021