def apm_parallel_mesh_generation(): r""" Processes the command line arguments and generates the mesh """ # namespace = parser.parse_args() if namespace.verbose: set_main_logger_level('debug') # # initial mesh parameters mesh_params = { 'convertToMeters': '2.680E-5', 'numbersOfCells': '(1 1 1)', # 'boundary.left.type': 'wall', 'boundary.right.type': 'wall', 'boundary.top.type': 'wall', 'boundary.bottom.type': 'wall', 'boundary.front.type': 'wall', 'boundary.back.type': 'wall' } # # reading params file if supplied if namespace.read_file: logger.info('Reading parameters file...') read_params_file(namespace.read_file, mesh_params) # # creating data field from aperture map logger.info('Processing aperture map...') map_field = DataField(namespace.map_file) # # reading offset file if provided offset_field = None if namespace.offset_file: offset_field = DataField(namespace.offset_file) # # setting up mesh generator system_dir = os.path.join(namespace.system_path,'system') np = namespace.np kwargs = {'nprocs': np, 'avg_fact': namespace.avg_fact, 'mesh_params': mesh_params, 'offset_field': offset_field} # logger.info('Setting generator up...') pmg = ParallelMeshGen(map_field, system_dir, **kwargs) # # creating the mesh logger.info('Creating the mesh...') pmg.generate_mesh(namespace.mesh_type, path=namespace.output_dir, overwrite=namespace.force) # # moving mesh files out of region directory out_path = namespace.output_dir reg_dir = os.path.join(out_path, 'mesh-region0', '*') if namespace.force: os.system('cp -ralf {} {}'.format(reg_dir, out_path)) os.system('rm -rf {}'.format(os.path.join(out_path, 'mesh-region0'))) else: os.system('mv {} {}'.format(reg_dir, out_path)) os.system('rmdir {}'.format(os.path.join(out_path, 'mesh-region0')))