MFIX  2016-1
des_functions.f
Go to the documentation of this file.
1 
2 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
3 !
4 ! Function: DES_GETINDEXFROMPOS
5 ! Purpose: Knowing the current particle x, y, or z position determine
6 ! the associated i, j or k index by searching a specific region defined
7 ! by a lower and upper limit on the index that is known to contain
8 ! the particles position
9 !
10 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11 
12  INTEGER FUNCTION des_getindexfrompos(LIM1,LIM2,PART_POS,&
13  grid_pos,axis,axis_index)
14 
15 !-----------------------------------------------
16 ! Modules
17 !-----------------------------------------------
18  USE compar
19  USE funits
20  IMPLICIT NONE
21 !-----------------------------------------------
22 ! Dummy arguments
23 !-----------------------------------------------
24 ! given i, j, or k index values defining the upper and lower limits of
25 ! the region in space known to contain the particle
26  INTEGER, INTENT (IN) :: LIM1, LIM2
27 ! given current x, y, or z position of the particle
28  DOUBLE PRECISION, INTENT (IN) :: PART_POS
29 ! given position for the cell faces on the fluid grid in the x, y or z
30 ! direction
31  DOUBLE PRECISION, DIMENSION(:), INTENT (IN) :: GRID_POS
32 ! given axis (x, y, or z) and associated index (i, j, or k)
33  CHARACTER(LEN=1), INTENT (IN) :: AXIS, AXIS_INDEX
34 !-----------------------------------------------
35 ! Local Variables
36 !-----------------------------------------------
37 ! index & loop counter
38  INTEGER IND
39 !-----------------------------------------------
40 
41 ! error condition
42  ind = -1
43 
44  IF (lim1 <= lim2) THEN
45  DO ind = lim1, lim2
46  IF (part_pos >= grid_pos(ind-1) .AND. &
47  part_pos < grid_pos(ind)) EXIT
48  ENDDO
49  ELSEIF (lim1 > lim2) THEN
50  DO ind = lim1, lim2, -1
51  IF (part_pos >= grid_pos(ind-1) .AND. &
52  part_pos < grid_pos(ind)) EXIT
53  ENDDO
54  ENDIF
55 
56  IF (ind == -1) THEN
57  WRITE (unit_log, 1001) axis_index, axis, part_pos, &
58  axis_index, lim1, axis_index, lim2
59  WRITE (*,1001) axis_index, axis, part_pos, &
60  axis_index, lim1, axis_index, lim2
61 ! CALL MFIX_EXIT(myPE)
62  ENDIF
63 
65 
66  RETURN
67 
68  1001 FORMAT(/1x,70('*')//,' From: DES_GETINDEXFROMPOS',/,' Message: ',&
69  'Could not identify the ', a, ' index associated with the ',&
70  'particles ',/10x,a, '-position= ',es15.5,' between the ',&
71  'limits ',a,'=',i5,/10x,' and ',a,'=',i5,'.',/1x,70('*')/)
72 
73  END FUNCTION des_getindexfrompos
74 
75 
76 
77 
integer function des_getindexfrompos(LIM1, LIM2, PART_POS, GRID_POS, AXIS, AXIS_INDEX)
Definition: des_functions.f:14
integer, parameter unit_log
Definition: funits_mod.f:21