Skip to content
New issue

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

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

Already on GitHub? # to your account

Merge dev into main #67

Merged
merged 30 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
3d4ad1f
update Fuzzy write function
psauvan Mar 20, 2024
d123e67
several stp file update
psauvan Mar 23, 2024
f7cdf77
script to color CAD document following material label
psauvan Apr 9, 2024
db451b8
fix rounding error of z value acos(z) evaluation
psauvan Apr 9, 2024
f106652
Add a bug report template and .gitignore (#44)
AlvaroCubi Apr 9, 2024
4db7ce2
Removed unused imports and variables (#35)
repositony Apr 9, 2024
2d6e263
raise value error instead of exit (#41)
shimwell Apr 10, 2024
fdcd29d
Update to testing path (#40)
shimwell Apr 10, 2024
f14702d
Update bug_report.md
psauvan Apr 10, 2024
59731d8
raising catchable error instead of exit (#47)
shimwell Apr 16, 2024
377156b
added try for freecad import (#48)
shimwell Apr 16, 2024
dcb2c66
Solve SyntaxtError producing a bug (#49)
AlvaroCubi Apr 16, 2024
b132266
fixed error units in OpenMC output
psauvan Apr 16, 2024
b0742fd
GEOUNED training presentation added (#53)
akolsek Apr 18, 2024
9173938
Adding minimal ci to check cad converts (#52)
shimwell Apr 18, 2024
7a81367
Update pyproject.toml
psauvan Apr 18, 2024
6ed02e9
typo correction to test if CI is working (#54)
shimwell Apr 18, 2024
4cbd230
fix small bug with torus (bad identification of closed mozaic faces)
psauvan Apr 19, 2024
6e7f883
Adding minimal volume checking CI comparing CAD and CSG volumes (#56)
shimwell Apr 19, 2024
1a46bcd
Added mkdocs (#57)
shimwell Apr 19, 2024
d57bf81
Reverting mkdocs PR 57 (#58)
shimwell Apr 20, 2024
44ee8fa
Adding minimal particle transport tests on resulting csg files (#59)
shimwell Apr 20, 2024
a96e19d
Add the name to the cells in OpenMC to improve identification (#61)
ecasglez Apr 23, 2024
a4cc2cd
converting with no simplification = more geometry works (#62)
shimwell Apr 23, 2024
f741417
reduced number of skiped geoms (#63)
shimwell Apr 23, 2024
8e0e465
[skip ci] corrected bade to main branch (#64)
shimwell Apr 23, 2024
af70963
Improved import statements (#65)
shimwell Apr 23, 2024
6160952
Add bug report and .gitignore to main (#45) (#66)
shimwell Apr 23, 2024
90daab6
Merge branch 'main' into dev
AlvaroCubi Apr 23, 2024
213cb35
added standard gitignore for python project (#68)
shimwell Apr 23, 2024
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
62 changes: 62 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CI testing

on:
pull_request:
branches:
- dev
- main
push:
branches:
- main

jobs:
testing:
name: CI (Python=${{ matrix.python-version }}, OS=${{ matrix.os }})
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
python-version: ["3.11"]

include:
- python-version: "3.8"
os: "ubuntu-latest"
- python-version: "3.9"
os: "ubuntu-latest"
- python-version: "3.10"
os: "ubuntu-latest"
steps:
- name: checkout actions
uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: ${{ matrix.python-version }}
channels: conda-forge

- name: install dependencies
run: conda install -c conda-forge freecad -y

- name: install package
run: |
python -m pip install --upgrade pip
python -m pip install .
python -c 'import GEOUNED'
python -c 'from GEOReverse import reverse'
python -m pip install .[tests]

- name: testing GEOUNED functionality
run: python -m pytest -v tests/test_convert.py

- name: install openmc
if: ${{ matrix.os == 'ubuntu-latest'}}
run: conda install -c conda-forge openmc -y

- name: testing with OpenMC
if: ${{ matrix.os == 'ubuntu-latest'}}
run: |
python -m pytest -v tests/test_volumes.py
python -m pytest -v tests/test_transport.py
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ docs/build/**
docs/source/_autosummary/*
docs/jupyter_execute
.pytest_cache/**
build/
build/
tests_outputs/
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![CI testing](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/GEOUNED-org/GEOUNED/actions/workflows/ci.yml)

# GEOUNED
A tool to convert from CAD to CSG & CSG to CAD for Monte Carlo transport codes (MCNP & OpenMC).
This repository contains the implementation of the algorithm presented in the paper [GEOUNED: A new conversion tool from CAD to Monte Carlo geometry](https://doi.org/10.1016/j.net.2024.01.052).
Expand Down Expand Up @@ -27,7 +29,7 @@ In that case you can install directly de module using:
C:\Program Files\FreeCAD 0.XX\bin\python.exe -m pip install git+https://github.com/GEOUNED-code/GEOUNED.git
```
using this option you have directly access to both FreeCAD and GEOUNED python modules.
Furthermore, using this python compabilities problems between different versions of python are avoided (some dynamic libraries of FreeCAD depends on the version of python used during the built process).
Furthermore, using this python compatibilities problems between different versions of python are avoided (some dynamic libraries of FreeCAD depends on the version of python used during the built process).

## How to use

Expand Down
Binary file added docs/Training_on_GEOUNED_tool.pdf
Binary file not shown.
13 changes: 9 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "GEOUNED"
version = "1.0.0"
version = "1.0.1"
authors = [
{ name="Juan-Pablo Catalan", email="jpcatalan@ind.uned.es" },
{ name="Patrick Sauvan", email="psauvan@ind.uned.es" },
Expand All @@ -22,6 +22,11 @@ classifiers = [
]

[project.urls]
Homepage = "https://github.com/GEOUNED-code"
Repository = "https://github.com/GEOUNED-code/GEOUNED"
Documentation = "https://github.com/GEOUNED-code/GEOUNED/docs"
Homepage = "https://github.com/GEOUNED-org"
Repository = "https://github.com/GEOUNED-org/GEOUNED"
Documentation = "https://github.com/GEOUNED-org/GEOUNED/docs"

[project.optional-dependencies]
tests = [
"pytest",
]
50 changes: 50 additions & 0 deletions scripts/colorCADmat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import re
import sys

sys.path.append('/usr/lib64/freecad/lib64/')
import ImportGui

bd = 255
gd = 255*255
rd = 255* 255* 255
matNumber=re.compile(r"Material_(?P<matnum>\d+)")

def getColor(num,vmin=0,vmax=rd):
colRange = rd
dnum = vmax - vmin
dx = num - vmin
scale = colRange/dnum
snum = dx * scale + 1

red = snum//gd
r = snum - red * gd
green = r // bd
blue = r - green * bd
return (red/255,green/255,blue/255)

def setColorMaterial(documents):
featureObj = []
matMin = 999999999
matMax = 0
for obj in documents.Objects:
if obj.TypeId == 'Part::Feature' :
for o in obj.InListRecursive:
m = matNumber.search(o.Label)
if m :
mat = int(m.group('matnum'))
matMin = min(matMin,mat)
matMax = max(matMax,mat)
featureObj.append((obj,mat))

for obj,mat in featureObj:
obj.ViewObject.ShapeColor = getColor(mat,matMin,matMax)


# color solids in a Freecad document with respect to the material number
doc = App.ActiveDocument
setColorMaterial(doc)
name = doc.Label
outname = name+'_color'
ImportGui.export(doc.RootObjects,outname+'.stp')
doc.saveAs(outname+'.FCStd')

6 changes: 2 additions & 4 deletions scripts/geouned
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,9 @@ elif len(sys.argv) == 3:
runReverse = True
inifile = sys.argv[1]
else:
print('Bad option')
exit()
raise ValueError('Bad option')
else:
print('Too many input arguments')
exit()
raise ValueError('Too many input arguments')


if not runReverse :
Expand Down
8 changes: 3 additions & 5 deletions scripts/geouned.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,10 @@
runReverse = True
inifile = sys.argv[1]
else:
print('Bad option')
exit()
else:
print('Too many input arguments')
exit()
raise ValueError('Bad option')

else:
raise ValueError('Too many input arguments')

if not runReverse :
GEO = GEOUNED.GEOUNED(inifile)
Expand Down
16 changes: 8 additions & 8 deletions src/GEOReverse/Modules/MCNPinput.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import math
import os
import sys
import re

import FreeCAD
from GEOReverse.Modules.Parser import parser as mp
from GEOReverse.Modules.remh import cell_card_string, remove_hash
from GEOReverse.Modules.Objects import *
import math
import numpy as np
from numpy import linalg as LA

from .Objects import *
from .Parser import parser as mp
from .remh import cell_card_string, remove_hash


class MCNPinput:
def __init__(self,name):
if not os.path.isfile(name):
print("File %s does not exist" %name)
sys.exit()
return
raise FileNotFoundError (f"File {name} does not exist")
self.__inputcards__ = list(mp.get_cards(name))
self.Transformations = self.__getTransList__()
return
Expand Down
15 changes: 9 additions & 6 deletions src/GEOReverse/Modules/Objects.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from GEOReverse.Modules.buildSolidCell import BuildSolid
import FreeCAD, Part
import numpy as np
import math
from GEOReverse.Modules.remh import cline
from GEOReverse.Modules.Utils.booleanFunction import outterTerms,BoolSequence
from GEOReverse.Modules.Utils.BooleanSolids import buildCTableFromSolids

import FreeCAD
import numpy as np
import Part

from .buildSolidCell import BuildSolid
from .remh import cline
from .Utils.booleanFunction import BoolSequence, outterTerms


class CADCell:
def __init__(self,stringCell=None):
Expand Down
1 change: 1 addition & 0 deletions src/GEOReverse/Modules/Parser/PartialFormatter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import string

version = '3.6'

def make_label(item):
Expand Down
5 changes: 3 additions & 2 deletions src/GEOReverse/Modules/Parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
Functions for parsing MCNP input files.
"""

import os
import re
import warnings
import os
from GEOReverse.Modules.Parser.PartialFormatter import PartialFormatter

from .PartialFormatter import PartialFormatter

version = '3.6'

Expand Down
11 changes: 6 additions & 5 deletions src/GEOReverse/Modules/Utils/BooleanSolids.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# Conversion to MCNP v0.0
# Only one solid and planar surfaces
#
import FreeCAD
import BOPTools.SplitAPI
import math
import re
from GEOReverse.Modules.Utils.booleanFunction import BoolSequence

import BOPTools.SplitAPI
import FreeCAD

from .booleanFunction import BoolSequence

BoolVals = (None,True,False)

Expand Down Expand Up @@ -481,7 +482,7 @@ def checkSign(solid,surf):
apex,axis,t,dbl = surf.params
r = point - apex
r.normalize()
z = axis.dot(r)
z = round(axis.dot(r),15)
alpha = math.acos(z)

if alpha > math.atan(t) :
Expand Down
1 change: 1 addition & 0 deletions src/GEOReverse/Modules/Utils/booleanFunction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import re

mostinner=re.compile(r"\([^\(^\)]*\)") # identify most inner parentheses
number =re.compile(r"(?P<value>[-+]?\d+)")
mix =re.compile(r"(?P<value>([-+]?\d+|\[0+\]))")
Expand Down
3 changes: 2 additions & 1 deletion src/GEOReverse/Modules/XMLParser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from GEOReverse.Modules.remh import cline
from .remh import cline


class cellCARD:

Expand Down
17 changes: 8 additions & 9 deletions src/GEOReverse/Modules/XMLinput.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import math
import os
import sys
import re
import xml.etree.ElementTree as ET

import FreeCAD
from GEOReverse.Modules.remh import cell_card_string, remove_hash
from GEOReverse.Modules.Objects import *
from GEOReverse.Modules.XMLParser import get_cards
import math
import numpy as np
from numpy import linalg as LA
import xml.etree.ElementTree as ET

from .Objects import *
from .XMLParser import get_cards


class XMLinput:
def __init__(self,name):
if not os.path.isfile(name):
print("File %s does not exist" %name)
sys.exit()
return
raise FileNotFoundError(f"File {name} does not exist")

tree = ET.parse(name)
root = tree.getroot()
Expand Down
6 changes: 2 additions & 4 deletions src/GEOReverse/Modules/buildCAD.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import FreeCAD, Part
import BOPTools.SplitAPI
from GEOReverse.Modules.buildSolidCell import FuseSolid
from GEOReverse.Modules.Utils.BooleanSolids import buildCTableFromSolids
from GEOReverse.Modules.Utils.booleanFunction import BoolSequence

from .buildSolidCell import FuseSolid
from .Utils.booleanFunction import BoolSequence


def buildCAD(UnivCell,data,config):
Expand Down
14 changes: 5 additions & 9 deletions src/GEOReverse/Modules/buildSolidCell.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import FreeCAD, Part
import BOPTools.SplitAPI
from BOPTools import GeneralFuseResult as GFR
from GEOReverse.Modules.Utils.booleanFunction import BoolSequence
from GEOReverse.Modules.splitFunction import SplitSolid,splitBase,joinBase
from GEOReverse.Modules.Utils.BooleanSolids import buildCTableFromSolids
from GEOReverse.Modules.options import Options

import math
import Part

from .options import Options
from .splitFunction import SplitSolid, joinBase, splitBase
from .Utils.booleanFunction import BoolSequence


def getPart(slist):
Expand Down
Loading