def handle_mesh_materials(mesh, mcnp_geom, gen_mmgrid=False, mmgrid_rays=10, isscd=True): """Tag the mesh with materials Parameters ---------- mesh : ScdMesh or iMesh.Mesh() Mesh object to be tagged. mcnp_geom : string Filename/path for CAD geometry to be loaded into DAGMC from. gen_mmgrid : boolean Whether to generate a new macromaterials grid mmgrid_rays : integer Number of rays in each dimension to run mmgrid with isscd : boolean If True, handle geometry as a structured mesh. Otherwise mesh is assumed to be unstructured and materials are based on voxel centers. """ print "Loading geometry file `{0}'".format(mcnp_geom) mmgrid.load_geom(mcnp_geom) if not isscd: # is unstructured # Use non-structured mesh approach: tag material of voxel center points grid = mmgrid.SingleMatGrid(mesh) grid.generate() grid.create_tags() elif gen_mmgrid: # Do ray tracing to create macromaterials, if enabled. print "Will use {0} rays per mesh row".format(mmgrid_rays) grid = mmgrid.mmGrid(mesh) grid.generate(mmgrid_rays, False) grid.create_tags() else: # Materials should already exist, e.g. via mmgrid return
def handle_mesh_materials(mesh, mcnp_geom, gen_mmgrid=False, mmgrid_rays=10, isscd=True): """Tag the mesh with materials Parameters ---------- mesh : ScdMesh or iMesh.Mesh() Mesh object to be tagged. mcnp_geom : string Filename/path for CAD geometry to be loaded into DAGMC from. gen_mmgrid : boolean Whether to generate a new macromaterials grid mmgrid_rays : integer Number of rays in each dimension to run mmgrid with isscd : boolean If True, handle geometry as a structured mesh. Otherwise mesh is assumed to be unstructured and materials are based on voxel centers. """ print "Loading geometry file `{0}'".format(mcnp_geom) mmgrid.load_geom(mcnp_geom) if not isscd: # is unstructured # Use non-structured mesh approach: tag material of voxel center points grid = mmgrid.SingleMatGrid(mesh) grid.generate() grid.create_tags() elif gen_mmgrid: # Do ray tracing to create macromaterials, if enabled. print "Will use {0} rays per mesh row".format(mmgrid_rays) grid = mmgrid.mmGrid( mesh ) grid.generate( mmgrid_rays, False ) grid.create_tags() else: # Materials should already exist, e.g. via mmgrid return
if gen_mmgrid == False: print "Attempting to re-use existing ScdMesh file '{0}'".format(datafile) alt_sm = ScdMesh.fromFile(datafile) try: smesh = read_meshtal(meshtal_file, tally_lines[0], smesh=alt_sm) except ScdMeshError: print "ERROR:" print "Existing mesh in '{0}' does not match mesh in '{1}'. Set the " \ "'gen_mmgrid' option to True in your 'r2s.cfg' file.".format( \ datafile, meshtal_file) sys.exit() else: smesh = read_meshtal(meshtal_file, tally_lines[0]) print "Loading geometry file `{0}'".format(mcnp_geom) mmgrid.load_geom(mcnp_geom) # Do ray tracing to create macromaterials, if enabled. if gen_mmgrid: print "Will use {0} rays per mesh row".format(mmgrid_rays) grid = mmgrid.mmGrid( smesh ) grid.generate( mmgrid_rays, False ) grid.createTags() print "Saving fluxes and materials to `{0}'".format(datafile) smesh.imesh.save(datafile) if visfile != None: print "Producing visualization file `{0}' with mbconvert".format(visfile)