Skip to content

Repository files navigation

openmc2dolfinx

Conda CIDocker CICode 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

fromopenmc2dolfinximportStructuredGridReader, UnstructuredMeshReaderimportpyvistaaspvimportnumpyasnpimportdolfinxfrommpi4pyimportMPI# download an example tetmeshfilename=pv.examples.download_tetrahedron(load=False)
grid=pv.read(filename)
# assign random cell datagrid.cell_data["mean"] =np.arange(grid.n_cells)
grid.save("out.vtk")
# read the vtk filereader=UnstructuredMeshReader("out.vtk")
# make a dolfinx functionu=reader.create_dolfinx_function("mean")
# export to vtk for visualisationwriter=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

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages