LBM_differentiate_LBM_1D_field.F90 10.1 KB
Newer Older
Femi Kadri's avatar
Femi Kadri committed
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
SUBROUTINE LBM_differentiate_LBM_1D_field(&
& global_x_min_real,global_x_max_real,&
& global_y_min_real,global_y_max_real,&
& global_z_min_real,global_z_max_real,&
& local_x_min_real,local_x_max_real,&
& local_y_min_real,local_y_max_real,&
& local_z_min_real,local_z_max_real,&
& divide_x,divide_y,divide_z,&
& local_x_min_ghost,local_x_max_ghost,&
& local_y_min_ghost,local_y_max_ghost,&
& local_z_min_ghost,local_z_max_ghost,&
& LST_local_walls,My_MPI_Process_ID,&
& my_mpi_real_data_type,&
& east,west,up,down,in,out,&
& cartesian_communicator,&
& local_x_nodes_ghost,&
& local_y_nodes_ghost,&
& local_z_nodes_ghost,&
& local_x_nodes_real,&
& local_y_nodes_real,&
& local_z_nodes_real,&
& Number_Of_Processes,&
& lattice_dimension,&
& ROOT,&
& local_field_to_be_differentiated,&
& local_differentiated_field_wrt_x,&
& local_differentiated_field_wrt_y,&
& local_differentiated_field_wrt_z)

USE debug_module

!THIS SUBROUTINE WILL DIFFERENTIATE THE REAL NODES OF UX UY AND UZ WITH RESPECT TO X Y AND Z
!THEN IT WILL UPDATE THE GHOST BOUNDARIES OF UX, UY AND UZ
!THEN IT WILL WRITE THESE TO UX, UY AND UZ TO FILES

	IMPLICIT NONE

	!-----------INTENT(IN)-----------------------------------------------------------------------------------------------
	INTEGER,INTENT(IN) :: local_x_min_ghost,local_x_max_ghost
	INTEGER,INTENT(IN) :: local_y_min_ghost,local_y_max_ghost
	INTEGER,INTENT(IN) :: local_z_min_ghost,local_z_max_ghost
	INTEGER,INTENT(IN) :: global_x_min_real,global_x_max_real !GLOBAL BOUNDS X
	INTEGER,INTENT(IN) :: global_y_min_real,global_y_max_real !GLOBAL BOUNDS Y
	INTEGER,INTENT(IN) :: global_z_min_real,global_z_max_real !GLOBAL BOUNDS Z
	INTEGER,INTENT(IN) :: local_x_min_real,local_x_max_real
	INTEGER,INTENT(IN) :: local_y_min_real,local_y_max_real
	INTEGER,INTENT(IN) :: local_z_min_real,local_z_max_real
	INTEGER,INTENT(IN) :: My_MPI_Process_ID
	INTEGER,INTENT(IN) :: my_mpi_real_data_type
	INTEGER,INTENT(IN) :: east,west,up,down,in,out
	INTEGER,INTENT(IN) :: cartesian_communicator
	INTEGER,INTENT(IN) :: lattice_dimension
	INTEGER,INTENT(IN) :: Number_Of_Processes
!	INTEGER,INTENT(IN) :: local_non_wall_count_real
!	INTEGER,INTENT(IN) :: filename_number_of_letters
	INTEGER,INTENT(IN) :: ROOT
!	INTEGER,INTENT(IN),DIMENSION(0:Number_Of_Processes-1) :: all_local_non_wall_counts_real

	INTEGER,INTENT(IN) :: local_x_nodes_ghost,local_y_nodes_ghost,local_z_nodes_ghost
	INTEGER,INTENT(IN) :: local_x_nodes_real,local_y_nodes_real,local_z_nodes_real

	REAL,INTENT(IN),DIMENSION(&
	& local_x_min_ghost:local_x_max_ghost,&
	& local_y_min_ghost:local_y_max_ghost,&
	& local_z_min_ghost:local_z_max_ghost) :: local_field_to_be_differentiated


	LOGICAL*4,INTENT(IN) :: divide_x,divide_y,divide_z
	LOGICAL*4,INTENT(IN),DIMENSION(local_x_min_ghost:local_x_max_ghost,&
	& local_y_min_ghost:local_y_max_ghost,&
	& local_z_min_ghost:local_z_max_ghost) :: LST_local_walls 
	LOGICAL*4,PARAMETER :: debug = GLOBAL_DEBUG
	!-----------INTENT(OUT)-----------------------------------------------------------------------------------------------
	REAL,INTENT(OUT),DIMENSION(&
	& local_x_min_ghost:local_x_max_ghost,&
	& local_y_min_ghost:local_y_max_ghost,&
	& local_z_min_ghost:local_z_max_ghost) :: &
	& local_differentiated_field_wrt_x,&
	& local_differentiated_field_wrt_y,&
	& local_differentiated_field_wrt_z

	!------------NO INTENT------------------------------------------------------------------------------------------------


	INTEGER,PARAMETER :: x = 1
	INTEGER,PARAMETER :: y = 2
	INTEGER,PARAMETER :: z = 3
	INTEGER :: I_PLUS1,I_MINUS1,J_PLUS1,J_MINUS1,K_PLUS1,K_MINUS1
	INTEGER :: I,J,K
	!CHARACTER(LEN = filename_number_of_letters) filename


