def get(self): app.logger.info('apiDomainList') l = db.get('cache-domain-list') if l is None: domainList = Domains(cfg.dataPath, cfg.domainPath, cfg.domains) l = domainList.keys() db.set('cache-domain-list', json.dumps(l)) else: l = json.loads(l) return l
def load_domains(path): '''Load domains from a domains.yaml. If domains.yaml is not found, then a single 'app' domain referring to the top-level build folder is created and returned. ''' domains_file = Path(path) / 'domains.yaml' if not domains_file.is_file(): return Domains.from_data({'default': 'app', 'build_dir': path, 'domains': [{'name': 'app', 'build_dir': path}]}) return Domains.from_file(domains_file)
def __init__(self, kRef, meshname, doms, J_is='BlockedDiscrete'): if isinstance(doms, list): domains = Domains(doms) elif isinstance(doms, Domains): domains = doms else: raise TypeError( 'configuration needs to be a list or a Domains class') self._collected = False self._assembled = False self._A_assembled = False self._X_assembled = False self._J_assembled = False self._iJ_assembled = False self._J_is = J_is self.domains = domains self.N = len(domains) print('==Importing Grid/Mesh', end=' ', flush=True) self.grid = grid = bem.import_grid(meshname) print('done.', flush=True) N = self.N self.opA = bem.BlockedOperator(N, N) self.opX = bem.BlockedOperator(N, N) self.opI = bem.BlockedOperator(N, N) if np.abs(kRef) <= 0.0: kernel = 'lapl' self.kRef = 0.0 dtype = np.float else: kernel = 'helm' self.kRef = kRef #float(kRef) dtype = np.complex self.kernel = kernel if dtype is None: if kernel == 'helm': dtype = np.complex else: dtype = np.float self.dtype = dtype if kernel == 'helm': funEFIE = lambda trial, ran, test, k: bem.operators.boundary.maxwell.electric_field( trial, ran, test, k) funMFIE = lambda trial, ran, test, k: bem.operators.boundary.maxwell.magnetic_field( trial, ran, test, k) self._funEFIE = funEFIE self._funMFIE = funMFIE self._funI = bem.operators.boundary.sparse.maxwell_identity
conf = sanitize_config(init_offset=truefalse, tag=i+1, kRef=kRef, rad=rads[i], phys=phys[i], center=centers[i], ) dgen = generate_concentric_dict(conf) cmds = write_params_geo(conf) call(cmds) dgens.append(dgen) doms = merge_msh_bubbles(dgens) myd = Domains(doms) myd.write2dot('graph.dot') call(['dot', '-Teps', 'graph.dot'], stdout=open('graph.eps', 'wb')) dd = myd print(N) ################################## meshname = "./geo/all.msh" mtf = MultiTrace(kRef, meshname, dd) At, X, J, iJ = mtf.tolinop()
if "start.bg" in href and "javascript:" not in href: inbound.add(href) elif "link.php" in href: outbound.add(href) else: others.add(href) return { "inbound": inbound, "outbound": outbound, "others": others } while True: domains_to_visit = Domains.get_all_unvisited_domains(conn) if len(domains_to_visit) == 0: break for domain_row in domains_to_visit: result = collect_domain(domain_row["domain"]) domain_id = domain_row["domain_id"] Domains.visit_domain(conn, domain_id) Domains.insert_domains(conn, result["inbound"]) Links.insert_links(conn, result["outbound"], domain_id) print("Sleeping for 20 seconds ZzZzz") time.sleep(20)
def __init__(self, kRef, meshname, doms, J_is='BlockedDiscrete', X_is='BlockedDiscrete', use_slp=True): if isinstance(doms, list): domains = Domains(doms) elif isinstance(doms, Domains): domains = doms else: raise TypeError( 'configuration needs to be a list or a Domains class') self._collected = False self._assembled = False self._A_assembled = False self._X_assembled = False self._J_assembled = False self._iJ_assembled = False if not J_is in ['BlockedDiscrete', 'CSC', 'Blocked']: warnings.warn('{0} is not supported. Default used {1}'.format( J_is, 'BlockedDiscrete')) J_is = 'BlockedDiscrete' self._J_is = J_is if not X_is in ['BlockedDiscrete', 'Blocked']: warnings.warn('{0} is not supported. Default used {1}'.format( J_is, 'BlockedDiscrete')) X_is = 'BlockedDiscrete' self._X_is = X_is self.use_slp = use_slp print('==J_is: {0} , X_is: {1} , use_slp={2}'.format( J_is, X_is, use_slp)) self.domains = domains self.N = len(domains) print('==Importing Grid/Mesh {}'.format(meshname), end=' ', flush=True) self.grid = grid = bem.import_grid(meshname) print('done.', flush=True) N = self.N self.opA = bem.BlockedOperator(N, N) self.opX = bem.BlockedOperator(N, N) self.opI = bem.BlockedOperator(N, N) if np.abs(kRef) == 0.0: kernel = 'lapl' self.kRef = 0.0 dtype = np.float else: kernel = 'helm' self.kRef = kRef #float(kRef) dtype = np.complex self.kernel = kernel if not dtype is None: if kernel == 'helm': if dtype != np.complex: warnings.warn('Helmholtz is complex. dtype={}'.format( np.complex)) dtype = np.complex else: if dtype != np.float: warnings.warn('Unsupported dtype. Converted to {}'.format( np.float)) dtype = np.float self.dtype = dtype if kernel == 'helm': funK = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.double_layer( trial, ran, test, k) funV = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.single_layer( trial, ran, test, k) funQ = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.adjoint_double_layer( trial, ran, test, k) funW = lambda trial, ran, test, k: bem.operators.boundary.helmholtz.hypersingular( trial, ran, test, k, use_slp=use_slp) else: funK = lambda trial, ran, test, k: bem.operators.boundary.laplace.double_layer( trial, ran, test) funV = lambda trial, ran, test, k: bem.operators.boundary.laplace.single_layer( trial, ran, test) funQ = lambda trial, ran, test, k: bem.operators.boundary.laplace.adjoint_double_layer( trial, ran, test) funW = lambda trial, ran, test, k: bem.operators.boundary.laplace.hypersingular( trial, ran, test, use_slp=use_slp) self._funK, self._funV = funK, funV self._funW, self._funQ = funW, funQ self._funI = bem.operators.boundary.sparse.identity self.spaces = [(('test_d', 'trial_d'), ('test_n', 'trial_n')) for d in domains]
return cfg if __name__ == '__main__': import argparse parser = argparse.ArgumentParser() parser.add_argument('--config', default='./indie-stats.cfg') parser.add_argument('--echo', default=True, action='store_true') parser.add_argument('--seed' , default=False, action='store_true') parser.add_argument('--refresh', default=False, action='store_true') args = parser.parse_args() cfg = loadConfig(args.config) initLogging(log, cfg['dataPath'], args.echo) log.info('starting') domains = Domains(cfg['dataPath'], cfg['domainPath'], cfg['domains']) log.info('%d domains loaded from datastore' % len(domains)) if args.seed: gather(cfg, domains) if args.refresh: refresh(cfg, domains) domains.store()
for link in soup.find_all("a"): href = link.get("href") if href is None: continue if "start.bg" in href and "javascript:" not in href: inbound.add(href) elif "link.php" in href: outbound.add(href) else: others.add(href) return {"inbound": inbound, "outbound": outbound, "others": others} while True: domains_to_visit = Domains.get_all_unvisited_domains(conn) if len(domains_to_visit) == 0: break for domain_row in domains_to_visit: result = collect_domain(domain_row["domain"]) domain_id = domain_row["domain_id"] Domains.visit_domain(conn, domain_id) Domains.insert_domains(conn, result["inbound"]) Links.insert_links(conn, result["outbound"], domain_id)