diff --git a/src/interpolation.F90 b/src/interpolation.F90 new file mode 100644 index 0000000..2a526be --- /dev/null +++ b/src/interpolation.F90 @@ -0,0 +1,93 @@ +!!***************************************************************************** +!! +!! module: interpolation - subroutines for different kinds of interpolation +!! +!! Copyright (C) 2008 Grzegorz Kowal +!! +!!***************************************************************************** +!! +!! This file is part of Godunov-AMR. +!! +!! Godunov-AMR is free software; you can redistribute it and/or modify +!! it under the terms of the GNU General Public License as published by +!! the Free Software Foundation; either version 3 of the License, or +!! (at your option) any later version. +!! +!! Godunov-AMR is distributed in the hope that it will be useful, +!! but WITHOUT ANY WARRANTY; without even the implied warranty of +!! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +!! GNU General Public License for more details. +!! +!! You should have received a copy of the GNU General Public License +!! along with this program. If not, see . +!! +!!***************************************************************************** +!! +! +module interpolation + + implicit none + + contains +! +!=============================================================================== +! +! reconstruct: subroutine for the reconstruction of the values at the right and +! left interfaces of cells from their cell centered representation +! +!=============================================================================== +! + subroutine reconstruct(n, vx, vl, vr) + + implicit none + +! input/output arguments +! + integer , intent(in) :: n + real, dimension(n), intent(in) :: vx + real, dimension(n), intent(out) :: vl, vr + +! local variables +! + integer :: i + real :: dv + real, dimension(n) :: ds, dvl, dvr +! +!------------------------------------------------------------------------------ +! +! second order interpolation +! + dvl(1) = 0.0 + dvr(n) = 0.0 + + do i = 1, n-1 + dvr(i ) = vx(i+1) - vx(i) + dvl(i+1) = dvr(i) + enddo + + do i = 1, n + ds (i) = dvr(i) * dvl(i) + + if (ds(i) .gt. 0.0) then + dv = ds(i) / (dvr(i) + dvl(i)) + + vl(i) = vx(i) + dv + vr(i) = vx(i) - dv + else + vl(i) = vx(i) + vr(i) = vx(i) + endif + enddo + + do i = 1, n-1 + vr(i) = vr(i+1) + enddo + vr(n) = vx(n) + +!------------------------------------------------------------------------------- +! + end subroutine reconstruct + +!=============================================================================== +! +end module diff --git a/src/makefile b/src/makefile index 295b5e7..d4171a9 100644 --- a/src/makefile +++ b/src/makefile @@ -78,10 +78,10 @@ name = godunov-amr default: $(name).x -sources = blocks.F90 config.F90 driver.F90 error.F90 evolution.F90 io.F90 \ - mesh.F90 problem.F90 scheme.F90 timer.F90 -objects = blocks.o config.o driver.o error.o evolution.o io.o \ - mesh.o problem.o scheme.o timer.o +sources = blocks.F90 config.F90 driver.F90 error.F90 evolution.F90 \ + interpolation.F90 io.F90 mesh.F90 problem.F90 scheme.F90 timer.F90 +objects = blocks.o config.o driver.o error.o evolution.o \ + interpolation.o io.o mesh.o problem.o scheme.o timer.o files = $(sources) makefile make.default config.in license.txt hosts $(name).x: $(objects) @@ -103,10 +103,11 @@ config.o : config.F90 error.o driver.o : driver.F90 config.o evolution.o io.o mesh.o timer.o error.o : error.F90 evolution.o : evolution.F90 blocks.o config.o mesh.o scheme.o +interpolation.o : interpolation.F90 io.o : io.F90 blocks.o error.o mesh.o : mesh.F90 blocks.o config.o error.o problem.o problem.o : problem.F90 blocks.o -scheme.o : scheme.F90 blocks.o config.o +scheme.o : scheme.F90 blocks.o config.o interpolation.o timer.o : timer.F90 #------------------------------------------------------------------------------- diff --git a/src/scheme.F90 b/src/scheme.F90 index a2bc846..249913c 100644 --- a/src/scheme.F90 +++ b/src/scheme.F90 @@ -188,7 +188,7 @@ module scheme ! subroutine hll(m, n, uc, f) -! use interpolation, only : reconstruct, point2avg + use interpolation, only : reconstruct implicit none @@ -205,8 +205,6 @@ module scheme real, dimension(m,n) :: fl, fr, fx real, dimension(n) :: cl, cr real :: al, ar, ap, div - - integer, parameter, dimension(6) :: pos = (/ 1, 0, 0, 0, 1, 1 /) ! !---------------------------------------------------------------------- ! @@ -214,7 +212,7 @@ module scheme ! reconstruct left and right states of conserved variables ! do p = 1, m -! call reconstruct(n,uc(p,:),ul(p,:),ur(p,:),pos(p)) + call reconstruct(n,uc(p,:),ul(p,:),ur(p,:)) enddo ! calculate primitive variables @@ -230,7 +228,7 @@ module scheme ! reconstruct left and right states of primitive variables ! do p = 1, m -! call reconstruct(n,qc(p,:),ql(p,:),qr(p,:),pos(p)) + call reconstruct(n,qc(p,:),ql(p,:),qr(p,:)) enddo ! calculate conservative variables at states