コード例 #1
0
ファイル: test.py プロジェクト: dbstein/pykifmm2d
    reference_eval = np.zeros(N_total, dtype=float)
    Kernel_Self_Apply(px, py, tau, reference_eval)
    time_direct_eval = (time.time() - st) * 1000
    print('\nDirect evaluation took:        {:0.1f}'.format(time_direct_eval))
# by FMMLIB2D, if available
try:
    source = np.row_stack([px, py])
    st = time.time()
    if problem == 'Laplace':
        out = pyfmmlib2d.RFMM(source,
                              charge=tau,
                              compute_source_potential=True)
        reference_eval = -out['source']['u'] / (2 * np.pi)
    elif problem == 'Modified Helmholtz':
        out = pyfmmlib2d.HFMM(source,
                              charge=tau,
                              compute_source_potential=True,
                              helmholtz_parameter=1j * helmholtz_k)
        reference_eval = out['source']['u'] * 2 * np.pi
    elif problem == 'Biharmonic':
        out = pyfmmlib2d.BFMM(source,
                              charge=tau.astype(complex),
                              compute_source_velocity=True)
    else:
        raise Exception('No FMMLIB function provided.')
    et = time.time()
    time_fmmlib_eval = (et - st) * 1000
    print('FMMLIB evaluation took:        {:0.1f}'.format(time_fmmlib_eval))
except:
    pass
try:
    reference_eval
コード例 #2
0
         time_self_eval))
     print('Direct target evaluation took:      {:0.1f}'.format(
         time_target_eval))
 else:
     # by FMMLIB2D, if available
     try:
         import pyfmmlib2d
         source = np.row_stack([px, py])
         target = np.row_stack([rx, ry])
         dumb_targ = np.row_stack(
             [np.array([0.6, 0.6]),
              np.array([0.5, 0.5])])
         st = time.time()
         out = pyfmmlib2d.HFMM(source,
                               dumb_targ,
                               charge=tau,
                               compute_target_potential=True,
                               precision=reference_precision,
                               helmholtz_parameter=1j * helmholtz_k)
         tform = time.time() - st
         print('FMMLIB generation took:               {:0.1f}'.format(
             tform * 1000))
         print('...Points/Second/Core (thousands)    \033[1m',
               int(N_source / tform / cpu_num / 1000), '\033[0m ')
         st = time.time()
         out = pyfmmlib2d.HFMM(source,
                               charge=tau,
                               compute_source_potential=True,
                               precision=reference_precision,
                               helmholtz_parameter=1j * helmholtz_k)
         self_reference_eval_u = out['source']['u'].real
         tt = time.time() - st - tform
コード例 #3
0
ファイル: hankel.py プロジェクト: dbstein/pykifmm2d
     time_self_eval = (time.time() - st)*1000
     st = time.time()
     target_reference_eval = np.zeros(N_target, dtype=complex)
     KA(px, py, rx, ry, tau, out=target_reference_eval)
     time_target_eval = (time.time() - st)*1000
     print('\nDirect self evaluation took:        {:0.1f}'.format(time_self_eval))
     print('Direct target evaluation took:      {:0.1f}'.format(time_target_eval))
 else:
     # by FMMLIB2D, if available
     try:
         import pyfmmlib2d
         source = np.row_stack([px, py])
         target = np.row_stack([rx, ry])
         dumb_targ = np.row_stack([np.array([0.6, 0.6]), np.array([0.5, 0.5])])
         st = time.time()
         out = pyfmmlib2d.HFMM(source, dumb_targ, charge=tau, compute_target_potential=True, helmholtz_parameter=helmholtz_k)
         tform = time.time() - st
         print('FMMLIB generation took:               {:0.1f}'.format(tform*1000))
         print('...Points/Second/Core (thousands)    \033[1m', int(N_source/tform/cpu_num/1000), '\033[0m ')
         st = time.time()
         out = pyfmmlib2d.HFMM(source, charge=tau, compute_source_potential=True, helmholtz_parameter=helmholtz_k)
         self_reference_eval = out['source']['u']
         tt = time.time() - st - tform
         print('FMMLIB self only eval took:           {:0.1f}'.format(tt*1000))
         print('...Points/Second/Core (thousands)    \033[1m', int(N_source/tt/cpu_num/1000), '\033[0m ')
         st = time.time()
         out = pyfmmlib2d.HFMM(source, target, charge=tau, compute_target_potential=True, helmholtz_parameter=helmholtz_k)
         target_reference_eval = out['target']['u']
         tt = time.time() - st - tform
         print('FMMLIB target only eval took:         {:0.1f}'.format(tt*1000))
         print('...Points/Second/Core (thousands)    \033[1m', int(N_target/tt/cpu_num/1000), '\033[0m ')