Skip to content

festim-dev/openmc2dolfinx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openmc2dolfinx

Conda CI Docker CI Code style: Ruff

openmc2dolfinx is a lightweight tool for converting OpenMC output data (in .vtk format) into dolfinx-compatible fem.Function objects. It is primarily designed to facilitate multiphysics coupling between OpenMC and finite element simulations (e.g. thermal, diffusion, or tritium transport analyses).

Key features

  • Convert structured and unstructured VTK meshes to dolfinx meshes.
  • Interpolate OpenMC tally results directly into dolfinx Function spaces.
  • Integrated with PyVista for mesh and data inspection.

Installation

Using conda:

conda create -n openmc2dolfinx-env
conda activate openmc2dolfinx-env
conda install -c conda-forge fenics-dolfinx=0.9.0 mpich pyvista

Once in the created in environment:

python -m pip install openmc2dolfinx

Example usage

from openmc2dolfinx import StructuredGridReader, UnstructuredMeshReader
import pyvista as pv
import numpy as np
import dolfinx
from mpi4py import MPI

# download an example tetmesh
filename = pv.examples.download_tetrahedron(load=False)

grid = pv.read(filename)

# assign random cell data
grid.cell_data["mean"] = np.arange(grid.n_cells)
grid.save("out.vtk")

# read the vtk file
reader = UnstructuredMeshReader("out.vtk")

# make a dolfinx function
u = reader.create_dolfinx_function("mean")

# export to vtk for visualisation
writer = dolfinx.io.VTXWriter(MPI.COMM_WORLD, "out.bp", u, "BP5")
writer.write(t=0)

About

A repository to handle the conversion of OpenMC data to dolfinx functions

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages