Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major refactor, gmsh instead of tessellation #16

Merged
merged 55 commits into from
Sep 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
47259ce
started rewrite
shimwell Sep 12, 2022
c2c0f82
[skip ci] Apply formatting changes
shimwell Sep 12, 2022
62dfea8
moved some code to bpf
shimwell Sep 13, 2022
fa4ae0a
merge conflict
shimwell Sep 13, 2022
44454fe
[skip ci] Apply formatting changes
shimwell Sep 13, 2022
7618eee
updated to latest development api
shimwell Sep 20, 2022
68a2640
[skip ci] Apply formatting changes
shimwell Sep 20, 2022
0570525
added sphere cad to tests
shimwell Sep 21, 2022
e1f6dd5
fixed examples
shimwell Sep 21, 2022
03235c9
added link to examples
shimwell Sep 21, 2022
5af1286
[skip ci] Apply formatting changes
shimwell Sep 21, 2022
f3e396d
added conda packaging
shimwell Sep 21, 2022
5ac017a
Merge branch 'major_refactor' of github.com:fusion-energy/cad_to_dagm…
shimwell Sep 21, 2022
7540b8b
[skip ci] Apply formatting changes
shimwell Sep 21, 2022
6fd132b
added missing packages
shimwell Sep 21, 2022
f0719ec
py 3.8 and 3.9 only
shimwell Sep 21, 2022
8ee127b
cq master version
shimwell Sep 21, 2022
100cb2e
added missing packages
shimwell Sep 21, 2022
9b8dde8
openmc v0.13.1
shimwell Sep 21, 2022
718fee1
added -y to uninstall
shimwell Sep 21, 2022
55af8e9
not testing conda package
shimwell Sep 21, 2022
fdf4db9
moved to conda build
shimwell Sep 21, 2022
6429b3d
trying remove instead of uninstall
shimwell Sep 22, 2022
0135692
using conda to remove packages
shimwell Sep 22, 2022
a52a343
conda for install
shimwell Sep 22, 2022
225a69b
added examples
shimwell Sep 22, 2022
6dc6f33
added conda install details
shimwell Sep 22, 2022
872d992
added verbose option
shimwell Sep 22, 2022
55caab2
added compound test
shimwell Sep 22, 2022
ba26dc9
added missing import
shimwell Sep 22, 2022
daebe29
added compound
shimwell Sep 22, 2022
9af1041
[skip ci] Apply formatting changes
shimwell Sep 22, 2022
b6eba36
removed the location shift for a sphere
shimwell Sep 22, 2022
d28c221
split up examples
shimwell Sep 23, 2022
5c999da
added line spacing
shimwell Sep 23, 2022
3af3d27
trying to fix
shimwell Sep 23, 2022
ecba2a8
[skip ci] Apply formatting changes
shimwell Sep 23, 2022
08217e2
switched example
shimwell Sep 23, 2022
3fb5bc0
Merge branch 'major_refactor' of github.com:fusion-energy/cad_to_dagm…
shimwell Sep 23, 2022
1b76f3e
added support for assemblies
shimwell Sep 23, 2022
2408832
removed stp files
shimwell Sep 23, 2022
1b10f5d
added assembly example
shimwell Sep 23, 2022
3ef2696
added stp file creation script
shimwell Sep 23, 2022
2248d11
making stp files needed for tests
shimwell Sep 23, 2022
cdf2405
[skip ci] Apply formatting changes
shimwell Sep 23, 2022
d84fb8a
correct dir
shimwell Sep 23, 2022
bfbf739
Merge branch 'major_refactor' of github.com:fusion-energy/cad_to_dagm…
shimwell Sep 23, 2022
652e7b9
Typo fix
shimwell Sep 23, 2022
4b455dd
typo fix
shimwell Sep 23, 2022
57d647f
removed cad files
shimwell Sep 24, 2022
4296f17
removed vtk file
shimwell Sep 24, 2022
cdd2509
removed old proto scripts
shimwell Sep 24, 2022
a38be3f
not removing moab
shimwell Sep 24, 2022
b0f2cdf
mamba install
shimwell Sep 24, 2022
08f9514
removed old h5m file
shimwell Sep 25, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/anaconda-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: anaconda-publish

