MFIX  2016-1
calc_cell.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Subroutine name: CALC_CELL C
4 ! Purpose: calculate the i, j or k cell index for the corresponding C
5 ! x y or z reactor location. the index returned depends on which C
6 ! half of the i, j or k cell that the x, y, or z position C
7 ! intersects C
8 ! C
9 ! Author: P. Nicoletti Date: 02-DEC-91 C
10 ! C
11 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
12 
13  SUBROUTINE calc_cell(RMIN, REACTOR_LOC, D_DIR, N_DIR, CELL_LOC)
14 
15 !-----------------------------------------------
16 ! Modules
17 !-----------------------------------------------
18  USE param1, only : half
19  IMPLICIT NONE
20 !-----------------------------------------------
21 ! Dummy arguments
22 !-----------------------------------------------
23 ! the starting value of the x, y or z axis for which the i, j or k cell
24 ! index is to be found -- XMIN need not be zero, however, YMIN and ZMIN
25 ! are assumed to be zero.
26  DOUBLE PRECISION, INTENT(IN) :: RMIN
27 ! the x, y or z location along the axis for which the cell index (i, j
28 ! or k) is to be found
29  DOUBLE PRECISION, INTENT(IN) :: REACTOR_LOC
30 ! number of cells in the corresponding direction (IMAX, JMAX, or KMAX)
31  INTEGER, INTENT(IN) :: N_DIR
32 ! the cell lengths along the corresponding axis (DX, DY or DZ)
33  DOUBLE PRECISION, INTENT(IN), DIMENSION(0:(N_DIR+3)) :: D_DIR
34 ! the i, j, or k cell index that corresponds to the x, y or z
35 ! reactor_location (calculated value)
36  INTEGER, INTENT(INOUT) :: CELL_LOC
37 !-----------------------------------------------
38 ! Local variables
39 !-----------------------------------------------
40 ! loop counter
41  INTEGER :: LC
42 ! start and end coordinate for cell
43  DOUBLE PRECISION :: CELL_START, CELL_END
44 !-----------------------------------------------
45 
46  cell_loc = -1
47  cell_start = rmin
48  DO lc = 2, n_dir + 1
49  cell_end = cell_start + d_dir(lc)
50  IF (reactor_loc <= cell_start + half*d_dir(lc)) THEN
51  cell_loc = lc - 1
52  RETURN
53  ELSEIF (reactor_loc <= cell_end + half*d_dir(lc+1)) THEN
54  cell_loc = lc
55  RETURN
56  ENDIF
57  cell_start = cell_end
58  ENDDO
59  RETURN
60  END SUBROUTINE calc_cell
61 
62 
63 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
64 ! C
65 ! Subroutine name: CALC_LOC C
66 ! Purpose: calculate the x, y, or z position corresponding to the C
67 ! given i, j or k cell index. this call returns the x, y or z C
68 ! position corresponding to the east, north or top face of the C
69 ! cell with the given i, j or k index. C
70 ! C
71 ! Author: P. Nicoletti Date: 02-DEC-91 C
72 ! C
73 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
74 
75  SUBROUTINE calc_loc(RMIN, D_DIR, CELL_LOC, REACTOR_LOC)
76 
77 !-----------------------------------------------
78 ! Modules
79 !-----------------------------------------------
80  IMPLICIT NONE
81 !-----------------------------------------------
82 ! Dummy arguments
83 !-----------------------------------------------
84 ! the starting value of the x, y or z axis for which the x, y or z
85 ! position is to be found -- XMIN need not be zero, however, YMIN and
86 ! ZMIN are assumed to be zero.
87  DOUBLE PRECISION, INTENT(IN) :: RMIN
88 ! the i, j, or k cell index that corresponds to the x, y or z
89 ! reactor_location to be found
90  INTEGER, INTENT(IN) :: CELL_LOC
91 ! the cell lengths along the corresponding axis (DX, DY or DZ)
92  DOUBLE PRECISION, INTENT(IN), DIMENSION(0:CELL_LOC) :: D_DIR
93 ! the x, y or z location along the axis that corresponds to the i, j
94 ! k cell index (calculated value)
95  DOUBLE PRECISION, INTENT(INOUT) :: REACTOR_LOC
96 !-----------------------------------------------
97 ! Local variables
98 !-----------------------------------------------
99 ! loop counter
100  INTEGER :: LC
101 !-----------------------------------------------
102 
103  reactor_loc = rmin
104  lc = 2
105  IF (cell_loc - 1 > 0) THEN
106  reactor_loc = reactor_loc + sum(d_dir(2:cell_loc))
107  lc = cell_loc + 1
108  ENDIF
109  RETURN
110  END SUBROUTINE calc_loc
111 
112 
113 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
114 ! !
115 ! Subroutine: CALC_CELL_INTERSECT !
116 ! Author: J.Musser Date: 23-APR-14 !
117 ! !
118 ! Purpose: Calculate the cell index that intersects LOC. Unlike the !
119 ! base routine (CALC_CELL), this routine does not shift the index !
120 ! based on which half of the cell the point intersects. !
121 ! !
122 ! Comment: This is a brute force approach and should not be called !
123 ! from within any critical routines/loops. !
124 ! !
125 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
126  SUBROUTINE calc_cell_intersect(RMIN, LOC, D_DIR, N_DIR, CELL)
128  IMPLICIT NONE
129 
130 ! Passed Arguments:
131 !---------------------------------------------------------------------//
132 ! Starting value of the axis (ZERO except for maybe XMIN)
133  DOUBLE PRECISION, INTENT(in) :: RMIN
134 ! Point to check for intersection.
135  DOUBLE PRECISION, INTENT(in) :: LOC
136 ! Number of cells in this direction (IMAX,JMAX,KMAX)
137  INTEGER, INTENT(in) :: N_DIR
138 ! Cell lengths (DX,DY,DZ)
139  DOUBLE PRECISION, INTENT(IN) :: D_DIR(0:(n_dir+3))
140 ! Cell indices corresponding to LOC
141  INTEGER, INTENT(out) :: CELL
142 
143 ! Local Variables:
144 !---------------------------------------------------------------------//
145 ! Loop counter
146  INTEGER :: LC
147 ! Start/End coordinates for cell
148  DOUBLE PRECISION :: CELL_START, CELL_END
149 !......................................................................!
150 
151  cell = -1
152 
153  cell_start = rmin
154  DO lc=2, n_dir+1
155  cell_end = cell_start + d_dir(lc)
156  IF(cell_start <= loc .AND. loc <= cell_end) THEN
157  cell = lc
158  RETURN
159  ENDIF
160  cell_start=cell_end
161  ENDDO
162 
163  RETURN
164  END SUBROUTINE calc_cell_intersect
subroutine calc_cell(RMIN, REACTOR_LOC, D_DIR, N_DIR, CELL_LOC)
Definition: calc_cell.f:14
subroutine calc_cell_intersect(RMIN, LOC, D_DIR, N_DIR, CELL)
Definition: calc_cell.f:127
double precision, parameter half
Definition: param1_mod.f:28
subroutine calc_loc(RMIN, D_DIR, CELL_LOC, REACTOR_LOC)
Definition: calc_cell.f:76