Skip to content

Commit

Permalink
Adding commands to the journal file to optimize import and reduce gra…
Browse files Browse the repository at this point in the history
…phics noise
  • Loading branch information
pshriwise committed Oct 24, 2024
1 parent dd41ae0 commit b199d80
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 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,28 @@ 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

0 comments on commit b199d80

Please sign in to comment.