on:
workflow_dispatch:
release:
types: [published]

jobs:
build:
runs-on: ubuntu-latest
container: continuumio/miniconda3:4.10.3

steps:
- uses: actions/checkout@v2

- name: Set up conda
run: |
apt-get --allow-releaseinfo-change update
apt install -y libgl1-mesa-glx
conda install -y anaconda-client conda-build
conda config --set anaconda_upload no
conda install boa -c conda-forge
- name: Build and publish to conda
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
conda mambabuild conda -c fusion-energy -c cadquery -c conda-forge --config-file conda/conda_build_config.yaml
conda convert /opt/conda/conda-bld/linux-64/*.tar.bz2 --platform osx-64
anaconda upload -f /opt/conda/conda-bld/*/*.tar.bz2

# Note conversion to windows is not supported as MOAB is a dependency
78 changes: 72 additions & 6 deletions .github/workflows/ci_with_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ jobs:
apt-get update -y
apt-get upgrade -y
apt-get install -y libgl1-mesa-glx libgl1-mesa-dev libglu1-mesa-dev freeglut3-dev libosmesa6 libosmesa6-dev libgles2-mesa-dev
conda install -c conda-forge mamba
mamba install -c cadquery -c conda-forge cadquery=master moab
conda install -c conda-forge moab
conda install -c conda-forge gmsh
conda install -c conda-forge python-gmsh
conda install -c cadquery -c conda-forge cadquery=master

- name: install package
run: |
Expand All @@ -44,13 +46,77 @@ jobs:
run: |
pip install .[tests]
pytest tests/test_h5m_creation.py -v
# pytest tests/test_h5m_creation.py -v --cov=cad_to_dagmc --cov-append --cov-report term --cov-report xml

- name: create stp files
run: |
cd examples
python create_stp_files_for_examples.py


- name: Run example cadquery_assembly
run: |
cd examples
python cadquery_assembly.py


- name: Run example cadquery_compound
run: |
cd examples
python cadquery_compound.py


- name: Run example cadquery_object_and_stp_file
run: |
cd examples
python cadquery_object_and_stp_file.py


- name: Run example cadquery_text
run: |
cd examples
python cadquery_text.py


- name: Run example curved_cadquery_object
run: |
cd examples
python curved_cadquery_object.py


- name: Run example multiple_cadquery_objects
run: |
cd examples
python multiple_cadquery_objects.py


- name: Run example multiple_stp_files
run: |
cd examples
python multiple_stp_files.py


- name: Run example single_stp_file_multiple_volumes.py
run: |
cd examples
python single_stp_file_multiple_volumes.py


- name: Run example single_cadquery_object
run: |
cd examples
python single_cadquery_object.py


- name: Run example single_stp_file
run: |
cd examples
python single_stp_file.py

- name: install non pypi dependencies for neutronics
run: |
mamba uninstall moab
mamba uninstall cadquery
mamba install -c conda-forge -y "openmc=0.13.0=dagmc*nompi*"
conda remove cadquery -y
conda install -c conda-forge mamba -y
mamba install -c conda-forge -y "openmc=0.13.1=dagmc*nompi*"

- name: Run simulation tests
run: |
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/conda-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: conda-build-test

on:
workflow_dispatch:
pull_request:
branches:
- develop
- main

jobs:
build:
runs-on: ubuntu-latest
container: continuumio/miniconda3:4.10.3

steps:
- uses: actions/checkout@v2

