2929from microstructpy import seeding
3030from microstructpy import verification
3131from microstructpy .meshing import PolyMesh
32+ from microstructpy .meshing import RasterMesh
3233from microstructpy .meshing import TriMesh
3334from microstructpy .meshing .trimesh import facet_check
3435
@@ -301,7 +302,8 @@ def run(phases, domain, verbose=False, restart=True, directory='.',
301302 edge_opt_n_iter (int): *(optional)* Maximum number of iterations per
302303 edge during optimization. Ignored if `edge_opt` set to False.
303304 Defaults to 100.
304- mesher (str): {'Triangle/TetGen' | 'Triangle' | 'TetGen' | 'gmsh'}
305+ mesher (str): {'raster' | 'Triangle/TetGen' | 'Triangle' | 'TetGen' |
306+ 'gmsh'}
305307 specify the mesh generator. Default is 'Triangle/TetGen'.
306308 mesh_max_volume (float): *(optional)* The maximum volume (area in 2D)
307309 of a mesh cell in the triangular mesh. Default is infinity,
@@ -491,28 +493,41 @@ def run(phases, domain, verbose=False, restart=True, directory='.',
491493 # ----------------------------------------------------------------------- #
492494 # Create Triangular Mesh #
493495 # ----------------------------------------------------------------------- #
494- tri_basename = 'trimesh.txt'
496+ raster = mesher == 'raster'
497+ if raster :
498+ tri_basename = 'rastermesh.txt'
499+ else :
500+ tri_basename = 'trimesh.txt'
495501 tri_filename = os .path .join (directory , tri_basename )
496502 exts = {'abaqus' : '.inp' , 'txt' : '.txt' , 'str' : '.txt' , 'tet/tri' : '' ,
497503 'vtk' : '.vtk' }
498504
499505 if restart and os .path .exists (tri_filename ) and not poly_created :
500506 # Read triangle mesh
501507 if verbose :
502- print ('Reading triangular mesh.' )
503- print ('Triangular mesh filename: ' + tri_filename )
508+ if raster :
509+ print ('Reading raster mesh.' )
510+ else :
511+ print ('Reading triangular mesh.' )
512+ print ('Mesh filename: ' + tri_filename )
504513
505514 tmesh = TriMesh .from_file (tri_filename )
506515 tri_created = False
507516 else :
508517 tri_created = True
509518 # Create triangular mesh
510519 if verbose :
511- print ('Creating triangular mesh.' )
520+ if raster :
521+ print ('Creating raster mesh.' )
522+ else :
523+ print ('Creating triangular mesh.' )
512524
513- tmesh = TriMesh .from_polymesh (pmesh , phases , mesher , mesh_min_angle ,
514- mesh_max_volume , mesh_max_edge_length ,
515- mesh_size )
525+ if raster :
526+ tmesh = RasterMesh .from_polymesh (pmesh , mesh_size , phases )
527+ else :
528+ tmesh = TriMesh .from_polymesh (pmesh , phases , mesher ,
529+ mesh_min_angle , mesh_max_volume ,
530+ mesh_max_edge_length , mesh_size )
516531
517532 # Write triangular mesh
518533 tri_types = filetypes .get ('tri' , [])
@@ -535,12 +550,19 @@ def run(phases, domain, verbose=False, restart=True, directory='.',
535550
536551 plot_files = []
537552 for ext in plot_types :
538- fname = os .path .join (directory , 'trimesh.' + str (ext ))
553+ if raster :
554+ bname = 'rastermesh'
555+ else :
556+ bname = 'trimesh'
557+ fname = os .path .join (directory , bname + '.' + str (ext ))
539558 if tri_created or not os .path .exists (fname ):
540559 plot_files .append (fname )
541560
542561 if plot_files and verbose :
543- print ('Plotting triangular mesh.' )
562+ if raster :
563+ print ('Plotting raster mesh.' )
564+ else :
565+ print ('Plotting triangular mesh.' )
544566
545567 if plot_files :
546568 plot_tri (tmesh , phases , seeds , pmesh , plot_files , plot_axes , color_by ,
0 commit comments