Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion input/EX3_Limiter/Analysis/EX3_Case1.Analysis
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Total run time (in seconds):
200.0

Time step (in seconds):
0.001
0.0005

Upstream boundary condition, constant flow (m^3/s):
0.18
Expand Down
15,004 changes: 10,002 additions & 5,002 deletions input/EX3_Limiter/Model/EX3_Limiter_s1.par

Large diffs are not rendered by default.

10,003 changes: 10,003 additions & 0 deletions input/EX3_Limiter/Model/EX3_Limiter_s1_p_10000.par

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/Simulator/Driver_Simulation.f90
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ program Shallow_Water_Equations
ModelInfo%Version = 2.0_SGL ! Reports the version of the code

! Time and Date signature =========================================================================
call system_clock(TotalTime%startSys, TotalTime%clock_rate)
call TotalTime%start()
call GETDAT(TimeDate%Year, TimeDate%Month, TimeDate%Day)
call GETTIM(TimeDate%Hour, TimeDate%Minute, TimeDate%Seconds, TimeDate%S100th)
Expand Down Expand Up @@ -173,6 +174,8 @@ program Shallow_Water_Equations

! RUNNING TIME OF THE CODE ========================================================================
call TotalTime%stop()
call system_clock(TotalTime%endSys, TotalTime%clock_rate)


write(*, fmt="(' Input time: ',F23.10 , ' seconds.' )") InputTime%elapsedTime()
write(FileInfo, fmt="(' Input time: ',F23.10 , ' seconds.' )") InputTime%elapsedTime()
Expand All @@ -186,7 +189,7 @@ program Shallow_Water_Equations
write(FileInfo, fmt="(' Total simulation time: ',F23.10 , ' seconds.' )") TotalTime%elapsedTime()



write(*, fmt="(' FINAL SIMULATION TIME: ',F23.10 , ' seconds.' )") real(TotalTime%endSys-TotalTime%startSys)/real(TotalTime%clock_rate)

! End the code ====================================================================================
write(*, Fmt_SUC); write(FileInfo, Fmt_SUC);
Expand Down
70 changes: 49 additions & 21 deletions src/Simulator/Limiter_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,13 @@ subroutine Solver_1D_with_Limiter_sub(this)
integer(kind=Lng) :: i_Cell ! loop index over the Cells
integer(kind=Lng) :: i_steps ! loop index over the number steps
integer(kind=Lng) :: NSteps ! Total number of steps for time marching
integer(kind=Lng) :: chunk ! the chunk of work dedicated to each rank for omp
integer(kind=Lng) :: counter !

integer(kind=Tiny) :: i_eigen ! loop index over the eigenvalues (only two in case of 1D SWE)
integer(kind=Tiny) :: i_Interface ! loop index over the interfaces (only two in case of 1D SWE)

integer(kind=Smll) :: ERR_Alloc, ERR_DeAlloc ! Allocating and DeAllocating errors

! - real variables --------------------------------------------------------------------------------
real(kind=Dbl) :: dt ! time step, should be structured/constant in each reach
Expand All @@ -209,7 +212,8 @@ subroutine Solver_1D_with_Limiter_sub(this)
real(kind=Dbl) :: height_interface ! height of water at the current interface/time
real(kind=Dbl) :: velocity_interface ! velocity of water at the current interface/time

! - real Arrays -----------------------------------------------------------------------------------
! - integer Arrays -----------------------------------------------------------------------------------
integer(kind=Lng), allocatable, dimension(:) :: map

! - logical variables -----------------------------------------------------------------------------
logical :: PrintResults
Expand All @@ -234,7 +238,8 @@ subroutine Solver_1D_with_Limiter_sub(this)
type(vector) :: F_H ! Contribution of high-resolution method (Lax-Wendroff) in the solution.

type(vector) :: Delta_U ! holds (U_i- U_i-1)
type(vector), dimension(-1_Lng:this%Discretization%NCells+2_Lng) ::UU, UN ! solution at n and n+1
type(vector), dimension(-1_Lng:this%Discretization%NCells+2_Lng) ::UU ! solution at n and n+1
type(vector), allocatable, dimension(:) ::UN ! solution at n and n+1

!type(vector), dimension(this%Discretization%NCells) :: S ! Source term
! the first term holds "h" and the second holds "uh"
Expand Down Expand Up @@ -300,44 +305,58 @@ subroutine Solver_1D_with_Limiter_sub(this)
Results%ModelInfo = this%ModelInfo