- name: Set up conda
run: |
apt-get --allow-releaseinfo-change update
apt install -y libgl1-mesa-glx
conda install -y anaconda-client conda-build
conda config --set anaconda_upload no
- name: Build and test
env:
GIT_DESCRIBE_TAG: 0.1
run: |
conda build conda -c fusion-energy -c cadquery -c conda-forge --config-file conda/conda_build_config.yaml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,6 @@ dmypy.json
*.out
*.h5m
*.json
*.vtk
*.stp
cad_to_dagmc/_version.py
91 changes: 35 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
[![CI with install](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/ci_with_install.yml)

Single volumes pass tests :heavy_check_mark:

Multiple non touching volumes pass tests :heavy_check_mark:

Multiple touching volumes FAIL tests :heavy_multiplication_x:

Assigning material tags to correct volumes NON EXISTENT tests :heavy_multiplication_x:
[![Upload Python Package](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml/badge.svg)](https://github.com/fusion-energy/cad_to_dagmc/actions/workflows/python-publish.yml)

___

Expand All @@ -15,71 +9,56 @@ A minimal package that uses CadQuery functionality to convert Cad geometry to DA
This particular method of producing DAGMC compatible h5m files from CAD geometry
is intended to convert STP files or [CadQuery](https://cadquery.readthedocs.io) objects to h5m file.

The use of CadQuery based surface tesselation and then conversion of the
vertices and triangle sets into h5m files directly (in memory) is relatively
fast with minimal file IO and the resulting meshed volumes have low triangle
count while maintaining a good representation of the volume as described in
[this](https://www.sciencedirect.com/science/article/abs/pii/S0920379615301484)
publication.
One unique feature of this package is the ability to combine STP files with CadQuery objects.
This allows for the addition of parametric geometry to static geometry.

# Install (Conda)

While this package concentrates on loading the CAD and meshing the surface it
then hands off the vertices and triangles sets to
[vertices_to_h5m](https://github.com/fusion-energy/vertices_to_h5m) which
converts these into a h5m geometry file.
Due to the modularity of this workflow if you have a preferred meshing
algorithm then it is entirely possible to pipe your own vertices and triangles
directly into vertices_to_h5m.
Creates a new empty Conda environment
```bash
conda create --name new_env python=3.9
```

Installs cad_to_dagmc and dependencies
```bash
conda install -c fusion-energy -c cadquery -c conda-forge cad_to_dagmc
```
# Install (Mamba)

Creates a new empty Conda environment
```bash
conda create --name new_env python=3.9
```

Installs Mamba
```bash
conda install -c conda-forge mamba
```

# Install
Installs cad_to_dagmc and dependencies
```bash
mamba install -c fusion-energy -c cadquery -c conda-forge cad_to_dagmc
```

You will some dependencies installing (moab, pymoab and cadquery).
# Install (Conda + pip)

You will need to install some dependencies that are not available via PyPi.
```bash
conda install -c conda-forge mamba
mamba install -c conda-forge moab
mamba install -c cadquery -c conda-forge cadquery=master
```

There you can install the ```cad_to_dagmc``` package
Then you can install the cad_to_dagmc package with ```pip```

```bash
pip install cad_to_dagmc
```

# Usage

To use the h5m geometry you will need a transport code with DAGMC enabled such as OpenMC.
Just to note that currently the conda install for CadQuery and OpenMC can't be installed in the same conda environment.
A work around for this is to create the h5m geometry in one conda environment and simulate with OpenMC in another conda environment.

# Usage

Produces a tagged h5m file for a STP file with a single part / volume

```python
import cad_to_dagmc

stp_file = cad_to_dagmc.load_stp_file("tests/single_cube.stp")
vertices, triangles = cad_to_dagmc.tessellate(stp_file, tolerance=2)

vertices_to_h5m(
vertices=vertices,
triangles=triangles,
material_tags=["mat1"],
h5m_filename="dagmc.h5m",
)
```

Produces a tagged h5m file for a STP file with a multiple part / volume

```python
import cad_to_dagmc

stp_file = cad_to_dagmc.load_stp_file("tests/multi_volume_cylinders.stp")
vertices, triangles = cad_to_dagmc.tessellate(stp_file, tolerance=2)

vertices_to_h5m(
vertices=vertices,
triangles=triangles,
material_tags=["mat1", "mat2", "mat3", "mat4", "mat5", "mat6"],
h5m_filename="dagmc.h5m",
)
````
For examples see the [examples folder](https://github.com/fusion-energy/cad_to_dagmc/tree/main/examples)
6 changes: 1 addition & 5 deletions cad_to_dagmc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
from .core import (
load_stp_file,
merge_surfaces,
tessellate,
)
from .core import CadToDagmc
Loading