subroutine MeshGeneration_FluidModule Use TD_DrillStemComponents Use TD_WellElements Use TD_WellGeometry Use TD_StringConnectionData Use GeoElements_FluidModule Use CPumpsVariables Use CStringConfigurationVariables Use CBopStackVariables !Use Drawworks_VARIABLES , only: Drawworks implicit none Integer :: ii , jj , semijj , kk , k , m , s Integer :: ElementsCount , StringConfigCount REAL(8) :: mm , nn , dl , StartAngle , EndAngle REAL(8) :: A(30) !?????????10 REAL(8) :: TD_ElementLength A = 0.d0 A(1) = BopStackSpecification%AboveAnnularHeight ! WellHead[ft] jj = 1 !==================================================== ! Mesh Generation of DrillStem Components !==================================================== !TD_String%StringConfigurationCount = StringConfigurationCount !??????????? StringConfigCount = TD_String%StringConfigurationCount if (allocated(F_String)) Deallocate(F_String) if (TD_DrillStem(1)%ComponentType==0) then Allocate (F_String(StringConfigCount-1)) else Allocate (F_String(StringConfigCount)) end if if (TD_DrillStem(1)%ComponentType==0) then ElementsCount = 1 Do ii=1,(StringConfigCount-1) F_String(ii)%ID = TD_DrillStem(ii+1)%Id*12.d0 ![inch] F_String(ii)%OD = TD_DrillStem(ii+1)%Od*12.d0 ![inch] F_String(ii)%FirstElement = ElementsCount+1 F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii+1)%Numbs-1) F_String(ii)%ElType = TD_DrillStem(ii+1)%ComponentType ElementsCount = F_String(ii)%LastElement End Do StringConfigCount = StringConfigCount-1 else ElementsCount = 0 Do ii=1,StringConfigCount F_String(ii)%ID = TD_DrillStem(ii)%Id*12.d0 ![inch] F_String(ii)%OD = TD_DrillStem(ii)%Od*12.d0 ![inch] F_String(ii)%FirstElement = ElementsCount+1 F_String(ii)%LastElement = F_String(ii)%FirstElement+(TD_DrillStem(ii)%Numbs-1) F_String(ii)%ElType = TD_DrillStem(ii)%ComponentType ElementsCount = F_String(ii)%LastElement End Do end if Do ii=1,StringConfigCount F_String(ii)%TopDepth = TD_DrillStems(F_String(ii)%LastElement)%TopDepthIni ![ft] F_String(ii)%DownDepth = TD_DrillStems(F_String(ii)%FirstElement)%DownDepthIni ![ft] if (F_String(ii)%DownDepth>A(1)) then jj = jj+1 A(jj) = F_String(ii)%DownDepth end if End Do !=========> Removed Volume Calculation in DrillStem TD_ElementLength = F_String(StringConfigCount)%DownDepth-F_String(StringConfigCount)%TopDepth if ( StringConfigCount==TD_Vol%PreCount ) then if ( TD_Vol%PreElementLength>TD_ElementLength ) then TD_Vol%RemoveVolume = (TD_Vol%PreElementLength-TD_ElementLength)*((pi*((F_String(StringConfigCount)%ID/12.d0)**2))/4.d0) ![ft^3] else TD_Vol%RemoveVolume = 0.d0 end if else if ( StringConfigCount Out of Well Intervals F_Interval(1)%StartTVD = 0.0d0 !?????????????? F_Interval(1)%EndTVD = -TD_StConn%ConnectionHeight F_Interval(1)%StartAngle = 0.d0 !??????????????????????? F_Interval(1)%EndAngle = 0.d0 !??????????????????????? F_Counts%OutOfWellIntervalCounts = 1 Do ii= 2 , StringConfigCount+1 if ( F_Interval(ii)%StartDepth<=0.d0 ) then F_Interval(ii)%StartTVD = F_Interval(ii)%StartDepth F_Interval(ii)%StartAngle = 0.0d0 end if if ( F_Interval(ii)%EndDepth<=0.d0 ) then F_Interval(ii)%EndTVD = F_Interval(ii)%EndDepth F_Interval(ii)%EndAngle = 0.0d0 F_Counts%OutOfWellIntervalCounts = F_Counts%OutOfWellIntervalCounts+1 end if End Do !=========> if (allocated(TDGeo%TVD)) Deallocate(TDGeo%TVD) Allocate (TDGeo%TVD(jj)) if (allocated(TDGeo%Angle)) Deallocate(TDGeo%Angle) Allocate (TDGeo%Angle(jj)) TDGeo%TVD(1) = TD_WellGeneral%WellTotalVerticalLength !????? !print*, 'TD_WellGeneral%WellTotalVerticalLength=' ,TD_WellGeneral%WellTotalVerticalLength TDGeo%TVD(jj) = BopStackSpecification%AboveAnnularHeight ! WellHead[ft] !0.d0 ???????????????? k = 1 mm = 0.d0 nn = 0.d0 EndAngle = TD_WellGeo(1)%StartAngle !??????????????? TDGeo%Angle(jj) = EndAngle Do ii = jj-1,1,-1 !???1or2 do kk = k, TD_WellGeneral%WellIntervalsCount StartAngle = EndAngle if ( TDGeo%MD(ii)>TD_WellGeo(kk)%TopDepth ) then if ( TDGeo%MD(ii)>TD_WellGeo(kk)%DownDepth ) then dl = TD_WellGeo(kk)%DownDepth-nn ![ft] nn = TD_WellGeo(kk)%DownDepth if ( TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle !print*, 'StartAngle1=' ,ii , kk, StartAngle !print*, 'EndAngle1=' ,ii , kk, EndAngle TDGeo%TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) ![ft] TDGeo%Angle(ii) = EndAngle !print*, 'TDGeo%TVD(ii)1=' ,ii , kk, TDGeo%TVD(ii) else if ( TD_WellGeo(kk)%HoleType==1 ) then EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !????????????????? !print*, 'StartAngle2=' ,ii , kk, StartAngle !print*, 'EndAngle2=' ,ii , kk, EndAngle TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) TDGeo%Angle(ii) = EndAngle !print*, 'TDGeo%TVD(ii)2=' , ii , kk, TDGeo%TVD(ii) else if ( TD_WellGeo(kk)%HoleType==2 ) then EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !????????????????? !print*, 'StartAngle22=' ,ii , kk, StartAngle !print*, 'EndAngle22=' ,ii , kk, EndAngle TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) TDGeo%Angle(ii) = EndAngle !print*, 'TDGeo%TVD(ii)22=' , ii , kk, TDGeo%TVD(ii) end if mm = TDGeo%TVD(ii) else dl = TDGeo%MD(ii)-nn nn = TDGeo%MD(ii) if ( TD_WellGeo(kk)%HoleType==0 ) then EndAngle = StartAngle !print*, 'StartAngle3=' ,ii , kk, StartAngle !print*, 'EndAngle3=' ,ii , kk, EndAngle TDGeo%TVD(ii) = mm+(dl*cos(TD_WellGeo(kk)%StartAngle)) TDGeo%Angle(ii) = EndAngle !print*, 'TDGeo%TVD(ii)3=' ,ii , kk, TDGeo%TVD(ii) else if ( TD_WellGeo(kk)%HoleType==1 ) then EndAngle = StartAngle+(dl/TD_WellGeo(kk)%RCurvature) !??????????????????? !print*, 'StartAngle4=' ,ii , kk, StartAngle !print*, 'EndAngle4=' ,ii , kk, EndAngle TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))*cos(abs(StartAngle)))-(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(EndAngle)-abs(StartAngle)))*sin(abs(StartAngle))) TDGeo%Angle(ii) = EndAngle !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) !print*, 'mm=' ,mm !print*, 'TDGeo%TVD(ii)4=' ,ii , kk, TDGeo%TVD(ii) else if ( TD_WellGeo(kk)%HoleType==2 ) then EndAngle = StartAngle-(dl/TD_WellGeo(kk)%RCurvature) !??????????????????? !print*, 'StartAngle44=' ,ii , kk, StartAngle !print*, 'EndAngle44=' ,ii , kk, EndAngle TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) TDGeo%Angle(ii) = EndAngle !TDGeo%TVD(ii) = mm+(TD_WellGeo(kk)%RCurvature*sin(abs(EndAngle)-abs(StartAngle))) !print*, 'mm=' ,mm , (TD_WellGeo(kk)%RCurvature*sin(abs(abs(EndAngle)-abs(StartAngle)))*cos(abs(StartAngle)))+(TD_WellGeo(kk)%RCurvature*(1.-cos(abs(abs(EndAngle)-abs(StartAngle))))*sin(abs(StartAngle))) !print*, 'TDGeo%TVD(ii)44=' ,ii , kk, TDGeo%TVD(ii) end if mm = TDGeo%TVD(ii) k = kk exit end if end if end do End Do !if (F_Counts%OutOfWellIntervalCounts==1) then ! s = 2 !else ! s = F_Counts%OutOfWellIntervalCounts !end if ! Do ii = (F_Counts%OutOfWellIntervalCounts+1),F_Counts%IntervalsTotalCounts do kk = jj,1,-1 if ( F_Interval(ii)%StartDepth==TDGeo%MD(kk) ) then F_Interval(ii)%StartTVD = TDGeo%TVD(kk) ![ft] F_Interval(ii)%StartAngle = TDGeo%Angle(kk) ![rad] end if if ( F_Interval(ii)%EndDepth==TDGeo%MD(kk) ) then F_Interval(ii)%EndTVD = TDGeo%TVD(kk) ![ft] F_Interval(ii)%EndAngle = TDGeo%Angle(kk) ![rad] end if end do End Do !Do ii=1,(F_Counts%IntervalsTotalCounts) ! print*, 'F_Interval(ii)%StartTVD=' , ii , F_Interval(ii)%StartTVD ! print*, 'F_Interval(ii)%EndTVD=' , ii , F_Interval(ii)%EndTVD ! print*, 'F_Interval(ii)%StartAngle=' , ii , F_Interval(ii)%StartAngle ! print*, 'F_Interval(ii)%EndAngle=' , ii , F_Interval(ii)%EndAngle !end do ! ! !Do ii=1,TD_WellGeneral%WellIntervalsCount ! print*, 'TD_WellGeo(kk)%TopDepth=' , ii , TD_WellGeo(ii)%TopDepth ! print*, 'TD_WellGeo(kk)%DownDepth=' , ii , TD_WellGeo(ii)%DownDepth ! print*, 'TD_WellGeo(kk)%HoleType=' , ii , TD_WellGeo(ii)%HoleType ! print*, 'TD_WellGeo(kk)%RCurvature=' , ii , TD_WellGeo(ii)%RCurvature ! print*, 'TD_WellGeo(kk)%EndAngle=' , ii , TD_WellGeo(ii)%EndAngle ! print*, 'TD_WellGeo(kk)%StartAngle=' , ii , TD_WellGeo(ii)%StartAngle !end do end subroutine