!!$OMP PARALLEL default(private) SHARED(UN,UU,S, dt, dx, dtdx) firstprivate(this,SourceTerms,LimiterFunc,Jacobian_neighbor,Jacobian,alpha, alpha_neighbor, alpha_tilda, Wave, Wave_neighbor, Wave_tilda, F_L, F_H, Delta_U,TempSolution,i_steps, NSteps)
!$OMP PARALLEL default(none) SHARED(UN,UU, dt, dx, dtdx) private(i_Cell,its,mts,height,velocity,Coefficient,height_interface, velocity_interface, speed) firstprivate(this,SourceTerms,LimiterFunc,Jacobian_neighbor,Jacobian,alpha, alpha_neighbor, alpha_tilda, Wave, Wave_neighbor, Wave_tilda, F_L, F_H, Delta_U,TempSolution,i_steps, NSteps, Results)
!$OMP PARALLEL private(ITS, MTS)

!$ ITS = OMP_GET_THREAD_NUM()
!$ MTS = OMP_GET_NUM_THREADS()

!$ write(*, fmt="(' I am thread ',I4,' out of ',I4,' threads.')") ITS,MTS
!$ write(FileInfo,fmt="(' I am thread ',I4,' out of ',I4,' threads.')") ITS,MTS

!!$OMP END PARALLEL
chunk = ceiling( this%Discretization%NCells / dble(MTS) )

!$ write(*,*)" the chunk size: ", chunk

!$OMP END PARALLEL


allocate( UN(chunk), map(chunk), stat=ERR_Alloc)

if (ERR_Alloc /= 0) then
write (*, Fmt_ALLCT) ERR_Alloc; write (FileInfo, Fmt_ALLCT) ERR_Alloc;
write(*, Fmt_FL); write(FileInfo, Fmt_FL); read(*, Fmt_End); stop;
end if



!!$OMP PARALLEL default(private) SHARED(UN,UU,S, dt, dx, dtdx) firstprivate(this,SourceTerms,LimiterFunc,Jacobian_neighbor,Jacobian,alpha, alpha_neighbor, alpha_tilda, Wave, Wave_neighbor, Wave_tilda, F_L, F_H, Delta_U,TempSolution,i_steps, NSteps)
!$OMP PARALLEL default(none) SHARED(UU, dt, dx, dtdx) private(i_Cell,its,mts,height,velocity,Coefficient,height_interface, velocity_interface, speed, counter, map, UN, PrintResults) firstprivate(this,SourceTerms,LimiterFunc,Jacobian_neighbor,Jacobian,alpha, alpha_neighbor, alpha_tilda, Wave, Wave_neighbor, Wave_tilda, F_L, F_H, Delta_U,TempSolution,i_steps, NSteps, Results)
!$ ITS = OMP_GET_THREAD_NUM()
!$ MTS = OMP_GET_NUM_THREADS()

! Time marching
Time_Marching: do i_steps = 1_Lng, NSteps

!print*, "----------------Step:", i_steps
! write down data for visualization
! write down data for visualization
if (mod(i_steps,this%Plot_Inc)==1 .or. PrintResults) then
!$ if (ITS==0) then
print*, "----------------Step:", i_steps
Results%U(:) = UU(1:this%Discretization%NCells)
call Results%plot_results(i_steps)
!$ end if
end if

!print*,i_steps,uu(2), UU(3) ! <delete>
!read(*,*)
counter = 0_lng


!!$OMP PARALLEL DO default(none) SHARED(UN,UU,S, phi, theta,dt, dx, dtdx) private(i_Cell,its,mts,height,velocity,Coefficient,height_interface, velocity_interface, speed) firstprivate(this,SourceTerms,LimiterFunc,Jacobian_neighbor,Jacobian,alpha, alpha_neighbor, alpha_tilda, Wave, Wave_neighbor, Wave_tilda, F_L, F_H, Delta_U,TempSolution)
!!$OMP PARALLEL DO default(private) SHARED(UN,UU,S, dt, dx, dtdx) firstprivate(this,SourceTerms,LimiterFunc,Jacobian_neighbor,Jacobian,alpha, alpha_neighbor, alpha_tilda, Wave, Wave_neighbor, Wave_tilda, F_L, F_H, Delta_U,TempSolution)
!!$OMP DO default(none) SHARED(UN,UU,S, phi, theta,dt, dx, dtdx) private(i_Cell,its,mts,height,velocity,Coefficient,height_interface, velocity_interface, speed) firstprivate(this,SourceTerms,LimiterFunc,Jacobian_neighbor,Jacobian,alpha, alpha_neighbor, alpha_tilda, Wave, Wave_neighbor, Wave_tilda, F_L, F_H, Delta_U,TempSolution)
!$OMP DO
do i_Cell = 2_Lng, this%Discretization%NCells-1 ! Loop over cells except the boundary cells