IF(debug) WRITE (0,*) My_MPI_Process_ID,'ENTERED SUBROUTINE LBM_differentiate_LBM_1D_field'
IF(debug) WRITE (9,*) My_MPI_Process_ID,'ENTERED SUBROUTINE LBM_differentiate_LBM_1D_field'

!set to 100 for debug purposes
local_differentiated_field_wrt_x(:,:,:) = 100.0
local_differentiated_field_wrt_y(:,:,:) = 100.0
local_differentiated_field_wrt_z(:,:,:) = 100.0


DO K = local_z_min_real, local_z_max_real
			
	IF(K.EQ.global_z_max_real.AND..NOT.divide_z) THEN !PERIODICITY IN Z
	
		K_PLUS1 = global_z_min_real
		K_MINUS1 = K-1
	
	ELSEIF(K.EQ.global_z_min_real.AND..NOT.divide_z) THEN
	
		K_PLUS1 = K+1
		K_MINUS1 = global_z_max_real

	ELSE

		K_PLUS1=K+1
		K_MINUS1=K-1
	
	ENDIF


	DO J = local_y_min_real, local_y_max_real
		
		IF(J.EQ.global_y_max_real.AND..NOT.divide_y) THEN !PERIODICITY IN Y
		
			J_PLUS1 = global_y_min_real
			J_MINUS1 = J-1
	
		ELSEIF(J.EQ.global_y_min_real.AND..NOT.divide_y) THEN
		
			J_PLUS1 = J+1
			J_MINUS1 = global_y_max_real
		
		ELSE
		
			J_PLUS1 = J+1
			J_MINUS1 = J-1
		
		ENDIF

		DO I = local_x_min_real, local_x_max_real
						
			IF(I.EQ.global_x_max_real.AND..NOT.divide_x) THEN !PERIODICITY IN X
		
				I_PLUS1 = global_x_min_real
				I_MINUS1 = I-1
		
			ELSEIF(I.EQ.global_x_min_real.AND..NOT.divide_x) THEN
		
				I_PLUS1 = I+1
				I_MINUS1 = global_x_max_real
		
			ELSE
		
				I_PLUS1 = I+1
				I_MINUS1 = I-1
		
			ENDIF
	
			IF(.NOT.LST_local_walls(I,J,K)) THEN 
											
				!COMPUTE SPACIAL DERIVATIVES IN X
				CALL numerical_1st_order_derivative1D(&
				& My_MPI_Process_ID,&
				& LST_local_walls(I_PLUS1,J,K),LST_local_walls(I_MINUS1,J,K),&
Femi Kadri's avatar
Femi Kadri committed
166 167
				& local_field_to_be_differentiated(I_PLUS1,J,K),&
				& local_field_to_be_differentiated(I_MINUS1,J,K),&
Femi Kadri's avatar
Femi Kadri committed
168 169 170 171 172 173 174
				& local_field_to_be_differentiated(I,J,K),&
				& local_differentiated_field_wrt_x(I,J,K))

				!COMPUTE SPACIAL DERIVATIVES IN Y 
				CALL numerical_1st_order_derivative1D(&
				& My_MPI_Process_ID,&
				& LST_local_walls(I,J_PLUS1,K),LST_local_walls(I,J_MINUS1,K),&
Femi Kadri's avatar
Femi Kadri committed
175 176
				& local_field_to_be_differentiated(I,J_PLUS1,K),&
				& local_field_to_be_differentiated(I,J_MINUS1,K),&
Femi Kadri's avatar
Femi Kadri committed
177 178 179 180 181 182
				& local_field_to_be_differentiated(I,J,K),&
				& local_differentiated_field_wrt_y(I,J,K))

				!COMPUTE SPACIAL DERIVATIVES IN Z
				CALL numerical_1st_order_derivative1D(&
				& My_MPI_Process_ID,&
Femi Kadri's avatar
Femi Kadri committed
183
				& LST_local_walls(I,J,K_PLUS1),&
Femi Kadri's avatar
Femi Kadri committed
184
				& LST_local_walls(I,J,K_MINUS1),&
Femi Kadri's avatar
Femi Kadri committed
185 186
				& local_field_to_be_differentiated(I,J,K_PLUS1),&
				& local_field_to_be_differentiated(I,J,K_MINUS1),&
Femi Kadri's avatar
Femi Kadri committed
187
				& local_field_to_be_differentiated(I,J,K),&
Femi Kadri's avatar
Femi Kadri committed
188 189 190 191
				& local_differentiated_field_wrt_z(I,J,K))

