Esempio n. 1
0
 # define the smoother from the split smoother class on each level,
 # where the last level is solved directly
 # omega = 1/np.sqrt(2)
 omega = 0.5
 l_plus = np.asarray([0, -2.0/omega, 0])
 l_minus = np.asarray([1.0, -2.0*(1.0 - 1.0/omega), 1.0])
 top_jacobi_smoother = SplitSmoother(l_plus / top_level.h**2,
                                     l_minus / top_level.h**2,
                                     top_level)
 mid_jacobi_smoother = SplitSmoother(l_plus / mid_level.h**2,
                                     l_minus / mid_level.h**2,
                                     mid_level)
 low_jacobi_smoother = SplitSmoother(l_plus / low_level.h**2,
                                     l_minus / low_level.h**2,
                                     low_level)
 low_direct_smoother = DirectSolverSmoother(laplace_stencil, low_level)
 # time to test the relaxation methods
 print("===== DirectSolverSmoother Test =====")
 low_level.rhs[:] = 0.0
 low_level.pad()
 print("arr:", low_level.arr)
 laplace_stencil.modify_rhs(low_level)
 print("rhs:", low_level.rhs)
 low_direct_smoother.relax()
 print(low_level.arr)
 low_level.pad()
 # Lets test the SplitSmoother by using the jacobi smoother
 # but for this case we need an initial guess
 print("===== JacobiSmoother Test =====")
 # define the 3 different JacobiSmoother Implementations
 jacobi_loop = WeightedJacobiSmoother(laplace_stencil,
Esempio n. 2
0
    mid_jacobi_smoother = SplitSmoother(l_plus / mid_level.h**2,
                                        l_minus / mid_level.h**2,
                                        mid_level)
    low_jacobi_smoother = SplitSmoother(l_plus / low_level.h**2,
                                        l_minus / low_level.h**2,
                                        low_level)


    top_stencil = Stencil(laplace_array / top_level.h**2)
    mid_stencil = Stencil(laplace_array / mid_level.h**2)
    low_stencil = Stencil(laplace_array / low_level.h**2)

    print("jacobi minus: %s" % top_stencil.l_minus_jacobi(1.))
    print("jacobi plus: %s" % top_stencil.l_plus_jacobi(1.))

    low_direct_smoother = DirectSolverSmoother(low_stencil, low_level)
    center = np.asarray([0])

    # restriction
    rst_stencil = Stencil(np.asarray([0.25, 0.5, 0.25]))
    rst_top_to_mid = RestrictionByStencilForLevelsClassical(top_level, mid_level, rst_stencil)
    rst_mid_to_low = RestrictionByStencilForLevelsClassical(mid_level, low_level, rst_stencil)

    # ipl
    ipl_stencil_list_standard = [(Stencil(np.asarray([1]), center), (1,)),
                                   (Stencil(np.asarray([0.5, 0.5]), center), (0,))]

    ipl_mid_to_top = InterpolationByStencilForLevelsClassical(mid_level, top_level, ipl_stencil_list_standard,
                                                              pre_assign=iadd)

    ipl_low_to_mid = InterpolationByStencilForLevelsClassical(low_level, mid_level, ipl_stencil_list_standard,