Nodes of different colours represent the following:
Solid arrows point from a parent (sub)module to the submodule which is descended from it. Dashed arrows point from a module being used to the module or program unit using it. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
type(vector), | intent(in) | :: | RayToFind | |||
integer, | intent(in) | :: | RadType | |||
integer, | intent(in) | :: | ISurf | |||
integer, | intent(in) | :: | IState | |||
type(BasisStruct), | intent(in) | :: | Basis | |||
real(kind=r64), | intent(out) | :: | Theta | |||
real(kind=r64), | intent(out) | :: | Phi |
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
Nodes of different colours represent the following:
Solid arrows point from a procedure to one which it calls. Dashed arrows point from an interface to procedures which implement that interface. This could include the module procedures in a generic interface or the implementation in a submodule of an interface in a parent module. Where possible, edges connecting nodes are given different colours to make them easier to distinguish in large graphs.
FUNCTION FindInBasis ( RayToFind, RadType,ISurf,IState,Basis,Theta,Phi) RESULT ( RayIndex )
! SUBROUTINE INFORMATION:
! AUTHOR Joe Klems
! DATE WRITTEN August 2011
! MODIFIED na
! RE-ENGINEERED na
! PURPOSE OF THIS FUNCTION:
!
! METHODOLOGY EMPLOYED:
! <n/a>
! REFERENCES:
! na
! USE STATEMENTS:
USE vectors
IMPLICIT NONE ! Enforce explicit typing of all variables in this routine
! SUBROUTINE ARGUMENT DEFINITIONS:
TYPE(vector), INTENT(IN) :: RayToFind !Ray vector direction in world CS
INTEGER, INTENT(IN) :: RadType !Type of radiation: Front_Incident, etc.
! INTEGER, INTENT(IN) :: IWind !window index in window list
INTEGER, INTENT(IN) :: ISurf !Window Surface number
INTEGER, INTENT(IN) :: IState !Complex Fenestration state number
TYPE (BasisStruct), INTENT(IN) :: Basis !Complex Fenestration basis root
REAL(r64), INTENT(OUT) :: Theta !Theta value for ray
REAL(r64), INTENT(OUT) :: Phi !Phi value for ray
INTEGER :: RayIndex !Index of ray in basis, zero if ray not in hemisphere
! SUBROUTINE PARAMETER DEFINITIONS:
! na
! INTERFACE BLOCK SPECIFICATIONS:
! na
! DERIVED TYPE DEFINITIONS:
! na
! SUBROUTINE LOCAL VARIABLE DECLARATIONS:
INTEGER :: ITheta !Table index of Theta
INTEGER :: IPhi !Table index of Phi, given ITheta
INTEGER :: IThDn !Theta lower table index
INTEGER :: IThUp !Theta upper table index
INTEGER :: IPhDn !Phi lower table index
INTEGER :: IPhUp !Phi upper table index
REAL(r64) :: Gamma !Gamma (tilt) angle of window
REAL(r64) :: Alpha !Alpha (azimuth) angle of window
REAL(r64) :: DotProd
Theta = 0.0d0
Phi = 0.0d0
! Check if surface and vector are pointing in different directions
DotProd = RayToFind .dot. Surface(ISurf)%NewellSurfaceNormalVector
IF (DotProd <= 0.0d0) THEN
RayIndex = 0
RETURN
END IF
!get window tilt and azimuth
Gamma = DegToRadians*Surface(ISurf)%Tilt
Alpha = DegToRadians*Surface(ISurf)%Azimuth
!get the corresponding local Theta, Phi for ray
CALL W6CoordsFromWorldVect (RayToFind, RadType, Gamma, Alpha,Theta, Phi)
IF (Theta >= 0.5d0*Pi) THEN !Ray was in not in correct hemisphere
RayIndex = 0
RETURN
ENDIF
IF (Basis%BasisSymmetryType == BasisSymmetry_None ) THEN
!Search the basis thetas
IF(Theta <= 0.0d0 ) THEN
!Special case, Theta = 0.; this is always the first basis element
RayIndex = 1
RETURN
ENDIF
!So here Theta > 0
!Note the table searches always go to the limit point, which is not itself a basis element
IThUp = SearchAscTable(Theta,Basis%NThetas + 1,Basis%Thetas)
IThDn = IThUP -1
!Determine which of the theta basis points is closer to the Theta value
IF (Theta <= Basis%Grid( Basis%BasisIndex(IThDn,1) )%UpprTheta ) THEN
!Note this will take care of both the special cases IThUp=2 and IThUp=NThetas +1
ITheta = IThDn
ELSE
ITheta = IThUp
ENDIF
!Now determine the Phi index
IF (Basis%NPhis(ITheta) == 1 ) THEN
!Note that for W6 basis this can only happen for the first basis element
!If later bases are introduced this logic may have to be redesigned
RayIndex = Basis%BasisIndex(ITheta,1)
RETURN
ENDIF
IPhUp = SearchAscTable( Phi, Basis%NPhis(ITheta)+1 , Basis%Phis (: , ITheta ) )
IPhDn = IPhUp - 1
IF (Phi <= Basis%Grid( Basis%BasisIndex(ITheta, IPhDn) )%UpprPhi ) THEN
IPhi = IPhDn
ELSE
IF (IPhUp == Basis%NPhis(ITheta) + 1 ) THEN
! Phi is above upper limit for highest Phi basis element, meaning it is closer to 2Pi,
! i.e., the first element
IPhi =1
ELSE
IPhi = IPhUp
ENDIF
ENDIF
RayIndex = Basis%BasisIndex( ITheta , IPhi )
RETURN
ELSE IF( Basis%BasisSymmetryType == BasisSymmetry_Axisymmetric ) THEN
!Search the basis thetas
IF(Theta <= 0.0d0 ) THEN
!Special case, Theta = 0.; this is always the first basis element
RayIndex = 1
RETURN
ENDIF
!So here Theta > 0
!Note the table searches always go to the limit point, which is not itself a basis element
IThUp = SearchAscTable(Theta,Basis%NThetas + 1,Basis%Thetas)
IThDn = IThUP -1
!Determine which of the theta basis points is closer to the Theta value
IF (Theta <= Basis%Grid( Basis%BasisIndex(IThDn,1) )%UpprTheta ) THEN
!Note this will take care of both the special cases IThUp=2 and IThUp=NThetas +1
ITheta = IThDn
ELSE
ITheta = IThUp
ENDIF
RayIndex = Basis%BasisIndex( ITheta , 1 )
RETURN
ENDIF
!No other type is implemented
RayIndex = 0
RETURN
END FUNCTION FindInBasis