!				WRITE(9,'(3I6.5,3E19.10)') I,J,K,local_differentiated_field_wrt_x(I,J,K),&
!				& local_differentiated_field_wrt_y(I,J,K),&
Femi Kadri's avatar
Femi Kadri committed
192 193 194 195 196 197 198 199 200 201 202 203 204
!				& local_differentiated_field_wrt_z(I,J,K)

			ENDIF !LST_local_walls(I,J,K)

		END DO !I LOCAL

	END DO	!J LOCAL
	
END DO !K LOCAL

	!UPDATE local_differentiated_field_wrt_x GHOST BOUNDARIES
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: ABOUT TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_x'
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: ABOUT TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_x'
Femi Kadri's avatar
Femi Kadri committed
205 206 207 208 209

	CALL update_ghost_boundaries_REAL_3D(local_x_min_ghost,local_x_max_ghost,local_y_min_ghost,local_y_max_ghost,&
	& local_z_min_ghost,local_z_max_ghost,local_x_min_real,local_x_max_real,local_y_min_real,local_y_max_real,local_z_min_real,&
	& local_z_max_real,My_MPI_Process_ID,IN,OUT,WEST,EAST,UP,DOWN,cartesian_communicator,local_x_nodes_ghost,&
	& local_y_nodes_ghost,local_z_nodes_ghost,local_x_nodes_real,local_y_nodes_real,local_z_nodes_real,&
Femi Kadri's avatar
Femi Kadri committed
210 211 212 213 214
	& divide_x,divide_y,divide_z,local_differentiated_field_wrt_x)

	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: FINISHED TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_x'
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: FINISHED TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_x'

Femi Kadri's avatar
Femi Kadri committed
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

	!UPDATE local_differentiated_field_wrt_y GHOST BOUNDARIES
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: ABOUT TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_y'
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: ABOUT TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_y'

	CALL update_ghost_boundaries_REAL_3D(local_x_min_ghost,local_x_max_ghost,local_y_min_ghost,local_y_max_ghost,&
	& local_z_min_ghost,local_z_max_ghost,local_x_min_real,local_x_max_real,local_y_min_real,local_y_max_real,local_z_min_real,&
	& local_z_max_real,My_MPI_Process_ID,IN,OUT,WEST,EAST,UP,DOWN,cartesian_communicator,local_x_nodes_ghost,&
	& local_y_nodes_ghost,local_z_nodes_ghost,local_x_nodes_real,local_y_nodes_real,local_z_nodes_real,&
	& divide_x,divide_y,divide_z,local_differentiated_field_wrt_y)

	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: FINISHED TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_y'
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: FINISHED TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_y'

	!UPDATE local_differentiated_field_wrt_z GHOST BOUNDARIES
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: ABOUT TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_z'
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: ABOUT TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_z'

	CALL update_ghost_boundaries_REAL_3D(local_x_min_ghost,local_x_max_ghost,local_y_min_ghost,local_y_max_ghost,&
	& local_z_min_ghost,local_z_max_ghost,local_x_min_real,local_x_max_real,local_y_min_real,local_y_max_real,local_z_min_real,&
	& local_z_max_real,My_MPI_Process_ID,IN,OUT,WEST,EAST,UP,DOWN,cartesian_communicator,local_x_nodes_ghost,&
	& local_y_nodes_ghost,local_z_nodes_ghost,local_x_nodes_real,local_y_nodes_real,local_z_nodes_real,&
	& divide_x,divide_y,divide_z,local_differentiated_field_wrt_z)

	IF(debug) WRITE (9,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: FINISHED TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_z'
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'LBM_differentiate_LBM_1D_field: FINISHED TO CALL update_ghost_boundaries_REAL_3D: local_differentiated_field_wrt_z'

Femi Kadri's avatar
Femi Kadri committed
242 243 244 245 246 247 248 249 250

IF(debug) WRITE (0,*) My_MPI_Process_ID,'ABOUT TO END SUBROUTINE LBM_differentiate_LBM_1D_field'
IF(debug) WRITE (9,*) My_MPI_Process_ID,'ABOUT TO END SUBROUTINE LBM_differentiate_LBM_1D_field'


RETURN
END SUBROUTINE LBM_differentiate_LBM_1D_field