Tuesday, August 11, 2009

SG_Dee: Chebyshev sparse grid method for elliptic equations (Dirichlet)


Purpose
  • "SG_Dee" provides an example of using the spectral sparge grid to solve elliptic equations with the homogeneous Dirichlet boundary condition in high dimensional cubes. The equation is discretized with a Chebyshev-Galerkin method, i.e., the sparse grid is in the frequency space (hyperbolic cross). The resultant linear system is solved with the bicgstab method.

Specifications
  • Name: SG_Dee.
  • Author: Feng Chen.
  • Finishing date: 08/11/2009.
  • Language: Fortran 90.
  • Required libraries: Template.

Simple Example
  • Equation: \begin{equation} \begin{aligned} &\alpha u - \beta \Delta u = f, &&\quad \text{in } \Omega, \\ &u = 0, && \quad \text{on } \partial \Omega. \end{aligned} \end{equation}
  • Parameters: \begin{equation} \Omega = (-1,1)^d,\quad d=5, \quad \alpha =2, \quad \beta=3. \end{equation}
  • Exact solution and input functions: \begin{equation} u(\boldsymbol{x}) = \Pi_{i=1}^d (e^{\cos\frac{\pi x_i}{2}}-1), \end{equation} then $f(\boldsymbol{x})$ is calculated accordingly.

Quick Start
  • Compiling and running:
    cd ./SG_Dee
    make library
    gfortran tst_SG_Dee.f90 -llibrary -ltemplate
    ./a.out
    
  • Output:
     
     dimension =           5
     dof =       61183
     max dof in 1-D =         255
     the max error is:  7.64327293492073068E-004
    ...
    
  • CPU: Intel(R) Xeon(R) CPU X5550 @2.67GHz.
  • OS: CentOS release 6.4 (Final).
  • Compiler: gfortran 4.5.1.

References
Code Highlights
    
    
    ! scheme_phi_cheb2 transforms bases like phi_{k} = T_{k+2} - T_{k}
    ! to bases in Cheb2 Structure, in the 1 dimension case.
    ! -----------------------------------------------------------------
      subroutine scheme_phi_cheb2(IS, PanelLv, nop, cin, cout)
        type(InterpScheme), intent(in) :: IS
        integer, intent(in) :: PanelLv, nop
        real(dp), intent(in), dimension(:) :: cin
        real(dp), intent(out), dimension(:) :: cout
        real(dp), dimension(:), allocatable :: cwork
        integer :: i, ks, ke, PanelLen
        PanelLen = IS%m(PanelLv)
        allocate(cwork(PanelLen+2))
    
        do i = 1, nop
           ks = (i-1)*PanelLen + 1
           ke = i*PanelLen
           cwork(1:PanelLen) = cin(ks:ke)
           cwork(PanelLen+1:PanelLen+2) = 0d0
           cout(ks:ke) = cwork(3:PanelLen+2) - cin(ks:ke)
        end do
    
        deallocate(cwork)
      end subroutine scheme_phi_cheb2
    
    
    

No comments:

Post a Comment