aboutsummaryrefslogtreecommitdiff
path: root/src/GRHydro_RiemannSolve.F90
blob: dd01bff1d5661e2bc901690430632abf9880c830 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
 /*@@
   @file      GRHydro_RiemannSolve.F90
   @date      Sat Jan 26 02:20:25 2002
   @author    
   @desc 
   A wrapper routine to call the correct Riemann solver
   @enddesc 
 @@*/

#include "cctk.h"
#include "cctk_Parameters.h"
#include "cctk_Arguments.h"
#include "cctk_Functions.h"
#include "GRHydro_Macros.h"

 /*@@
   @routine    RiemannSolve
   @date       Sat Jan 26 02:20:48 2002
   @author     Pedro Montero, Ian Hawke
   @desc 
   A wrapper routine to switch between the different Riemann solvers.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 

@@*/

subroutine RiemannSolve(CCTK_ARGUMENTS)

  implicit none
  
  DECLARE_CCTK_ARGUMENTS
  DECLARE_CCTK_PARAMETERS
  DECLARE_CCTK_FUNCTIONS

  CCTK_INT :: i,j,k
  
  if (CCTK_EQUALS(riemann_solver,"HLLE")) then
    
    call GRHydro_HLLE(CCTK_PASS_FTOF)

    if (evolve_tracer .ne. 0) then
    
      call GRHydro_HLLE_Tracer(CCTK_PASS_FTOF)

    end if
    
  else if (CCTK_EQUALS(riemann_solver,"Roe")) then   
    
    call GRHydro_RoeSolve(CCTK_PASS_FTOF)

    if (evolve_tracer .ne. 0) then
    
      call GRHydro_HLLE_Tracer(CCTK_PASS_FTOF)

    end if
    
  else if (CCTK_EQUALS(riemann_solver,"Marquina")) then   
    
    call GRHydro_Marquina(CCTK_PASS_FTOF)

!!$    Tracers are built directly in to the Marquina solver

  end if

end subroutine RiemannSolve

 /*@@
   @routine    RiemannSolvePolytype
   @date       Tue Mar 19 11:40:20 2002
   @author     Ian Hawke
   @desc 
   The same as above, just specializing to polytropic type EOS.
   Currently there is no point to this routine right now.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 

@@*/


subroutine RiemannSolvePolytype(CCTK_ARGUMENTS)

  implicit none
  
  DECLARE_CCTK_ARGUMENTS
  DECLARE_CCTK_PARAMETERS
  DECLARE_CCTK_FUNCTIONS

  CCTK_INT :: i,j,k
  
  if (CCTK_EQUALS(riemann_solver,"HLLE")) then
    
    call GRHydro_HLLE(CCTK_PASS_FTOF)

    if (evolve_tracer .ne. 0) then
    
      call GRHydro_HLLE_Tracer(CCTK_PASS_FTOF)

    end if
    
  else if (CCTK_EQUALS(riemann_solver,"Roe")) then   
    
    call GRHydro_RoeSolve(CCTK_PASS_FTOF)

    if (evolve_tracer .ne. 0) then
    
      call GRHydro_HLLE_Tracer(CCTK_PASS_FTOF)

    end if
    
  else if (CCTK_EQUALS(riemann_solver,"Marquina")) then   
    
    call GRHydro_Marquina(CCTK_PASS_FTOF)

!!$    Tracers are built directly in to the Marquina solver

  end if

end subroutine RiemannSolvePolytype



 /*@@
   @routine    RiemannSolveGeneral
   @date       Tue Mar 19 11:40:20 2002
   @author     Ian Hawke
   @desc 
   The Riemann solvers for the new general EOS routines.
   This sets the fluxes from the left and right reconstructed
   states, so that after this routine they are effectively 
   scratch space.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 

@@*/


subroutine RiemannSolveGeneral(CCTK_ARGUMENTS)

  USE GRHydro_Scalars

  implicit none
  
  DECLARE_CCTK_ARGUMENTS
  DECLARE_CCTK_PARAMETERS
  DECLARE_CCTK_FUNCTIONS

  CCTK_INT :: i,j,k, ierr
  CCTK_REAL, dimension(5) :: tmp_flux, cons_p, cons_m
  CCTK_REAL, dimension(6) :: prim_p, prim_m
  CCTK_REAL :: avg_det, avg_alp, avg_beta
  CCTK_REAL :: psi4h, gxxh, gyyh, gzzh, gxyh, gxzh, gyzh

  densflux = 0.d0
  sxflux   = 0.d0
  syflux   = 0.d0
  szflux   = 0.d0
  tauflux  = 0.d0

