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).
- 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.
Using conda:
conda create -n openmc2dolfinx-env
conda activate openmc2dolfinx-env
conda install -c conda-forge fenics-dolfinx=0.9.0 mpich pyvistaOnce in the created in environment:
python -m pip install openmc2dolfinxfromopenmc2dolfinximportStructuredGridReader, 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)