PeriDEM 0.3.0
PeriDEM -- Peridynamics-based high-fidelity model for granular media
Loading...
Searching...
No Matches
run.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -------------------------------------------
3# Copyright (c) 2021 - 2026 Prashant K. Jha
4# -------------------------------------------
5# PeriDEM https://github.com/prashjha/PeriDEM
6#
7# Distributed under the Boost Software License, Version 1.0. (See accompanying
8# file LICENSE)
9
10"""In-process Python run. Same DECK / NP / NTHREADS as ./run.sh."""
11
12from __future__ import annotations
13
14import sys
15from pathlib import Path
16
17HERE = Path(__file__).resolve().parent
18
19
20def _root() -> Path:
21 for p in [HERE, *HERE.parents]:
22 if (p / "python" / "peridem" / "__init__.py").is_file():
23 return p
24 raise SystemExit("PeriDEM repo root not found")
25
26
27ROOT = _root()
28sys.path.insert(0, str(ROOT / "python"))
29for _b in (ROOT / "build/linux/python", ROOT / "build/python"):
30 if (_b / "peridem").is_dir():
31 sys.path.insert(0, str(_b))
32 break
33
34from peridem.__main__ import example_script # noqa: E402
35
36raise SystemExit(
37 example_script(
38 HERE,
39 default_deck="input.json",
40 default_np=4,
41 default_nthreads=1,
42 )
43)
Path _root()
Definition run.py:20