!!$  Do the EOS call to set the pressure, derivative and cs2

  ierr = EOS_SetGFs(cctkGH, EOS_RiemannCallPlus)
  ierr = EOS_SetGFs(cctkGH, EOS_RiemannCallMinus)


  if (CCTK_EQUALS(riemann_solver,"HLLE")) then
    
    call GRHydro_HLLEGeneral(CCTK_PASS_FTOF)
    
    if (evolve_tracer .ne. 0) then
    
      call GRHydro_HLLE_TracerGeneral(CCTK_PASS_FTOF)

    end if

  else
          
    do k = GRHydro_stencil, cctk_lsh(3) - GRHydro_stencil
      do j = GRHydro_stencil, cctk_lsh(2) - GRHydro_stencil
        do i = GRHydro_stencil, cctk_lsh(1) - GRHydro_stencil        
          
!!$        Set the left (p for plus) and right (m for minus, i+1) states

          cons_p(1)   = densplus(i,j,k) 
          cons_p(2)   = sxplus(i,j,k)
          cons_p(3)   = syplus(i,j,k)
          cons_p(4)   = szplus(i,j,k)
          cons_p(5)   = tauplus(i,j,k)
          
          cons_m(1) = densminus(i+xoffset,j+yoffset,k+zoffset)
          cons_m(2) = sxminus(i+xoffset,j+yoffset,k+zoffset)
          cons_m(3) = syminus(i+xoffset,j+yoffset,k+zoffset)
          cons_m(4) = szminus(i+xoffset,j+yoffset,k+zoffset)
          cons_m(5) = tauminus(i+xoffset,j+yoffset,k+zoffset) 
          
          prim_p(1)   = rhoplus(i,j,k) 
          prim_p(2)   = velxplus(i,j,k)
          prim_p(3)   = velyplus(i,j,k) 
          prim_p(4)   = velzplus(i,j,k)
          prim_p(5)   = epsplus(i,j,k)
          prim_p(6)   = pressplus(i,j,k)
          
          prim_m(1) = rhominus(i+xoffset,j+yoffset,k+zoffset)
          prim_m(2) = velxminus(i+xoffset,j+yoffset,k+zoffset)
          prim_m(3) = velyminus(i+xoffset,j+yoffset,k+zoffset)
          prim_m(4) = velzminus(i+xoffset,j+yoffset,k+zoffset)
          prim_m(5) = epsminus(i+xoffset,j+yoffset,k+zoffset) 
          prim_m(6) = pressminus(i+xoffset,j+yoffset,k+zoffset) 
        
