DOUG 0.2

ConvInf.F90

Go to the documentation of this file.
00001 ! DOUG - Domain decomposition On Unstructured Grids
00002 ! Copyright (C) 1998-2006 Faculty of Computer Science, University of Tartu and
00003 ! Department of Mathematics, University of Bath
00004 !
00005 ! This library is free software; you can redistribute it and/or
00006 ! modify it under the terms of the GNU Lesser General Public
00007 ! License as published by the Free Software Foundation; either
00008 ! version 2.1 of the License, or (at your option) any later version.
00009 !
00010 ! This library is distributed in the hope that it will be useful,
00011 ! but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 ! Lesser General Public License for more details.
00014 !
00015 ! You should have received a copy of the GNU Lesser General Public
00016 ! License along with this library; if not, write to the Free Software
00017 ! Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00018 ! or contact the authors (University of Tartu, Faculty of Computer Science, Chair
00019 ! of Distributed Systems, Liivi 2, 50409 Tartu, Estonia, http://dougdevel.org,
00020 ! mailto:info(at)dougdevel.org)
00021 
00022 !----------------------------------
00025 module ConvInf_mod
00026 
00027   use RealKind
00028 
00029   implicit none
00030   
00031 #include<doug_config.h>
00032 
00033 #ifdef D_COMPLEX
00034 #define float complex
00035 #else
00036 #define float real
00037 #endif
00038 
00039   integer, parameter :: D_SOLVE_CONV_UNDEF      = -1 !< Undefined
00040   integer, parameter :: D_SOLVE_CONV_CONV       =  0 !< Method converged
00041   integer, parameter :: D_SOLVE_CONV_NOTCONV    =  1 !< Method didn't converge
00042   integer, parameter :: D_SOLVE_CONV_ILLPRECOND =  2 !< Preconditioner was ill-conditioned
00043   integer, parameter :: D_SOLVE_CONV_STAGN      =  3 !< Method stagnated
00044   
00046   type ConvInf
00050      integer :: flag  = D_SOLVE_CONV_UNDEF
00051      ! Residual
00052      float(kind=rk) :: residual   = 1.0e+10
00053      ! Number of performed interatoins
00054      integer        :: iterations = -1
00055      ! Vector of the relative residuals at each iteration
00056      float(kind=rk), dimension(:), pointer :: relres => NULL()
00057      ! Vector of the residuals at each iteration
00058      float(kind=rk), dimension(:), pointer :: res => NULL()
00059   end type ConvInf
00060 
00061 contains
00062 
00063   !
00064   !
00065   !
00066   subroutine ConvInf_Init(inf, maxit)
00067     implicit none
00068     
00069     type(ConvInf), intent(in out) :: inf
00070     integer, intent(in), optional  :: maxit
00071 
00072     inf%flag = D_SOLVE_CONV_UNDEF
00073     inf%residual = 1.0e+10
00074     inf%iterations = 0
00075     
00076     if (present(maxit)) then
00077        allocate(inf%relres(maxit))
00078        allocate(inf%res(maxit))
00079     end if
00080   end subroutine ConvInf_Init
00081 
00082 
00083   !
00084   !
00085   !
00086   subroutine ConvInf_Destroy(inf)
00087     implicit none
00088     
00089     type(ConvInf), intent(in out) :: inf
00090     
00091     if (associated(inf%relres)) deallocate(inf%relres)
00092     if (associated(inf%res))    deallocate(inf%res)
00093 
00094     inf%flag = D_SOLVE_CONV_UNDEF
00095     inf%residual = 1.0e+10
00096     inf%iterations = -1    
00097 
00098   end subroutine ConvInf_Destroy
00099 
00100 
00101 end module ConvInf_mod