!print*, "=============Cell:", i_Cell, ITS
!print*, "=============Cell:", i_Cell, ITS, i_steps
!print*, "=============Cell:", i_Cell

counter = counter + 1_Lng
map(counter) = i_Cell

! Initialize fluxes
F_L%U(:) = 0.0_Dbl ! upwind flux (not exactly, see notes)
Expand Down Expand Up @@ -497,28 +516,37 @@ subroutine Solver_1D_with_Limiter_sub(this)
TempSolution%U(:) = UU(i_cell)%U(:) - dtdx * F_L%U(:) - dtdx * F_H%U(:) &
+ SourceTerms%Source_1%U(:) - SourceTerms%Source_2%U(:)

UN(i_cell)%U(:) = matmul(SourceTerms%BI(:,:), TempSolution%U(:))
!print*,"solution at cell",i_Cell, UN(i_cell)
UN(counter)%U(:) = matmul(SourceTerms%BI(:,:), TempSolution%U(:))
!print*, "counter: ", counter, ITS

end do
!$OMP END DO

!!$OMP END PARALLEL DO
!$OMP CRITICAL
!print *, "rank: ", ITS, i_steps
!do i_Cell = 1, counter
! write(*,fmt="(2i5,2f20.10)") i_Cell, map(i_Cell), UN(i_Cell)
!end do
UU(map(1:counter)) = UN(1:counter)
!$OMP END CRITICAL

!$OMP single

UU(:) = UN(:)
!$OMP SINGLE

! apply boundary condition
call Impose_Boundary_Condition_1D_sub(UU, this%Discretization%NCells,this%AnalysisInfo%h_dw, &
this%AnalysisInfo%Q_Up,this%Discretization%WidthCell(1))

!$OMP END SINGLE

!$OMP end single
end do Time_Marching

!$OMP END PARALLEL

deallocate(UN, map, stat=ERR_DeAlloc)
if (ERR_DeAlloc /= 0) then
write (*, Fmt_DEALLCT) ERR_DeAlloc; write (FileInfo, Fmt_DEALLCT) ERR_DeAlloc;
write(*, Fmt_FL); write(FileInfo, Fmt_FL); write(*, Fmt_End); read(*,*); stop;
end if


write(*, *) " end subroutine < Solver_1D_with_Limiter_sub >"
Expand Down
2 changes: 2 additions & 0 deletions src/Simulator/Timer_mod.f90
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module Timer_mod
real(kind=dbl), private:: startTime = 0.0_dbl
real(kind=dbl), private:: finishTime = 0.0_dbl

integer(kind=Lng) :: startSys, endSys, clock_rate

contains
procedure, pass :: start => startTimer
procedure, pass :: stop => stopTimer
Expand Down
Binary file modified src/Simulator/main
Binary file not shown.
6 changes: 3 additions & 3 deletions src/Simulator/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
# =================================================================================================

F90=ifort
#F90=ifort -pg
#F90=ifort -pg #This is the profiler, gprof program-name [ data-file ] [ > output-file ] . ex: gprof main gmon.out
#F90= gfortran # not working because of ifort module
#F90= gfortran -ffree-line-length-none#F90= gfortran -ffree-line-length-none


#FFLAGS=-O2 -qopenmp -g -debug all -debug-parameters all -traceback -check all -fp-stack-check -check bounds -check stack -gen-interfaces -warn interfaces -ftrapuv -fpe0 -CB
#FFLAGS=-O2 -qopenmp
FFLAGS=-O2
FFLAGS=-O2 -qopenmp
#FFLAGS=-O2

SOURCESF= Parameters_mod.f90 \
Timer_mod.f90 \
Expand Down
Loading