!!$        Set metric terms at interface
          
          if (shift_state .ne. 0) then
            if (flux_direction == 1) then
              avg_beta = 0.5d0 * (betax(i+xoffset,j+yoffset,k+zoffset) + &
                   betax(i,j,k))
            else if (flux_direction == 2) then
              avg_beta = 0.5d0 * (betay(i+xoffset,j+yoffset,k+zoffset) + &
                   betay(i,j,k))
            else if (flux_direction == 3) then
              avg_beta = 0.5d0 * (betaz(i+xoffset,j+yoffset,k+zoffset) + &
                   betaz(i,j,k))
            else
              call CCTK_WARN(0, "Flux direction not x,y,z")
            end if
          else
            avg_beta = 0.d0
          end if
          
          avg_alp = 0.5 * (alp(i,j,k) + alp(i+xoffset,j+yoffset,k+zoffset))
          
          gxxh = 0.5d0 * (gxx(i+xoffset,j+yoffset,k+zoffset) + &
               gxx(i,j,k))
          gxyh = 0.5d0 * (gxy(i+xoffset,j+yoffset,k+zoffset) + &
               gxy(i,j,k))
          gxzh = 0.5d0 * (gxz(i+xoffset,j+yoffset,k+zoffset) + &
               gxz(i,j,k))
          gyyh = 0.5d0 * (gyy(i+xoffset,j+yoffset,k+zoffset) + &
               gyy(i,j,k))
          gyzh = 0.5d0 * (gyz(i+xoffset,j+yoffset,k+zoffset) + &
               gyz(i,j,k))
          gzzh = 0.5d0 * (gzz(i+xoffset,j+yoffset,k+zoffset) + &
               gzz(i,j,k))
          
          avg_det = SPATIAL_DETERMINANT(gxxh,gxyh,gxzh,gyyh,gyzh,gzzh)
          
          if (flux_direction == 1) then
            
            call num_x_flux(cons_p(1),cons_p(2),cons_p(3),cons_p(4),cons_p(5),&
                 tmp_flux(1),tmp_flux(2),tmp_flux(3),tmp_flux(4),tmp_flux(5), &
                 prim_p(2),prim_p(6), &
                 avg_det,avg_alp,avg_beta)
            
            densflux(i,j,k) = 0.5d0 * tmp_flux(1)
            sxflux(i,j,k)   = 0.5d0 * tmp_flux(2)
            syflux(i,j,k)   = 0.5d0 * tmp_flux(3)
            szflux(i,j,k)   = 0.5d0 * tmp_flux(4)
            tauflux(i,j,k)  = 0.5d0 * tmp_flux(5)
            
            call num_x_flux(cons_m(1),cons_m(2),cons_m(3),cons_m(4),cons_m(5),&
                 tmp_flux(1),tmp_flux(2),tmp_flux(3),tmp_flux(4),tmp_flux(5), &
                 prim_m(2),prim_m(6), &
                 avg_det,avg_alp,avg_beta)
            
            densflux(i,j,k) = densflux(i,j,k) + 0.5d0 * tmp_flux(1)
            sxflux(i,j,k)   = sxflux(i,j,k)   + 0.5d0 * tmp_flux(2)
            syflux(i,j,k)   = syflux(i,j,k)   + 0.5d0 * tmp_flux(3)
            szflux(i,j,k)   = szflux(i,j,k)   + 0.5d0 * tmp_flux(4)
            tauflux(i,j,k)  = tauflux(i,j,k)  + 0.5d0 * tmp_flux(5)
            
          else if (flux_direction == 2) then
            
            call num_x_flux(cons_p(1),cons_p(3),cons_p(4),cons_p(2),cons_p(5),&
                 tmp_flux(1),tmp_flux(3),tmp_flux(4),tmp_flux(2),tmp_flux(5), &
                 prim_p(3),prim_p(6), &
                 avg_det,avg_alp,avg_beta)
            
            densflux(i,j,k) = 0.5d0 * tmp_flux(1)
            sxflux(i,j,k)   = 0.5d0 * tmp_flux(2)
            syflux(i,j,k)   = 0.5d0 * tmp_flux(3)
            szflux(i,j,k)   = 0.5d0 * tmp_flux(4)
            tauflux(i,j,k)  = 0.5d0 * tmp_flux(5)
            
            call num_x_flux(cons_m(1),cons_m(3),cons_m(4),cons_m(2),cons_m(5),&
                 tmp_flux(1),tmp_flux(3),tmp_flux(4),tmp_flux(2),tmp_flux(5), &
                 prim_m(3),prim_m(6), &
                 avg_det,avg_alp,avg_beta)
            
            densflux(i,j,k) = densflux(i,j,k) + 0.5d0 * tmp_flux(1)
            sxflux(i,j,k)   = sxflux(i,j,k)   + 0.5d0 * tmp_flux(2)
            syflux(i,j,k)   = syflux(i,j,k)   + 0.5d0 * tmp_flux(3)
            szflux(i,j,k)   = szflux(i,j,k)   + 0.5d0 * tmp_flux(4)
            tauflux(i,j,k)  = tauflux(i,j,k)  + 0.5d0 * tmp_flux(5)
            
          else if (flux_direction == 3) then
            
            call num_x_flux(cons_p(1),cons_p(4),cons_p(2),cons_p(3),cons_p(5),&
                 tmp_flux(1),tmp_flux(4),tmp_flux(2),tmp_flux(3),tmp_flux(5), &
                 prim_p(4),prim_p(6), &
                 avg_det,avg_alp,avg_beta)
            
            densflux(i,j,k) = 0.5d0 * tmp_flux(1)
            sxflux(i,j,k)   = 0.5d0 * tmp_flux(2)
            syflux(i,j,k)   = 0.5d0 * tmp_flux(3)
            szflux(i,j,k)   = 0.5d0 * tmp_flux(4)
            tauflux(i,j,k)  = 0.5d0 * tmp_flux(5)
            
            call num_x_flux(cons_m(1),cons_m(4),cons_m(2),cons_m(3),cons_m(5),&
                 tmp_flux(1),tmp_flux(4),tmp_flux(2),tmp_flux(3),tmp_flux(5), &
                 prim_m(4),prim_m(6), &
                 avg_det,avg_alp,avg_beta)
            
            densflux(i,j,k) = densflux(i,j,k) + 0.5d0 * tmp_flux(1)
            sxflux(i,j,k)   = sxflux(i,j,k)   + 0.5d0 * tmp_flux(2)
            syflux(i,j,k)   = syflux(i,j,k)   + 0.5d0 * tmp_flux(3)
            szflux(i,j,k)   = szflux(i,j,k)   + 0.5d0 * tmp_flux(4)
            tauflux(i,j,k)  = tauflux(i,j,k)  + 0.5d0 * tmp_flux(5)
            
          else
            
            call CCTK_WARN(0, "Flux direction not x,y,z")
            
          end if
          
        end do
      end do
    end do
    
    if (CCTK_EQUALS(riemann_solver,"Roe")) then   
      
      call GRHydro_RoeSolveGeneral(CCTK_PASS_FTOF)
  
      if (evolve_tracer .ne. 0) then
    
        call GRHydro_HLLE_TracerGeneral(CCTK_PASS_FTOF)

      end if
      
    else if (CCTK_EQUALS(riemann_solver,"Marquina")) then   
      
      call GRHydro_MarquinaGeneral(CCTK_PASS_FTOF)
      
!!$    Tracers are built directly in to the Marquina solver

    end if

 end if

end subroutine RiemannSolveGeneral