Skip to main content

Convert Omega_h mesh files generated using TOMMS for TOKAMAKs to CSG format for OpenMC and Degas2.

Project description

Convert Omega_h Mesh to CSG Format

License GitHub Actions build status (Linux) Release

Efficiently convert Tokamak mesh of Omega_h (.osh) format to Constructive Solid Geometry (CSG). It supports creating CSG representation in

  1. Degas2's geometry.nc format
  2. OpenMC's geometry XML or a Python openmc.Universe object.

Installation

1. Pre-built Wheel

This is the recommended way to install this package. We provide a pre-built wheel (Kokkos with OpenMP backend) for Python. Follow these steps to install the latest version of readOH2csg using pip:

Wheels are built in CI and uploaded as workflow artifacts for each Python version and build type.

  1. On any Linux system, make sure you have Python (Version ≥ 3.11) installed. Go to the terminal and cd to the directory where you want to install the Python virtual environment.
python -m venv readoh2csg-env # or any name you prefer
source readoh2csg-env/bin/activate

[!TIP] Make sure that the Python version of the virtual environment is 3.11 or higher. You can check it by running python --version.

  1. Install dependencies:
pip install --extra-index-url https://shimwell.github.io/wheels openmc
pip install netCDF4==1.7.2
  1. Install readOH2csg:
pip install omegah2csg

Or if you want to install the latest release from GitHub:

pip install <link-to-release-wheel-file> omegah2csg

[!TIP] Find the latest release on the Releases Page and copy the link to the wheel file for your Python version and system architecture.

  1. Try running the CLI tool, and it should print the help message:
convert2degas2 --help

2. From Source

It depends on Omega_h. Omega_h has to be built with Kokkos and it supports any Kokkos backend.

Follow these steps to build and install readOH2csg from source:

  1. Make sure you have compilers (at least g++ or some alternative), Python (Version ≥ 3.11), and CMake available.
  2. Install Kokkos following the instructions in Kokkos Build Documentation. You can choose any backend supported. Here's an example for building with the OpenMP backend:
git clone --depth=2 --branch 4.7.02 https://github.com/kokkos/kokkos.git
cd kokkos
cmake -S . -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_CXX_COMPILER=g++ \
  -DBUILD_SHARED_LIBS=ON \
  -DKokkos_ENABLE_OPENMP=ON \
  -DCMAKE_INSTALL_PREFIX=<Kokkos_install_dir>

cmake --build build -j4 --target install
  1. Install Omega_h with Kokkos support:
git clone https://github.com/SCOREC/omega_h.git
cd omega_h
cmake -S . -B build \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_CXX_COMPILER=g++ \
  -DBUILD_SHARED_LIBS=ON \
  -DOmega_h_USE_Kokkos=ON \
  -DKokkos_ROOT=<Kokkos_install_dir> \
  -DCMAKE_INSTALL_PREFIX=<Omega_h_install_dir>

cmake --build build -j4 --target install
  1. Now, install readOH2csg:
git clone https://github.com/Fuad-HH/readOH2csg.git --branch parallel
cd readOH2csg

# configure
cmake -S . -B build \
  -DOmega_h_ROOT=<Omega_h_install_dir> \
  -DKokkos_ROOT=<Kokkos_install_dir> \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=<readOH2csg_install_dir>

# build
cmake --build build -j4 --target install

[!WARNING] For now, only the Python API and CLI work. Please do not turn off the option for Python bindings. It is enabled by default.

  1. Create Python virtual environment and install dependencies as described in the Pre-built Wheel section.
  2. Install readOH2csg and run the CLI tool, and it should print the help message:
# from the source directory
export KOKKOS_ROOT=<Kokkos_install_dir>
export OMEGA_H_ROOT=<Omega_h_install_dir>
python -m pip install .
convert2degas2 --help

Usage

Check an example case in tests/assets/simple_degas2_case/degas2-case. Please read the README.md file first for detailed instructions on how to run the example case.

To run an OpenMC example, running convert2openmc <mesh-name> will generate the geometry.xml file and, run the case following OpenMC Documentation.

[!TIP] If omegah2csg was installed with Kokkos OpenMP backend or using pip, try setting OpenMP environment variables for faster execution.

export OMP_PROC_BIND=spread && export OMP_PLACES=threads && export OMP_NUM_THREADS=<number of threads you want>

Documentation

More details on strategies, logic, and math are included in the doc/ directory.

Developer's Guide

For myself and future development, use the Developer's Guide to understand the code structure, design decisions, and how to contribute to this project.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

omegah2csg-0.0.2.tar.gz (2.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

omegah2csg-0.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (9.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

omegah2csg-0.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (9.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

omegah2csg-0.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (9.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file omegah2csg-0.0.2.tar.gz.

File metadata

  • Download URL: omegah2csg-0.0.2.tar.gz
  • Upload date:
  • Size: 2.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for omegah2csg-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2b538e0d0f83597e2233103cf2f5e2f2c3db07072c8dedea71681a17fea411aa
MD5 c38a44fc3ee68c538630d0491d62bd2f
BLAKE2b-256 1c111734cfef8f49d22da5bb718b34f5c6eb38b485ddc9accdbe588276be998b

See more details on using hashes here.

File details

Details for the file omegah2csg-0.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for omegah2csg-0.0.2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e8a9b944e670c1b32b64ce8393574f2733d38cd0a1e5c673d8a0397f9f98e49a
MD5 7674d7beb781222e91a92c37aadd169b
BLAKE2b-256 aa4a39430538d8d17ae98efce0f311a0d3b188b9e132714becca05be3f952cff

See more details on using hashes here.

File details

Details for the file omegah2csg-0.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for omegah2csg-0.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 940eff407866201ac0218a60d44e52d82c57bcd261c9e6042088f6760690f377
MD5 7b98b323bf4ed89a86415a4daed55075
BLAKE2b-256 68464738a4d7c2dbaeacf878ecd2813a5c86034dc838d785b059a114c6b247f6

See more details on using hashes here.

File details

Details for the file omegah2csg-0.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for omegah2csg-0.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 525b3a66c78414ff95871b4057671a269c7c6a5b3c4d465b0e5262964619fd5f
MD5 1acdd8b6d0737f7f68e5d9fb1e786e5b
BLAKE2b-256 52724b2b9fa7e1158c6f3ef4aaadcaf43ea37642afdbebaa458085feea59607c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page