def refine(opts, nlev, mesh=None): """ REFINE generate a mesh using an inc. bisection strategy. """ if (not isinstance(opts, jigsaw_jig_t)): raise Exception("Incorrect type: OPTS.") if (mesh is not None and not isinstance(mesh, jigsaw_msh_t)): raise Exception("Incorrect type: MESH.") #---------------------------- call JIGSAW via inc. bisection opts.mesh_iter = +0 opts.optm_div_ = False opts.optm_zip_ = False for ilev in reversed(range(nlev + 1)): if (opts.optm_dual is not None): #------------------------ create/write current DUAL data opts.optm_dual = ilev == 0 #------------------------ call JIGSAW kernel at this lev jigsaw(opts, mesh) if (ilev <= +0): break if (opts.mesh_file is not None): #------------------------ create/write current INIT data path = Path(opts.mesh_file).parent name = Path(opts.mesh_file).stem fext = Path(opts.mesh_file).suffix name = str(name) fext = str(fext) name = name + "-ITER" + fext opts.init_file = str(path / name) bisect(mesh) attach(mesh) savemsh(opts.init_file, mesh, opts.mesh_tags) return
def tetris(opts, nlev, mesh=None): """ TETRIS generate a mesh using an inc. bisection strategy. """ if (not isinstance(opts, jigsaw_jig_t)): raise Exception("Incorrect type: OPTS.") if (mesh is not None and not isinstance(mesh, jigsaw_msh_t)): raise Exception("Incorrect type: MESH.") #---------------------------- call JIGSAW via inc. bisection SCAL = +2.**nlev OPTS = copy.deepcopy(opts) flag = +1 while (nlev >= +0): if (opts.optm_qlim is not None): #------------------------ create/write current QLIM data scal = min(2.0, (nlev + 1)**(1. / 4.)) QLIM = opts.optm_qlim OPTS.optm_qlim = QLIM / scal else: scal = min(2.0, (nlev + 1)**(1. / 4.)) QLIM = 0.93750 OPTS.optm_qlim = QLIM / scal if (opts.optm_dual is not None): #------------------------ create/write current DUAL data OPTS.optm_dual = nlev == 0 if (opts.hfun_hmax is not None): #------------------------ create/write current HMAX data OPTS.hfun_hmax = \ opts.hfun_hmax * SCAL if (opts.hfun_hmin is not None): #------------------------ create/write current HMIN data OPTS.hfun_hmin = \ opts.hfun_hmin * SCAL if (opts.hfun_file is not None): #------------------------ create/write current HFUN data path = Path(opts.hfun_file).parent name = Path(opts.hfun_file).stem fext = Path(opts.hfun_file).suffix name = str(name) fext = str(fext) name = name + "-ITER" + fext OPTS.hfun_file = str(path / name) HFUN = jigsaw_msh_t() loadmsh(opts.hfun_file, HFUN) HFUN.value = HFUN.value * SCAL savemsh(OPTS.hfun_file, HFUN, OPTS.hfun_tags) if (nlev <= 1 or flag == 0): #------------------------ call JIGSAW kernel at this lev ninc = min(64, nlev**2) flag = +1 jitter(OPTS, 2 + ninc, 3, mesh) else: ninc = min(64, nlev**2) flag = +0 jitter(OPTS, 2 + ninc, 2, mesh) nlev = nlev - 1 SCAL = SCAL / 2. if (nlev < +0): break if (opts.init_file is not None): #------------------------ create/write current INIT data path = Path(opts.init_file).parent name = Path(opts.init_file).stem fext = Path(opts.init_file).suffix name = str(name) fext = str(fext) name = name + "-ITER" + fext OPTS.init_file = str(path / name) bisect(mesh) attach(mesh) savemsh(OPTS.init_file, mesh, OPTS.init_tags) else: #------------------------ create/write current INIT data path = Path(opts.mesh_file).parent name = Path(opts.mesh_file).stem fext = Path(opts.mesh_file).suffix name = str(name) fext = str(fext) name = name + "-ITER" + fext OPTS.init_file = str(path / name) bisect(mesh) attach(mesh) savemsh(OPTS.init_file, mesh, OPTS.mesh_tags) return
def tetris(opts, nlev, mesh=None): """ TETRIS generate a mesh using an inc. bisection strategy. """ if (not isinstance(opts, jigsaw_jig_t)): raise Exception("Incorrect type: OPTS.") if (mesh is not None and not isinstance(mesh, jigsaw_msh_t)): raise Exception("Incorrect type: MESH.") #---------------------------- call JIGSAW via inc. bisection SCAL = +2. ** nlev OPTS = copy.copy(opts) while (nlev >= +0): if (opts.optm_dual is not None): #------------------------ create/write current DUAL data OPTS.optm_dual = nlev == 0 if (opts.hfun_hmax is not None): #------------------------ create/write current HMAX data OPTS.hfun_hmax = \ opts.hfun_hmax * SCAL if (opts.hfun_hmin is not None): #------------------------ create/write current HMIN data OPTS.hfun_hmin = \ opts.hfun_hmin * SCAL if (opts.hfun_file is not None): #------------------------ create/write current HFUN data path = Path(opts.hfun_file).parent name = Path(opts.hfun_file).stem fext = Path(opts.hfun_file).suffix name = str(name) fext = str(fext) name = name + "-ITER" + fext OPTS.hfun_file = str(path / name) HFUN = jigsaw_msh_t() loadmsh(opts.hfun_file, HFUN) HFUN.value = HFUN.value * SCAL savemsh(OPTS.hfun_file, HFUN) #------------------------ call JIGSAW kernel at this lev if (nlev >= +1): njit = round( 3 * (nlev + 1) ** (+5. / 4.)) jitter(OPTS, njit, +1, mesh) else: njit = round( 3 * (nlev + 1) ** (+5. / 4.)) jitter(OPTS, njit, +1, mesh) nlev = nlev - 1 SCAL = SCAL / 2. if (nlev < +0): break if (opts.init_file is not None): #------------------------ create/write current INIT data path = Path(opts.init_file).parent name = Path(opts.init_file).stem fext = Path(opts.init_file).suffix name = str(name) fext = str(fext) name = name + "-ITER" + fext OPTS.init_file = str(path / name) bisect(mesh) attach(mesh) savemsh(OPTS.init_file, mesh) else: #------------------------ create/write current INIT data path = Path(opts.mesh_file).parent name = Path(opts.mesh_file).stem fext = Path(opts.mesh_file).suffix name = str(name) fext = str(fext) name = name + "-ITER" + fext OPTS.init_file = str(path / name) bisect(mesh) attach(mesh) savemsh(OPTS.init_file, mesh) return