Skip to content

Commit

Permalink
Merge pull request #7 from openmc-dev/opt
Browse files Browse the repository at this point in the history
Optimize journal file
  • Loading branch information
pshriwise authored Oct 24, 2024
2 parents eef99de + 0cfa906 commit 91c7cac
Show file tree
Hide file tree
Showing 17 changed files with 219 additions and 20 deletions.
31 changes: 23 additions & 8 deletions src/openmc_cad_adapter/to_cubit_journal.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,6 @@ def to_cubit_journal(geometry : openmc.Geometry, world : Iterable[Real] = None,

cmds = []
cmds.extend( [
"set graphics off",
"set journal off",
#"set undo off",
#"set default autosizing off", # especially when the CAD is complex (contains many spline surfaces) this can have a massive effect
#"set info off",
Expand Down Expand Up @@ -538,9 +536,7 @@ def do_cell(cell, cell_ids: Iterable[int] = None):
cell_filename = filename[:-4] + f"_cell{cell.id}.jou"
else:
cell_filename = filename + f"_cell{cell.id}"
with open(cell_filename, "w" ) as f:
for x in cmds[before:after]:
f.write( x + "\n" )
write_journal_file(cell_filename, cmds[before:after])

for cell in geom.root_universe._cells.values():
if cells is not None and cell.id in cells:
Expand All @@ -549,9 +545,7 @@ def do_cell(cell, cell_ids: Iterable[int] = None):
do_cell( cell )

if filename:
with open( filename, "w" ) as f:
for x in cmds:
f.write( x + "\n" )
write_journal_file(filename, cmds)

if to_cubit:
cubit.cmd( "reset" )
Expand All @@ -560,6 +554,27 @@ def do_cell(cell, cell_ids: Iterable[int] = None):
cubit.cmd(f"save as {filename[:-4]}.cub overwrite")


def write_journal_file(filename, cmds, verbose_journal=False):
with open(filename, "w") as f:
if not verbose_journal:
f.write("set echo off\n")
f.write("set info off\n")
f.write("set warning off\n")
f.write("graphics pause\n")
f.write("set journal off\n")
f.write("set default autosize off\n")
for x in cmds:
f.write(x + "\n")
if not verbose_journal:
f.write("graphics flush\n")
f.write("set default autosize on\n")
f.write("zoom reset\n")
f.write("set echo on\n")
f.write("set info on\n")
f.write("set warning on\n")
f.write("set journal on\n")


def material_assignment(cell, geom_id, assignment_type='group'):
if cell.fill is None:
mat_identifier = "mat:void"
Expand Down
13 changes: 12 additions & 1 deletion test/gold/assembly.jou
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 7
cylinder height 500 radius 0.39218
#{ id1 = Id("body") }
Expand Down Expand Up @@ -8093,3 +8097,10 @@ brick x 1.26 y 1.26 z 500
subtract body { id3178 } from body { id3179 }
body { id3179 } name "Cell_3"
move body { id3179 } midpoint location 10.08 10.08 0 except z
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/cylinder.jou
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 3
cylinder height 500 radius 6.0
#{ id1 = Id("body") }
body { id1 } rotate 90.0 about Y
body { id1 } rotate 45.0 about Z
body { id1 } name "Cell_3"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/lattice-hexagonal.jou
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 1
create prism height 2.0 sides 6 radius 0.5
#{ id1 = Id("body") }
Expand Down Expand Up @@ -643,3 +647,10 @@ rotate body { id159 } about z angle 30
subtract body { id158 } from body { id159 }
body { id159 } name "cell 6"
move body { id159 } midpoint location 0.0 0.0 4.0
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/pincell.jou
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 1
cylinder height 500 radius 0.39218
#{ id1 = Id("body") }
Expand Down Expand Up @@ -69,3 +73,10 @@ intersect body { id27 } { id28 }
#{id31 = ( id29 == id30 ) ? id28 : id30}
body { id31 } name "Cell_4"
group "mat:Borated water" add body { id31 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 13 additions & 0 deletions test/gold/pincell_cell1.jou
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 1
cylinder height 500 radius 0.39218
#{ id1 = Id("body") }
body { id1 } name "Cell_1"
group "mat:UO2 fuel at 2.4% wt enrichme" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 13 additions & 0 deletions test/gold/pincell_cell2.jou
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 2
cylinder height 500 radius 0.39218
#{ id2 = Id("body") }
Expand All @@ -12,3 +18,10 @@ intersect body { id3 } { id4 }
#{id7 = ( id5 == id6 ) ? id4 : id6}
body { id7 } name "Cell_2"
group "mat:Helium for gap" add body { id7 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 13 additions & 0 deletions test/gold/pincell_cell3.jou
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 3
cylinder height 500 radius 0.40005
#{ id8 = Id("body") }
Expand All @@ -12,3 +18,10 @@ intersect body { id9 } { id10 }
#{id13 = ( id11 == id12 ) ? id10 : id12}
body { id13 } name "Cell_3"
group "mat:Zircaloy 4" add body { id13 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 13 additions & 0 deletions test/gold/pincell_cell4.jou
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 4
cylinder height 500 radius 0.4572
#{ id14 = Id("body") }
Expand Down Expand Up @@ -34,3 +40,10 @@ intersect body { id27 } { id28 }
#{id31 = ( id29 == id30 ) ? id28 : id30}
body { id31 } name "Cell_4"
group "mat:Borated water" add body { id31 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/x_cone.jou
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 4
create frustum height 500 radius 50.0 top 0
#{ id1 = Id("body") }
rotate body { id1 } about y angle 90
body { id1 } move 30.0 3.0 5.0
body { id1 } name "Cell_4"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/x_torus.jou
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 7
torus major radius 5.0 minor radius 2.0
#{ id1 = Id("body") }
rotate body { id1 } about y angle 90
body { id1 } move 10.0 10.0 10.0
body { id1 } name "Cell_7"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/xcylinder.jou
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 1
cylinder height 500 radius 1.0
#{ id1 = Id("body") }
rotate body { id1 } about y angle 90
body { id1 } move 0 10.0 5.0
body { id1 } name "Cell_1"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/y_cone.jou
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 5
create frustum height 500 radius 31.622776601683793 top 0
#{ id1 = Id("body") }
rotate body { id1 } about x angle 90
body { id1 } move 40.0 20.0 7.0
body { id1 } name "Cell_5"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/y_torus.jou
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 8
torus major radius 5.0 minor radius 2.0
#{ id1 = Id("body") }
rotate body { id1 } about x angle 90
body { id1 } move -10.0 -10.0 -10.0
body { id1 } name "Cell_8"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/ycylinder.jou
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 2
cylinder height 500 radius 1.0
#{ id1 = Id("body") }
rotate body { id1 } about x angle 90
body { id1 } move 10.0 0 5.0
body { id1 } name "Cell_2"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
13 changes: 12 additions & 1 deletion test/gold/z_cone.jou
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
set graphics off
set echo off
set info off
set warning off
graphics pause
set journal off
set default autosize off
#CELL 6
create frustum height 500 radius 22.360679774997898 top 0
#{ id1 = Id("body") }
body { id1 } move 50.0 10.0 2.0
body { id1 } name "Cell_6"
group "mat:void" add body { id1 }
graphics flush
set default autosize on
zoom reset
set echo on
set info on
set warning on
set journal on
Loading

0 comments on commit 91c7cac

Please sign in to comment.