module solvers

! objetivo: resolver sistema linear

use variaveis

contains

!-------------------------------------------------

  subroutine resolve_T

    integer :: iti ! auxiliar
    integer jx

    do iti = 1, nitm

       ! pontos internos
       ! considera-se que an=as, ae=aw e fonte nulo
     
	   do j = 2, ny-1
          jx = (j-1)*nx
          do i = 2, nx-1
             np = jx + i
             T(np) = ( as * ( T(np-nx) + T(np+nx) ) &
                     + aw * ( T(np-1)  + T(np+1)  ) ) / ap
          end do
       end do

     end do

  end subroutine resolve_T

!-------------------------------------------------

  subroutine resolve_dt

    integer :: iti ! auxiliar
    integer jx

    do iti = 1, nitm

       ! pontos internos
       ! considera-se que an=as e ae=aw

       do j = 2, ny-1
          jx = npa + (j-1)*nxg(m)
          do i = 2, nx-1
             npg = jx + i
             dt(npg) = ( as * ( dt(npg-nx) + dt(npg+nx) ) &
                       + aw * ( dt(npg-1)  + dt(npg+1)  ) + f(npg) ) / ap
          end do
       end do

    end do

  end subroutine resolve_dt

!-------------------------------------------------

end module solvers
