-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboundary.F90
679 lines (570 loc) · 20.4 KB
/
boundary.F90
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
module boundary
! Module for Capreole
! Author: Garrelt Mellema
! Date: 2007-10-05 (previous 2004-05-11)
!
! This module contains the routines related with handling the grid
! boundaries. This is mostly the internal boundaries.
!
! History:
! 2007-10-05: clean-up, added only's to use statements.
use precision, only: dp
use my_mpi
use sizes, only: neq, mbc, RHO, RHVX, RHVY, RHVZ, EN, nrofDim
use mesh, only: sx,ex,sy,ey,sz,ez
use grid, only: vol,volx
use geometry, only: presfunc
use hydro, only: state, NEW, OLD, set_state_pointer
implicit none
private
! Define outflow types
integer,parameter,public :: REFLECTIVE=-1
integer,parameter,public :: REFLECTIVE_SHIFT=-2
integer,parameter,public :: OUTFLOW=1
integer,parameter,public :: PROBLEM_DEF=2
integer,parameter,public :: X_IN=1
integer,parameter,public :: X_OUT=2
integer,parameter,public :: Y_IN=3
integer,parameter,public :: Y_OUT=4
integer,parameter,public :: Z_IN=5
integer,parameter,public :: Z_OUT=6
public :: boundaries
contains
!=======================================================================
subroutine boundaries (newold, &
domainboundaryconditions, &
problem_boundary_routine)
! Deals with the boundary conditions: internal boundaries (exchanges
! boundary cells between neighbours) and external boundaries.
! extend of boundary: mbc
integer,intent(in) :: newold
integer,dimension(nrOfDim,2),intent(in) :: domainboundaryconditions
interface
subroutine problem_boundary_routine (boundary_id, state_id)
integer,intent(in) :: boundary_id
integer,intent(in) :: state_id
end subroutine problem_boundary_routine
end interface
#ifdef MPI
real(kind=dp),dimension(mbc,1-mbc:ey-sy+1+mbc,1-mbc:ez-sz+1+mbc,neq) :: &
xplane1
real(kind=dp),dimension(mbc,1-mbc:ey-sy+1+mbc,1-mbc:ez-sz+1+mbc,neq) :: &
xplane2
real(kind=dp),dimension(mbc,1-mbc:ey-sy+1+mbc,1-mbc:ez-sz+1+mbc,neq) :: &
xplane3
real(kind=dp),dimension(mbc,1-mbc:ey-sy+1+mbc,1-mbc:ez-sz+1+mbc,neq) :: &
xplane4
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,mbc,1-mbc:ez-sz+1+mbc,neq) :: &
yplane1
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,mbc,1-mbc:ez-sz+1+mbc,neq) :: &
yplane2
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,mbc,1-mbc:ez-sz+1+mbc,neq) :: &
yplane3
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,mbc,1-mbc:ez-sz+1+mbc,neq) :: &
yplane4
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,1-mbc:ey-sy+1+mbc,mbc,neq) :: &
zplane1
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,1-mbc:ey-sy+1+mbc,mbc,neq) :: &
zplane2
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,1-mbc:ey-sy+1+mbc,mbc,neq) :: &
zplane3
real(kind=dp),dimension(1-mbc:ex-sx+1+mbc,1-mbc:ey-sy+1+mbc,mbc,neq) :: &
zplane4
integer :: status(MPI_STATUS_SIZE)
integer :: i,j,k,ieq
integer :: sizex,sizey,sizez
integer,parameter :: xfromright=101,xfromleft=102 ! tags
integer :: request1,request2
integer,parameter :: yfromdown=201,yfromup=202 ! tags
integer :: request3,request4
integer,parameter :: zfrombelow=301,zfromabove=302 ! tags
integer :: request5,request6
#endif
integer :: ierror
! Point state to appropriate array
state => set_state_pointer(newold)
! Account for non-existing neighbours, these are real boundaries
! the [inner,outer][x,y]bound routines need to be supplied
if (nbrleft == MPI_PROC_NULL) &
call innerxbound(newold,domainboundaryconditions(1,1),problem_boundary_routine)
if (nbrright == MPI_PROC_NULL) &
call outerxbound(newold,domainboundaryconditions(1,2),problem_boundary_routine)
if (nbrdown == MPI_PROC_NULL) &
call innerybound(newold,domainboundaryconditions(2,1),problem_boundary_routine)
if (nbrup == MPI_PROC_NULL) &
call outerybound(newold,domainboundaryconditions(2,2),problem_boundary_routine)
if (nbrbelow == MPI_PROC_NULL) &
call innerzbound(newold,domainboundaryconditions(3,1),problem_boundary_routine)
if (nbrabove == MPI_PROC_NULL) &
call outerzbound(newold,domainboundaryconditions(3,2),problem_boundary_routine)
#ifdef MPI
! Sizes in x and y direction
sizex=ex-sx+1
sizey=ey-sy+1
sizez=ez-sz+1
! Exchange mbc wide yrows with left and right neighbours
do ieq=1,neq ! put planes to be sent in array
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx,sx+mbc-1
xplane1(i-sx+1,j-sy+1,k-sz+1,ieq)=state(i,j,k,ieq)
enddo
do i=ex-mbc+1,ex
xplane2(i-ex+mbc,j-sy+1,k-sz+1,ieq)=state(i,j,k,ieq)
enddo
enddo
enddo
enddo
! SendReceive planes to left and right neighbours
call MPI_SENDRECV( &
xplane1,mbc*(sizey+2*mbc)*(sizez+2*mbc)*neq, &
MPI_DOUBLE_PRECISION,nbrleft,xfromright, &
xplane4,mbc*(sizey+2*mbc)*(sizez+2*mbc)*neq, &
MPI_DOUBLE_PRECISION,nbrright,xfromright, &
MPI_COMM_NEW,status,ierror)
call MPI_SENDRECV( &
xplane2,mbc*(sizey+2*mbc)*(sizez+2*mbc)*neq, &
MPI_DOUBLE_PRECISION,nbrright,xfromleft, &
xplane3,mbc*(sizey+2*mbc)*(sizez+2*mbc)*neq, &
MPI_DOUBLE_PRECISION,nbrleft,xfromleft, &
MPI_COMM_NEW,status,ierror)
! Fill the boundaries with the received planes
if (nbrleft /= MPI_PROC_NULL) then
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,sx-1
state(i,j,k,ieq)=xplane3(i-sx+mbc+1,j-sy+1,k-sz+1,ieq)
enddo
enddo
enddo
enddo
endif
if (nbrright /= MPI_PROC_NULL) then
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=ex+1,ex+mbc
state(i,j,k,ieq)=xplane4(i-ex,j-sy+1,k-sz+1,ieq)
enddo
enddo
enddo
enddo
endif
! Wait for the sends to be completed
call MPI_BARRIER(MPI_COMM_NEW,ierror)
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! Y
! Exchange mbc thick y-planes with the neighbours
do ieq=1,neq ! put planes to be sent in array
do k=sz-mbc,ez+mbc
do i=sx-mbc,ex+mbc
do j=sy,sy+mbc-1
yplane1(i-sx+1,j-sy+1,k-sz+1,ieq)=state(i,j,k,ieq)
enddo
do j=ey-mbc+1,ey
yplane2(i-sx+1,j-ey+mbc,k-sz+1,ieq)=state(i,j,k,ieq)
enddo
enddo
enddo
enddo
! SendReceive planes to down and up neighbours
call MPI_SENDRECV( &
yplane1,(sizex+2*mbc)*(sizez+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrdown,yfromup, &
yplane4,(sizex+2*mbc)*(sizez+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrup,yfromup, &
MPI_COMM_NEW,status,ierror)
call MPI_SENDRECV( &
yplane2,(sizex+2*mbc)*(sizez+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrup,yfromdown, &
yplane3,(sizex+2*mbc)*(sizez+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrdown,yfromdown, &
MPI_COMM_NEW,status,ierror)
! Fill the boundaries with the received planes
if (nbrdown /= MPI_PROC_NULL) then
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=sy-mbc,sy-1
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=yplane3(i-sx+1,j-sy+mbc+1,k-sz+1,ieq)
enddo
enddo
enddo
enddo
endif
if (nbrup /= MPI_PROC_NULL) then
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=ey+1,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=yplane4(i-sx+1,j-ey,k-sz+1,ieq)
enddo
enddo
enddo
enddo
endif
! Wait for the sends to be completed
call MPI_BARRIER(MPI_COMM_NEW,ierror)
! - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
! Z
! Exchange z-planes with the neighbours
do ieq=1,neq ! put planes to be sent in array
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
do k=sz,sz+mbc-1
zplane1(i-sx+1,j-sy+1,k-sz+1,ieq)=state(i,j,k,ieq)
enddo
do k=ez-mbc+1,ez
zplane2(i-sx+1,j-sy+1,k-ez+mbc,ieq)=state(i,j,k,ieq)
enddo
enddo
enddo
enddo
! SendReceive planes to down and above neighbours
call MPI_SENDRECV( &
zplane1,(sizex+2*mbc)*(sizey+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrbelow,zfromabove, &
zplane4,(sizex+2*mbc)*(sizey+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrabove,zfromabove, &
MPI_COMM_NEW,status,ierror)
call MPI_SENDRECV( &
zplane2,(sizex+2*mbc)*(sizey+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrabove,zfrombelow, &
zplane3,(sizex+2*mbc)*(sizey+2*mbc)*mbc*neq, &
MPI_DOUBLE_PRECISION,nbrbelow,zfrombelow, &
MPI_COMM_NEW,status,ierror)
! Fill the boundaries with the received planes
if (nbrbelow /= MPI_PROC_NULL) then
do ieq=1,neq
do k=sz-mbc,sz-1
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=zplane3(i-sx+1,j-sy+1,k-sz+mbc+1,ieq)
enddo
enddo
enddo
enddo
endif
if (nbrabove /= MPI_PROC_NULL) then
do ieq=1,neq
do k=ez+1,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=zplane4(i-sx+1,j-sy+1,k-ez,ieq)
enddo
enddo
enddo
enddo
endif
! Wait for the sends to be completed
call MPI_BARRIER(MPI_COMM_NEW,ierror)
#endif
! Calculate the pressure in the newly set boundary cells
! the presfunc routine has to be supplied
call presfunc(sx-mbc,ex+mbc,sy-mbc,ey+mbc,sz-mbc,ez+mbc,newold,ierror)
!! call presfunc(ex+1,ex+mbc,sy-1,ey+1,0)
!! call presfunc(sx-1,ex+1,sy-mbc,sy-1,0)
!! call presfunc(sx-1,ex+1,ey+1,ey+mbc,0)
end subroutine boundaries
!==========================================================================
subroutine innerxbound (newold, boundarycondition, problem_boundary)
! This routine resets the inner x boundary
integer :: i,j,k,ieq
integer,intent(in) :: newold
integer,intent(in) :: boundarycondition
interface
subroutine problem_boundary (boundary_id, state_id)
integer,intent(in) :: boundary_id
integer,intent(in) :: state_id
end subroutine problem_boundary
end interface
state => set_state_pointer(newold)
select case (boundarycondition)
case (REFLECTIVE)
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,sx-1
state(i,j,k,RHO)=state(2*sx-1-i,j,k,RHO)
state(i,j,k,RHVX)=-state(2*sx-1-i,j,k,RHVX)
state(i,j,k,RHVY:neq)=state(2*sx-1-i,j,k,RHVY:neq)
enddo
enddo
enddo
case (REFLECTIVE_SHIFT)
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,sx-1
state(i,j,k,RHO)=state(2*sx-i,j,k,RHO)
state(i,j,k,RHVX)=-state(2*sx-i,j,k,RHVX)
state(i,j,k,RHVY:neq)=state(2*sx-i,j,k,RHVY:neq)
enddo
enddo
enddo
case(OUTFLOW)
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,sx-1
state(i,j,k,ieq)=state(sx,j,k,ieq)
enddo
enddo
enddo
enddo
case(PROBLEM_DEF)
call problem_boundary(X_IN,newold)
end select
end subroutine innerxbound
!==========================================================================
subroutine outerxbound (newold, boundarycondition, problem_boundary)
! This routine resets the outer x boundary
integer :: i,j,k,ieq
integer,intent(in) :: newold
integer,intent(in) :: boundarycondition
interface
subroutine problem_boundary (boundary_id, state_id)
integer,intent(in) :: boundary_id
integer,intent(in) :: state_id
end subroutine problem_boundary
end interface
state => set_state_pointer(newold)
select case (boundarycondition)
case (REFLECTIVE)
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=ex+1,ex+mbc
state(i,j,k,RHO)=state(2*ex+1-i,j,k,RHO)
state(i,j,k,RHVX)=-state(2*ex+1-i,j,k,RHVX)
state(i,j,k,RHVY:neq)=state(2*ex+1-i,j,k,RHVY:neq)
enddo
enddo
enddo
case (REFLECTIVE_SHIFT)
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=ex+1,ex+mbc
state(i,j,k,RHO)=state(2*ex-i,j,k,RHO)
state(i,j,k,RHVX)=-state(2*ex-i,j,k,RHVX)
state(i,j,k,RHVY:neq)=state(2*ex-i,j,k,RHVY:neq)
enddo
enddo
enddo
case(OUTFLOW)
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=sy-mbc,ey+mbc
do i=ex+1,ex+mbc
state(i,j,k,ieq)=state(ex,j,k,ieq)
enddo
enddo
enddo
enddo
case(PROBLEM_DEF)
call problem_boundary(X_OUT,newold)
end select
end subroutine outerxbound
!==========================================================================
subroutine innerybound (newold, boundarycondition, problem_boundary)
! This routine resets the inner y boundary
integer :: i,j,k,ieq
integer,intent(in) :: newold
integer,intent(in) :: boundarycondition
interface
subroutine problem_boundary (boundary_id, state_id)
integer,intent(in) :: boundary_id
integer,intent(in) :: state_id
end subroutine problem_boundary
end interface
state => set_state_pointer(newold)
select case (boundarycondition)
case (REFLECTIVE)
do k=sz-mbc,ez+mbc
do j=sy-mbc,sy-1
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,2*sy-1-j,k,RHO)
state(i,j,k,RHVX)=state(i,2*sy-1-j,k,RHVX)
state(i,j,k,RHVY)=-state(i,2*sy-1-j,k,RHVY)
state(i,j,k,RHVZ:neq)=state(i,2*sy-1-j,k,RHVZ:neq)
enddo
enddo
enddo
case (REFLECTIVE_SHIFT)
do k=sz-mbc,ez+mbc
do j=sy-mbc,sy-1
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,2*sy-j,k,RHO)
state(i,j,k,RHVX)=state(i,2*sy-j,k,RHVX)
state(i,j,k,RHVY)=-state(i,2*sy-j,k,RHVY)
state(i,j,k,RHVZ:neq)=state(i,2*sy-j,k,RHVZ:neq)
enddo
enddo
enddo
case(OUTFLOW)
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=sy-mbc,sy-1
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=state(i,sy,k,ieq)
enddo
enddo
enddo
enddo
case(PROBLEM_DEF)
call problem_boundary(Y_IN,newold)
end select
end subroutine innerybound
!==========================================================================
subroutine outerybound (newold, boundarycondition, problem_boundary)
! This routine resets the outer y boundary
integer :: i,j,k,ieq
integer,intent(in) :: newold
integer,intent(in) :: boundarycondition
interface
subroutine problem_boundary (boundary_id, state_id)
integer,intent(in) :: boundary_id
integer,intent(in) :: state_id
end subroutine problem_boundary
end interface
state => set_state_pointer(newold)
select case (boundarycondition)
case (REFLECTIVE)
do k=sz-mbc,ez+mbc
do j=ey+1,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,2*ey+1-j,k,RHO)
state(i,j,k,RHVX)=state(i,2*ey+1-j,k,RHVX)
state(i,j,k,RHVY)=-state(i,2*ey+1-j,k,RHVY)
state(i,j,k,RHVZ:neq)=state(i,2*ey+1-j,k,RHVZ:neq)
enddo
enddo
enddo
case (REFLECTIVE_SHIFT)
do k=sz-mbc,ez+mbc
do j=ey+1,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,2*ey-j,k,RHO)
state(i,j,k,RHVX)=state(i,2*ey-j,k,RHVX)
state(i,j,k,RHVY)=-state(i,2*ey-j,k,RHVY)
state(i,j,k,RHVZ:neq)=state(i,2*ey-j,k,RHVZ:neq)
enddo
enddo
enddo
case(OUTFLOW)
do ieq=1,neq
do k=sz-mbc,ez+mbc
do j=ey+1,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=state(i,ey,k,ieq)
enddo
enddo
enddo
enddo
case(PROBLEM_DEF)
call problem_boundary(Y_OUT,newold)
end select
end subroutine outerybound
!==========================================================================
subroutine innerzbound (newold, boundarycondition, problem_boundary)
! This routine resets the inner z boundary
integer,intent(in) :: newold
integer,intent(in) :: boundarycondition
interface
subroutine problem_boundary (boundary_id, state_id)
integer,intent(in) :: boundary_id
integer,intent(in) :: state_id
end subroutine problem_boundary
end interface
integer :: i,j,k,ieq
state => set_state_pointer(newold)
select case (boundarycondition)
case (REFLECTIVE)
do k=sz-mbc,sz-1
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,j,2*sz-1-k,RHO)
state(i,j,k,RHVX)=state(i,j,2*sz-1-k,RHVX)
state(i,j,k,RHVY)=state(i,j,2*sz-1-k,RHVY)
state(i,j,k,RHVZ)=-state(i,j,2*sz-1-k,RHVZ)
state(i,j,k,EN:neq)=state(i,j,2*sz-1-k,EN:neq)
enddo
enddo
enddo
case (REFLECTIVE_SHIFT)
do k=sz-mbc,sz-1
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,j,2*sz-k,RHO)
state(i,j,k,RHVX)=state(i,j,2*sz-k,RHVX)
state(i,j,k,RHVY)=state(i,j,2*sz-k,RHVY)
state(i,j,k,RHVZ)=-state(i,j,2*sz-k,RHVZ)
state(i,j,k,EN:neq)=state(i,j,2*sz-k,EN:neq)
enddo
enddo
enddo
case(OUTFLOW)
do ieq=1,neq
do k=sz-mbc,sz-1
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=state(i,j,sz,ieq)
enddo
enddo
enddo
enddo
case(PROBLEM_DEF)
call problem_boundary(Z_IN,newold)
end select
end subroutine innerzbound
!==========================================================================
subroutine outerzbound (newold, boundarycondition, problem_boundary)
! This routine resets the outer y boundary
integer,intent(in) :: newold
integer,intent(in) :: boundarycondition
interface
subroutine problem_boundary (boundary_id, state_id)
integer,intent(in) :: boundary_id
integer,intent(in) :: state_id
end subroutine problem_boundary
end interface
integer :: i,j,k,ieq
state => set_state_pointer(newold)
select case (boundarycondition)
case (REFLECTIVE)
do k=ez+1,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,j,2*ez+1-k,RHO)
state(i,j,k,RHVX)=state(i,j,2*ez+1-k,RHVX)
state(i,j,k,RHVY)=state(i,j,2*ez+1-k,RHVY)
state(i,j,k,RHVZ)=-state(i,j,2*ez+1-k,RHVZ)
state(i,j,k,EN:neq)=state(i,j,2*ez+1-k,EN:neq)
enddo
enddo
enddo
case (REFLECTIVE_SHIFT)
do k=ez+1,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,RHO)=state(i,j,2*ez-k,RHO)
state(i,j,k,RHVX)=state(i,j,2*ez-k,RHVX)
state(i,j,k,RHVY)=state(i,j,2*ez-k,RHVY)
state(i,j,k,RHVZ)=-state(i,j,2*ez-k,RHVZ)
state(i,j,k,EN:neq)=state(i,j,2*ez-k,EN:neq)
enddo
enddo
enddo
case(OUTFLOW)
do ieq=1,neq
do k=ez+1,ez+mbc
do j=sy-mbc,ey+mbc
do i=sx-mbc,ex+mbc
state(i,j,k,ieq)=state(i,j,ez,ieq)
enddo
enddo
enddo
enddo
case(PROBLEM_DEF)
call problem_boundary(Z_OUT,newold)
end select
end subroutine outerzbound
end module boundary