Skip to content

Commit

Permalink
Merge pull request #21 from fusion-energy/better_docs
Browse files Browse the repository at this point in the history
added missing packages and doc strings
  • Loading branch information
shimwell authored Dec 21, 2022
2 parents dc18fe9 + 7efb680 commit 4320515
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ mamba install -c fusion-energy -c cadquery -c conda-forge cad_to_dagmc
# Install (Conda + pip)

You will need to install some dependencies that are not available via PyPi.
This example uses mamba but conda could also be used.
```bash
conda install -c conda-forge mamba
mamba install -c conda-forge moab
mamba install -c conda-forge gmsh
mamba install -c conda-forge python-gmsh
mamba install -c cadquery -c conda-forge cadquery=master
```

Expand Down
32 changes: 24 additions & 8 deletions src/cad_to_dagmc/core.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tempfile import mkstemp

from typing import Iterable
import typing
from cadquery import importers
from cadquery import Assembly
from OCP.GCPnts import GCPnts_QuasiUniformDeflection
Expand All @@ -22,7 +22,10 @@ def __init__(self):
self.material_tags = []

def add_stp_file(
self, filename: str, material_tags: Iterable[str], scale_factor: float = 1.0
self,
filename: str,
material_tags: typing.Iterable[str],
scale_factor: float = 1.0,
):
"""Loads the parts from stp file into the model keeping track of the
parts and their material tags.
Expand All @@ -45,11 +48,24 @@ def add_stp_file(
scaled_part = part
else:
scaled_part = part.scale(scale_factor)
self.add_cadquery_object(scaled_part, material_tags)
self.add_cadquery_object(object=scaled_part, material_tags=material_tags)

def add_cadquery_object(self, object, material_tags):
def add_cadquery_object(
self,
object: typing.Union[
cq.assembly.Assembly, cq.occ_impl.shapes.Compound, cq.occ_impl.shapes.Solid
],
material_tags: typing.Iterable[str],
):
"""Loads the parts from CadQuery object into the model keeping track of
the parts and their material tags.
Args:
object: the cadquery object to convert
material_tags: the names of the DAGMC material tags to assign.
These will need to be in the same order as the volumes in the
STP file and match the material tags used in the neutronics
code (e.g. OpenMC).
"""

if isinstance(object, cq.assembly.Assembly):
Expand All @@ -71,10 +87,10 @@ def add_cadquery_object(self, object, material_tags):

def export_dagmc_h5m_file(
self,
filename="dagmc.h5m",
min_mesh_size=1,
max_mesh_size=10,
verbose=False,
filename: str = "dagmc.h5m",
min_mesh_size: float = 1,
max_mesh_size: float = 10,
verbose: bool = False,
):

volume_atol: float = 0.000001
Expand Down

0 comments on commit 4320515

Please sign in to comment.