numerical_1st_order_derivative1D.F90 2.47 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
SUBROUTINE numerical_1st_order_derivative1D(&
& My_MPI_Process_ID,&
& forward_wall,backward_wall,&
& forward_Fx,backward_Fx,Fx,&
& derivative_FxDdim)


!DIFFERENTIATE A 1D ARRAY IN 1 CARTESIAN DIRECTION
!OUTPUT 1 DERIVATIVES

USE debug_module
!USE precision_detector

	IMPLICIT NONE
	REAL,PARAMETER :: Inverse_3  = 1.0 / 3.0  
	!-----------INTENT(IN)-----------------------------------------------------------------------------------------------
	INTEGER,INTENT(IN) :: My_MPI_Process_ID
	REAL,INTENT(IN) :: forward_Fx,backward_Fx,Fx
	LOGICAL*4,INTENT(IN) :: forward_wall,backward_wall
	LOGICAL*4,PARAMETER :: debug = GLOBAL_DEBUG
	!-----------INTENT(OUT)-----------------------------------------------------------------------------------------------
	REAL,INTENT(OUT) :: derivative_FxDdim

	IF(debug) WRITE (0,*) My_MPI_Process_ID,'entered SUBROUTINE numerical_1st_order_derivative1D'
	IF(debug) WRITE (9,*) My_MPI_Process_ID,'entered SUBROUTINE numerical_1st_order_derivative1D'

	IF ( .NOT.forward_wall.AND..NOT.backward_wall ) THEN !COMPUTE SPACIAL DERIVATIVES IN X OF VELOCITY
		
		derivative_FxDdim = ( forward_Fx - backward_Fx ) / 2.0 !2ND ORDER CENTERED FINITE-DIFFERENCE

	ELSEIF ( forward_wall.AND..NOT.backward_wall ) THEN !IF FORWARD = WALL AND BACKWARD = FLUID

		
		derivative_FxDdim = - Inverse_3 * backward_Fx - Fx !2ND ORDER LAGRANGE INTERPOLATING POLYNOMIAL W/ HALF WAY BOUNCE BACK BC
		!derivative_FxDdim = ( Fx - backward_Fx ) !1ST ORDER BACKWARD FINITE-DIVIDED DIFFERENCE

	ELSEIF ( .NOT.forward_wall.AND.backward_wall ) THEN !IF BACKWARD = WALL AND FORWARD = FLUID

		derivative_FxDdim = Fx + Inverse_3 * forward_Fx !2ND ORDER LAGRANGE INTERPOLATING POLYNOMIAL W/ HALF WAY BOUNCE BACK BC

		!derivative_FxDdim = ( forward_Fx - Fx ) !1ST ORDER FORWARD FINITE-DIVIDED DIFFERENCE
		!derivative_FyDdim = ( forward_Fy - Fy )
		!derivative_FzDdim = ( forward_Fz - Fz )

	ELSE
		
!		IF(debug) PRINT*,My_MPI_Process_ID,'PROBLEM WITH STRESSES IN X'
!		IF(debug) PRINT*,My_MPI_Process_ID,'I_PLUS1',I_PLUS1,'J',J,'K',K,'local_walls',forward_wall
!		IF(debug) PRINT*,My_MPI_Process_ID,'I_MINUS1',I_MINUS1,'J',J,'K',K,'local_walls',backward_wall
		!STOP
		derivative_FxDdim = -123456789

	ENDIF !CHECK IF NEAREST NEIGHBORS ARE WALLS

	IF(debug) WRITE (9,*) My_MPI_Process_ID,'numerical_1st_order_derivative1D: about to return from SUBROUTINE'
	IF(debug) WRITE (0,*) My_MPI_Process_ID,'numerical_1st_order_derivative1D: about to return from SUBROUTINE'

    RETURN
    END SUBROUTINE numerical_1st_order_derivative1D